diff --git a/README.md b/README.md index 63e3bac4..3ecddca5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,2 @@ # Luban-Lite SDK -Luban-Lite 是 ArtInChip 针对 RTOS 领域开发的一套 SDK。 - -相关帮助文档如下: - -- [用户使用指南_Linux环境](doc/luban-lite_user_guid_linux.md) -- [用户使用指南_Windows环境](doc/luban-lite_user_guid_windows.md) -- [驱动开发指南](doc/luban-lite_driver_development_guid.md) \ No newline at end of file diff --git a/ReleaseNote.md b/ReleaseNote.md index 0fb1fb98..5e72654f 100644 --- a/ReleaseNote.md +++ b/ReleaseNote.md @@ -1,3 +1,39 @@ +# V1.1.1 # +## 新增 ## +- FreeType:D13x支持独立使用PSRAM Heap +- MPP:支持FLAC的Audio封装格式 +- USB Display:增加Linux Host端的驱动安装包 +- Camera:框架增加更多的摄像头调节接口;GM7150支持调整色度 +- 打包:支持自动计算NFTL分区的镜像大小 +- Benchmark:支持单精度浮点的模式 +- 新增示例:test_camera +- I2C:新增软件模拟I2C的驱动实现 +- G73x:支持栈回溯功能 +- Touch:框架中支持翻转、旋转、缩放、裁剪,目前已适配GT911 +- 新增方案:G73x scan +- 新增器件: +- NAND:XT26G02D + +## 优化 ## +- Boot:自动计算BootLoader的size信息,默认将其放在PSRAM的末尾 +- MPP:优化第一次播放时的噪声处理 +- GMAC:优化内存资源的占用 +- USB Display:优化Touch的同步处理;OSD对屏幕分辨率自适应;支持屏幕有效区域的裁剪 +- WiFi:RTL完善功能支持 +- test_dvp & UVC:优化调试log中的信息描述,提升易读性 +- 启动动画:优化内存资源占用;支持 480x272 小分辨率的屏幕 +- LVGL V9:优化多处资源管理和处理性能;支持图片cache的大小配置 + +## 修改 ## +- LVGL V9:默认关闭性能监测;支持导出Framebuffer;完善绘画Buf的处理;支持从SD卡中读取RTP配置 +- AWTK:修正第一帧的vsync处理 +- DE:修正CCM、GAMMA参数 +- Audio:调整AMIC的默认配置参数 +- 启动动画:修正动画过程中的图片切换同步 +- LittleFS、PSADC:修正打开 RT_DEBUG 后的编译问题 +- 修正colorblock在屏幕裁剪模式中的越界问题; +- 修正同时播放视频时的画面撕裂问题 + # V1.1.0 # ## 新增 ## - 支持LVGL9,并适配了所有Demo diff --git a/application/Kconfig b/application/Kconfig index 880b0ab1..6b387ccc 100644 --- a/application/Kconfig +++ b/application/Kconfig @@ -263,6 +263,16 @@ config LV_CACHE_IMG_NUM default 2 depends on LPKG_USING_LVGL +config LV_CACHE_DEF_SIZE + hex "LVGL image cached size" + default 0x800000 + depends on LVGL_V_9 + +config LV_IMAGE_HEADER_CACHE_DEF_CNT + int "LVGL image header cached number" + default 20 + depends on LVGL_V_9 + config LV_DISPLAY_ROTATE_EN bool "LVGL enable display rotation" default n @@ -294,6 +304,21 @@ config LV_ROTATE_DEGREE default 180 if LV_ROTATE_180 default 270 if LV_ROTATE_270 +config MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE + bool "Limit the output size of MPP JPEG decoder" + default n + depends on LPKG_USING_LVGL + +if MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE + config MPP_JPEG_DEC_MAX_OUT_WIDTH + int "Max output width of MPP JPEG decoder" + default 2048 + + config MPP_JPEG_DEC_MAX_OUT_HEIGHT + int "Max output height of MPP JPEG decoder" + default 2048 +endif + # Parameters for LVGL meter demo if AIC_LVGL_METER_DEMO config LV_METER_SIMPLE_POINT diff --git a/application/baremetal/bootloader/Kconfig b/application/baremetal/bootloader/Kconfig index 9b33d412..44e0efae 100644 --- a/application/baremetal/bootloader/Kconfig +++ b/application/baremetal/bootloader/Kconfig @@ -8,18 +8,25 @@ config AIC_BOOTLOADER select AIC_USING_UMM_HEAP menu "Memory" + config AIC_BOOTLOADER_MEM_AUTO + bool "Bootloader memory auto config" + default y + config AIC_BOOTLOADER_TEXT_BASE hex "BootLoader link address" default 0 + depends on !AIC_BOOTLOADER_MEM_AUTO config AIC_BOOTLOADER_TEXT_SIZE hex "BootLoader code memory size" - default 0 + default 0x3FF00 + config AIC_BOOTLOADER_HEAP_BASE hex "BootLoader heap address" default 0 + depends on !AIC_BOOTLOADER_MEM_AUTO config AIC_BOOTLOADER_HEAP_SIZE hex "BootLoader heap size" - default 0 + default 0xC0000 endmenu menu "Console" diff --git a/application/baremetal/bootloader/cmd/aicupg.c b/application/baremetal/bootloader/cmd/aicupg.c index 50d2376d..b5249fd4 100644 --- a/application/baremetal/bootloader/cmd/aicupg.c +++ b/application/baremetal/bootloader/cmd/aicupg.c @@ -544,7 +544,9 @@ err: static void do_brom_upg(void) { +#ifdef AIC_WRI_DRV aic_set_reboot_reason(REBOOT_REASON_UPGRADE); +#endif reboot_device(); } diff --git a/application/baremetal/bootloader/cmd/aicupg_detect.c b/application/baremetal/bootloader/cmd/aicupg_detect.c index 3cc3cd53..9532a860 100644 --- a/application/baremetal/bootloader/cmd/aicupg_detect.c +++ b/application/baremetal/bootloader/cmd/aicupg_detect.c @@ -190,11 +190,12 @@ static bool force_upg_check(void) int upg_type_check(enum boot_device bd) { - enum aic_reboot_reason r; - upg_type = UPG_TYPE_NONE; upg_mode = UPG_MODE_NORMAL; +#ifdef AIC_WRI_DRV + enum aic_reboot_reason r; + r = aic_get_reboot_reason(); /* * if REBOOT_REASON_UPGRADE is not clear in BROM or PBP, should be clear @@ -218,6 +219,7 @@ int upg_type_check(enum boot_device bd) aic_clr_reboot_reason(); return 0; } +#endif if (bd == BD_USB) { if (usbd_connect_pc_check()) { diff --git a/application/baremetal/bootloader/cmd/progress_bar.c b/application/baremetal/bootloader/cmd/progress_bar.c index 524d7f3d..376ab871 100644 --- a/application/baremetal/bootloader/cmd/progress_bar.c +++ b/application/baremetal/bootloader/cmd/progress_bar.c @@ -26,7 +26,7 @@ #define WIDTH_SPLIT_NUMERATOR 5 #define WIDTH_SPLIT_DENOMINATOR 6 -#define BAR_HEIGHT 35 +#define BAR_HEIGHT 32 #define SPLIT_WIDTH(w) \ ((w) * WIDTH_SPLIT_NUMERATOR / WIDTH_SPLIT_DENOMINATOR) @@ -139,13 +139,11 @@ void aicfb_draw_rect(struct aicfb_screeninfo *info, u8 red, u8 green, u8 blue) { #ifndef AIC_BOOTLOADER_CMD_ONLY_FB_CONSOLE - unsigned long dcache_size, fb_dcache_start; int pbytes = info->bits_per_pixel / 8; unsigned char *fb; int i, j; fb = (unsigned char *)(info->framebuffer + y * info->stride + x * pbytes); - fb_dcache_start = ALIGN_DOWM((unsigned long)fb, ARCH_DMA_MINALIGN); switch (info->format) { case MPP_FMT_ARGB_8888: @@ -183,9 +181,7 @@ void aicfb_draw_rect(struct aicfb_screeninfo *info, return; }; - dcache_size = ALIGN_UP((unsigned long)fb - fb_dcache_start, - ARCH_DMA_MINALIGN); - aicos_dcache_clean_range((unsigned long *)fb_dcache_start, dcache_size); + aicos_dcache_clean_range((unsigned long *)info->framebuffer, info->smem_len); #endif } @@ -293,7 +289,7 @@ void aicfb_draw_bar(unsigned int value) #if (AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE == 90) width = BAR_HEIGHT; height = SPLIT_WIDTH(info.height); - bar_x = (info.width - width) / 2; + bar_x = 0; bar_y = (info.height - height) / 2 + height; console_x = bar_x + BAR_HEIGHT + 5; console_y = info.height / 2; @@ -301,7 +297,7 @@ void aicfb_draw_bar(unsigned int value) width = SPLIT_WIDTH(info.width); height = BAR_HEIGHT; bar_x = (info.width - width) / 2; - bar_y = (info.height - height) / 2; + bar_y = 0; console_x = info.width / 2; console_y = bar_y + BAR_HEIGHT + 5; #endif diff --git a/application/baremetal/bootloader/include/aicupg.h b/application/baremetal/bootloader/include/aicupg.h index b851b531..7a73ea52 100644 --- a/application/baremetal/bootloader/include/aicupg.h +++ b/application/baremetal/bootloader/include/aicupg.h @@ -137,6 +137,9 @@ int aicupg_fat_direct_write(char *dst_type, u32 intf_id, char *fpath, typedef void (*progress_cb)(u32 percent); void aicupg_fat_set_process_cb(progress_cb cb); +void *aicupg_malloc_align(u32 size, size_t align); +void aicupg_free_align(void *ptr); + #ifdef __cplusplus } #endif diff --git a/application/baremetal/bootloader/lib/aicupg/basic_cmd.c b/application/baremetal/bootloader/lib/aicupg/basic_cmd.c index 2cd98729..52c2fae8 100644 --- a/application/baremetal/bootloader/lib/aicupg/basic_cmd.c +++ b/application/baremetal/bootloader/lib/aicupg/basic_cmd.c @@ -605,7 +605,7 @@ static s32 get_mem_buf_cmd_read_output_data(struct upg_cmd *cmd, u8 *buf, if (cmd->state == CMD_STATE_RESP) { memlen = (u32)(long)cmd->priv; - mem = aicos_malloc_align(0, memlen, ARCH_DMA_MINALIGN); + mem = aicupg_malloc_align(memlen, ARCH_DMA_MINALIGN); /* * Enter read RESP state, to make it simple, HOST should read * RESP in one read operation. @@ -669,7 +669,7 @@ static s32 free_mem_buf_cmd_write_input_data(struct upg_cmd *cmd, u8 *buf, memcpy(&addr, buf, 4); clen += 4; - aicos_free_align(0, (void *)(long)addr); + aicupg_free_align((void *)(long)addr); cmd_state_set_next(cmd, CMD_STATE_RESP); } diff --git a/application/baremetal/bootloader/lib/aicupg/mmc_fwc.c b/application/baremetal/bootloader/lib/aicupg/mmc_fwc.c index 014bb5dd..c4eb3c4e 100644 --- a/application/baremetal/bootloader/lib/aicupg/mmc_fwc.c +++ b/application/baremetal/bootloader/lib/aicupg/mmc_fwc.c @@ -138,7 +138,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part u32 *fill_buf, fill_buf_num_blks, fill_blks = 0; int i, j; - fill_buf = (u32 *)aicos_malloc_align(0, ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE); + fill_buf = (u32 *)aicupg_malloc_align(ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE); if (!fill_buf) { pr_err("Malloc failed for: CHUNK_TYPE_FILL\n"); return 0; @@ -193,7 +193,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part } out: - aicos_free_align(0, fill_buf); + aicupg_free_align(fill_buf); return fill_blks; } @@ -404,7 +404,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len) long n; u32 clen = 0, calc_len = 0; - rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE); + rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE); if (!rdbuf) { pr_err("Error: malloc buffer failed.\n"); return 0; @@ -468,7 +468,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len) out: if (rdbuf) - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return clen; } diff --git a/application/baremetal/bootloader/lib/aicupg/nand_fwc.c b/application/baremetal/bootloader/lib/aicupg/nand_fwc.c index e4d367e1..daa1d995 100644 --- a/application/baremetal/bootloader/lib/aicupg/nand_fwc.c +++ b/application/baremetal/bootloader/lib/aicupg/nand_fwc.c @@ -205,7 +205,7 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len) int total_len = 0, remain_offset = 0; u8 *wbuf = NULL, *pbuf = NULL; - wbuf = aicos_malloc_align(0, ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE); + wbuf = aicupg_malloc_align(ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE); if (!wbuf) { pr_err("malloc failed.\n"); return 0; @@ -293,13 +293,13 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len) pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size); fwc->calc_partition_crc = fwc->meta.crc; - aicos_free_align(0, wbuf); + aicupg_free_align(wbuf); return len; out: if (wbuf) - aicos_free_align(0, wbuf); + aicupg_free_align(wbuf); return ret; } @@ -350,7 +350,7 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len) int i, ret = 0, calc_len = 0; u8 *rdbuf, *buf_to_write, *buf_to_read; - rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE); + rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE); if (!rdbuf) { pr_err("Error: malloc buffer failed.\n"); return 0; @@ -431,11 +431,11 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len) pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size); - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return len; out: if (rdbuf) - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return 0; } @@ -449,7 +449,7 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len) int i, calc_len = 0, ret = 0; u8 *rdbuf; - rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE); + rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE); if (!rdbuf) { pr_err("Error: malloc buffer failed.\n"); return 0; @@ -514,11 +514,11 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len) pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size); (void)ret; - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return len; out: if (rdbuf) - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return 0; } #endif @@ -567,6 +567,9 @@ void nand_fwc_data_end(struct fwc_info *fwc) if (!priv) return; + if (priv->spl_flag) + nand_fwc_spl_end(priv); + #ifdef AIC_NFTL_SUPPORT struct nftl_api_handler_t *nftl_handler; for (int i = 0; i < MAX_DUPLICATED_PART; i++) { diff --git a/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.c b/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.c index 7e0968a1..6df2e22b 100644 --- a/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.c +++ b/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.c @@ -683,6 +683,17 @@ s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len) return len; } +s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv) +{ + struct aicupg_nand_spl *spl; + + spl = &g_nand_spl; + if (spl->image_buf) + free(spl->image_buf); + + return 0; +} + int nand_spl_get_candidate_blocks(u32 *blks, u32 size) { if (!blks || size < SPL_CANDIDATE_BLOCK_NUM) { diff --git a/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.h b/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.h index 41927e31..9d9f91cb 100644 --- a/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.h +++ b/application/baremetal/bootloader/lib/aicupg/nand_fwc_spl.h @@ -87,6 +87,7 @@ s32 nand_fwc_spl_reserve_blocks(struct aicupg_nand_priv *priv); s32 nand_fwc_spl_prepare(struct aicupg_nand_priv *priv, u32 datasiz, u32 blksiz); s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len); +s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv); int nand_spl_get_candidate_blocks(u32 *blks, u32 size); #ifdef __cplusplus diff --git a/application/baremetal/bootloader/lib/aicupg/nor_fwc.c b/application/baremetal/bootloader/lib/aicupg/nor_fwc.c index 08b073d1..eb8cde6c 100644 --- a/application/baremetal/bootloader/lib/aicupg/nor_fwc.c +++ b/application/baremetal/bootloader/lib/aicupg/nor_fwc.c @@ -137,7 +137,7 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len) int i, calc_len = 0, ret = 0; u8 *rdbuf; - rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE); + rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE); if (!rdbuf) { pr_err("Error: malloc buffer failed.\n"); return 0; @@ -201,12 +201,12 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len) fwc->trans_size += len; pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size); - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return len; out: if (rdbuf) - aicos_free_align(0, rdbuf); + aicupg_free_align(rdbuf); return ret; } diff --git a/application/baremetal/bootloader/lib/aicupg/trans_rw_data.c b/application/baremetal/bootloader/lib/aicupg/trans_rw_data.c index aa347006..9e16c7e2 100644 --- a/application/baremetal/bootloader/lib/aicupg/trans_rw_data.c +++ b/application/baremetal/bootloader/lib/aicupg/trans_rw_data.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Artinchip Technology Co., Ltd + * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -59,10 +59,10 @@ s32 trans_layer_rw_proc(struct phy_data_rw *rw, u8 *buffer, u32 len) if (!trans_pkt_buf) { trans_pkt_siz = TRANS_DATA_BUFF_MAX_SIZE; - trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE); + trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE); if (!trans_pkt_buf) { trans_pkt_siz = TRANS_DATA_BUFF_MIN_SIZE; - trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE); + trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE); if (!trans_pkt_buf) { pr_err("malloc trans pkt buf(%u) failed.\n", trans_pkt_siz); return -1; diff --git a/application/baremetal/bootloader/lib/aicupg/upg_fat.c b/application/baremetal/bootloader/lib/aicupg/upg_fat.c index eafce0e8..1ec3191f 100644 --- a/application/baremetal/bootloader/lib/aicupg/upg_fat.c +++ b/application/baremetal/bootloader/lib/aicupg/upg_fat.c @@ -33,21 +33,21 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align) switch (*size) { case DATA_WRITE_ONCE_MAX_SIZE: *size = ALIGN_DOWN(DATA_WRITE_ONCE_MAX_SIZE, fwc->block_size); - ptr = aicos_malloc_align(0, *size, align); + ptr = aicupg_malloc_align(*size, align); if (ptr) break; case DATA_WRITE_ONCE_MID_SIZE: *size = ALIGN_DOWN(DATA_WRITE_ONCE_MID_SIZE, fwc->block_size); - ptr = aicos_malloc_align(0, *size, align); + ptr = aicupg_malloc_align(*size, align); if (ptr) break; case DATA_WRITE_ONCE_MIN_SIZE: *size = ALIGN_DOWN(DATA_WRITE_ONCE_MIN_SIZE, fwc->block_size); - ptr = aicos_malloc_align(0, *size, align); + ptr = aicupg_malloc_align(*size, align); if (ptr) break; default: - ptr = aicos_malloc_align(0, *size, align); + ptr = aicupg_malloc_align(*size, align); if (ptr) break; } @@ -57,7 +57,7 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align) static void upg_fat_free_align(void *mem) { - aicos_free_align(0, mem); + aicupg_free_align(mem); } #define FRAME_LIST_SIZE 4096 @@ -73,7 +73,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta) fwc = NULL; buf = NULL; - fwc = aicos_malloc_align(0, sizeof(struct fwc_info), FRAME_LIST_SIZE); + fwc = aicupg_malloc_align(sizeof(struct fwc_info), FRAME_LIST_SIZE); if (!fwc) { pr_err("Error: malloc fwc failed.\n"); ret = -1; @@ -91,7 +91,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta) media_data_write_start(fwc); /*config write size once*/ - if (config_ram_size <= 0x100000) + if (config_ram_size <= 0x400000) write_once_size = DATA_WRITE_ONCE_MIN_SIZE; else write_once_size = DATA_WRITE_ONCE_MAX_SIZE; @@ -151,7 +151,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta) (total_len * 1000000 / start_us) / 1024 % 1024); upg_fat_free_align(buf); - aicos_free_align(0, fwc); + aicupg_free_align(fwc); return total_len; err: @@ -159,7 +159,7 @@ err: if (buf) upg_fat_free_align(buf); if (fwc) - aicos_free_align(0, fwc); + aicupg_free_align(fwc); return 0; } @@ -175,7 +175,7 @@ s32 aicupg_fat_write(char *image_name, char *protection, u64 total_len = 0; pmeta = NULL; - pmeta = (struct fwc_meta *)aicos_malloc_align(0, header->meta_size, FRAME_LIST_SIZE); + pmeta = (struct fwc_meta *)aicupg_malloc_align(header->meta_size, FRAME_LIST_SIZE); if (!pmeta) { pr_err("Error: malloc for meta failed.\n"); ret = -1; @@ -231,10 +231,10 @@ s32 aicupg_fat_write(char *image_name, char *protection, (ulong)((total_len * 1000000 / start_us) / 1024 / 1024), (ulong)((total_len * 1000000 / start_us) / 1024 % 1024)); - aicos_free_align(0, pmeta); + aicupg_free_align(pmeta); return write_len; err: if (pmeta) - aicos_free_align(0, pmeta); + aicupg_free_align(pmeta); return 0; } diff --git a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_mmc.c b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_mmc.c index a4eddd33..de1f3373 100644 --- a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_mmc.c +++ b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_mmc.c @@ -28,7 +28,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath, printf("Programming %s to 0x%x\n", fpath, doffset); printf("\t"); - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); soffset = 0; writecnt = 0; @@ -62,7 +62,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath, } if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); printf("\n"); return ret; } @@ -79,7 +79,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath, printf("Programming %s to 0x%x\n", fpath, doffset); printf("\t"); - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); soffset = 0; dolen = MAX_WRITE_SIZE; @@ -149,8 +149,8 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath, /* Read raw chunk data */ if (chunk_data_sz > MAX_WRITE_SIZE) { - aicos_free_align(0, buf); - buf = aicos_malloc_align(0, chunk_data_sz, FRAME_LIST_SIZE); + aicupg_free_align(buf); + buf = aicupg_malloc_align(chunk_data_sz, FRAME_LIST_SIZE); p = buf; } @@ -225,7 +225,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath, out: if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); printf("\n"); return ret; } diff --git a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nand.c b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nand.c index e7909051..1a3d1aea 100644 --- a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nand.c +++ b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nand.c @@ -65,7 +65,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd) return -1; } - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); soffset = 0; while (1) { actread = 0; @@ -91,7 +91,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd) } if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); return 0; } @@ -103,7 +103,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd, u32 soffset; ulong dolen, actread, writecnt; - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); soffset = 0; writecnt = 0; @@ -155,7 +155,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd, } if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); return ret; } @@ -216,7 +216,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset) goto out; } - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); if (!buf) { pr_err("Failed to malloc buffer.\n"); ret = -1; @@ -255,7 +255,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset) out: if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); if (nftl && nftl->nandt) aicos_free(MEM_CMA, nftl->nandt); if (nftl) diff --git a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nor.c b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nor.c index 0d8b6b9a..8ef75713 100644 --- a/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nor.c +++ b/application/baremetal/bootloader/lib/aicupg/upg_fat_direct_nor.c @@ -58,7 +58,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset) printf("Programming %s to 0x%x\n", fpath, doffset); printf("\t"); - buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE); + buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE); soffset = 0; writecnt = 0; @@ -103,7 +103,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset) } if (buf) - aicos_free_align(0, buf); + aicupg_free_align(buf); printf("\n"); return ret; } diff --git a/application/baremetal/bootloader/lib/aicupg/upg_main.c b/application/baremetal/bootloader/lib/aicupg/upg_main.c index dece0845..199c328b 100644 --- a/application/baremetal/bootloader/lib/aicupg/upg_main.c +++ b/application/baremetal/bootloader/lib/aicupg/upg_main.c @@ -451,3 +451,13 @@ void media_data_write_end(struct fwc_info *fwc) break; } } + +void *aicupg_malloc_align(u32 size, size_t align) +{ + return aicos_malloc_align(MEM_RESERVED, size, align); +} + +void aicupg_free_align(void *ptr) +{ + aicos_free_align(MEM_RESERVED, ptr); +} diff --git a/application/baremetal/bootloader/lib/fatfs/fatfs.c b/application/baremetal/bootloader/lib/fatfs/fatfs.c index e6f1c024..301ed342 100644 --- a/application/baremetal/bootloader/lib/fatfs/fatfs.c +++ b/application/baremetal/bootloader/lib/fatfs/fatfs.c @@ -1,9 +1,9 @@ /* - * Copyright (c) 2023, Artinchip Technology Co., Ltd + * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * - * Wu Dehuang + * Authors: Wu Dehuang */ #include @@ -487,8 +487,8 @@ static s32 exfat_search_file(struct fat_volume *vol, struct fat_file *file, /* Bingo */ file->start_clus = first_cluster; file->size = data_len; - pr_err("Start cluster: 0x%X\n", file->start_clus); - pr_err("bootcfg file size: 0x%X\n", file->size); + pr_debug("Start cluster: 0x%X\n", file->start_clus); + pr_debug("bootcfg file size: 0x%X\n", file->size); return 0; } } diff --git a/application/baremetal/bootloader/main.c b/application/baremetal/bootloader/main.c index 898392d4..ac13c400 100644 --- a/application/baremetal/bootloader/main.c +++ b/application/baremetal/bootloader/main.c @@ -63,7 +63,7 @@ struct hal_axicfg_table axi_cfg_table[HAL_AXICFG_PORT_MAX] = { static void aic_board_heap_init(enum boot_device bd) { - size_t heap_size, heap_start, real_ram_size = 0; + size_t real_ram_size = 0; #if AIC_PSRAM_SIZE config_ram_size = AIC_PSRAM_SIZE; @@ -79,15 +79,7 @@ static void aic_board_heap_init(enum boot_device bd) if (config_ram_size != real_ram_size) pr_warn("config ram size(0x%x) is not equal real ram size(0x%x)\n", (u32)config_ram_size, (u32)real_ram_size); - heap_size = ((size_t)&__heap_end) - ((size_t)&__heap_start); - - /* Limit bootloader's heap to 2MB */ - if (bd != BD_UDISK && bd != BD_SDFAT32 && bd != BD_USB && heap_size > 0x200000) - heap_size = 0x200000; - - heap_start = (size_t)&__heap_end - heap_size; - - heap_init((void *)heap_start, heap_size); + heap_init(); } static int board_init(enum boot_device bd) diff --git a/bsp/Kconfig b/bsp/Kconfig index 12963470..ec769ebf 100644 --- a/bsp/Kconfig +++ b/bsp/Kconfig @@ -313,22 +313,27 @@ config AIC_CIR_DRV_TEST depends on AIC_CIR_DRV config AIC_AUDIO_DRV_TEST - bool "Enable audio driver test command" + bool "Enable Audio driver test command" default n depends on AIC_AUDIO_DRV select RT_USING_LEGACY config AIC_I2S_DRV_TEST - bool "Enable i2s driver test command" + bool "Enable I2S driver test command" default n depends on AIC_I2S_DRV select RT_USING_LEGACY config AIC_I2C_DRV_TEST - bool "Enable i2c driver test command" + bool "Enable I2C driver test command" default n depends on AIC_I2C_DRV +config AIC_CAMERA_DRV_TEST + bool "Enable Camera driver test command" + default n + depends on AIC_USING_CAMERA + config AIC_DVP_TEST bool "Enable DVP driver test command" default n @@ -400,6 +405,11 @@ config AIC_QEP_DRV_TEST default n depends on AIC_QEP_DRV +config AIC_DCE_DRV_TEST + bool "Enable Dce driver test command" + default n + depends on AIC_DCE_DRV + config AIC_ADCIM_DM_TEST bool "Enable ADCIM DM test command" default n diff --git a/bsp/artinchip/SConscript b/bsp/artinchip/SConscript index 9c0e1c01..41575ff1 100644 --- a/bsp/artinchip/SConscript +++ b/bsp/artinchip/SConscript @@ -88,9 +88,12 @@ if GetDepend('AIC_QSPI_DRV'): ver = ver.replace('"','') if GetDepend('DRIVER_DRV_EN'): src += Glob('drv/qspi/*.c') + src += Glob('drv/spi/*.c') if GetDepend('DRIVER_HAL_EN'): src += Glob('hal/qspi/*.c', exclude=['hal/qspi/*_v*.c']) src += Glob('hal/qspi/*_v%sx.c' % (ver[0])) + if GetDepend('DRIVER_BARE_DRV_EN') and GetDepend('AIC_QSPI_DRV_TEST'): + src += Glob('drv_bare/qspi/*.c') # XSPI driver if GetDepend('AIC_XSPI_DRV'): @@ -378,6 +381,8 @@ if GetDepend('AIC_PWM_DRV'): if GetDepend('DRIVER_HAL_EN'): src += Glob('hal/pwm/*.c') + src += Glob('drv/xpwm/xpwm_info_v11.c') + if GetDepend('DRIVER_HAL_EN'): src += Glob('hal/xpwm/*.c') if GetDepend('AIC_HRTIMER_DRV_V12'): @@ -443,6 +448,13 @@ if GetDepend('AIC_CE_DRV'): if GetDepend('DRIVER_HAL_EN'): src += Glob('hal/ce/*.c') +# DCE driver +if GetDepend('AIC_DCE_DRV'): + if GetDepend('DRIVER_DRV_EN'): + src += Glob('drv/dce/*.c') + if GetDepend('DRIVER_HAL_EN'): + src += Glob('hal/dce/*.c') + # TOUCH driver if GetDepend('AIC_USING_TOUCH') and GetDepend('KERNEL_BAREMETAL'): if GetDepend('DRIVER_BARE_DRV_EN'): diff --git a/bsp/artinchip/drv/ce/drv_ce.c b/bsp/artinchip/drv/ce/drv_ce.c index 33c37b4d..d345d611 100644 --- a/bsp/artinchip/drv/ce/drv_ce.c +++ b/bsp/artinchip/drv/ce/drv_ce.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -15,6 +15,10 @@ #include #include #include +#ifdef AIC_DCE_DRV +#include +#include +#endif #define AES_BLOCK_SIZE 16 #define AES_MAX_KEY_LEN 32 @@ -649,6 +653,66 @@ static const struct hwcrypto_hash_ops hash_ops = { .finish = drv_hash_finish, }; +#ifdef AIC_DCE_DRV +#define CRC_32_POLY 0x04C11DB7 +rt_err_t drv_crc_init(struct rt_hwcrypto_ctx *ctx) +{ + rt_err_t res = RT_EOK; + + res = hal_dce_init(); + if (res) + res = -RT_ERROR; + + return res; +} + +static rt_uint32_t drv_crc_update(struct hwcrypto_crc *ctx, const rt_uint8_t *in, + rt_size_t length) +{ + rt_uint32_t crc_result = 0, ret; + + if (ctx->crc_cfg.poly != CRC_32_POLY) { + pr_err("Artinchip hardware crc only support CRC_32_POLY.\n"); + return -RT_ERROR; + } + + if (ctx->crc_cfg.xorout) + hal_dce_crc32_xor_val(ctx->crc_cfg.xorout); + if (ctx->crc_cfg.flags) + hal_dce_crc32_cfg((ctx->crc_cfg.flags & CRC_FLAG_REFIN), 0, + (ctx->crc_cfg.flags & CRC_FLAG_REFIN), + (ctx->crc_cfg.flags & CRC_FLAG_REFOUT)); + + hal_dce_crc32_start(ctx->crc_cfg.last_val, (u8 *)in, length); + ret = hal_dce_crc32_wait(); + if (!ret) { + crc_result = hal_dce_crc32_result(); + } else { + pr_err("\t%s error: time out\n", __func__); + return -RT_ERROR; + } + + ctx->crc_cfg.last_val = crc_result; + return crc_result; +} + +void drv_crc_uninit(struct rt_hwcrypto_ctx *ctx) +{ + if (!ctx) + return; + + if (ctx->contex) { + aicos_free_align(0, ctx->contex); + ctx->contex = NULL; + } + hal_dce_deinit(); +} + +static const struct hwcrypto_crc_ops crc_ops = { + .update = drv_crc_update, +}; +#endif + static rt_err_t aic_hwcrypto_create(struct rt_hwcrypto_ctx *ctx) { rt_err_t res = RT_EOK; @@ -677,6 +741,12 @@ static rt_err_t aic_hwcrypto_create(struct rt_hwcrypto_ctx *ctx) /* Setup HASH operation */ ((struct hwcrypto_hash *)ctx)->ops = &hash_ops; break; +#ifdef AIC_DCE_DRV + case HWCRYPTO_TYPE_CRC: + drv_crc_init(ctx); + ((struct hwcrypto_crc *)ctx)->ops = &crc_ops; + break; +#endif default: res = -RT_ERROR; break; @@ -703,6 +773,11 @@ static void aic_hwcrypto_destroy(struct rt_hwcrypto_ctx *ctx) case HWCRYPTO_TYPE_SHA2: drv_sha_uninit(ctx); break; +#ifdef AIC_DCE_DRV + case HWCRYPTO_TYPE_CRC: + drv_crc_uninit(ctx); + break; +#endif default: break; } @@ -743,7 +818,6 @@ static void aic_hwcrypto_reset(struct rt_hwcrypto_ctx *ctx) break; case HWCRYPTO_TYPE_RC4: case HWCRYPTO_TYPE_RNG: - case HWCRYPTO_TYPE_CRC: break; case HWCRYPTO_TYPE_BIGNUM: drv_rsa_init(ctx); @@ -754,6 +828,11 @@ static void aic_hwcrypto_reset(struct rt_hwcrypto_ctx *ctx) drv_sha_init(ctx); drv_sha_start(ctx); break; +#ifdef AIC_DCE_DRV + case HWCRYPTO_TYPE_CRC: + drv_crc_init(ctx); + break; +#endif default: break; } diff --git a/bsp/artinchip/drv/cir/Kconfig b/bsp/artinchip/drv/cir/Kconfig index 521b64c9..fe935d2d 100644 --- a/bsp/artinchip/drv/cir/Kconfig +++ b/bsp/artinchip/drv/cir/Kconfig @@ -3,7 +3,7 @@ #----------------------------- menu "CIR protocol select" - depends on AIC_USING_CIR + depends on (AIC_USING_CIR || AIC_USING_R_CIR) config AIC_CIR_NEC bool "NEC protocol" diff --git a/bsp/artinchip/drv/cir/drv_cir.c b/bsp/artinchip/drv/cir/drv_cir.c index 08337b9f..b2d223a3 100644 --- a/bsp/artinchip/drv/cir/drv_cir.c +++ b/bsp/artinchip/drv/cir/drv_cir.c @@ -180,6 +180,15 @@ int rt_hw_aic_cir_init(void) aic_cir_dev.dev.type = RT_Device_Class_Char; #endif +#ifdef AIC_USING_R_CIR + aic_cir_dev.aic_cir_ctrl.cir_base = R_CIR_BASE; + aic_cir_dev.aic_cir_ctrl.irq_num = R_CIR_IRQn; +#else + aic_cir_dev.aic_cir_ctrl.cir_base = CIR_BASE; + aic_cir_dev.aic_cir_ctrl.irq_num = CIR_IRQn; +#endif + aic_cir_dev.aic_cir_ctrl.clk_idx = CLK_CIR; + rt_mutex_init(&aic_cir_dev.lock, "cir_mutex", RT_IPC_FLAG_PRIO); rt_device_register(&aic_cir_dev.dev, "cir", 0); LOG_I("ArtInChip CIR device register success\n"); diff --git a/bsp/artinchip/drv/dce/Kconfig b/bsp/artinchip/drv/dce/Kconfig new file mode 100644 index 00000000..312a76f3 --- /dev/null +++ b/bsp/artinchip/drv/dce/Kconfig @@ -0,0 +1,3 @@ +#----------------------------- +# devices local parameter +#----------------------------- diff --git a/bsp/artinchip/drv/dce/drv_dce.c b/bsp/artinchip/drv/dce/drv_dce.c new file mode 100644 index 00000000..aafc456c --- /dev/null +++ b/bsp/artinchip/drv/dce/drv_dce.c @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2024, ArtInChip Technology CO.,LTD. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: Chen Junlong + */ +/* do nothing, dce drv is implemented in ce drv */ diff --git a/bsp/artinchip/drv/display/Kconfig b/bsp/artinchip/drv/display/Kconfig index 25144b41..854ee931 100644 --- a/bsp/artinchip/drv/display/Kconfig +++ b/bsp/artinchip/drv/display/Kconfig @@ -225,3 +225,26 @@ endif config AIC_PANEL_SPI_EMULATION bool default n + +config AIC_SCREEN_CROP + bool "Enable screen crop" + default n + help + Some LCD screen need to be cropped, the effective area displayed is less + than the timing signal. + If unsure select "N". + +if AIC_SCREEN_CROP + config AIC_SCREEN_CROP_POS_X + int "screen crop x position of pixels" + default 0 + config AIC_SCREEN_CROP_POS_Y + int "screen crop y position of pixels" + default 0 + config AIC_SCREEN_CROP_WIDTH + int "screen crop width" + default 0 + config AIC_SCREEN_CROP_HEIGHT + int "screen crop height" + default 0 +endif diff --git a/bsp/artinchip/drv/display/disp_conf.h b/bsp/artinchip/drv/display/disp_conf.h index 84bf5450..550d31ef 100644 --- a/bsp/artinchip/drv/display/disp_conf.h +++ b/bsp/artinchip/drv/display/disp_conf.h @@ -21,17 +21,42 @@ /** * lvds channel output order * - * default D3 CK D2 D1 D0 - * 4 3 2 1 0 + * link 0 default D3 CK D2 D1 D0 + * PD26/PD27 PD24/PD25 PD22/PD23 PD20/PD21 PD18/PD19 + * + * link 1 default D3 CK D2 D1 D0 + * PD16/PD17 PD14/PD15 PD12/PD13 PD10/PD11 PD8/PD9 + * + * + * link 0 example: + * D2 CK D3 D1 D0 + * PD26/PD27 PD24/PD25 PD22/PD23 PD20/PD21 PD18/PD19 + * + * AIC_LVDS_LINK0_LANES LVDS_LANES(LVDS_D2, LVDS_CK, LVDS_D3, LVDS_D1, LVDS_D0) + * link1 example is the same as link0 */ #define AIC_LVDS_LINK0_LANES LVDS_LANES(LVDS_D3, LVDS_CK, LVDS_D2, LVDS_D1, LVDS_D0) #define AIC_LVDS_LINK1_LANES LVDS_LANES(LVDS_D3, LVDS_CK, LVDS_D2, LVDS_D1, LVDS_D0) /** * lvds channel polarities + * + * link 0 default PD26/PD27 PD24/PD25 PD22/PD23 PD20/PD21 PD18/PD19 + * N/P N/P N/P N/P N/P + * + * link 1 default PD16/PD17 PD14/PD15 PD12/PD13 PD10/PD11 PD8/PD9 + * N/P N/P N/P N/P N/P + * + * + * link 0 example: + * PD26/PD27 PD24/PD25 PD22/PD23 PD20/PD21 PD18/PD19 + * N/P P/N N/P P/N N/P + * + * AIC_LVDS_LINK0_POL 0b01010 + * link1 example is the same as link0 */ -#define AIC_LVDS_LINK0_POL 0x0 -#define AIC_LVDS_LINK1_POL 0x0 +#define AIC_LVDS_LINK0_POL 0b00000 +#define AIC_LVDS_LINK1_POL 0b00000 /** * lvds channel phy config @@ -43,13 +68,41 @@ * MIPI-DSI options */ -/* data line assignments */ +/** + * data lane assignments + * + * default D3 D2 D1 D0 + * PD26/PD27 PD24/PD25 PD22/PD23 PD19/PD20 + * + * example D0 D1 D2 D3 + * PD26/PD27 PD24/PD25 PD22/PD23 PD19/PD20 + * + * LANE_ASSIGNMENTS 0x0123 + */ #define LANE_ASSIGNMENTS 0x3210 -/* data line polarities */ +/** + * data lane polarities + * + * default PD26/PD27 PD24/PD25 PD22/PD23 PD19/PD20 + * N/P N/P N/P N/P + * + * example PD26/PD27 PD24/PD25 PD22/PD23 PD19/PD20 + * P/N N/P P/N N/P + * + * LANE_POLARITIES 0b1010 + */ #define LANE_POLARITIES 0b0000 -/* data clk inverse */ +/** + * data clk inverse + * + * default PD24/PD25 + * N/P + * + * CLK_INVERSE 1 PD24/PD25 + * P/N + */ #define CLK_INVERSE 0 /* virtual channel id */ diff --git a/bsp/artinchip/drv/display/drv_de_core.c b/bsp/artinchip/drv/display/drv_de_core.c index b5ac78fd..8dd79523 100644 --- a/bsp/artinchip/drv/display/drv_de_core.c +++ b/bsp/artinchip/drv/display/drv_de_core.c @@ -17,9 +17,11 @@ #define DE_TIMEOUT_MS 100 -static unsigned int vsync_flag = 0; static struct aic_de_comp *g_aic_de_comp; +static int aic_de_set_gamma_config(struct aicfb_gamma_config *gamma); +static int aic_de_set_ccm_config(struct aicfb_ccm_config *ccm); + static struct aic_de_comp *aic_de_request_drvdata(void) { return g_aic_de_comp; @@ -38,10 +40,8 @@ static irqreturn_t aic_de_handler(int irq, void *ctx) status = de_timing_interrupt_status(comp->regs); de_timing_interrupt_clean_status(comp->regs, status); - if ((status & TIMING_INIT_V_BLANK_FLAG) && vsync_flag) { - vsync_flag = 0; + if (status & TIMING_INIT_V_BLANK_FLAG) aicos_wqueue_wakeup(comp->vsync_queue); - } if (comp->scaler_active & SCALER0_CTRL_ACTIVE) { comp->scaler_active = comp->scaler_active & 0xF; @@ -237,6 +237,9 @@ static int aic_de_timing_enable(void) de_timing_enable_interrupt(comp->regs, true, TIMING_INIT_UNDERFLOW_FLAG); #endif + aic_de_set_gamma_config(&comp->gamma); + aic_de_set_ccm_config(&comp->ccm); + de_timing_enable(comp->regs, 1); aic_de_release_drvdata(); @@ -257,7 +260,6 @@ static int aic_de_wait_for_vsync(void) struct aic_de_comp *comp = aic_de_request_drvdata(); int ret = 0; - vsync_flag = 1; ret = aicos_wqueue_wait(comp->vsync_queue, DE_TIMEOUT_MS); if (ret < 0) { hal_log_err("DE wait vsync irq failed, ret: %d\n", ret); diff --git a/bsp/artinchip/drv/display/drv_de_ui_layer.c b/bsp/artinchip/drv/display/drv_de_ui_layer.c index bbfcbf42..81a0ce12 100644 --- a/bsp/artinchip/drv/display/drv_de_ui_layer.c +++ b/bsp/artinchip/drv/display/drv_de_ui_layer.c @@ -208,6 +208,11 @@ int config_ui_layer_rect(struct aic_de_comp *comp, de_ui_layer_enable(comp->regs, 1); } +#ifdef AIC_SCREEN_CROP + x_offset += AIC_SCREEN_CROP_POS_X; + y_offset += AIC_SCREEN_CROP_POS_Y; +#endif + de_ui_layer_set_rect(comp->regs, in_w, in_h, x_offset, y_offset, stride0, addr0, layer_data->rect_id); de_ui_layer_rect_enable(comp->regs, layer_data->rect_id, 1); diff --git a/bsp/artinchip/drv/display/drv_de_vi_layer.c b/bsp/artinchip/drv/display/drv_de_vi_layer.c index 45b16d6c..0337cce0 100644 --- a/bsp/artinchip/drv/display/drv_de_vi_layer.c +++ b/bsp/artinchip/drv/display/drv_de_vi_layer.c @@ -746,6 +746,18 @@ static int de_vi_layer_config_format(struct aic_de_comp *comp, return -EINVAL; } +static void de_vi_layer_config_crop_pos(struct aic_de_comp *comp, + struct aicfb_layer_data *layer_data) +{ +#ifdef AIC_SCREEN_CROP + u32 x_offset = layer_data->pos.x + AIC_SCREEN_CROP_POS_X; + u32 y_offset = layer_data->pos.y + AIC_SCREEN_CROP_POS_Y; + + reg_write(comp->regs + VIDEO_LAYER_OFFSET, + VIDEO_LAYER_OFFSET_SET(x_offset, y_offset)); +#endif +} + int config_video_layer(struct aic_de_comp *comp, struct aicfb_layer_data *layer_data) { @@ -766,6 +778,7 @@ int config_video_layer(struct aic_de_comp *comp, } de_vi_layer_config_format(comp, format_info, layer_data); + de_vi_layer_config_crop_pos(comp, layer_data); return 0; } diff --git a/bsp/artinchip/drv/display/drv_fb.c b/bsp/artinchip/drv/display/drv_fb.c index 25cfef59..e31fabee 100644 --- a/bsp/artinchip/drv/display/drv_fb.c +++ b/bsp/artinchip/drv/display/drv_fb.c @@ -688,15 +688,20 @@ static void aicfb_fb_info_setup(struct aicfb_info *fbi) fbi->fb_rotate = 0; #endif +#ifdef AIC_SCREEN_CROP + active_w = AIC_SCREEN_CROP_WIDTH; + active_h = AIC_SCREEN_CROP_HEIGHT; +#else + active_w = fbi->panel->timings->hactive; + active_h = fbi->panel->timings->vactive; +#endif + if (fbi->fb_rotate == 90 || fbi->fb_rotate == 270) { - active_w = fbi->panel->timings->vactive; - active_h = fbi->panel->timings->hactive; - } - else - { - active_w = fbi->panel->timings->hactive; - active_h = fbi->panel->timings->vactive; + u32 tmp = active_w; + + active_w = active_h; + active_h = tmp; } stride = ALIGN_8B(active_w * bpp / 8); @@ -724,8 +729,8 @@ static void fb_color_block(struct aicfb_info *fbi) }; unsigned char *pos = (unsigned char *)fbi->fb_start; - width = fbi->panel->timings->hactive; - height = fbi->panel->timings->vactive; + width = fbi->width; + height = fbi->height; switch (fbi->bits_per_pixel) { #if defined(AICFB_ARGB8888) || defined(AICFB_ABGR8888) || defined(AICFB_XRGB8888) @@ -818,7 +823,6 @@ static void aicfb_update_alpha(struct aicfb_info *fbi) static void aicfb_update_layer(struct aicfb_info *fbi) { struct platform_driver *de = fbi->de; - struct aic_panel *panel = fbi->panel; struct aicfb_layer_data layer = {0}; layer.layer_id = AICFB_LAYER_TYPE_UI; @@ -830,11 +834,10 @@ static void aicfb_update_layer(struct aicfb_info *fbi) switch (fbi->fb_rotate) { case 0: - layer.buf.size.width = panel->timings->hactive; - layer.buf.size.height = panel->timings->vactive; + layer.buf.size.width = fbi->width; + layer.buf.size.height = fbi->height; layer.buf.stride[0] = fbi->stride; layer.buf.phy_addr[0] = (uintptr_t)fbi->fb_start; - layer.buf.format = AICFB_FORMAT; break; #ifdef AIC_FB_ROTATE_EN case 90: @@ -843,16 +846,15 @@ static void aicfb_update_layer(struct aicfb_info *fbi) unsigned int stride = ALIGN_8B(fbi->height * fbi->bits_per_pixel / 8); layer.buf.phy_addr[0] = (uintptr_t)fbi->fb_start + fbi->fb_size * AIC_FB_DRAW_BUF_NUM; - layer.buf.size.width = panel->timings->hactive; - layer.buf.size.height = panel->timings->vactive; + layer.buf.size.width = fbi->height; + layer.buf.size.height = fbi->width; layer.buf.stride[0] = stride; break; } case 180: - pr_info("rotate 180\n"); layer.buf.phy_addr[0] = (uintptr_t)fbi->fb_start + fbi->fb_size * AIC_FB_DRAW_BUF_NUM; - layer.buf.size.width = panel->timings->hactive; - layer.buf.size.height = panel->timings->vactive; + layer.buf.size.width = fbi->width; + layer.buf.size.height = fbi->height; layer.buf.stride[0] = fbi->stride; break; #endif diff --git a/bsp/artinchip/drv/i2c/Kconfig.dev b/bsp/artinchip/drv/i2c/Kconfig.dev index 83e0f881..ca9491a1 100644 --- a/bsp/artinchip/drv/i2c/Kconfig.dev +++ b/bsp/artinchip/drv/i2c/Kconfig.dev @@ -2,6 +2,25 @@ # i2c devices local parameter #----------------------------- +# soft_i2c parameter + +menu "SOFT_I2C Parameter" + depends on AIC_USING_SOFT_I2C + + config AIC_SOFT_I2C_SCL_PIN + string "SOFT_I2C SCL PIN" + default "PD.6" + + config AIC_SOFT_I2C_SDA_PIN + string "SOFT_I2C SDA PIN" + default "PD.7" + + config AIC_DEV_SOFT_I2C_DELAY_TIME + int "Setting SOFT_I2C GPIO Level Change Delay Time(us)" + default 5 + +endmenu + # i2c0 parameter menu "I2C0 Parameter" diff --git a/bsp/artinchip/drv/i2c/drv_i2c.c b/bsp/artinchip/drv/i2c/drv_i2c.c index 8a5d33c4..293e9dd6 100644 --- a/bsp/artinchip/drv/i2c/drv_i2c.c +++ b/bsp/artinchip/drv/i2c/drv_i2c.c @@ -117,17 +117,24 @@ struct aic_i2c_bus { struct rt_completion cmd_complete; }; -static struct aic_i2c_bus g_aic_i2c_dev[AIC_I2C_CH_NUM]; +static struct aic_i2c_bus g_aic_i2c_dev[I2C_MAX_CHAN]; irqreturn_t aic_i2c_slave_irqhandler(int irq, void * data) { - int index = irq - I2C0_IRQn; + int i, index = 0; uint32_t intr_stat; uint8_t val; uint8_t fifo_num; struct slave_param parm; aic_i2c_ctrl *i2c_dev; + for (i = 0; i < I2C_MAX_CHAN; i++) { + if (irq == g_aic_i2c_dev[i].aic_bus.irq_index) { + index = i; + break; + } + } + i2c_dev = &g_aic_i2c_dev[index].aic_bus; intr_stat = hal_i2c_get_raw_interrupt_state(i2c_dev); fifo_num = hal_i2c_get_receive_fifo_num(i2c_dev); @@ -280,10 +287,17 @@ static void aic_i2c_handle_write(struct aic_i2c_ctrl *i2c_dev) irqreturn_t aic_i2c_irqhandler(int irq, void * data) { - int index = irq - I2C0_IRQn; + int i, index = 0; uint32_t status = 0; aic_i2c_ctrl *i2c_dev; + for (i = 0; i < I2C_MAX_CHAN; i++) { + if (irq == g_aic_i2c_dev[i].aic_bus.irq_index) { + index = i; + break; + } + } + i2c_dev = &g_aic_i2c_dev[index].aic_bus; status = hal_i2c_get_raw_interrupt_state(i2c_dev); /* clear all interrupt flags */ @@ -386,7 +400,7 @@ static rt_size_t aic_i2c_master_xfer(struct rt_i2c_bus_device *bus, } hal_i2c_module_disable(i2c_dev); - return (ret < 0) ? ret : num; + return (ret < 0) ? 0 : num; } #else static rt_size_t aic_i2c_master_xfer(struct rt_i2c_bus_device *bus, diff --git a/bsp/artinchip/drv/i2c/drv_soft_i2c.c b/bsp/artinchip/drv/i2c/drv_soft_i2c.c new file mode 100644 index 00000000..f048ca05 --- /dev/null +++ b/bsp/artinchip/drv/i2c/drv_soft_i2c.c @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: hjh + */ +#include +#include +#include +#include +#include +#include +#include "aic_hal_clk.h" +#include "aic_common.h" +#include "aic_log.h" + +#define AIC_SOFT_I2C_TIMEOUT 1000 + +struct aic_soft_i2c_pin { + u32 sda_pin; + u32 scl_pin; +}; + +struct aic_soft_i2c_bus { + struct rt_i2c_bus_device bus; + struct aic_soft_i2c_pin aic_i2c_pin; +}; + +static struct aic_soft_i2c_bus g_aic_soft_i2c; + +static void aic_soft_i2c_set_sda(void *data, rt_int32_t state) +{ + rt_pin_mode(g_aic_soft_i2c.aic_i2c_pin.sda_pin, PIN_MODE_OUTPUT); + rt_pin_write(g_aic_soft_i2c.aic_i2c_pin.sda_pin, state); +} + +static void aic_soft_i2c_set_scl(void *data, rt_int32_t state) +{ + rt_pin_mode(g_aic_soft_i2c.aic_i2c_pin.scl_pin, PIN_MODE_OUTPUT); + rt_pin_write(g_aic_soft_i2c.aic_i2c_pin.scl_pin, state); +} + +static rt_int32_t aic_soft_i2c_get_sda(void *data) +{ + rt_int32_t ret; + + rt_pin_mode(g_aic_soft_i2c.aic_i2c_pin.sda_pin, PIN_MODE_INPUT_PULLUP); + ret = rt_pin_read(g_aic_soft_i2c.aic_i2c_pin.sda_pin); + + return ret; +} + +static rt_int32_t aic_soft_i2c_get_scl(void *data) +{ + rt_int32_t ret; + + rt_pin_mode(g_aic_soft_i2c.aic_i2c_pin.scl_pin, PIN_MODE_INPUT_PULLUP); + ret = rt_pin_read(g_aic_soft_i2c.aic_i2c_pin.scl_pin); + + return ret; +} + +static void aic_soft_i2c_udelay(rt_uint32_t us) +{ + aic_udelay(us); +} + +struct rt_i2c_bit_ops aic_soft_i2c_ops = { + .data = NULL, + .set_sda = aic_soft_i2c_set_sda, + .set_scl = aic_soft_i2c_set_scl, + .get_sda = aic_soft_i2c_get_sda, + .get_scl = aic_soft_i2c_get_scl, + .udelay = aic_soft_i2c_udelay, +#ifdef AIC_USING_SOFT_I2C + .delay_us = AIC_DEV_SOFT_I2C_DELAY_TIME, +#endif + .timeout = AIC_SOFT_I2C_TIMEOUT, +}; + +static int aic_soft_i2c_register() +{ + int ret = RT_EOK; + +#ifdef AIC_USING_SOFT_I2C + g_aic_soft_i2c.aic_i2c_pin.sda_pin = rt_pin_get(AIC_SOFT_I2C_SDA_PIN); + g_aic_soft_i2c.aic_i2c_pin.scl_pin = rt_pin_get(AIC_SOFT_I2C_SCL_PIN); + + g_aic_soft_i2c.bus.priv = &aic_soft_i2c_ops; + + ret = rt_i2c_bit_add_bus(&g_aic_soft_i2c.bus, "soft_i2c"); + if (ret) { + hal_log_err("register soft i2c fail\r\n"); + return ret; + } +#endif + + return ret; +} + +INIT_DEVICE_EXPORT(aic_soft_i2c_register); diff --git a/bsp/artinchip/drv/psadc/drv_psadc.c b/bsp/artinchip/drv/psadc/drv_psadc.c index 40b8c96f..7d476d2f 100644 --- a/bsp/artinchip/drv/psadc/drv_psadc.c +++ b/bsp/artinchip/drv/psadc/drv_psadc.c @@ -1,9 +1,9 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * - * Authors: Li Siyao + * Authors: Siyao Li */ #include @@ -229,9 +229,16 @@ static rt_uint8_t drv_psadc_resolution(struct rt_adc_device *dev) return 12; } +static rt_err_t drv_psadc_convert(struct rt_adc_device *dev, rt_uint32_t ch, + rt_uint32_t *value) +{ + return RT_EOK; +} + static const struct rt_adc_ops aic_adc_ops = { .enabled = drv_psadc_enabled, + .convert = drv_psadc_convert, .get_resolution = drv_psadc_resolution, .get_adc_values_poll = drv_psadc_get_adc_values_poll, .get_adc_values = drv_psadc_get_adc_values, diff --git a/bsp/artinchip/drv/qspi/drv_qspi.c b/bsp/artinchip/drv/qspi/drv_qspi.c index 46536a9f..84ca61df 100644 --- a/bsp/artinchip/drv/qspi/drv_qspi.c +++ b/bsp/artinchip/drv/qspi/drv_qspi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,7 +57,7 @@ static struct aic_qspi qspi_controller[] = { #endif }, #endif -#if defined(AIC_USING_QSPI1) +#if defined(AIC_USING_QSPI1) && !defined(AIC_QSPI1_BUS_SPI) { .name = "qspi1", .idx = 1, @@ -75,7 +75,7 @@ static struct aic_qspi qspi_controller[] = { #endif }, #endif -#if defined(AIC_USING_QSPI2) +#if defined(AIC_USING_QSPI2) && !defined(AIC_QSPI2_BUS_SPI) { .name = "qspi2", .idx = 2, @@ -93,7 +93,7 @@ static struct aic_qspi qspi_controller[] = { #endif }, #endif -#if defined(AIC_USING_QSPI3) +#if defined(AIC_USING_QSPI3) && !defined(AIC_QSPI3_BUS_SPI) { .name = "qspi3", .idx = 3, @@ -111,7 +111,7 @@ static struct aic_qspi qspi_controller[] = { #endif }, #endif -#if defined(AIC_USING_QSPI4) +#if defined(AIC_USING_QSPI4) && !defined(AIC_QSPI4_BUS_SPI) { .name = "qspi4", .idx = 4, diff --git a/bsp/artinchip/drv/spi/drv_spi.c b/bsp/artinchip/drv/spi/drv_spi.c new file mode 100644 index 00000000..e01f6144 --- /dev/null +++ b/bsp/artinchip/drv/spi/drv_spi.c @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Jiji Chen + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ASYNC_DATA_SIZE 64 + +struct aic_qspi { + struct rt_spi_bus dev; + char *name; + uint32_t idx; + uint32_t clk_id; + uint32_t clk_in_hz; + uint32_t dma_port_id; + uint32_t irq_num; +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + uint32_t cs_num; +#endif + qspi_master_handle handle; + struct rt_qspi_configuration configuration; + rt_sem_t xfer_sem; + bool inited; + uint32_t rxd_dlymode; + uint32_t txd_dlymode; + uint32_t txc_dlymode; + bool nonblock; +}; + +static struct aic_qspi spi_controller[] = { +#if defined(AIC_USING_QSPI1) && defined(AIC_QSPI1_BUS_SPI) + { + .name = "spi1", + .idx = 1, + .clk_id = CLK_QSPI1, + .clk_in_hz = AIC_DEV_QSPI1_MAX_SRC_FREQ_HZ, + .dma_port_id = DMA_ID_SPI1, + .irq_num = QSPI1_IRQn, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI1_CS_NUM, +#endif + .rxd_dlymode = AIC_DEV_QSPI1_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dlymode = AIC_DEV_QSPI1_TXD_DELAY_MODE, + .txc_dlymode = AIC_DEV_QSPI1_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI2) && defined(AIC_QSPI2_BUS_SPI) + { + .name = "spi2", + .idx = 2, + .clk_id = CLK_QSPI2, + .clk_in_hz = AIC_DEV_QSPI2_MAX_SRC_FREQ_HZ, + .dma_port_id = DMA_ID_SPI2, + .irq_num = QSPI2_IRQn, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI2_CS_NUM, +#endif + .rxd_dlymode = AIC_DEV_QSPI2_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dlymode = AIC_DEV_QSPI2_TXD_DELAY_MODE, + .txc_dlymode = AIC_DEV_QSPI2_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI3) && defined(AIC_QSPI3_BUS_SPI) + { + .name = "spi3", + .idx = 3, + .clk_id = CLK_QSPI3, + .clk_in_hz = AIC_DEV_QSPI3_MAX_SRC_FREQ_HZ, + .dma_port_id = DMA_ID_SPI3, + .irq_num = QSPI3_IRQn, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI3_CS_NUM, +#endif + .rxd_dlymode = AIC_DEV_QSPI3_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dlymode = AIC_DEV_QSPI3_TXD_DELAY_MODE, + .txc_dlymode = AIC_DEV_QSPI3_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI4) && defined(AIC_QSPI4_BUS_SPI) + { + .name = "spi4", + .idx = 4, + .clk_id = CLK_QSPI4, + .clk_in_hz = AIC_DEV_QSPI4_MAX_SRC_FREQ_HZ, + .dma_port_id = DMA_ID_SPI4, + .irq_num = QSPI4_IRQn, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI4_CS_NUM, +#endif + .rxd_dlymode = AIC_DEV_QSPI4_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dlymode = AIC_DEV_QSPI4_TXD_DELAY_MODE, + .txc_dlymode = AIC_DEV_QSPI4_TX_CLK_DELAY_MODE, +#endif + }, +#endif +}; + +static const u32 bit_mode_table[] = { +#ifdef AIC_QSPI1_BIT_MODE + 1, +#endif +#ifdef AIC_QSPI2_BIT_MODE + 2, +#endif +#ifdef AIC_QSPI3_BIT_MODE + 3, +#endif +}; + +static bool spi_support_bit_mode(struct aic_qspi *qspi) +{ + u32 i; + for (i = 0; i < ARRAY_SIZE(bit_mode_table); i++) { + if (bit_mode_table[i] == qspi->idx) + return true; + } + return false; +} + +#ifdef AIC_QSPI_DRV_DEBUG +void dump_cmd(uint8_t *data, uint32_t len) +{ + uint32_t i; + + printf("CMD: (%lu) ", (unsigned long)len); + for (i = 0; i < len; i++) + printf("%02X ", data[i]); + printf("\n"); +} +#endif + +static rt_uint32_t drv_spi_send(struct aic_qspi *qspi, + struct rt_spi_message *message, + const uint8_t *tx, uint32_t size) +{ + struct qspi_transfer t; + u32 ret = 0; + + t.rx_data = NULL; + t.tx_data = (uint8_t *)tx; + t.data_len = size; + ret = hal_qspi_master_transfer_sync(&qspi->handle, &t); + return ret; +} + +static rt_uint32_t drv_spi_receive(struct aic_qspi *qspi, + struct rt_spi_message *message, + const uint8_t *tx, uint32_t size) +{ + struct qspi_transfer t; + u32 ret = 0; + + t.tx_data = NULL; + t.rx_data = (uint8_t *)tx; + t.data_len = size; + ret = hal_qspi_master_transfer_sync(&qspi->handle, &t); + return ret; +} + +static rt_uint32_t drv_spi_transfer(struct aic_qspi *qspi, + struct rt_spi_message *message) +{ + u32 ret = 0; + struct qspi_transfer t; + + t.tx_data = (u8 *)message->send_buf; + t.rx_data = message->recv_buf; + t.data_len = message->length; + ret = hal_qspi_master_transfer_sync(&qspi->handle, &t); + return ret; +} + +static void spi_set_cs_before(struct rt_spi_device *device, + struct rt_spi_message *message) +{ + struct rt_qspi_configuration *cfg; + struct aic_qspi *qspi; + u32 cs_num = 0; + + qspi = (struct aic_qspi *)device->bus; + cfg = &qspi->configuration; + + if (message->cs_take && !(cfg->parent.mode & RT_SPI_NO_CS)) { +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + cs_num = qspi->cs_num; +#endif + hal_qspi_master_set_cs(&qspi->handle, cs_num, true); + } +} + +static void spi_set_cs_after(struct rt_spi_device *device, + struct rt_spi_message *message) +{ + struct rt_qspi_configuration *cfg; + struct aic_qspi *qspi; + u32 cs_num = 0; + + qspi = (struct aic_qspi *)device->bus; + cfg = &qspi->configuration; + + if (message->cs_release && !(cfg->parent.mode & RT_SPI_NO_CS)) { +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + cs_num = qspi->cs_num; +#endif + if (!qspi->nonblock) + hal_qspi_master_set_cs(&qspi->handle, cs_num, false); + } +} + +static rt_uint32_t spi_xfer(struct rt_spi_device *device, + struct rt_spi_message *message) +{ + struct aic_qspi *qspi; + rt_uint32_t ret = 0; + + RT_ASSERT(device != RT_NULL); + RT_ASSERT(device->bus != RT_NULL); + + qspi = (struct aic_qspi *)device->bus; + + spi_set_cs_before(device, message); + + if (message->recv_buf && message->send_buf) + ret = drv_spi_transfer(qspi, message); + else if (message->recv_buf) + ret = drv_spi_receive(qspi, message, message->recv_buf, message->length); + else if (message->send_buf) + ret = drv_spi_send(qspi, message, message->send_buf, message->length); + + spi_set_cs_after(device, message); + + if (ret) + return ret; + return message->length; +} + +static void qspi_master_async_callback(qspi_master_handle *h, void *priv) +{ + struct aic_qspi *qspi = priv; + u32 cs_num = 0; + +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + cs_num = qspi->cs_num; +#endif + rt_sem_release(qspi->xfer_sem); + hal_qspi_master_set_cs(&qspi->handle, cs_num, false); +} + +static irqreturn_t qspi_irq_handler(int irq_num, void *arg) +{ + qspi_master_handle *h = arg; + + rt_interrupt_enter(); + hal_qspi_master_irq_handler(h); + rt_interrupt_leave(); + + return IRQ_HANDLED; +} + +static rt_err_t spi_configure(struct rt_spi_device *device, + struct rt_spi_configuration *configuration) +{ + struct qspi_master_config cfg; + struct aic_qspi *qspi; + rt_uint32_t bus_hz; + rt_err_t ret = RT_EOK; + + RT_ASSERT(device != RT_NULL); + RT_ASSERT(configuration != RT_NULL); + + qspi = (struct aic_qspi *)device->bus; + + if (spi_support_bit_mode(qspi)) + qspi->handle.bit_mode = true; + else + qspi->handle.bit_mode = false; + + if ((rt_memcmp(&qspi->configuration, configuration, + sizeof(struct rt_spi_configuration)) != 0) || + (qspi->handle.bit_mode == true)) { + rt_memcpy(&qspi->configuration, configuration, + sizeof(struct rt_spi_configuration)); + rt_memset(&cfg, 0, sizeof(cfg)); + cfg.idx = qspi->idx; + cfg.clk_id = qspi->clk_id; + + bus_hz = configuration->max_hz; + if (bus_hz < HAL_QSPI_MIN_FREQ_HZ) + bus_hz = HAL_QSPI_MIN_FREQ_HZ; + if (bus_hz > HAL_QSPI_MAX_FREQ_HZ) + bus_hz = HAL_QSPI_MAX_FREQ_HZ; + cfg.clk_in_hz = qspi->clk_in_hz; + if (cfg.clk_in_hz > HAL_QSPI_MAX_FREQ_HZ) + cfg.clk_in_hz = HAL_QSPI_MAX_FREQ_HZ; + if (qspi->clk_in_hz % bus_hz) + cfg.clk_in_hz = bus_hz; + if (cfg.clk_in_hz < HAL_QSPI_INPUT_MIN_FREQ_HZ) + cfg.clk_in_hz = HAL_QSPI_INPUT_MIN_FREQ_HZ; + + if (configuration->mode & RT_SPI_MSB) + cfg.lsb_en = false; + else + cfg.lsb_en = true; + if (configuration->mode & RT_SPI_CPHA) + cfg.cpha = HAL_QSPI_CPHA_SECOND_EDGE; + else + cfg.cpha = HAL_QSPI_CPHA_FIRST_EDGE; + + if (configuration->mode & RT_SPI_CPOL) + cfg.cpol = HAL_QSPI_CPOL_ACTIVE_LOW; + else + cfg.cpol = HAL_QSPI_CPOL_ACTIVE_HIGH; + if (configuration->mode & RT_SPI_CS_HIGH) + cfg.cs_polarity = HAL_QSPI_CS_POL_VALID_HIGH; + else + cfg.cs_polarity = HAL_QSPI_CS_POL_VALID_LOW; + cfg.rx_dlymode = qspi->rxd_dlymode; + cfg.tx_dlymode = aic_convert_tx_dlymode(qspi->txc_dlymode, qspi->txd_dlymode); + + ret = hal_qspi_master_init(&qspi->handle, &cfg); + if (ret) { + pr_err("spi init failed.\n"); + return ret; + } + + if (!qspi->inited) { +#ifdef AIC_DMA_DRV + struct qspi_master_dma_config dmacfg; + rt_memset(&dmacfg, 0, sizeof(dmacfg)); + dmacfg.port_id = qspi->dma_port_id; + + ret = hal_qspi_master_dma_config(&qspi->handle, &dmacfg); + if (ret) { + pr_err("qspi dma config failed.\n"); + return ret; + } +#endif + ret = hal_qspi_master_register_cb(&qspi->handle, + qspi_master_async_callback, qspi); + if (ret) { + pr_err("qspi register async callback failed.\n"); + return ret; + } + aicos_request_irq(qspi->irq_num, qspi_irq_handler, 0, NULL, + (void *)&qspi->handle); + aicos_irq_enable(qspi->irq_num); + } + bus_hz = configuration->max_hz; + if (bus_hz > HAL_QSPI_MAX_FREQ_HZ) + bus_hz = HAL_QSPI_MAX_FREQ_HZ; + hal_qspi_master_set_bus_freq(&qspi->handle, bus_hz); + if (ret) { + pr_err("qspi set bus frequency failed.\n"); + return ret; + } + } + qspi->inited = true; + return ret; +} + +static rt_err_t spi_nonblock_set(struct rt_spi_device *device, + rt_uint32_t nonblock) +{ + struct aic_qspi *qspi; + + qspi = (struct aic_qspi *)device->bus; + if (nonblock == 1) + qspi->nonblock = true; + else + qspi->nonblock = false; + + return RT_EOK; +} + +static rt_uint32_t spi_get_transfer_status(struct rt_spi_device *device) +{ + struct aic_qspi *qspi; + + qspi = (struct aic_qspi *)device->bus; + + return hal_qspi_master_get_status(&qspi->handle); +} + +rt_err_t aic_spi_bus_attach_device(const char *bus_name, + const char *device_name) +{ + struct rt_spi_device *spi_device = RT_NULL; + rt_err_t result = RT_EOK; + + RT_ASSERT(bus_name != RT_NULL); + RT_ASSERT(device_name != RT_NULL); + + spi_device = + (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); + + result = rt_spi_bus_attach_device(spi_device, device_name, + bus_name, RT_NULL); + + if (result != RT_EOK && spi_device != NULL) + rt_free(spi_device); + + return result; +} + +static const struct rt_spi_ops aic_spi_ops = { + .configure = spi_configure, + .xfer = spi_xfer, + .nonblock = spi_nonblock_set, + .gstatus = spi_get_transfer_status, +}; + +static int rt_hw_spi_bus_init(void) +{ + char sem_name[RT_NAME_MAX]; + rt_err_t ret = RT_EOK; + int i; + + for (i = 0; i < ARRAY_SIZE(spi_controller); i++) { + ret = rt_spi_bus_register(&spi_controller[i].dev, + spi_controller[i].name, &aic_spi_ops); + if (ret != RT_EOK) + break; + rt_sprintf(sem_name, "%s_s", spi_controller[i].name); + spi_controller[i].xfer_sem = + rt_sem_create(sem_name, 0, RT_IPC_FLAG_PRIO); + if (!spi_controller[i].xfer_sem) { + ret = RT_ENOMEM; + break; + } + } + + return ret; +} + +INIT_BOARD_EXPORT(rt_hw_spi_bus_init); diff --git a/bsp/artinchip/drv/uart/Kconfig.dev b/bsp/artinchip/drv/uart/Kconfig.dev index b47f9933..4ea74420 100644 --- a/bsp/artinchip/drv/uart/Kconfig.dev +++ b/bsp/artinchip/drv/uart/Kconfig.dev @@ -94,6 +94,10 @@ menu "UART0 Parameter" default 6 if AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART0_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART0_RTS_ENABLE bool prompt "Enable RTS" @@ -258,6 +262,10 @@ menu "UART1 Parameter" default 6 if AIC_DEV_UART1_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART1_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART1_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART1_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART1_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART1_RTS_ENABLE bool prompt "Enable RTS" @@ -422,6 +430,9 @@ menu "UART2 Parameter" default 6 if AIC_DEV_UART2_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART2_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART2_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART2_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART2_MODE_RS232_SW_HW_FLOW_CTRL menuconfig AIC_UART2_RTS_ENABLE bool @@ -588,6 +599,10 @@ menu "UART3 Parameter" default 6 if AIC_DEV_UART3_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART3_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART3_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART3_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART3_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART3_RTS_ENABLE bool prompt "Enable RTS" @@ -752,6 +767,10 @@ menu "UART4 Parameter" default 6 if AIC_DEV_UART4_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART4_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART4_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART4_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART4_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART4_RTS_ENABLE bool prompt "Enable RTS" @@ -917,6 +936,10 @@ menu "UART5 Parameter" default 6 if AIC_DEV_UART5_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART5_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART5_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART5_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART5_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART5_RTS_ENABLE bool prompt "Enable RTS" @@ -1081,6 +1104,10 @@ menu "UART6 Parameter" default 6 if AIC_DEV_UART6_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART6_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART6_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART6_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART6_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART6_RTS_ENABLE bool prompt "Enable RTS" @@ -1245,6 +1272,10 @@ menu "UART7 Parameter" default 6 if AIC_DEV_UART7_MODE_RS232_SW_HW_FLOW_CTRL default 7 if AIC_DEV_UART7_MODE_RS485_SIMULATION + config AIC_SERIAL_USING_FLOWCTRL + bool + default y if AIC_DEV_UART7_MODE_RS232_UNAUTO_FLOW_CTRL || AIC_DEV_UART7_MODE_RS232_SW_FLOW_CTRL || AIC_DEV_UART7_MODE_RS232_SW_HW_FLOW_CTRL + menuconfig AIC_UART7_RTS_ENABLE bool prompt "Enable RTS" diff --git a/bsp/artinchip/drv_bare/console/console.c b/bsp/artinchip/drv_bare/console/console.c index 343bcdee..048f28a5 100644 --- a/bsp/artinchip/drv_bare/console/console.c +++ b/bsp/artinchip/drv_bare/console/console.c @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Wu Dehuang + */ + #include #include #include @@ -383,7 +391,8 @@ static int console_run_cmd_internal(struct tiny_console *cons, for (c = root; c; c = c->next) { int rc = CONSOLE_OK; - if (strncasecmp(c->cmdname, args[starg_arg], strlen(args[starg_arg]))) + if (strncasecmp(c->cmdname, args[starg_arg], strlen(c->cmdname)) || + strlen(c->cmdname) != strlen(args[starg_arg])) continue; /* name is matched */ diff --git a/bsp/artinchip/drv_bare/qspi/spi.c b/bsp/artinchip/drv_bare/qspi/spi.c new file mode 100644 index 00000000..b52ce3b9 --- /dev/null +++ b/bsp/artinchip/drv_bare/qspi/spi.c @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: jiji.chen + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct aic_qspi_bus qspi_bus_arr[] = { +#if defined(AIC_USING_QSPI0) && defined(AIC_QSPI0_DEVICE_SPINOR) + { + .name = "qspi0", + .idx = 0, + .clk_id = CLK_QSPI0, + .clk_in_hz = AIC_DEV_QSPI0_MAX_SRC_FREQ_HZ, + .bus_hz = AIC_QSPI0_DEVICE_SPINOR_FREQ, + .dma_port_id = DMA_ID_SPI0, + .irq_num = QSPI0_IRQn, + .dl_width = AIC_QSPI0_BUS_WIDTH, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI0_CS_NUM, +#endif + .rxd_dylmode = AIC_DEV_QSPI0_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dylmode = AIC_DEV_QSPI0_TXD_DELAY_MODE, + .txc_dylmode = AIC_DEV_QSPI0_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI1) && defined(AIC_QSPI1_DEVICE_SPINOR) + { + .name = "qspi1", + .idx = 1, + .clk_id = CLK_QSPI1, + .clk_in_hz = AIC_DEV_QSPI1_MAX_SRC_FREQ_HZ, + .bus_hz = AIC_QSPI1_DEVICE_SPINOR_FREQ, + .dma_port_id = DMA_ID_SPI1, + .irq_num = QSPI1_IRQn, + .dl_width = AIC_QSPI1_BUS_WIDTH, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI1_CS_NUM, +#endif + .rxd_dylmode = AIC_DEV_QSPI1_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dylmode = AIC_DEV_QSPI1_TXD_DELAY_MODE, + .txc_dylmode = AIC_DEV_QSPI1_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI2) && defined(AIC_QSPI2_DEVICE_SPINOR) + { + .name = "qspi2", + .idx = 2, + .clk_id = CLK_QSPI2, + .clk_in_hz = AIC_DEV_QSPI2_MAX_SRC_FREQ_HZ, + .bus_hz = AIC_QSPI2_DEVICE_SPINOR_FREQ, + .dma_port_id = DMA_ID_SPI2, + .irq_num = QSPI2_IRQn, + .dl_width = AIC_QSPI2_BUS_WIDTH, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI2_CS_NUM, +#endif + .rxd_dylmode = AIC_DEV_QSPI2_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dylmode = AIC_DEV_QSPI2_TXD_DELAY_MODE, + .txc_dylmode = AIC_DEV_QSPI2_TX_CLK_DELAY_MODE, +#endif + }, +#endif +#if defined(AIC_USING_QSPI3) + { + .name = "qspi3", + .idx = 3, + .clk_id = CLK_QSPI3, + .clk_in_hz = AIC_DEV_QSPI3_MAX_SRC_FREQ_HZ, + .bus_hz = AIC_QSPI3_DEVICE_SPINOR_FREQ, + .dma_port_id = DMA_ID_SPI3, + .irq_num = QSPI3_IRQn, + .dl_width = AIC_QSPI3_BUS_WIDTH, +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + .cs_num = AIC_QSPI3_CS_NUM, +#endif + .rxd_dylmode = AIC_DEV_QSPI3_DELAY_MODE, +#if defined(AIC_QSPI_DRV_V20) + .txd_dylmode = AIC_DEV_QSPI3_TXD_DELAY_MODE, + .txc_dylmode = AIC_DEV_QSPI3_TX_CLK_DELAY_MODE, +#endif + }, +#endif +}; + +int spi_write_read(struct aic_qspi_bus *qspi, + const uint8_t *write_buf, size_t write_size, + uint8_t *read_buf, size_t read_size) +{ + struct qspi_transfer t; + int ret = 0; + u32 cs_num = 0; + + hal_qspi_master_set_bus_width(&qspi->handle, HAL_QSPI_BUS_WIDTH_SINGLE); +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + cs_num = qspi->cs_num; +#endif + hal_qspi_master_set_cs(&qspi->handle, cs_num, true); + if (write_size) { + t.rx_data = NULL; + t.tx_data = (uint8_t *)write_buf; + t.data_len = write_size; + ret = hal_qspi_master_transfer_sync(&qspi->handle, &t); + if (ret < 0) + goto out; + } + if (read_size) { + t.rx_data = read_buf; + t.tx_data = NULL; + t.data_len = read_size; + ret = hal_qspi_master_transfer_sync(&qspi->handle, &t); + } +out: +#if defined(AIC_QSPI_MULTIPLE_CS_NUM) + cs_num = qspi->cs_num; +#endif + hal_qspi_master_set_cs(&qspi->handle, cs_num, false); + return ret; +} + +static struct aic_qspi_bus *get_qspi_by_index(u32 idx) +{ + struct aic_qspi_bus *qspi; + u32 i; + + qspi = NULL; + for (i = 0; i < ARRAY_SIZE(qspi_bus_arr); i++) { + if (qspi_bus_arr[i].idx == idx) { + qspi = &qspi_bus_arr[i]; + break; + } + } + + return qspi; +} + +struct aic_qspi_bus *qspi_probe(u32 spi_bus) +{ + + struct aic_qspi_bus *qspi; + int ret; + struct qspi_master_config cfg = {0}; + + qspi = get_qspi_by_index(spi_bus); + if (!qspi) { + pr_err("spi bus is invalid: %d\n", spi_bus); + return NULL; + } + + if (qspi->probe_flag) + return qspi; + + memset(&cfg, 0, sizeof(cfg)); + cfg.idx = qspi->idx; + cfg.clk_in_hz = qspi->clk_in_hz; + cfg.clk_id = qspi->clk_id; + cfg.cpol = HAL_QSPI_CPOL_ACTIVE_HIGH; + cfg.cpha = HAL_QSPI_CPHA_FIRST_EDGE; + cfg.cs_polarity = HAL_QSPI_CS_POL_VALID_LOW; + cfg.rx_dlymode = qspi->rxd_dylmode; + cfg.tx_dlymode = aic_convert_tx_dlymode(qspi->txc_dylmode, qspi->txd_dylmode); + + ret = hal_qspi_master_init(&qspi->handle, &cfg); + if (ret) { + pr_err("hal_qspi_master_init failed. ret %d\n", ret); + return NULL; + } + +#ifdef AIC_DMA_DRV + struct qspi_master_dma_config dmacfg; + memset(&dmacfg, 0, sizeof(dmacfg)); + dmacfg.port_id = qspi->dma_port_id; + + ret = hal_qspi_master_dma_config(&qspi->handle, &dmacfg); + if (ret) { + pr_err("qspi dma config failed.\n"); + return NULL; + } + +#endif + + qspi->probe_flag = true; + return qspi; +} diff --git a/bsp/artinchip/drv_bare/umm_heap/malloc_port.c b/bsp/artinchip/drv_bare/umm_heap/malloc_port.c index 422c76e3..b598b0b8 100644 --- a/bsp/artinchip/drv_bare/umm_heap/malloc_port.c +++ b/bsp/artinchip/drv_bare/umm_heap/malloc_port.c @@ -1,44 +1,237 @@ +/* + * Copyright (C) 2023-2024 ArtInChip Technology Co.,Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: Dehuang Wu + */ + #include #include #include #include +#include #include "umm_malloc.h" -int heap_init(void *ptr, size_t size) +/* mem check */ + +#if defined(AIC_BOOTLOADER) && defined(AIC_BOOTLOADER_MEM_AUTO) +#if AIC_PSRAM_SIZE + #if (AIC_BOOTLOADER_TEXT_BASE < CPU_PSRAM_BASE) + #error AIC_BOOTLOADER_TEXT_BASE less than CPU_PSRAM_BASE + #endif + #if (AIC_BOOTLOADER_TEXT_BASE > (CPU_PSRAM_BASE + AIC_PSRAM_SIZE)) + #error AIC_BOOTLOADER_TEXT_BASE more than (CPU_PSRAM_BASE + AIC_PSRAM_SIZE) + #endif +#elif AIC_DRAM_TOTAL_SIZE + #if (AIC_BOOTLOADER_TEXT_BASE < CPU_DRAM_BASE) + #error AIC_BOOTLOADER_TEXT_BASE less than CPU_DRAM_BASE + #endif + #if (AIC_BOOTLOADER_TEXT_BASE > (CPU_DRAM_BASE + AIC_DRAM_TOTAL_SIZE)) + #error AIC_BOOTLOADER_TEXT_BASE more than (CPU_DRAM_BASE + AIC_DRAM_TOTAL_SIZE) + #endif +#elif AIC_SRAM_SIZE + #if (AIC_BOOTLOADER_TEXT_BASE < CPU_SRAM_BASE) + #error AIC_BOOTLOADER_TEXT_BASE less than CPU_SRAM_BASE + #endif + #if (AIC_BOOTLOADER_TEXT_BASE > (CPU_SRAM_BASE + AIC_SRAM_SIZE)) + #error AIC_BOOTLOADER_TEXT_BASE more than (CPU_SRAM_BASE + AIC_SRAM_SIZE) + #endif +#elif AIC_SRAM_TOTAL_SIZE + #if (AIC_BOOTLOADER_TEXT_BASE < CPU_SRAM_BASE) + #error AIC_BOOTLOADER_TEXT_BASE less than CPU_SRAM_BASE + #endif + #if (AIC_BOOTLOADER_TEXT_BASE > (CPU_SRAM_BASE + AIC_SRAM_TOTAL_SIZE)) + #error AIC_BOOTLOADER_TEXT_BASE more than (CPU_SRAM_BASE + AIC_SRAM_TOTAL_SIZE) + #endif +#endif +#endif + +typedef struct { + char * name; + aic_mem_region_t type; + size_t start; + size_t end; +} heap_def_t; + +static struct umm_heap_config heap[MAX_MEM_REGION]; + +static heap_def_t heap_def[MAX_MEM_REGION] = { + { + .name = "sys", + .type = MEM_DEFAULT, + .start = (size_t)(&__heap_start), + .end = (size_t)(&__heap_end), + }, + +#if defined(AIC_BOOTLOADER) && defined(AIC_BOOTLOADER_MEM_AUTO) + { + .name = "reserved", + .type = MEM_RESERVED, +#if AIC_PSRAM_SIZE + .start = (size_t)(CPU_PSRAM_BASE), + .end = (size_t)(AIC_BOOTLOADER_TEXT_BASE - 0x100), +#elif AIC_DRAM_TOTAL_SIZE + .start = (size_t)(CPU_DRAM_BASE), + .end = (size_t)(AIC_BOOTLOADER_TEXT_BASE - 0x100), + +#elif AIC_SRAM_SIZE || AIC_SRAM_TOTAL_SIZE + .start = (size_t)(CPU_SRAM_BASE), + .end = (size_t)(AIC_BOOTLOADER_TEXT_BASE - 0x100), +#endif + }, +#endif +}; + +int heap_init(void) { - umm_init_heap(ptr, size); + int i = 0; + size_t start, end; + + for (i = 0; i < MAX_MEM_REGION; i++) { + start = heap_def[i].start; + end = heap_def[i].end; + if (start >= end) { + pr_err("%s: region %d addr err. start = 0x%x, end = 0x%x\n", __func__, i, (u32)start, (u32)end); + return -1; + } + + umm_init_heap(&heap[i], (void *)start, (end - start)); + } + return 0; } #ifndef TLSF_MEM_HEAP -void *aic_tlsf_malloc(uint32_t mem_type, uint32_t nbytes) +void *aic_tlsf_malloc(u32 mem_type, u32 nbytes) { - return umm_malloc(nbytes); + void *ptr; + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + ptr = umm_malloc(&heap[0], nbytes); + return ptr; + } + + ptr = umm_malloc(&heap[i], nbytes); + + pr_debug("%s: ptr = 0x%x, nbytes = 0x%x.\n", __func__, (u32)(uintptr_t)ptr, nbytes); + + return ptr; } -void aic_tlsf_free(uint32_t mem_type, void *ptr) +void aic_tlsf_free(u32 mem_type, void *ptr) { - umm_free(ptr); + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + pr_debug("%s: ptr = 0x%x.\n", __func__, (u32)(uintptr_t)ptr); + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + umm_free(&heap[0], ptr); + return; + } + + umm_free(&heap[i], ptr); } -void *aic_tlsf_malloc_align(uint32_t mem_type, uint32_t size, uint32_t align) +void *aic_tlsf_malloc_align(u32 mem_type, u32 nbytes, u32 align) { - return umm_malloc_align(size, align); + void *ptr; + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + ptr = umm_malloc_align(&heap[0], nbytes, align); + return ptr; + } + + ptr = umm_malloc_align(&heap[i], nbytes, align); + + pr_debug("%s: ptr = 0x%x, nbytes = 0x%x.\n", __func__, (u32)(uintptr_t)ptr, nbytes); + + return ptr; } -void aic_tlsf_free_align(uint32_t mem_type, void *ptr) +void aic_tlsf_free_align(u32 mem_type, void *ptr) { - umm_free_align(ptr); + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + pr_debug("%s: ptr = 0x%x.\n", __func__, (u32)(uintptr_t)ptr); + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + umm_free_align(&heap[0], ptr); + return; + } + + umm_free_align(&heap[i], ptr); } -void *aic_tlsf_realloc(uint32_t mem_type, void *ptr, uint32_t nbytes) +void *aic_tlsf_realloc(u32 mem_type, void *ptr, u32 nbytes) { - return umm_realloc(ptr, nbytes); + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + ptr = umm_realloc(&heap[0], ptr, nbytes); + return ptr; + } + + ptr = umm_realloc(&heap[i], ptr, nbytes); + + pr_debug("%s: ptr = 0x%x, nbytes = 0x%x.\n", __func__, (u32)(uintptr_t)ptr, nbytes); + + return ptr; } -void *aic_tlsf_calloc(uint32_t mem_type, uint32_t count, uint32_t size) +void *aic_tlsf_calloc(u32 mem_type, u32 count, u32 nbytes) { - return umm_calloc(count, size); + void *ptr; + int i = 0; + + for (i = 0; i < sizeof(heap_def) / sizeof(heap_def_t); i++) { + if (heap_def[i].type == mem_type) + break; + } + + if (i >= MAX_MEM_REGION) { + pr_debug("%s: not found mem type %d, use mem type 0.\n", __func__, mem_type); + ptr = umm_calloc(&heap[0], count, nbytes); + return ptr; + } + + ptr = umm_calloc(&heap[i], count, nbytes); + + pr_debug("%s: ptr = 0x%x, nbytes = 0x%x.\n", __func__, (u32)(uintptr_t)ptr, nbytes); + + return ptr; } #endif diff --git a/bsp/artinchip/drv_bare/umm_heap/newlib_syscalls.c b/bsp/artinchip/drv_bare/umm_heap/newlib_syscalls.c index 7d9a6d63..ddd1ef06 100644 --- a/bsp/artinchip/drv_bare/umm_heap/newlib_syscalls.c +++ b/bsp/artinchip/drv_bare/umm_heap/newlib_syscalls.c @@ -19,13 +19,14 @@ #include #include #include -#include +#include +#include void *_malloc_r(struct _reent *ptr, size_t size) { void* result; - result = (void*)umm_malloc(size); + result = (void*)aic_tlsf_malloc(MEM_DEFAULT, size); if (result == NULL) { ptr->_errno = ENOMEM; @@ -38,7 +39,7 @@ void *_realloc_r(struct _reent *ptr, void *old, size_t newlen) { void* result; - result = (void*)umm_realloc(old, newlen); + result = (void*)aic_tlsf_realloc(MEM_DEFAULT, old, newlen); if (result == NULL) { ptr->_errno = ENOMEM; @@ -51,7 +52,7 @@ void *_calloc_r(struct _reent *ptr, size_t size, size_t len) { void* result; - result = (void*)umm_calloc(size, len); + result = (void*)aic_tlsf_calloc(MEM_DEFAULT, size, len); if (result == NULL) { ptr->_errno = ENOMEM; @@ -62,7 +63,7 @@ void *_calloc_r(struct _reent *ptr, size_t size, size_t len) void _free_r(struct _reent *ptr, void *addr) { - umm_free(addr); + aic_tlsf_free(MEM_DEFAULT, addr); } int *__errno(void) diff --git a/bsp/artinchip/drv_bare/umm_heap/umm_malloc.c b/bsp/artinchip/drv_bare/umm_heap/umm_malloc.c index 7e077b8a..f21d1430 100644 --- a/bsp/artinchip/drv_bare/umm_heap/umm_malloc.c +++ b/bsp/artinchip/drv_bare/umm_heap/umm_malloc.c @@ -34,6 +34,7 @@ * R.Hempel 2020-02-01 - Macro functions are uppercased - See Issue 34 * R.Hempel 2020-06-20 - Support alternate body size - See Issue 42 * R.Hempel 2021-05-02 - Support explicit memory umm_init_heap() - See Issue 53 + * K.Whitlock 2023-07-06 - Add support for multiple heaps * ---------------------------------------------------------------------------- */ @@ -81,18 +82,9 @@ UMM_H_ATTPACKPRE typedef struct umm_block_t { /* ------------------------------------------------------------------------- */ -struct umm_heap_config { - umm_block *pheap; - size_t heap_size; - uint16_t numblocks; -}; - -struct umm_heap_config umm_heap_current; -// struct umm_heap_config umm_heaps[UMM_NUM_HEAPS]; - -#define UMM_HEAP (umm_heap_current.pheap) -#define UMM_HEAPSIZE (umm_heap_current.heap_size) -#define UMM_NUMBLOCKS (umm_heap_current.numblocks) +#define UMM_HEAP ((umm_block *)heap->pheap) +#define UMM_HEAPSIZE (heap->heap_size) +#define UMM_NUMBLOCKS (heap->numblocks) #define UMM_BLOCKSIZE (sizeof(umm_block)) #define UMM_BLOCK_LAST (UMM_NUMBLOCKS - 1) @@ -200,7 +192,8 @@ static uint16_t umm_blocks(size_t size) { * * Note that free pointers are NOT modified by this function. */ -static void umm_split_block(uint16_t c, +static void umm_split_block(umm_heap *heap, + uint16_t c, uint16_t blocks, uint16_t new_freemask) { @@ -213,7 +206,7 @@ static void umm_split_block(uint16_t c, /* ------------------------------------------------------------------------ */ -static void umm_disconnect_from_free_list(uint16_t c) { +static void umm_disconnect_from_free_list(umm_heap *heap, uint16_t c) { /* Disconnect this block from the FREE list */ UMM_NFREE(UMM_PFREE(c)) = UMM_NFREE(c); @@ -230,7 +223,7 @@ static void umm_disconnect_from_free_list(uint16_t c) { * next block is free. */ -static void umm_assimilate_up(uint16_t c) { +static void umm_assimilate_up(umm_heap *heap, uint16_t c) { if (UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_FREELIST_MASK) { @@ -245,7 +238,7 @@ static void umm_assimilate_up(uint16_t c) { /* Disconnect the next block from the FREE list */ - umm_disconnect_from_free_list(UMM_NBLOCK(c)); + umm_disconnect_from_free_list(heap, UMM_NBLOCK(c)); /* Assimilate the next block with this one */ @@ -260,7 +253,7 @@ static void umm_assimilate_up(uint16_t c) { * up before assimilating down. */ -static uint16_t umm_assimilate_down(uint16_t c, uint16_t freemask) { +static uint16_t umm_assimilate_down(umm_heap *heap, uint16_t c, uint16_t freemask) { // We are going to assimilate down to the previous block because // it was free, so remove it from the fragmentation metric @@ -285,10 +278,10 @@ static uint16_t umm_assimilate_down(uint16_t c, uint16_t freemask) { /* ------------------------------------------------------------------------- */ -void umm_init_heap(void *ptr, size_t size) +void umm_init_heap(umm_heap *heap, void *ptr, size_t size) { /* init heap pointer and size, and memset it to 0 */ - UMM_HEAP = (umm_block *)ptr; + heap->pheap = ptr; UMM_HEAPSIZE = size; UMM_NUMBLOCKS = (UMM_HEAPSIZE / UMM_BLOCKSIZE); memset(UMM_HEAP, 0x00, UMM_HEAPSIZE); @@ -337,10 +330,10 @@ void umm_init_heap(void *ptr, size_t size) } -void umm_init(void) { +void umm_init(umm_heap *heap) { /* Initialize the heap from linker supplied values */ - umm_init_heap(UMM_MALLOC_CFG_HEAP_ADDR, UMM_MALLOC_CFG_HEAP_SIZE); + umm_init_heap(heap, UMM_MALLOC_CFG_HEAP_ADDR, UMM_MALLOC_CFG_HEAP_SIZE); } /* ------------------------------------------------------------------------ @@ -348,7 +341,7 @@ void umm_init(void) { * UMM_CRITICAL_ENTRY(id) and UMM_CRITICAL_EXIT(id). */ -static void umm_free_core(void *ptr) { +static void umm_free_core(umm_heap *heap, void *ptr) { uint16_t c; @@ -369,7 +362,7 @@ static void umm_free_core(void *ptr) { /* Now let's assimilate this block with the next one if possible. */ - umm_assimilate_up(c); + umm_assimilate_up(heap, c); /* Then assimilate with the previous block if possible */ @@ -377,7 +370,7 @@ static void umm_free_core(void *ptr) { DBGLOG_DEBUG("Assimilate down to previous block, which is FREE\n"); - c = umm_assimilate_down(c, UMM_FREELIST_MASK); + c = umm_assimilate_down(heap, c, UMM_FREELIST_MASK); } else { /* * The previous block is not a free block, so add this one to the head @@ -398,7 +391,7 @@ static void umm_free_core(void *ptr) { /* ------------------------------------------------------------------------ */ -void umm_free(void *ptr) { +void umm_free(umm_heap *heap, void *ptr) { UMM_CRITICAL_DECL(id_free); UMM_CHECK_INITIALIZED(); @@ -411,11 +404,20 @@ void umm_free(void *ptr) { return; } + /* If we're being asked to free an out of range pointer - do nothing */ + /* TODO: remove the check for NULL pointer later */ + + if ((ptr < heap->pheap) || ((size_t)ptr >= (size_t)heap->pheap + heap->heap_size)) { + DBGLOG_DEBUG("free an out of range pointer -> do nothing\n"); + + return; + } + /* Free the memory withing a protected critical section */ UMM_CRITICAL_ENTRY(id_free); - umm_free_core(ptr); + umm_free_core(heap, ptr); UMM_CRITICAL_EXIT(id_free); } @@ -425,7 +427,7 @@ void umm_free(void *ptr) { * UMM_CRITICAL_ENTRY(id) and UMM_CRITICAL_EXIT(id). */ -static void *umm_malloc_core(size_t size) { +static void *umm_malloc_core(umm_heap *heap, size_t size) { uint16_t blocks; uint16_t blockSize = 0; @@ -493,7 +495,7 @@ static void *umm_malloc_core(size_t size) { /* Disconnect this block from the FREE list */ - umm_disconnect_from_free_list(cf); + umm_disconnect_from_free_list(heap, cf); } else { /* It's not an exact fit and we need to split off a block. */ @@ -503,7 +505,7 @@ static void *umm_malloc_core(size_t size) { * split current free block `cf` into two blocks. The first one will be * returned to user, so it's not free, and the second one will be free. */ - umm_split_block(cf, blocks, UMM_FREELIST_MASK /*new block is free*/); + umm_split_block(heap, cf, blocks, UMM_FREELIST_MASK /*new block is free*/); UMM_FRAGMENTATION_METRIC_ADD(UMM_NBLOCK(cf)); @@ -536,7 +538,7 @@ static void *umm_malloc_core(size_t size) { /* ------------------------------------------------------------------------ */ -void *umm_malloc(size_t size) { +void *umm_malloc(umm_heap *heap, size_t size) { UMM_CRITICAL_DECL(id_malloc); void *ptr = NULL; @@ -560,7 +562,7 @@ void *umm_malloc(size_t size) { UMM_CRITICAL_ENTRY(id_malloc); - ptr = umm_malloc_core(size); + ptr = umm_malloc_core(heap, size); UMM_CRITICAL_EXIT(id_malloc); @@ -569,7 +571,7 @@ void *umm_malloc(size_t size) { /* ------------------------------------------------------------------------ */ -void *umm_realloc(void *ptr, size_t size) { +void *umm_realloc(umm_heap *heap, void *ptr, size_t size) { UMM_CRITICAL_DECL(id_realloc); uint16_t blocks; @@ -594,7 +596,7 @@ void *umm_realloc(void *ptr, size_t size) { if (((void *)NULL == ptr)) { DBGLOG_DEBUG("realloc the NULL pointer - call malloc()\n"); - return umm_malloc(size); + return umm_malloc(heap, size); } /* @@ -606,7 +608,7 @@ void *umm_realloc(void *ptr, size_t size) { if (0 == size) { DBGLOG_DEBUG("realloc to 0 size, just free the block\n"); - umm_free(ptr); + umm_free(heap, ptr); return (void *)NULL; } @@ -698,20 +700,20 @@ void *umm_realloc(void *ptr, size_t size) { // Case 2 - block + next block fits EXACTLY } else if ((blockSize + nextBlockSize) == blocks) { DBGLOG_DEBUG("exact realloc using next block - %i\n", blocks); - umm_assimilate_up(c); + umm_assimilate_up(heap, c); blockSize += nextBlockSize; // Case 3 - prev block NOT free and block + next block fits } else if ((0 == prevBlockSize) && (blockSize + nextBlockSize) >= blocks) { DBGLOG_DEBUG("realloc using next block - %i\n", blocks); - umm_assimilate_up(c); + umm_assimilate_up(heap, c); blockSize += nextBlockSize; // Case 4 - prev block + block fits } else if ((prevBlockSize + blockSize) >= blocks) { DBGLOG_DEBUG("realloc using prev block - %i\n", blocks); - umm_disconnect_from_free_list(UMM_PBLOCK(c)); - c = umm_assimilate_down(c, 0); + umm_disconnect_from_free_list(heap, UMM_PBLOCK(c)); + c = umm_assimilate_down(heap, c, 0); memmove((void *)&UMM_DATA(c), ptr, curSize); ptr = (void *)&UMM_DATA(c); blockSize += prevBlockSize; @@ -719,9 +721,9 @@ void *umm_realloc(void *ptr, size_t size) { // Case 5 - prev block + block + next block fits } else if ((prevBlockSize + blockSize + nextBlockSize) >= blocks) { DBGLOG_DEBUG("realloc using prev and next block - %i\n", blocks); - umm_assimilate_up(c); - umm_disconnect_from_free_list(UMM_PBLOCK(c)); - c = umm_assimilate_down(c, 0); + umm_assimilate_up(heap, c); + umm_disconnect_from_free_list(heap, UMM_PBLOCK(c)); + c = umm_assimilate_down(heap, c, 0); memmove((void *)&UMM_DATA(c), ptr, curSize); ptr = (void *)&UMM_DATA(c); blockSize += (prevBlockSize + nextBlockSize); @@ -730,10 +732,10 @@ void *umm_realloc(void *ptr, size_t size) { } else { DBGLOG_DEBUG("realloc a completely new block %i\n", blocks); void *oldptr = ptr; - if ((ptr = umm_malloc_core(size))) { + if ((ptr = umm_malloc_core(heap, size))) { DBGLOG_DEBUG("realloc %i to a bigger block %i, copy, and free the old\n", blockSize, blocks); memcpy(ptr, oldptr, curSize); - umm_free_core(oldptr); + umm_free_core(heap, oldptr); } else { DBGLOG_DEBUG("realloc %i to a bigger block %i failed - return NULL and leave the old block!\n", blockSize, blocks); /* This space intentionally left blnk */ @@ -747,8 +749,8 @@ void *umm_realloc(void *ptr, size_t size) { if (blockSize > blocks) { DBGLOG_DEBUG("split and free %i blocks from %i\n", blocks, blockSize); - umm_split_block(c, blocks, 0); - umm_free_core((void *)&UMM_DATA(c + blocks)); + umm_split_block(heap, c, blocks, 0); + umm_free_core(heap, (void *)&UMM_DATA(c + blocks)); } /* Release the critical section... */ @@ -759,10 +761,10 @@ void *umm_realloc(void *ptr, size_t size) { /* ------------------------------------------------------------------------ */ -void *umm_calloc(size_t num, size_t item_size) { +void *umm_calloc(umm_heap *heap, size_t num, size_t item_size) { void *ret; - ret = umm_malloc((size_t)(item_size * num)); + ret = umm_malloc(heap, (size_t)(item_size * num)); if (ret) { memset(ret, 0x00, (size_t)(item_size * num)); @@ -771,7 +773,7 @@ void *umm_calloc(size_t num, size_t item_size) { return ret; } -void *umm_malloc_align(size_t size, size_t align) +void *umm_malloc_align(umm_heap *heap, size_t size, size_t align) { void *ptr; void *align_ptr; @@ -788,7 +790,7 @@ void *umm_malloc_align(size_t size, size_t align) /* get total aligned size */ align_size = ((size + uintptr_size) & ~uintptr_size) + align; /* allocate memory block from heap */ - ptr = umm_malloc(align_size); + ptr = umm_malloc(heap, align_size); if (ptr != NULL) { /* the allocated memory block is aligned */ if (((unsigned long)ptr & (align - 1)) == 0) { @@ -807,7 +809,7 @@ void *umm_malloc_align(size_t size, size_t align) return ptr; } -void umm_free_align(void *ptr) +void umm_free_align(umm_heap *heap, void *ptr) { void *real_ptr; @@ -815,6 +817,6 @@ void umm_free_align(void *ptr) if (ptr == NULL) return; real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *)); - umm_free(real_ptr); + umm_free(heap, real_ptr); } /* ------------------------------------------------------------------------ */ diff --git a/bsp/artinchip/drv_bare/umm_heap/umm_malloc.h b/bsp/artinchip/drv_bare/umm_heap/umm_malloc.h index eb8eb5d0..a3fafacf 100644 --- a/bsp/artinchip/drv_bare/umm_heap/umm_malloc.h +++ b/bsp/artinchip/drv_bare/umm_heap/umm_malloc.h @@ -16,15 +16,21 @@ extern "C" { /* ------------------------------------------------------------------------ */ -extern void umm_init_heap(void *ptr, size_t size); -extern void umm_init(void); +typedef struct umm_heap_config { + void *pheap; + size_t heap_size; + uint16_t numblocks; +} umm_heap; -extern void *umm_malloc(size_t size); -extern void *umm_calloc(size_t num, size_t size); -extern void *umm_realloc(void *ptr, size_t size); -extern void umm_free(void *ptr); -extern void *umm_malloc_align(size_t size, size_t align); -extern void umm_free_align(void *ptr); +extern void umm_init_heap(umm_heap *heap, void *ptr, size_t size); +extern void umm_init(umm_heap *heap); + +extern void *umm_malloc(umm_heap *heap, size_t size); +extern void *umm_calloc(umm_heap *heap, size_t num, size_t size); +extern void *umm_realloc(umm_heap *heap, void *ptr, size_t size); +extern void umm_free(umm_heap *heap, void *ptr); +extern void *umm_malloc_align(umm_heap *heap, size_t size, size_t align); +extern void umm_free_align(umm_heap *heap, void *ptr); /* ------------------------------------------------------------------------ */ diff --git a/bsp/artinchip/hal/cir/hal_cir.c b/bsp/artinchip/hal/cir/hal_cir.c index 3adb0311..439aeedb 100644 --- a/bsp/artinchip/hal/cir/hal_cir.c +++ b/bsp/artinchip/hal/cir/hal_cir.c @@ -15,9 +15,6 @@ int hal_cir_init(aic_cir_ctrl_t *aic_cir_ctrl) int ret = 0; uint32_t reg_val; - aic_cir_ctrl->cir_base = CIR_BASE; - aic_cir_ctrl->irq_num = CIR_IRQn; - aic_cir_ctrl->clk_idx = CLK_CIR; ret = hal_clk_enable_deassertrst(aic_cir_ctrl->clk_idx); /* Set noise thresholld */ @@ -56,7 +53,7 @@ int hal_cir_set_tx_carrier(aic_cir_ctrl_t * aic_cir_ctrl, { uint32_t mod_clk, clk_div, carrier_high, carrier_low, val; - mod_clk = hal_clk_get_freq(CLK_CIR); + mod_clk = hal_clk_get_freq(aic_cir_ctrl->clk_idx); if (protocol == 1) { /* RC5 protocol */ clk_div = DIV_ROUND_UP(mod_clk, 36000); @@ -79,7 +76,7 @@ void hal_cir_set_rx_sample_clock(aic_cir_ctrl_t * aic_cir_ctrl, { uint32_t mod_clk, clk_div; - mod_clk = hal_clk_get_freq(CLK_CIR); + mod_clk = hal_clk_get_freq(aic_cir_ctrl->clk_idx); if (protocol == 1) { /* RC5 protocol */ clk_div = DIV_ROUND_UP(mod_clk, 36000); diff --git a/bsp/artinchip/hal/dce/hal_dce.c b/bsp/artinchip/hal/dce/hal_dce.c new file mode 100644 index 00000000..7a15484c --- /dev/null +++ b/bsp/artinchip/hal/dce/hal_dce.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024, ArtInChip Technology CO.,LTD. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Chen JunLong + */ +#include +#include +#include +#include +#include +#include "aic_hal_clk.h" + +int hal_dce_init(void) +{ + int ret = 0; + + ret = hal_clk_enable(CLK_DCE); + if (ret < 0) { + hal_log_err("Failed to enable DCE clk.\n"); + return -EFAULT; + } + + ret = hal_clk_enable_deassertrst(CLK_DCE); + if (ret < 0) { + hal_log_err("Failed to reset DCE deassert.\n"); + return -EFAULT; + } + return 0; +} + +void hal_dce_deinit(void) +{ + hal_clk_disable(CLK_DCE); + hal_clk_disable_assertrst(CLK_DCE); +} + +void hal_dce_checksum_start(u8 *data, u32 len) +{ + writel((u32)data, DCE_ADDR_REG); + writel(len, DCE_LEN_REG); + writel(DCE_ALG_SUM, DCE_CFG_REG); + writel(0x1, DCE_CTL_REG); +} + +u32 hal_dce_checksum_wait(void) +{ + int ret = 0, cnt = 0; + u32 val; + + while (1) { + val = readl(DCE_ISR_REG); + if (val & DCE_SUM_FINISH_MSK) { + ret = 0; + break; + } + if (val & DCE_ERR_ALL_MSK) { + ret = DCE_CALC_ERR; + break; + } + cnt++; + if (cnt >= DCE_WAIT_CNT) { + ret = DCE_CALC_TMO; + break; + } + aic_udelay(100); + } + /* Clear all status */ + writel(0xFFFFFFFF, DCE_ISR_REG); + return ret; +} + +u32 hal_dce_checksum_result(void) +{ + return readl(DCE_SUM_RST_REG); +} + +/* + * param u32 out_bit_in_word:OUTPUT_BIT_IN_WORD_REV 0 or 1 + * param u32 input_bit_in_byte:INPUT_BIT_IN_BYTE_REV 0 or 1 + * param u32 input_bit_in_word:INPUT_BIT_IN_WORD_REV 0 or 1 + * param u32 input_byte_in_word:INPUT_BYTE_IN_WORD_REV 0 or 1 + * return 0 success other failed + */ +void hal_dce_crc32_cfg(u32 out_bit_in_word, u32 input_bit_in_byte, + u32 input_bit_in_word, u32 input_byte_in_word) +{ + u32 val = 0; + + if (out_bit_in_word) + val |= OUTPUT_BIT_IN_WORD_REV; + if (input_bit_in_byte) + val |= INPUT_BIT_IN_BYTE_REV; + if (input_bit_in_word) + val |= INPUT_BIT_IN_WORD_REV; + if (input_byte_in_word) + val |= INPUT_BYTE_IN_WORD_REV; + writel(val, DCE_CRC_CFG_REG); +} + +void hal_dce_crc32_xor_val(u32 val) +{ + writel(val, DCE_CRC_XOROUT_REG); +} + +void hal_dce_crc32_start(u32 crc, u8 *data, u32 len) +{ + if (crc) + writel(crc, DCE_CRC_INIT_REG); + writel((u32)data, DCE_ADDR_REG); + writel(len, DCE_LEN_REG); + writel(DCE_ALG_CRC, DCE_CFG_REG); + writel(0x1, DCE_CTL_REG); +} + +int hal_dce_crc32_wait(void) +{ + int ret = 0, cnt = 0; + u32 val; + + while (1) { + val = readl(DCE_ISR_REG); + if (val & DCE_CRC_FINISH_MSK) { + ret = 0; + break; + } + if (val & DCE_ERR_ALL_MSK) { + ret = DCE_CALC_ERR; + break; + } + cnt++; + if (cnt >= DCE_WAIT_CNT) { + ret = DCE_CALC_TMO; + break; + } + aic_udelay(100); + } + /* Clear all status */ + writel(0xFFFFFFFF, DCE_ISR_REG); + return ret; +} + +u32 hal_dce_crc32_result(void) +{ + return readl(DCE_CRC_RST_REG); +} + +u32 hal_get_version(void) +{ + return readl(DCE_GET_VERSION_REG); +} diff --git a/bsp/artinchip/hal/ge/hal_ge_hw.c b/bsp/artinchip/hal/ge/hal_ge_hw.c index 6d06ee4d..2a3f4dcb 100644 --- a/bsp/artinchip/hal/ge/hal_ge_hw.c +++ b/bsp/artinchip/hal/ge/hal_ge_hw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -12,28 +12,28 @@ #define CSC_COEFFS_NUM 12 -static const unsigned int yuv2rgb_bt601[CSC_COEFFS_NUM] = { - 0x04a8, 0x0000, 0x0662, 0x3212, - 0x04a8, 0x1e70, 0x1cc0, 0x087a, - 0x04a8, 0x0811, 0x0000, 0x2eb4 +static const int yuv2rgb_bt601[CSC_COEFFS_NUM] = { + 1192, 0, 1634, -3269, + 1192, -401, -833, 2467, + 1192, 2066, 0, -4131 }; -static const unsigned int yuv2rgb_bt709[CSC_COEFFS_NUM] = { - 0x04a8, 0x0000, 0x0722, 0x3093, - 0x04a8, 0x1f27, 0x1ddf, 0x04ce, - 0x04a8, 0x0873, 0x0000, 0x2df2 +static const int yuv2rgb_bt709[CSC_COEFFS_NUM] = { + 1192, 0, 1836, -3970, + 1192, -218, -546, 1230, + 1192, 2163, 0, -4624 }; -static const unsigned int yuv2rgb_bt601_full[CSC_COEFFS_NUM] = { - 0x0400, 0x0000, 0x059c, 0x34ca, - 0x0400, 0x1ea1, 0x1d26, 0x0877, - 0x0400, 0x0717, 0x0000, 0x31d4 +static const int yuv2rgb_bt601_full[CSC_COEFFS_NUM] = { + 1024, 0, 1436, -2871, + 1024, -352, -731, 2167, + 1024, 1815, 0, -3629 }; -static const unsigned int yuv2rgb_bt709_full[CSC_COEFFS_NUM] = { - 0x0400, 0x0000, 0x064d, 0x3368, - 0x0400, 0x1f41, 0x1e22, 0x053e, - 0x0400, 0x076c, 0x0000, 0x3129 +static const int yuv2rgb_bt709_full[CSC_COEFFS_NUM] = { + 1024, 0, 1613, -3225, + 1024, -192, -479, 1342, + 1024, 1900, 0, -3800 }; static const int rgb2yuv_bt601[CSC_COEFFS_NUM] = { @@ -274,7 +274,7 @@ void ge_scaler0_enable(unsigned long base_addr, u32 enable) void ge_set_csc_coefs(unsigned long base_addr, int color_space, u32 csc) { - const u32 *coefs; + const int *coefs; int i; switch (color_space) { diff --git a/bsp/artinchip/hal/ge/hal_ge_normal.c b/bsp/artinchip/hal/ge/hal_ge_normal.c index d2aee609..d76a1b3b 100644 --- a/bsp/artinchip/hal/ge/hal_ge_normal.c +++ b/bsp/artinchip/hal/ge/hal_ge_normal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -381,8 +381,8 @@ static int check_bitblt(struct aic_ge_data *data, struct ge_bitblt *blt) } if (blt->src_buf.crop_en) { - if (src_rect->x < 0 || - src_rect->y < 0 || + if (src_rect->x < 0 || !src_rect->width || + src_rect->y < 0 || !src_rect->height || src_rect->x >= src_size->width || src_rect->y >= src_size->height) { hal_log_err("%s failed, invalid src crop\n", @@ -392,8 +392,8 @@ static int check_bitblt(struct aic_ge_data *data, struct ge_bitblt *blt) } if (blt->dst_buf.crop_en) { - if (dst_rect->x < 0 || - dst_rect->y < 0 || + if (dst_rect->x < 0 || !dst_rect->width || + dst_rect->y < 0 || !dst_rect->height || dst_rect->x >= dst_size->width || dst_rect->y >= dst_size->height) { hal_log_err("%s failed, invalid dst crop\n", @@ -402,6 +402,12 @@ static int check_bitblt(struct aic_ge_data *data, struct ge_bitblt *blt) } } + if (!src_size->width || !src_size->height || + !dst_size->width || !dst_size->height) { + hal_log_err("Invalid size\n"); + return -1; + } + if (!blt->src_buf.crop_en) { src_rect->x = 0; src_rect->y = 0; diff --git a/bsp/artinchip/hal/qspi/hal_qspi_slave.c b/bsp/artinchip/hal/qspi/hal_qspi_slave.c index 391d3533..347afb1b 100644 --- a/bsp/artinchip/hal/qspi/hal_qspi_slave.c +++ b/bsp/artinchip/hal/qspi/hal_qspi_slave.c @@ -183,6 +183,52 @@ void hal_qspi_show_ists(u32 id, u32 sts) printf(" ISTS_BIT_TDONE\n"); } +static void qspi_irq_tx_remain_handle(struct qspi_slave_state *qspi, u32 sts) +{ + u32 base, total, free_len, dolen, imsk; + + base = qspi_hw_index_to_base(qspi->idx); + + if (qspi->async_tx) { + if (qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_CPU || qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_CPU) { + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + if (qspi->async_tx_remain) { + dolen = min(free_len, qspi->async_tx_remain); + qspi_hw_write_fifo(base, qspi->async_tx, dolen); + qspi->async_tx += dolen; + qspi->async_tx_wcnt += dolen; + qspi->async_tx_remain -= dolen; + } else { + imsk = ISTS_BIT_TF_EMP | ISTS_BIT_TF_RDY; + qspi_hw_interrupt_disable(base, imsk); + } + total = qspi->async_tx_remain + qspi->async_tx_wcnt; + qspi->async_tx_count = total - qspi_hw_get_tx_fifo_cnt(base); + if ((sts & ISTS_BIT_TDONE) && qspi_hw_get_tx_fifo_cnt(base)) + qspi->async_tx_count -= 4; + } + } +} + +static void qspi_irq_rx_remain_handle(struct qspi_slave_state *qspi, u32 sts) +{ + u32 base, dolen; + + base = qspi_hw_index_to_base(qspi->idx); + + if (qspi->async_rx && qspi->async_rx_remain) { + if ((qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_CPU) || qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_CPU) { + dolen = qspi_hw_get_rx_fifo_cnt(base); + if (dolen > qspi->async_rx_remain) + dolen = qspi->async_rx_remain; + qspi_hw_read_fifo(base, qspi->async_rx, dolen); + qspi->async_rx += dolen; + qspi->async_rx_count += dolen; + qspi->async_rx_remain -= dolen; + } + } +} + void hal_qspi_slave_irq_handler(qspi_slave_handle *h) { struct qspi_slave_state *qspi; @@ -197,53 +243,20 @@ void hal_qspi_slave_irq_handler(qspi_slave_handle *h) if (sts & ISTS_BIT_TF_OVF) qspi->status |= HAL_QSPI_STATUS_TX_OVER_FLOW; - if ((sts & ISTS_BIT_TF_EMP) || (sts & ISTS_BIT_TF_RDY)) { - u32 dolen, free_len; - if ((qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_CPU) && - qspi->async_tx) { - u32 total; - - free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); - if (qspi->async_tx_remain) { - dolen = min(free_len, qspi->async_tx_remain); - qspi_hw_write_fifo(base, qspi->async_tx, dolen); - qspi->async_tx += dolen; - qspi->async_tx_wcnt += dolen; - qspi->async_tx_remain -= dolen; - } else { - imsk = ISTS_BIT_TF_EMP | ISTS_BIT_TF_RDY; - qspi_hw_interrupt_disable(base, imsk); - } - total = qspi->async_tx_remain + qspi->async_tx_wcnt; - qspi->async_tx_count = total - qspi_hw_get_tx_fifo_cnt(base); - } - } + /* remain work handle in cpu copy */ + if ((sts & ISTS_BIT_TF_EMP) || (sts & ISTS_BIT_TF_RDY) || (sts & ISTS_BIT_TDONE)) + qspi_irq_tx_remain_handle(qspi, sts); + if ((sts & ISTS_BIT_RF_FUL) || (sts & ISTS_BIT_RF_RDY) || (sts & ISTS_BIT_TDONE)) + qspi_irq_rx_remain_handle(qspi, sts); if (sts & ISTS_BIT_RF_UDR) qspi->status |= HAL_QSPI_STATUS_RX_UNDER_RUN; - if (sts & ISTS_BIT_RF_OVF) - qspi->status |= HAL_QSPI_STATUS_RX_OVER_FLOW; - if ((sts & ISTS_BIT_RF_FUL) || (sts & ISTS_BIT_RF_RDY) || (sts & ISTS_BIT_TDONE)) { - u32 dolen; - if ((qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_CPU) && qspi->async_rx && - qspi->async_rx_remain) { - dolen = qspi_hw_get_rx_fifo_cnt(base); - if (dolen > qspi->async_rx_remain) - dolen = qspi->async_rx_remain; - qspi_hw_read_fifo(base, qspi->async_rx, dolen); - qspi->async_rx += dolen; - qspi->async_rx_count += dolen; - qspi->async_rx_remain -= dolen; - } - } - if ((sts & ISTS_BIT_TF_EMP) && (sts & ISTS_BIT_TDONE)) { - /* Write 4 bytes 0 to clear TX Buffer, - * Note: - * Every time user send new data, please reset TX FIFO - */ - u32 zeros = 0; - qspi_hw_write_fifo(base, (void *)&zeros, 4); + if (sts & ISTS_BIT_RF_OVF) { + /* ignore the RF_OVF in tx. */ + if (!(qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_CPU || qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_DMA)) + qspi->status |= HAL_QSPI_STATUS_RX_OVER_FLOW; } + if (sts & ISTS_BIT_TDONE) { if (qspi->status == HAL_QSPI_STATUS_IN_PROGRESS) qspi->status = HAL_QSPI_STATUS_OK; @@ -255,14 +268,12 @@ void hal_qspi_slave_irq_handler(qspi_slave_handle *h) qspi_hw_interrupt_disable(base, imsk); qspi->status |= HAL_QSPI_STATUS_ASYNC_TDONE; if (QSPI_IS_ASYNC_ALL_DONE(qspi->status, qspi->done_mask)) { - if (qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_DMA) { - qspi->async_rx_count = - qspi->async_rx_remain - qspi_hw_get_idma_rx_len(base); + if (qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_DMA || qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_DMA) { + qspi->async_rx_count = qspi->async_rx_remain - qspi_hw_get_idma_rx_len(base); aicos_dcache_invalid_range(qspi->async_rx, qspi->async_rx_count); } - if (qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_DMA) { - qspi->async_tx_count = - qspi->async_tx_remain - qspi_hw_get_tx_fifo_cnt(base); + if (qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_DMA || qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_DMA) { + qspi->async_tx_count = qspi->async_tx_remain - qspi_hw_get_idma_tx_len(base); } if (qspi->cb) qspi->cb(h, qspi->cb_priv); @@ -275,6 +286,7 @@ int qspi_slave_transfer_cpu_async(struct qspi_slave_state *qspi, struct qspi_transfer *t) { u32 base, txlen, rxlen; + u32 free_len, dolen; int ret = 0; base = qspi_hw_index_to_base(qspi->idx); @@ -285,9 +297,39 @@ int qspi_slave_transfer_cpu_async(struct qspi_slave_state *qspi, return -EINVAL; qspi_hw_reset_fifo(base); + qspi_hw_ctrl_reset(base); qspi_hw_interrupt_disable(base, ICR_BIT_ALL_MSK); qspi->status = HAL_QSPI_STATUS_IN_PROGRESS; - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + if (qspi->bus_width != 1) { + hal_log_err("Full duplex mode did not support. bus width: %d\n", qspi->bus_width); + return -1; + } + qspi->work_mode = QSPI_WORK_MODE_ASYNC_DUPLEX_CPU; + qspi->done_mask = HAL_QSPI_STATUS_ASYNC_TDONE; + qspi->async_rx = t->rx_data; + qspi->async_rx_count = 0; + qspi->async_rx_remain = t->data_len; + qspi->async_tx = t->tx_data; + qspi->async_tx_count = 0; + qspi->async_tx_wcnt = 0; + qspi->async_tx_remain = t->data_len; + + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + if (qspi->async_tx_remain) { + dolen = min(free_len, qspi->async_tx_remain); + qspi_hw_write_fifo(base, qspi->async_tx, dolen); + qspi->async_tx += dolen; + qspi->async_tx_wcnt += dolen; + qspi->async_tx_remain -= dolen; + } + + qspi_hw_set_slave_output_en(base, 1); + qspi_hw_interrupt_enable(base, ICR_BIT_ERRS | ICR_BIT_TDONE_INTE | + ISTS_BIT_TF_RDY | ISTS_BIT_TF_EMP | + ICR_BIT_CS_INV_INTE); + qspi_hw_clear_interrupt_status(base, ISTS_BIT_ALL_MSK); + } else if (t->tx_data) { txlen = t->data_len; qspi->work_mode = QSPI_WORK_MODE_ASYNC_TX_CPU; qspi->done_mask = HAL_QSPI_STATUS_ASYNC_TDONE; @@ -298,6 +340,16 @@ int qspi_slave_transfer_cpu_async(struct qspi_slave_state *qspi, qspi->async_tx_count = 0; qspi->async_tx_wcnt = 0; qspi->async_tx_remain = txlen; + + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + if (qspi->async_tx_remain) { + dolen = min(free_len, qspi->async_tx_remain); + qspi_hw_write_fifo(base, qspi->async_tx, dolen); + qspi->async_tx += dolen; + qspi->async_tx_wcnt += dolen; + qspi->async_tx_remain -= dolen; + } + if (qspi->bus_width > 1) qspi_hw_set_slave_output_en(base, 1); else @@ -338,10 +390,29 @@ static int qspi_slave_transfer_dma_async(struct qspi_slave_state *qspi, struct q return -EINVAL; qspi_hw_reset_fifo(base); + qspi_hw_ctrl_reset(base); qspi_hw_set_idma_busrt_auto_len_en(base, 1); qspi_hw_interrupt_disable(base, ICR_BIT_ALL_MSK); qspi->status = HAL_QSPI_STATUS_IN_PROGRESS; - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + qspi->work_mode = QSPI_WORK_MODE_ASYNC_DUPLEX_DMA; + qspi->done_mask = HAL_QSPI_STATUS_ASYNC_TDONE; + qspi->async_tx_remain = t->data_len; + qspi->async_tx = t->tx_data; + qspi->async_rx = t->rx_data; + qspi_hw_set_slave_output_en(base, 1); + aicos_dcache_clean_range(qspi->async_tx, t->data_len); + qspi_hw_set_idma_tx_addr(base, (u32)t->tx_data); + qspi_hw_set_idma_tx_len(base, (u32)t->data_len); + qspi_hw_set_idma_tx_en(base, 1); + + qspi->async_rx_remain = t->data_len; + qspi->async_rx = t->rx_data; + qspi_hw_set_idma_rx_addr(base, (u32)t->rx_data); + qspi_hw_set_idma_rx_len(base, (u32)t->data_len); + qspi_hw_set_idma_rx_en(base, 1); + qspi_hw_interrupt_enable(base, ICR_BIT_IDMA_MSK | ICR_BIT_CS_INV_INTE); + } else if (t->tx_data) { qspi->work_mode = QSPI_WORK_MODE_ASYNC_TX_DMA; qspi->done_mask = HAL_QSPI_STATUS_ASYNC_TDONE; txlen = t->data_len; @@ -353,7 +424,9 @@ static int qspi_slave_transfer_dma_async(struct qspi_slave_state *qspi, struct q qspi_hw_set_idma_tx_addr(base, (u32)t->tx_data); qspi_hw_set_idma_tx_len(base, (u32)txlen); qspi_hw_set_idma_tx_en(base, 1); - qspi_hw_interrupt_enable(base, ICR_BIT_IDMA_MSK | ICR_BIT_CS_INV_INTE); + imsk = ICR_BIT_IDMA_MSK | ICR_BIT_CS_INV_INTE; + imsk &= ~ISTS_BIT_RF_OVF; + qspi_hw_interrupt_enable(base, imsk); } else if (t->rx_data) { qspi->work_mode = QSPI_WORK_MODE_ASYNC_RX_DMA; qspi->done_mask = HAL_QSPI_STATUS_ASYNC_TDONE; @@ -381,13 +454,12 @@ static int qspi_slave_can_dma(struct qspi_slave_state *qspi, struct qspi_transfe return 0; } if (t->rx_data) { - /* RX: date length require 4 bytes alignment */ - if (t->data_len & 0x3) - return 0; /* Meet DMA's address align requirement */ if (((unsigned long)t->rx_data) & (AIC_DMA_ALIGN_SIZE - 1)) return 0; } + if (t->data_len < QSPI_FIFO_DEPTH) + return 0; return 1; #else return 0; @@ -443,7 +515,9 @@ int hal_qspi_slave_transfer_count(qspi_slave_handle *h) qspi = (struct qspi_slave_state *)h; if ((qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_CPU) || - (qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_DMA)) { + (qspi->work_mode == QSPI_WORK_MODE_ASYNC_RX_DMA) || + (qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_CPU) || + (qspi->work_mode == QSPI_WORK_MODE_ASYNC_DUPLEX_DMA)) { return qspi->async_rx_count; } if ((qspi->work_mode == QSPI_WORK_MODE_ASYNC_TX_CPU) || diff --git a/bsp/artinchip/hal/qspi/hal_qspi_v1x.c b/bsp/artinchip/hal/qspi/hal_qspi_v1x.c index 945ac63a..f26f98a8 100644 --- a/bsp/artinchip/hal/qspi/hal_qspi_v1x.c +++ b/bsp/artinchip/hal/qspi/hal_qspi_v1x.c @@ -21,25 +21,6 @@ #include "qspi_hw_v1.0.h" #endif -void qspi_reg_dump(u32 base) -{ - u32 *p, i; - - p = (void *)(unsigned long)base; - for (i = 0; i < 40; i++) { - if (i % 4 == 0) - printf("\n0x%lX : ", (unsigned long)p); - printf("%08X ", *p); - p++; - } - printf("\n"); -} - -void show_freq(char *msg, u32 id, u32 hz) -{ - printf("qspi%d %s: %dHz\n", id, msg, hz); -} - void hal_qspi_master_bit_mode_init(u32 base) { #if AIC_SUPPORT_SPI_X_WIRE_IN_BIT_MODE == 4 @@ -243,60 +224,9 @@ int hal_qspi_master_set_cs(qspi_master_handle *h, u32 cs_num, bool enable) return 0; } -static u32 qspi_master_get_best_div_param(u32 sclk, u32 bus_hz, u32 *div) -{ - u32 cdr1_clk, cdr2_clk; - int cdr2, cdr1; - - /* Get the best cdr1 param if going to use cdr1 */ - cdr1 = 0; - while ((sclk >> cdr1) > bus_hz) - cdr1++; - if (cdr1 > 0xF) - cdr1 = 0xF; - - /* Get the best cdr2 param if going to use cdr2 */ - cdr2 = (int)(sclk / (bus_hz * 2)) - 1; - if (cdr2 < 0) - cdr2 = 0; - if (cdr2 > 0xFF) - cdr2 = 0xFF; - cdr2_clk = sclk / (2 * cdr2 + 1); - - cdr1_clk = sclk >> cdr1; - cdr2_clk = sclk / (2 * cdr2 + 1); - - /* cdr1 param vs cdr2 param, use the best */ - if (cdr1_clk == bus_hz) { - *div = cdr1; - return 0; - } else if (cdr2_clk == bus_hz) { - *div = cdr2; - return 1; - } else if ((cdr2_clk < bus_hz) && (cdr1_clk < bus_hz)) { - /* Two clks less than expect clk, use the larger one */ - if (cdr2_clk > cdr1_clk) { - *div = cdr2; - return 1; - } - *div = cdr1; - return 0; - } - /* - * 1. Two clks great than expect clk, use least one - * 2. There is one clk less than expect clk, use it - */ - if (cdr2_clk < cdr1_clk) { - *div = cdr2; - return 1; - } - *div = cdr1; - return 0; -} - int hal_qspi_master_set_bus_freq(qspi_master_handle *h, u32 bus_hz) { - u32 base, sclk, divider, div, cal_clk; + u32 base, sclk, divider, div, cal_clk = 0; struct qspi_master_state *qspi; CHECK_PARAM(h, -EINVAL); @@ -359,6 +289,43 @@ int qspi_wait_transfer_done(u32 base, u32 tmo) return 0; } +int qspi_fifo_write_read(u32 base, u8 *tx, u8 *rx, u32 len, u32 tmo) +{ + u32 free_len, dolen, cnt = 0; + + while (len) { + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + while (free_len <= (QSPI_FIFO_DEPTH >> 3)) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + continue; + } + dolen = min(free_len, len); + qspi_hw_write_fifo(base, tx, dolen); + while (qspi_hw_get_rx_fifo_cnt(base) != dolen) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + } + qspi_hw_read_fifo(base, rx, dolen); + tx += dolen; + rx += dolen; + len -= dolen; + } + + /* Data are written to FIFO, waiting all data are sent out */ + while (qspi_hw_get_tx_fifo_cnt(base)) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + } + return 0; +} int qspi_fifo_write_data(u32 base, u8 *data, u32 len, u32 tmo) { @@ -416,36 +383,12 @@ int qspi_fifo_read_data(u32 base, u8 *data, u32 len, u32 tmo) return 0; } -u32 qspi_calc_timeout(u32 bus_hz, u32 len) -{ - u32 tmo_cnt, tmo_us; - u32 tmo_speed = 100; - - if (bus_hz < HAL_QSPI_MIN_FREQ_HZ) - tmo_us = (1000000 * len * 8) / bus_hz; - else if (bus_hz < 1000000) - tmo_us = (1000 * len * 8) / (bus_hz / 1000); - else - tmo_us = (len * 8) / (bus_hz / 1000000); - - /* Add 100ms time padding */ - tmo_us += 100000; - tmo_cnt = tmo_us / HAL_QSPI_WAIT_PER_CYCLE; - - /* Consider the speed limit of DMA or CPU copy. - */ - if (len >= QSPI_TRANSFER_DATA_LEN_1M) - tmo_speed = ((len / QSPI_CPU_DMA_MIN_SPEED_MS) + 1) * 1000; - - return max(tmo_cnt, tmo_speed); -} - static int qspi_master_transfer_cpu_sync(qspi_master_handle *h, struct qspi_transfer *t) { u32 base, tmo_cnt, txlen, tx_1line_cnt, rxlen, sts; struct qspi_master_state *qspi; - int ret; + int ret = 0; CHECK_PARAM(h, -EINVAL); CHECK_PARAM(t, -EINVAL); @@ -463,7 +406,21 @@ static int qspi_master_transfer_cpu_sync(qspi_master_handle *h, tmo_cnt *= 10; qspi_hw_reset_fifo(base); - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + if (qspi_hw_get_bus_width(base) != QSPI_BUS_WIDTH_SINGLE) { + hal_log_err("Full duplex mode did not support.\n"); + goto out; + } + qspi->work_mode = QSPI_WORK_MODE_SYNC_DUPLEX_CPU; + qspi_hw_set_transfer_cnt(base, t->data_len, t->data_len, 0, 0); + qspi_hw_drop_invalid_data(base, QSPI_RECV_ALL_INPUT_DATA); + qspi_hw_start_transfer(base); + ret = qspi_fifo_write_read(base, t->tx_data, t->rx_data, t->data_len, tmo_cnt); + if (ret < 0) { + hal_log_err("read write fifo failure.\n"); + goto out; + } + } else if (t->tx_data) { txlen = t->data_len; tx_1line_cnt = 0; if (qspi_hw_get_bus_width(base) == QSPI_BUS_WIDTH_SINGLE) @@ -494,13 +451,14 @@ static int qspi_master_transfer_cpu_sync(qspi_master_handle *h, goto out; } out: + qspi_hw_drop_invalid_data(base, QSPI_DROP_INVALID_DATA); qspi_hw_get_interrupt_status(base, &sts); qspi_hw_clear_interrupt_status(base, sts); return ret; } #ifdef AIC_DMA_DRV -const u32 dynamic_dma_table[] = { +static const u32 dynamic_dma_table[] = { #ifdef AIC_QSPI1_DYNAMIC_DMA 1, #endif @@ -617,6 +575,118 @@ static int qspi_master_wait_dma_done(struct aic_dma_chan *ch, u32 tmo) return 0; } +static int qspi_txrx_dma_sync(qspi_master_handle *h, + struct qspi_transfer *t, u32 tmo_cnt) +{ + struct qspi_master_state *qspi; + struct dma_slave_config dmacfg; + u32 base; + int ret; + + CHECK_PARAM(h, -EINVAL); + CHECK_PARAM(t, -EINVAL); + + qspi = (struct qspi_master_state *)h; + base = qspi_hw_index_to_base(qspi->idx); + + if (qspi_hw_get_bus_width(base) != QSPI_BUS_WIDTH_SINGLE) { + hal_log_err("Full duplex mode did not support.\n"); + return -1; + } + qspi->work_mode = QSPI_WORK_MODE_SYNC_DUPLEX_DMA; + qspi_hw_tx_dma_enable(base); + qspi_hw_rx_dma_enable(base); + qspi_hw_set_transfer_cnt(base, t->data_len, t->data_len, 0, 0); + qspi_hw_drop_invalid_data(base, QSPI_RECV_ALL_INPUT_DATA); + + /* config tx DMA channel */ + dmacfg.direction = DMA_MEM_TO_DEV; + dmacfg.slave_id = qspi->dma_cfg.port_id; + dmacfg.src_addr = (unsigned long)t->tx_data; + dmacfg.dst_addr = (unsigned long)QSPI_REG_TXD(base); + + dmacfg.src_addr_width = qspi->dma_cfg.mem_bus_width; + dmacfg.src_maxburst = qspi->dma_cfg.mem_max_burst; + if (!(t->data_len % HAL_QSPI_DMA_4BYTES_LINE)) + dmacfg.dst_addr_width = qspi->dma_cfg.dev_bus_width; + else + dmacfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dmacfg.dst_maxburst = qspi->dma_cfg.dev_max_burst; + + ret = hal_dma_chan_config(qspi->dma_tx, &dmacfg); + if (ret < 0) { + hal_log_err("TX dma chan config failure.\n"); + return -1; + } + ret = hal_dma_chan_prep_device(qspi->dma_tx, PTR2U32(QSPI_REG_TXD(base)), + PTR2U32(t->tx_data), t->data_len, + DMA_MEM_TO_DEV); + if (ret < 0) { + hal_log_err("TX dma chan prepare failure.\n"); + return -1; + } + + ret = hal_dma_chan_start(qspi->dma_tx); + if (ret < 0) { + hal_log_err("TX dma chan start failure.\n"); + return -1; + } + + /* config rx DMA channel */ + dmacfg.direction = DMA_DEV_TO_MEM; + dmacfg.slave_id = qspi->dma_cfg.port_id; + dmacfg.src_addr = (unsigned long)QSPI_REG_RXD(base); + dmacfg.dst_addr = (unsigned long)t->rx_data; + + if (!(t->data_len % HAL_QSPI_DMA_4BYTES_LINE)) + dmacfg.src_addr_width = qspi->dma_cfg.dev_bus_width; + else + dmacfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dmacfg.src_maxburst = qspi->dma_cfg.mem_max_burst; + dmacfg.dst_addr_width = qspi->dma_cfg.dev_bus_width; + dmacfg.dst_maxburst = qspi->dma_cfg.dev_max_burst; + + ret = hal_dma_chan_config(qspi->dma_rx, &dmacfg); + if (ret < 0) { + hal_log_err("RX dma chan config failure.\n"); + return -1; + } + ret = hal_dma_chan_prep_device(qspi->dma_rx, PTR2U32(t->rx_data), + PTR2U32(QSPI_REG_RXD(base)), t->data_len, + DMA_DEV_TO_MEM); + if (ret < 0) { + hal_log_err("RX dma chan prepare failure.\n"); + return -1; + } + ret = hal_dma_chan_start(qspi->dma_rx); + if (ret < 0) { + hal_log_err("RX dma chan start failure.\n"); + return -1; + } + + qspi_hw_start_transfer(base); + ret = qspi_wait_transfer_done(base, tmo_cnt); + if (ret < 0) { + hal_log_err("Wait transfer done timeout.\n"); + } + ret = qspi_master_wait_dma_done(qspi->dma_rx, tmo_cnt); + if (ret < 0) { + hal_log_err("RX wait dma done timeout.\n"); + } + + qspi_hw_drop_invalid_data(base, QSPI_DROP_INVALID_DATA); + qspi_hw_rx_dma_disable(base); + qspi_hw_tx_dma_disable(base); + hal_dma_chan_stop(qspi->dma_rx); + hal_dma_chan_stop(qspi->dma_tx); + if (qspi_master_dynamic_dma(qspi)) { + hal_release_dma_chan(qspi->dma_tx); + hal_release_dma_chan(qspi->dma_rx); + } + + return ret; +} + static int qspi_master_transfer_dma_sync(qspi_master_handle *h, struct qspi_transfer *t) { @@ -624,7 +694,7 @@ static int qspi_master_transfer_dma_sync(qspi_master_handle *h, struct qspi_master_state *qspi; struct aic_dma_chan *dma_rx, *dma_tx; struct dma_slave_config dmacfg; - int ret; + int ret = 0; CHECK_PARAM(h, -EINVAL); CHECK_PARAM(t, -EINVAL); @@ -641,7 +711,9 @@ static int qspi_master_transfer_dma_sync(qspi_master_handle *h, tmo_cnt = qspi_calc_timeout(qspi->bus_hz, t->data_len); qspi_hw_reset_fifo(base); - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + ret = qspi_txrx_dma_sync(h, t, tmo_cnt); + } else if (t->tx_data) { txlen = t->data_len; tx_1line_cnt = 0; if (qspi_hw_get_bus_width(base) == QSPI_BUS_WIDTH_SINGLE) diff --git a/bsp/artinchip/hal/qspi/hal_qspi_v2x.c b/bsp/artinchip/hal/qspi/hal_qspi_v2x.c index 8c53dca5..f7883b4c 100644 --- a/bsp/artinchip/hal/qspi/hal_qspi_v2x.c +++ b/bsp/artinchip/hal/qspi/hal_qspi_v2x.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,25 +17,6 @@ #include "qspi_hw_v2.0.h" -void qspi_reg_dump(u32 base) -{ - u32 *p, i; - - p = (void *)(unsigned long)base; - for (i = 0; i < 40; i++) { - if (i % 4 == 0) - printf("\n0x%lX : ", (unsigned long)p); - printf("%08X ", *p); - p++; - } - printf("\n"); -} - -void show_freq(char *msg, u32 id, u32 hz) -{ - printf("qspi%d %s: %dHz\n", id, msg, hz); -} - void hal_qspi_master_bit_mode_init(u32 base) { #if AIC_SUPPORT_SPI_X_WIRE_IN_BIT_MODE == 4 @@ -276,57 +257,6 @@ int hal_qspi_master_set_cs(qspi_master_handle *h, u32 cs_num, bool enable) return 0; } -static u32 qspi_master_get_best_div_param(u32 sclk, u32 bus_hz, u32 *div) -{ - u32 cdr1_clk, cdr2_clk; - int cdr2, cdr1; - - /* Get the best cdr1 param if going to use cdr1 */ - cdr1 = 0; - while ((sclk >> cdr1) > bus_hz) - cdr1++; - if (cdr1 > 0xF) - cdr1 = 0xF; - - /* Get the best cdr2 param if going to use cdr2 */ - cdr2 = (int)(sclk / (bus_hz * 2)) - 1; - if (cdr2 < 0) - cdr2 = 0; - if (cdr2 > 0xFF) - cdr2 = 0xFF; - cdr2_clk = sclk / (2 * cdr2 + 1); - - cdr1_clk = sclk >> cdr1; - cdr2_clk = sclk / (2 * cdr2 + 1); - - /* cdr1 param vs cdr2 param, use the best */ - if (cdr1_clk == bus_hz) { - *div = cdr1; - return 0; - } else if (cdr2_clk == bus_hz) { - *div = cdr2; - return 1; - } else if ((cdr2_clk < bus_hz) && (cdr1_clk < bus_hz)) { - /* Two clks less than expect clk, use the larger one */ - if (cdr2_clk > cdr1_clk) { - *div = cdr2; - return 1; - } - *div = cdr1; - return 0; - } - /* - * 1. Two clks great than expect clk, use least one - * 2. There is one clk less than expect clk, use it - */ - if (cdr2_clk < cdr1_clk) { - *div = cdr2; - return 1; - } - *div = cdr1; - return 0; -} - int hal_qspi_master_set_bus_freq(qspi_master_handle *h, u32 bus_hz) { u32 base, sclk, divider, div; @@ -427,6 +357,44 @@ int qspi_wait_gpdma_rx_done(u32 base, u32 tmo) } #endif +int qspi_fifo_write_read(u32 base, u8 *tx, u8 *rx, u32 len, u32 tmo) +{ + u32 free_len, dolen, cnt = 0; + + while (len) { + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + while (free_len <= (QSPI_FIFO_DEPTH >> 3)) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + free_len = QSPI_FIFO_DEPTH - qspi_hw_get_tx_fifo_cnt(base); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + continue; + } + dolen = min(free_len, len); + qspi_hw_write_fifo(base, tx, dolen); + while (qspi_hw_get_rx_fifo_cnt(base) != dolen) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + } + qspi_hw_read_fifo(base, rx, dolen); + tx += dolen; + rx += dolen; + len -= dolen; + } + + /* Data are written to FIFO, waiting all data are sent out */ + while (qspi_hw_get_tx_fifo_cnt(base)) { + aic_udelay(HAL_QSPI_WAIT_DELAY_US); + cnt++; + if (cnt > tmo) + return -ETIMEDOUT; + } + return 0; +} + int qspi_fifo_write_data(u32 base, u8 *data, u32 len, u32 tmo) { u32 dolen, free_len, cnt = 0; @@ -483,36 +451,12 @@ int qspi_fifo_read_data(u32 base, u8 *data, u32 len, u32 tmo) return 0; } -u32 qspi_calc_timeout(u32 bus_hz, u32 len) -{ - u32 tmo_cnt, tmo_us; - u32 tmo_speed = 100; - - if (bus_hz < HAL_QSPI_MIN_FREQ_HZ) - tmo_us = (1000000 * len * 8) / bus_hz; - else if (bus_hz < 1000000) - tmo_us = (1000 * len * 8) / (bus_hz / 1000); - else - tmo_us = (len * 8) / (bus_hz / 1000000); - - /* Add 100ms time padding */ - tmo_us += 100000; - tmo_cnt = tmo_us / HAL_QSPI_WAIT_PER_CYCLE; - - /* Consider the speed limit of DMA or CPU copy. - */ - if (len >= QSPI_TRANSFER_DATA_LEN_1M) - tmo_speed = ((len / QSPI_CPU_DMA_MIN_SPEED_MS) + 1) * 1000; - - return max(tmo_cnt, tmo_speed); -} - static int qspi_master_transfer_cpu_sync(qspi_master_handle *h, struct qspi_transfer *t) { u32 base, tmo_cnt, txlen, tx_1line_cnt, rxlen, sts; struct qspi_master_state *qspi; - int ret; + int ret = 0; CHECK_PARAM(h, -EINVAL); CHECK_PARAM(t, -EINVAL); @@ -530,7 +474,21 @@ static int qspi_master_transfer_cpu_sync(qspi_master_handle *h, tmo_cnt *= 10; qspi_hw_reset_fifo(base); - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + if (qspi_hw_get_bus_width(base) != QSPI_BUS_WIDTH_SINGLE) { + hal_log_err("Full duplex mode did not support.\n"); + goto out; + } + qspi->work_mode = QSPI_WORK_MODE_SYNC_DUPLEX_CPU; + qspi_hw_set_transfer_cnt(base, t->data_len, t->data_len, 0, 0); + qspi_hw_drop_invalid_data(base, QSPI_RECV_ALL_INPUT_DATA); + qspi_hw_start_transfer(base); + ret = qspi_fifo_write_read(base, t->tx_data, t->rx_data, t->data_len, tmo_cnt); + if (ret < 0) { + hal_log_err("read write fifo failure.\n"); + goto out; + } + } else if (t->tx_data) { txlen = t->data_len; tx_1line_cnt = 0; if (qspi_hw_get_bus_width(base) == QSPI_BUS_WIDTH_SINGLE) @@ -581,6 +539,115 @@ static int qspi_master_wait_dma_done(struct aic_dma_chan *ch, u32 tmo) return 0; } +static int qspi_txrx_dma_sync(qspi_master_handle *h, + struct qspi_transfer *t, u32 tmo_cnt) +{ + struct qspi_master_state *qspi; + struct dma_slave_config dmacfg; + u32 base; + int ret; + + CHECK_PARAM(h, -EINVAL); + CHECK_PARAM(t, -EINVAL); + + qspi = (struct qspi_master_state *)h; + base = qspi_hw_index_to_base(qspi->idx); + + if (qspi_hw_get_bus_width(base) != QSPI_BUS_WIDTH_SINGLE) { + hal_log_err("Full duplex mode did not support.\n"); + return -1; + } + qspi->work_mode = QSPI_WORK_MODE_SYNC_DUPLEX_DMA; + qspi_hw_tx_dma_enable(base); + qspi_hw_rx_dma_enable(base); + qspi_hw_set_transfer_cnt(base, t->data_len, t->data_len, 0, 0); + qspi_hw_drop_invalid_data(base, QSPI_RECV_ALL_INPUT_DATA); + + /* config tx DMA channel */ + dmacfg.direction = DMA_MEM_TO_DEV; + dmacfg.slave_id = qspi->dma_cfg.port_id; + dmacfg.src_addr = (unsigned long)t->tx_data; + dmacfg.dst_addr = (unsigned long)QSPI_REG_TXD(base); + + dmacfg.src_addr_width = qspi->dma_cfg.mem_bus_width; + dmacfg.src_maxburst = qspi->dma_cfg.mem_max_burst; + if (!(t->data_len % HAL_QSPI_DMA_4BYTES_LINE)) + dmacfg.dst_addr_width = qspi->dma_cfg.dev_bus_width; + else + dmacfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dmacfg.dst_maxburst = qspi->dma_cfg.dev_max_burst; + + ret = hal_dma_chan_config(qspi->dma_tx, &dmacfg); + if (ret < 0) { + hal_log_err("TX dma chan config failure.\n"); + return -1; + } + ret = hal_dma_prep_mode_device(qspi->dma_tx, PTR2U32(QSPI_REG_TXD(base)), + PTR2U32(t->tx_data), t->data_len, + DMA_MEM_TO_DEV, TYPE_IO_FAST); + if (ret < 0) { + hal_log_err("TX dma chan prepare failure.\n"); + return -1; + } + + ret = hal_dma_chan_start(qspi->dma_tx); + if (ret < 0) { + hal_log_err("TX dma chan start failure.\n"); + return -1; + } + + /* config rx DMA channel */ + dmacfg.direction = DMA_DEV_TO_MEM; + dmacfg.slave_id = qspi->dma_cfg.port_id; + dmacfg.src_addr = (unsigned long)QSPI_REG_RXD(base); + dmacfg.dst_addr = (unsigned long)t->rx_data; + + if (!(t->data_len % HAL_QSPI_DMA_4BYTES_LINE)) + dmacfg.src_addr_width = qspi->dma_cfg.dev_bus_width; + else + dmacfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dmacfg.src_maxburst = qspi->dma_cfg.mem_max_burst; + dmacfg.dst_addr_width = qspi->dma_cfg.dev_bus_width; + dmacfg.dst_maxburst = qspi->dma_cfg.dev_max_burst; + + ret = hal_dma_chan_config(qspi->dma_rx, &dmacfg); + if (ret < 0) { + hal_log_err("RX dma chan config failure.\n"); + return -1; + } + ret = hal_dma_prep_mode_device(qspi->dma_rx, PTR2U32(t->rx_data), + PTR2U32(QSPI_REG_RXD(base)), t->data_len, + DMA_DEV_TO_MEM, TYPE_IO_FAST); + if (ret < 0) { + hal_log_err("RX dma chan prepare failure.\n"); + return -1; + } + ret = hal_dma_chan_start(qspi->dma_rx); + if (ret < 0) { + hal_log_err("RX dma chan start failure.\n"); + return -1; + } + + qspi_hw_start_transfer(base); + ret = qspi_wait_transfer_done(base, tmo_cnt); + if (ret < 0) { + hal_log_err("Wait transfer done timeout.\n"); + } + ret = qspi_master_wait_dma_done(qspi->dma_rx, tmo_cnt); + if (ret < 0) { + hal_log_err("RX wait dma done timeout.\n"); + } + + qspi_hw_drop_invalid_data(base, QSPI_DROP_INVALID_DATA); + qspi_hw_rx_dma_disable(base); + qspi_hw_tx_dma_disable(base); + hal_dma_chan_stop(qspi->dma_rx); + hal_dma_chan_stop(qspi->dma_tx); + + return ret; +} + + static int qspi_master_transfer_dma_sync(qspi_master_handle *h, struct qspi_transfer *t) { @@ -588,7 +655,7 @@ static int qspi_master_transfer_dma_sync(qspi_master_handle *h, struct qspi_master_state *qspi; struct aic_dma_chan *dma_rx, *dma_tx; struct dma_slave_config dmacfg; - int ret; + int ret = 0; CHECK_PARAM(h, -EINVAL); CHECK_PARAM(t, -EINVAL); @@ -605,7 +672,9 @@ static int qspi_master_transfer_dma_sync(qspi_master_handle *h, tmo_cnt = qspi_calc_timeout(qspi->bus_hz, t->data_len); qspi_hw_reset_fifo(base); - if (t->tx_data) { + if (t->tx_data && t->rx_data) { + ret = qspi_txrx_dma_sync(h, t, tmo_cnt); + } else if (t->tx_data) { txlen = t->data_len; tx_1line_cnt = 0; if (qspi_hw_get_bus_width(base) == QSPI_BUS_WIDTH_SINGLE) diff --git a/bsp/artinchip/hal/qspi/qspi_hw_v1.0.h b/bsp/artinchip/hal/qspi/qspi_hw_v1.0.h index c0cd6f16..792bf3dc 100644 --- a/bsp/artinchip/hal/qspi/qspi_hw_v1.0.h +++ b/bsp/artinchip/hal/qspi/qspi_hw_v1.0.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -444,6 +444,15 @@ static inline void qspi_hw_drop_invalid_data(u32 base, bool drop) writel(val, QSPI_REG_TCFG(base)); } +static inline void qspi_hw_ctrl_reset(u32 base) +{ + u32 val; + + val = readl(QSPI_REG_CFG(base)); + val |= CFG_BIT_CTRL_RST_MSK; + writel(val, QSPI_REG_CFG(base)); +} + static inline void qspi_hw_reset_fifo(u32 base) { u32 val = readl(QSPI_REG_FCTL(base)); diff --git a/bsp/artinchip/hal/qspi/qspi_hw_v1.1.h b/bsp/artinchip/hal/qspi/qspi_hw_v1.1.h index e3a03674..f486245a 100644 --- a/bsp/artinchip/hal/qspi/qspi_hw_v1.1.h +++ b/bsp/artinchip/hal/qspi/qspi_hw_v1.1.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -595,6 +595,15 @@ static inline void qspi_hw_drop_invalid_data(u32 base, bool drop) writel(val, QSPI_REG_TCFG(base)); } +static inline void qspi_hw_ctrl_reset(u32 base) +{ + u32 val; + + val = readl(QSPI_REG_CFG(base)); + val |= CFG_BIT_CTRL_RST_MSK; + writel(val, QSPI_REG_CFG(base)); +} + static inline void qspi_hw_reset_fifo(u32 base) { u32 val = readl(QSPI_REG_FCTL(base)); diff --git a/bsp/artinchip/hal/qspi/qspi_internal.c b/bsp/artinchip/hal/qspi/qspi_internal.c new file mode 100644 index 00000000..86c2a2c9 --- /dev/null +++ b/bsp/artinchip/hal/qspi/qspi_internal.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Jiji Chen + */ + +#include +#include +#include +#include +#include +#include +#include "qspi_internal.h" + +void qspi_reg_dump(u32 base) +{ + u32 *p, i; + + p = (void *)(unsigned long)base; + for (i = 0; i < 40; i++) { + if (i % 4 == 0) + printf("\n0x%lX : ", (unsigned long)p); + printf("%08X ", *p); + p++; + } + printf("\n"); +} + +void show_freq(char *msg, u32 id, u32 hz) +{ + printf("qspi%d %s: %dHz\n", id, msg, hz); +} + +u32 qspi_calc_timeout(u32 bus_hz, u32 len) +{ + u32 tmo_cnt, tmo_us; + u32 tmo_speed = 100; + + if (bus_hz < HAL_QSPI_MIN_FREQ_HZ) + tmo_us = (1000000 * len * 8) / bus_hz; + else if (bus_hz < 1000000) + tmo_us = (1000 * len * 8) / (bus_hz / 1000); + else + tmo_us = (len * 8) / (bus_hz / 1000000); + + /* Add 100ms time padding */ + tmo_us += 100000; + tmo_cnt = tmo_us / HAL_QSPI_WAIT_PER_CYCLE; + + /* Consider the speed limit of DMA or CPU copy. + */ + if (len >= QSPI_TRANSFER_DATA_LEN_1M) + tmo_speed = ((len / QSPI_CPU_DMA_MIN_SPEED_MS) + 1) * 1000; + + return max(tmo_cnt, tmo_speed); +} + +u32 qspi_master_get_best_div_param(u32 sclk, u32 bus_hz, u32 *div) +{ + u32 cdr1_clk, cdr2_clk; + int cdr2, cdr1; + + /* Get the best cdr1 param if going to use cdr1 */ + cdr1 = 0; + while ((sclk >> cdr1) > bus_hz) + cdr1++; + if (cdr1 > 0xF) + cdr1 = 0xF; + + /* Get the best cdr2 param if going to use cdr2 */ + cdr2 = (int)(sclk / (bus_hz * 2)) - 1; + if (cdr2 < 0) + cdr2 = 0; + if (cdr2 > 0xFF) + cdr2 = 0xFF; + cdr2_clk = sclk / (2 * cdr2 + 1); + + cdr1_clk = sclk >> cdr1; + cdr2_clk = sclk / (2 * cdr2 + 1); + + /* cdr1 param vs cdr2 param, use the best */ + if (cdr1_clk == bus_hz) { + *div = cdr1; + return 0; + } else if (cdr2_clk == bus_hz) { + *div = cdr2; + return 1; + } else if ((cdr2_clk < bus_hz) && (cdr1_clk < bus_hz)) { + /* Two clks less than expect clk, use the larger one */ + if (cdr2_clk > cdr1_clk) { + *div = cdr2; + return 1; + } + *div = cdr1; + return 0; + } + /* + * 1. Two clks great than expect clk, use least one + * 2. There is one clk less than expect clk, use it + */ + if (cdr2_clk < cdr1_clk) { + *div = cdr2; + return 1; + } + *div = cdr1; + return 0; +} + diff --git a/bsp/artinchip/hal/qspi/qspi_internal.h b/bsp/artinchip/hal/qspi/qspi_internal.h index 71a2974b..e5ca27cf 100644 --- a/bsp/artinchip/hal/qspi/qspi_internal.h +++ b/bsp/artinchip/hal/qspi/qspi_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,12 +13,16 @@ extern "C" { #endif -#define QSPI_WORK_MODE_SYNC_RX_CPU 0 -#define QSPI_WORK_MODE_SYNC_TX_CPU 1 -#define QSPI_WORK_MODE_ASYNC_RX_CPU 2 -#define QSPI_WORK_MODE_ASYNC_TX_CPU 3 -#define QSPI_WORK_MODE_ASYNC_RX_DMA 4 -#define QSPI_WORK_MODE_ASYNC_TX_DMA 5 +#define QSPI_WORK_MODE_SYNC_RX_CPU 0 +#define QSPI_WORK_MODE_SYNC_TX_CPU 1 +#define QSPI_WORK_MODE_ASYNC_RX_CPU 2 +#define QSPI_WORK_MODE_ASYNC_TX_CPU 3 +#define QSPI_WORK_MODE_ASYNC_RX_DMA 4 +#define QSPI_WORK_MODE_ASYNC_TX_DMA 5 +#define QSPI_WORK_MODE_SYNC_DUPLEX_CPU 6 +#define QSPI_WORK_MODE_SYNC_DUPLEX_DMA 7 +#define QSPI_WORK_MODE_ASYNC_DUPLEX_CPU 8 +#define QSPI_WORK_MODE_ASYNC_DUPLEX_DMA 9 #define HAL_QSPI_STATUS_INTERNAL_MSK (0xFFFFUL << 16) #define HAL_QSPI_STATUS_ASYNC_TDONE (0x1UL << 16) @@ -30,13 +34,14 @@ extern "C" { #define QSPI_TRANSFER_DATA_LEN_1M 0x100000 #define QSPI_CPU_DMA_MIN_SPEED_MS (0x800000 >> 10) +void qspi_reg_dump(u32 base); void show_freq(char *msg, u32 id, u32 hz); -void hal_qspi_fifo_reset(u32 base, u32 fifo); -void hal_qspi_show_ists(u32 id, u32 sts); +u32 qspi_calc_timeout(u32 bus_hz, u32 len); +u32 qspi_master_get_best_div_param(u32 sclk, u32 bus_hz, u32 *div); + int qspi_fifo_write_data(u32 base, u8 *data, u32 len, u32 tmo); int qspi_fifo_read_data(u32 base, u8 *data, u32 len, u32 tmo_us); int qspi_wait_transfer_done(u32 base, u32 tmo); -u32 qspi_calc_timeout(u32 bus_hz, u32 len); #ifdef __cplusplus } diff --git a/bsp/artinchip/include/drv_bare/aic_drv_bare.h b/bsp/artinchip/include/drv_bare/aic_drv_bare.h index 8a47bf71..a1e3d0b3 100644 --- a/bsp/artinchip/include/drv_bare/aic_drv_bare.h +++ b/bsp/artinchip/include/drv_bare/aic_drv_bare.h @@ -31,6 +31,7 @@ extern "C" { #include "usb_drv.h" #endif #include "wdt.h" +#include "gpai.h" #ifdef __cplusplus } diff --git a/bsp/examples_bare/test-gpai/test_gpai.h b/bsp/artinchip/include/drv_bare/gpai.h similarity index 97% rename from bsp/examples_bare/test-gpai/test_gpai.h rename to bsp/artinchip/include/drv_bare/gpai.h index 0579f448..db077f3c 100644 --- a/bsp/examples_bare/test-gpai/test_gpai.h +++ b/bsp/artinchip/include/drv_bare/gpai.h @@ -1,10 +1,11 @@ /* - * Copyright (c) 2024, Artinchip Technology Co., Ltd + * Copyright (c) 2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * - * Authors: Li Siyao + * Authors: Siyao Li */ +#include "hal_gpai.h" struct aic_gpai_ch aic_gpai_chs[] = { #ifdef AIC_USING_GPAI0 diff --git a/bsp/artinchip/include/drv_bare/heap.h b/bsp/artinchip/include/drv_bare/heap.h index f880ee98..3129b9ab 100644 --- a/bsp/artinchip/include/drv_bare/heap.h +++ b/bsp/artinchip/include/drv_bare/heap.h @@ -1,7 +1,9 @@ /* - * Copyright (c) 2023, Artinchip Technology Co., Ltd + * Copyright (C) 2023-2024 ArtInChip Technology Co.,Ltd * * SPDX-License-Identifier: Apache-2.0 + * + * Author: Dehuang Wu */ #ifndef __BL_HEAP_H_ @@ -11,7 +13,7 @@ extern "C" { #endif -int heap_init(void *ptr, size_t size); +int heap_init(void); #ifdef __cplusplus } diff --git a/bsp/artinchip/include/hal/hal_audio.h b/bsp/artinchip/include/hal/hal_audio.h index d1ca74c3..8d818727 100644 --- a/bsp/artinchip/include/hal/hal_audio.h +++ b/bsp/artinchip/include/hal/hal_audio.h @@ -24,7 +24,7 @@ #define AUDIO_TRANSFER_TYPE_AMIC 6 #define MAX_VOLUME_0DB 160 -#define AIC_AMIC_DEF_VAL 220 +#define AIC_AMIC_DEF_VAL 200 struct aic_audio_config { diff --git a/bsp/artinchip/include/hal/hal_audio_reg.h b/bsp/artinchip/include/hal/hal_audio_reg.h index 199bf646..46062e2d 100644 --- a/bsp/artinchip/include/hal/hal_audio_reg.h +++ b/bsp/artinchip/include/hal/hal_audio_reg.h @@ -190,7 +190,7 @@ #define ADC_CTL2_REG (0xA4) #define ADC_CTL2_MBIAS_CTL (8) -#define ADC_CTL2_PGA_GAIN_SEL (0xA) +#define ADC_CTL2_PGA_GAIN_SEL (0xF) #define ADC_CTL2_PGA_GAIN_MASK GENMASK(3, 0) #define DEFAULT_AUDIO_FREQ (24576000) diff --git a/bsp/artinchip/include/hal/hal_dce.h b/bsp/artinchip/include/hal/hal_dce.h new file mode 100644 index 00000000..d69ca817 --- /dev/null +++ b/bsp/artinchip/include/hal/hal_dce.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024, ArtInChip Technology CO.,LTD. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Chen JunLong + */ +#ifndef _AIC_HAL_DCE_H_ +#define _AIC_HAL_DCE_H_ + +#include +#include + +#define DCE_CTL_REG (DCE_BASE + 0x000) +#define DCE_CFG_REG (DCE_BASE + 0x004) +#define DCE_IRQ_REG (DCE_BASE + 0x008) +#define DCE_ISR_REG (DCE_BASE + 0x00C) +#define DCE_ADDR_REG (DCE_BASE + 0x010) +#define DCE_LEN_REG (DCE_BASE + 0x014) +#define DCE_RST_REG (DCE_BASE + 0x040) +#define DCE_CRC_CFG_REG (DCE_BASE + 0x080) +#define DCE_CRC_INIT_REG (DCE_BASE + 0x084) +#define DCE_CRC_XOROUT_REG (DCE_BASE + 0x088) +#define DCE_CRC_RST_REG (DCE_BASE + 0x0C0) +#define DCE_SUM_RST_REG (DCE_BASE + 0x140) +#define DCE_GET_VERSION_REG (DCE_BASE + 0xFFC) + +#define DCE_WAIT_CNT 10000 +#define DCE_CALC_OK 0 +#define DCE_CALC_ERR -1 +#define DCE_CALC_TMO -2 + +#define DCE_ALG_CRC 0x1 +#define DCE_ALG_SUM 0x2 + +#define DCE_ERR_ALL_MSK 0x07000000 +#define DCE_CRC_FINISH_MSK 0x01 +#define DCE_SUM_FINISH_MSK 0x02 + +#define OUTPUT_BIT_IN_WORD_REV (0x1 << 0) +#define INPUT_BIT_IN_BYTE_REV (0x1 << 1) +#define INPUT_BIT_IN_WORD_REV (0x1 << 2) +#define INPUT_BYTE_IN_WORD_REV (0x1 << 3) + +int hal_dce_init(void); +void hal_dce_deinit(void); +void hal_dce_checksum_start(u8 *data, u32 len); +u32 hal_dce_checksum_wait(void); +u32 hal_dce_checksum_result(void); +void hal_dce_crc32_cfg(u32 out_bit_in_word, u32 input_bit_in_byte, + u32 input_bit_in_word, u32 input_byte_in_word); +void hal_dce_crc32_xor_val(u32 val); +void hal_dce_crc32_start(u32 crc, u8 *data, u32 len); +int hal_dce_crc32_wait(void); +u32 hal_dce_crc32_result(void); +u32 hal_get_version(void); + +#endif diff --git a/bsp/artinchip/include/hal/hal_dma.h b/bsp/artinchip/include/hal/hal_dma.h index 3198637c..eb04640e 100644 --- a/bsp/artinchip/include/hal/hal_dma.h +++ b/bsp/artinchip/include/hal/hal_dma.h @@ -93,9 +93,7 @@ struct aic_dma_task { */ struct aic_dma_task *v_next; }; -#endif - -#ifdef AIC_DMA_DRV_V20 +#else struct aic_dma_task { u32 link_id; u32 cfg1; /* dma transfer configuration */ @@ -168,12 +166,6 @@ int hal_dma_chan_start(struct aic_dma_chan *chan); int hal_dma_chan_stop(struct aic_dma_chan *chan); int hal_dma_chan_pause(struct aic_dma_chan *chan); int hal_dma_chan_resume(struct aic_dma_chan *chan); -#if defined(AIC_DMA_DRV_V20) -int hal_dma_chan_link_pause(struct aic_dma_chan *chan); -int hal_dma_chan_abandon(struct aic_dma_chan *chan); -int hal_dma_chan_wb_enable(struct aic_dma_chan *chan, - u32 src_addr, u32 dst_addr); -#endif int hal_dma_chan_terminate_all(struct aic_dma_chan *chan); int hal_dma_chan_register_cb(struct aic_dma_chan *chan, dma_async_callback callback, diff --git a/bsp/artinchip/include/hal/hal_i2c.h b/bsp/artinchip/include/hal/hal_i2c.h index ad2a573a..4df50a65 100644 --- a/bsp/artinchip/include/hal/hal_i2c.h +++ b/bsp/artinchip/include/hal/hal_i2c.h @@ -207,6 +207,8 @@ enum i2c_slave_event { #define I2C_7BIT_ADDR 0 #define I2C_10BIT_ADDR 1 +#define I2C_MAX_CHAN 8 + #define I2C_INTR_MASTER_MASK (I2C_INTR_RX_UNDER |\ I2C_INTR_RX_FULL |\ I2C_INTR_TX_EMPTY |\ @@ -224,6 +226,10 @@ static inline void hal_i2c_module_enable(aic_i2c_ctrl *i2c_dev) { uint32_t reg_val; + reg_val = readl(i2c_dev->reg_base + I2C_CTL); + reg_val |= I2C_CTL_RESTART_ENABLE; + writel(reg_val, i2c_dev->reg_base + I2C_CTL); + reg_val = readl(i2c_dev->reg_base + I2C_ENABLE); reg_val |= I2C_ENABLE_BIT | I2C_SDA_STUCK_RECOVERY_ENABLE; writel(reg_val, i2c_dev->reg_base + I2C_ENABLE); diff --git a/bsp/artinchip/include/hal/hal_qspi.h b/bsp/artinchip/include/hal/hal_qspi.h index 46038fbf..a19d2a13 100644 --- a/bsp/artinchip/include/hal/hal_qspi.h +++ b/bsp/artinchip/include/hal/hal_qspi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -249,6 +249,8 @@ int hal_qspi_slave_transfer_abort(qspi_slave_handle *h); int hal_qspi_slave_transfer_count(qspi_slave_handle *h); void hal_qspi_slave_fifo_reset(qspi_slave_handle *h, u32 fifo); +void hal_qspi_show_ists(u32 id, u32 sts); + #endif //AIC_QSPI_DRV_V11 int hal_qspi_master_init(qspi_master_handle *h, struct qspi_master_config *cfg); @@ -263,6 +265,10 @@ int hal_qspi_master_transfer_async(qspi_master_handle *h, struct qspi_transfer * int hal_qspi_master_get_status(qspi_master_handle *h); void hal_qspi_master_irq_handler(qspi_master_handle *h); void hal_qspi_master_fifo_reset(qspi_master_handle *h, u32 fifo); +void hal_qspi_fifo_reset(u32 base, u32 fifo); + +int hal_spi_master_transfer_sync(qspi_master_handle *h, struct qspi_transfer *t); +int hal_spi_master_transfer_async(qspi_master_handle *h, struct qspi_transfer *t); int hal_qspi_master_transfer_bit_mode(qspi_master_handle *h, struct qspi_bm_transfer *t); diff --git a/bsp/artinchip/sys/d12x/Kconfig.chip b/bsp/artinchip/sys/d12x/Kconfig.chip index 6169842c..83a8454e 100644 --- a/bsp/artinchip/sys/d12x/Kconfig.chip +++ b/bsp/artinchip/sys/d12x/Kconfig.chip @@ -36,6 +36,16 @@ config CPU_BASE default 0xE0000000 if QEMU_RUN depends on AIC_CHIP_D12X +config CPU_PSRAM_BASE + hex + default 0x40000000 + depends on AIC_CHIP_D12X + +config CPU_SRAM_BASE + hex + default 0x30040000 + depends on AIC_CHIP_D12X + #-------------------------------------------- # cmu driver global option #-------------------------------------------- diff --git a/bsp/artinchip/sys/d12x/aic_gpio_id.c b/bsp/artinchip/sys/d12x/aic_gpio_id.c new file mode 100644 index 00000000..39cdb507 --- /dev/null +++ b/bsp/artinchip/sys/d12x/aic_gpio_id.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +const int aic_gpio_groups_list[] = { + PA_GROUP, + PB_GROUP, + PC_GROUP, + PD_GROUP, + PE_GROUP, +}; + +const int aic_gpio_group_size = sizeof(aic_gpio_groups_list) / sizeof(aic_gpio_groups_list[0]); diff --git a/bsp/artinchip/sys/d12x/boot_param.c b/bsp/artinchip/sys/d12x/boot_param.c index bc5f56a8..71f768db 100644 --- a/bsp/artinchip/sys/d12x/boot_param.c +++ b/bsp/artinchip/sys/d12x/boot_param.c @@ -67,6 +67,11 @@ void *aic_get_boot_resource(void) return (void *)(boot_params_stash.r.a[1]); } +void aic_set_boot_resource(void *res_addr) +{ + boot_params_stash.r.a[1] = (u32)(uintptr_t)res_addr; +} + int aic_get_boot_image_id(void) { return get_boot_image_id(boot_params_stash.r.a[0]); diff --git a/bsp/artinchip/sys/d12x/include/aic_gpio_id.h b/bsp/artinchip/sys/d12x/include/aic_gpio_id.h index 4a9614d1..c9d438a8 100644 --- a/bsp/artinchip/sys/d12x/include/aic_gpio_id.h +++ b/bsp/artinchip/sys/d12x/include/aic_gpio_id.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,6 +20,9 @@ enum { GPIO_GROUP_MAX, }; +extern const int aic_gpio_groups_list[]; +extern const int aic_gpio_group_size; + #define PA_BASE 0 #define PB_BASE 32 #define PC_BASE 64 @@ -34,7 +37,7 @@ enum { #define PL_BASE 352 #define PM_BASE 384 #define PN_BASE 416 -#define PO_BASE 448 +#define PU_BASE 448 #define GPIOA(n) (PA_BASE + (n)) #define GPIOB(n) (PB_BASE + (n)) #define GPIOC(n) (PC_BASE + (n)) @@ -49,7 +52,7 @@ enum { #define GPIOL(n) (PL_BASE + (n)) #define GPIOM(n) (PM_BASE + (n)) #define GPION(n) (PN_BASE + (n)) -#define GPIOO(n) (PO_BASE + (n)) +#define GPIOU(n) (PO_BASE + (n)) typedef enum { PA0 = GPIOA(0), diff --git a/bsp/artinchip/sys/d12x/include/boot_param.h b/bsp/artinchip/sys/d12x/include/boot_param.h index 819f3151..e9852d34 100644 --- a/bsp/artinchip/sys/d12x/include/boot_param.h +++ b/bsp/artinchip/sys/d12x/include/boot_param.h @@ -85,6 +85,7 @@ enum boot_controller aic_get_boot_controller(void); int aic_get_boot_image_id(void); unsigned long aic_timer_get_us(void); void *aic_get_boot_resource(void); +void aic_set_boot_resource(void *res_addr); void *aic_get_boot_resource_from_nand(void *dev, unsigned long pagesize, nand_read fn); void *aic_get_boot_args(void); diff --git a/bsp/artinchip/sys/d12x/startup_gcc.S b/bsp/artinchip/sys/d12x/startup_gcc.S index 7506ee00..921a0721 100644 --- a/bsp/artinchip/sys/d12x/startup_gcc.S +++ b/bsp/artinchip/sys/d12x/startup_gcc.S @@ -186,6 +186,10 @@ save_boot_params_ret: bltu a0, a1, 1b 2: + /* Reloc private params */ + la a5, reloc_private_params + jalr a5 + #ifndef __NO_SYSTEM_INIT la a5, SystemInit jalr a5 diff --git a/bsp/artinchip/sys/d13x/Kconfig.chip b/bsp/artinchip/sys/d13x/Kconfig.chip index c9e2f6ad..42614dbd 100644 --- a/bsp/artinchip/sys/d13x/Kconfig.chip +++ b/bsp/artinchip/sys/d13x/Kconfig.chip @@ -36,6 +36,16 @@ config CPU_BASE default 0xE0000000 if QEMU_RUN depends on AIC_CHIP_D13X +config CPU_PSRAM_BASE + hex + default 0x40000000 + depends on AIC_CHIP_D13X + +config CPU_SRAM_BASE + hex + default 0x30040000 + depends on AIC_CHIP_D13X + #-------------------------------------------- # interrupt global option #-------------------------------------------- diff --git a/bsp/artinchip/sys/d13x/aic_gpio_id.c b/bsp/artinchip/sys/d13x/aic_gpio_id.c new file mode 100644 index 00000000..b539a220 --- /dev/null +++ b/bsp/artinchip/sys/d13x/aic_gpio_id.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2024, ArtInChip, Artinchip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +const int aic_gpio_groups_list[] = { + PA_GROUP, + PB_GROUP, + PC_GROUP, + PD_GROUP, + PE_GROUP, + PU_GROUP, +}; + +const int aic_gpio_group_size = sizeof(aic_gpio_groups_list) / sizeof(aic_gpio_groups_list[0]); diff --git a/bsp/artinchip/sys/d13x/boot_param.c b/bsp/artinchip/sys/d13x/boot_param.c index bc5f56a8..71f768db 100644 --- a/bsp/artinchip/sys/d13x/boot_param.c +++ b/bsp/artinchip/sys/d13x/boot_param.c @@ -67,6 +67,11 @@ void *aic_get_boot_resource(void) return (void *)(boot_params_stash.r.a[1]); } +void aic_set_boot_resource(void *res_addr) +{ + boot_params_stash.r.a[1] = (u32)(uintptr_t)res_addr; +} + int aic_get_boot_image_id(void) { return get_boot_image_id(boot_params_stash.r.a[0]); diff --git a/bsp/artinchip/sys/d13x/d13x.pbp b/bsp/artinchip/sys/d13x/d13x.pbp index 137eed88..20e3e875 100644 Binary files a/bsp/artinchip/sys/d13x/d13x.pbp and b/bsp/artinchip/sys/d13x/d13x.pbp differ diff --git a/bsp/artinchip/sys/d13x/include/aic_gpio_id.h b/bsp/artinchip/sys/d13x/include/aic_gpio_id.h index 6ee8c6a5..36bb691b 100644 --- a/bsp/artinchip/sys/d13x/include/aic_gpio_id.h +++ b/bsp/artinchip/sys/d13x/include/aic_gpio_id.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,17 +12,19 @@ extern "C" { #endif enum { - PA_GROUP, - PB_GROUP, - PC_GROUP, - PD_GROUP, - PE_GROUP, - PF_GROUP, - PG_GROUP, - PO_GROUP = 14, + PA_GROUP = 0, + PB_GROUP = 1, + PC_GROUP = 2, + PD_GROUP = 3, + PE_GROUP = 4, + + PU_GROUP = 14, GPIO_GROUP_MAX, }; +extern const int aic_gpio_groups_list[]; +extern const int aic_gpio_group_size; + #define PA_BASE 0 #define PB_BASE 32 #define PC_BASE 64 @@ -37,7 +39,7 @@ enum { #define PL_BASE 352 #define PM_BASE 384 #define PN_BASE 416 -#define PO_BASE 448 +#define PU_BASE 448 #define GPIOA(n) (PA_BASE + (n)) #define GPIOB(n) (PB_BASE + (n)) #define GPIOC(n) (PC_BASE + (n)) @@ -52,660 +54,597 @@ enum { #define GPIOL(n) (PL_BASE + (n)) #define GPIOM(n) (PM_BASE + (n)) #define GPION(n) (PN_BASE + (n)) -#define GPIOO(n) (PO_BASE + (n)) +#define GPIOU(n) (PU_BASE + (n)) typedef enum { - PA0 = GPIOA(0), - PA1 = GPIOA(1), - PA2 = GPIOA(2), - PA3 = GPIOA(3), - PA4 = GPIOA(4), - PA5 = GPIOA(5), - PA6 = GPIOA(6), - PA7 = GPIOA(7), - PA8 = GPIOA(8), - PA9 = GPIOA(9), - PA10 = GPIOA(10), - PA11 = GPIOA(11), + PA0 = GPIOA(0), + PA1 = GPIOA(1), + PA2 = GPIOA(2), + PA3 = GPIOA(3), + PA4 = GPIOA(4), + PA5 = GPIOA(5), + PA6 = GPIOA(6), + PA7 = GPIOA(7), + PA8 = GPIOA(8), + PA9 = GPIOA(9), + PA10 = GPIOA(10), + PA11 = GPIOA(11), + PA12 = GPIOA(12), + PA13 = GPIOA(13), + PA14 = GPIOA(14), + PA15 = GPIOA(15), - PB0 = GPIOB(0), - PB1 = GPIOB(1), - PB2 = GPIOB(2), - PB3 = GPIOB(3), - PB4 = GPIOB(4), - PB5 = GPIOB(5), - PB6 = GPIOB(6), - PB7 = GPIOB(7), - PB8 = GPIOB(8), - PB9 = GPIOB(9), - PB10 = GPIOB(10), - PB11 = GPIOB(11), + PB0 = GPIOB(0), + PB1 = GPIOB(1), + PB2 = GPIOB(2), + PB3 = GPIOB(3), + PB4 = GPIOB(4), + PB5 = GPIOB(5), + PB6 = GPIOB(6), + PB7 = GPIOB(7), + PB8 = GPIOB(8), + PB9 = GPIOB(9), + PB10 = GPIOB(10), + PB11 = GPIOB(11), + PB12 = GPIOB(12), + PB13 = GPIOB(13), + PB14 = GPIOB(14), + PB15 = GPIOB(15), + PB16 = GPIOB(16), + PB17 = GPIOB(17), - PC0 = GPIOC(0), - PC1 = GPIOC(1), - PC2 = GPIOC(2), - PC3 = GPIOC(3), - PC4 = GPIOC(4), - PC5 = GPIOC(5), - PC6 = GPIOC(6), - PC7 = GPIOC(7), + PC0 = GPIOC(0), + PC1 = GPIOC(1), + PC2 = GPIOC(2), + PC3 = GPIOC(3), + PC4 = GPIOC(4), + PC5 = GPIOC(5), + PC6 = GPIOC(6), + PC7 = GPIOC(7), + PC8 = GPIOC(8), + PC9 = GPIOC(9), + PC10 = GPIOC(10), + PC11 = GPIOC(11), - PD0 = GPIOD(0), - PD1 = GPIOD(1), - PD2 = GPIOD(2), - PD3 = GPIOD(3), - PD4 = GPIOD(4), - PD5 = GPIOD(5), - PD6 = GPIOD(6), - PD7 = GPIOD(7), - PD8 = GPIOD(8), - PD9 = GPIOD(9), - PD10 = GPIOD(10), - PD11 = GPIOD(11), - PD12 = GPIOD(12), - PD13 = GPIOD(13), - PD14 = GPIOD(14), - PD15 = GPIOD(15), - PD16 = GPIOD(16), - PD17 = GPIOD(17), - PD18 = GPIOD(18), - PD19 = GPIOD(19), - PD20 = GPIOD(20), - PD21 = GPIOD(21), - PD22 = GPIOD(22), - PD23 = GPIOD(23), - PD24 = GPIOD(24), - PD25 = GPIOD(25), - PD26 = GPIOD(26), - PD27 = GPIOD(27), + PD0 = GPIOD(0), + PD1 = GPIOD(1), + PD2 = GPIOD(2), + PD3 = GPIOD(3), + PD4 = GPIOD(4), + PD5 = GPIOD(5), + PD6 = GPIOD(6), + PD7 = GPIOD(7), + PD8 = GPIOD(8), + PD9 = GPIOD(9), + PD10 = GPIOD(10), + PD11 = GPIOD(11), + PD12 = GPIOD(12), + PD13 = GPIOD(13), + PD14 = GPIOD(14), + PD15 = GPIOD(15), + PD16 = GPIOD(16), + PD17 = GPIOD(17), + PD18 = GPIOD(18), + PD19 = GPIOD(19), + PD20 = GPIOD(20), + PD21 = GPIOD(21), + PD22 = GPIOD(22), + PD23 = GPIOD(23), + PD24 = GPIOD(24), + PD25 = GPIOD(25), + PD26 = GPIOD(26), + PD27 = GPIOD(27), - PE0 = GPIOE(0), - PE1 = GPIOE(1), - PE2 = GPIOE(2), - PE3 = GPIOE(3), - PE4 = GPIOE(4), - PE5 = GPIOE(5), - PE6 = GPIOE(6), - PE7 = GPIOE(7), - PE8 = GPIOE(8), - PE9 = GPIOE(9), - PE10 = GPIOE(10), - PE11 = GPIOE(11), - PE12 = GPIOE(12), - PE13 = GPIOE(13), - PE14 = GPIOE(14), - PE15 = GPIOE(15), - PE16 = GPIOE(16), - PE17 = GPIOE(17), - PE18 = GPIOE(18), - PE19 = GPIOE(19), + PE0 = GPIOE(0), + PE1 = GPIOE(1), + PE2 = GPIOE(2), + PE3 = GPIOE(3), + PE4 = GPIOE(4), + PE5 = GPIOE(5), + PE6 = GPIOE(6), + PE7 = GPIOE(7), + PE8 = GPIOE(8), + PE9 = GPIOE(9), + PE10 = GPIOE(10), + PE11 = GPIOE(11), + PE12 = GPIOE(12), + PE13 = GPIOE(13), + PE14 = GPIOE(14), + PE15 = GPIOE(15), + PE16 = GPIOE(16), + PE17 = GPIOE(17), - PF0 = GPIOF(0), - PF1 = GPIOF(1), - PF2 = GPIOF(2), - PF3 = GPIOF(3), - PF4 = GPIOF(4), - PF5 = GPIOF(5), - PF6 = GPIOF(6), - PF7 = GPIOF(7), - PF8 = GPIOF(8), - PF9 = GPIOF(9), - PF10 = GPIOF(10), - PF11 = GPIOF(11), - PF12 = GPIOF(12), - PF13 = GPIOF(13), - PF14 = GPIOF(14), - PF15 = GPIOF(15), + PU0 = GPIOU(0), + PU1 = GPIOU(1), - PG0 = GPIOG(0), - PG1 = GPIOG(1), - PG2 = GPIOG(2), - PG3 = GPIOG(3), - - /* To aviod compile warnings. */ GPIO_MAX_PIN, } pin_name_t; typedef enum { - PA0_GPAI0 = 2U, - PA0_PSADC0 = 3U, - PA0_I2C0_SCK = 4U, - PA0_UART0_TX = 5U, - PA0_AMIC_IN = 6U, - PA0_IR_TX = 7U, - PA0_EPHY_LED0 = 8U, - PA1_GPAI1 = 2U, - PA1_PSADC1 = 3U, - PA1_I2C0_SDA = 4U, - PA1_UART0_RX = 5U, - PA1_AMIC_BIAS = 6U, - PA1_IR_RX = 7U, - PA1_EPHY_LED1 = 8U, - PA2_GPAI2 = 2U, - PA2_PSADC2 = 3U, - PA2_UART0_RTS = 5U, - PA3_GPAI3 = 2U, - PA3_PSADC3 = 3U, - PA3_UART0_CTS = 5U, - PA4_GPAI4 = 2U, - PA4_PSADC4 = 3U, - PA4_UART1_TX = 5U, - PA5_GPAI5 = 2U, - PA5_PSADC5 = 3U, - PA5_UART1_RX = 5U, - PA6_GPAI6 = 2U, - PA6_PSADC6 = 3U, - PA6_I2C1_SCK = 4U, - PA6_UART1_RTS = 5U, - PA7_GPAI7 = 2U, - PA7_PSADC7 = 3U, - PA7_I2C1_SDA = 4U, - PA7_UART1_CTS = 5U, - PA8_RTP_XP = 2U, - PA8_PSADC8 = 3U, - PA8_I2C2_SCK = 4U, - PA8_UART2_TX = 5U, - PA8_JTAG_DO = 6U, - PA9_RTP_YP = 2U, - PA9_PSADC9 = 3U, - PA9_I2C2_SDA = 4U, - PA9_UART2_RX = 5U, - PA9_JTAG_DI = 6U, - PA10_RTP_XN = 2U, - PA10_PSADC10 = 3U, - PA10_I2C3_SCK = 4U, - PA10_UART2_RTS = 5U, - PA10_JTAG_MS = 6U, - PA11_RTP_YN = 2U, - PA11_PSADC11 = 3U, - PA11_I2C3_SDA = 4U, - PA11_UART2_CTS = 5U, - PA11_JTAG_CK = 6U, - PA11_PSADC_TRIG = 7U, - PB0_SDC0_CMD = 2U, - PB0_SPI0_HOLD = 3U, - PB0_I2C1_SCK = 4U, - PB0_UART7_TX = 5U, - PB0_EPHY_LED0 = 8U, - PB1_SDC0_CLK = 2U, - PB1_SPI0_WP = 3U, - PB1_I2C1_SDA = 4U, - PB1_UART7_RX = 5U, - PB1_EPHY_LED1 = 8U, - PB2_SDC0_D3 = 2U, - PB2_SPI0_CS = 3U, - PB3_SDC0_D0 = 2U, - PB3_SPI0_MISO = 3U, - PB4_SDC0_D1 = 2U, - PB4_SPI0_MOSI = 3U, - PB5_SDC0_D2 = 2U, - PB5_SPI0_CLK = 3U, - PB6_SDC0_D4 = 2U, - PB6_SPI1_HOLD = 3U, - PB6_I2C2_SCK = 4U, - PB6_UART4_TX = 5U, - PB6_CLK_OUT2 = 7U, - PB6_CLK_OUT3 = 8U, - PB7_SDC0_D5 = 2U, - PB7_SPI1_WP = 3U, - PB7_I2C2_SDA = 4U, - PB7_UART4_RX = 5U, - PB8_SDC0_D6 = 2U, - PB8_SPI1_CS = 3U, - PB8_UART4_RTS = 4U, - PB8_UART5_TX = 5U, - PB8_PSADC_TRIG = 6U, - PB8_IR_RX = 7U, - PB9_SDC0_D7 = 2U, - PB9_SPI1_MISO = 3U, - PB9_UART6_RTS = 4U, - PB9_UART5_RX = 5U, - PB9_IR_TX = 7U, - PB10_SDC0_DS = 2U, - PB10_SPI1_MOSI = 3U, - PB10_UART6_TX = 5U, - PB11_SDC0_RST = 2U, - PB11_SPI1_CLK = 3U, - PB11_UART6_RX = 5U, - PC0_SDC1_D1 = 2U, - PC0_LCD_D5 = 3U, - PC0_SPI2_CLK = 4U, - PC0_UART1_TX = 5U, - PC0_JTAG_MS = 6U, - PC0_PWM0 = 7U, - PC0_DBG_IO0 = 8U, - PC1_SDC1_D0 = 2U, - PC1_LCD_D4 = 3U, - PC1_SPI2_CS = 4U, - PC1_UART1_RX = 5U, - PC1_JTAG_DI = 6U, - PC1_PWM1 = 7U, - PC1_DBG_IO1 = 8U, - PC2_SDC1_CLK = 2U, - PC2_LCD_D3 = 3U, - PC2_SPI2_MOSI = 4U, - PC2_UART1_RTS = 5U, - PC2_UART0_TX = 6U, - PC2_PWM2 = 7U, - PC2_DBG_IO2 = 8U, - PC3_SDC1_CMD = 2U, - PC3_LCD_D2 = 3U, - PC3_SPI2_MISO = 4U, - PC3_UART2_TX = 5U, - PC3_JTAG_DO = 6U, - PC3_PWM3 = 7U, - PC3_DBG_IO3 = 8U, - PC4_SDC1_D3 = 2U, - PC4_LCD_D1 = 3U, - PC4_UART2_RX = 5U, - PC4_UART0_RX = 6U, - PC4_PWM4 = 7U, - PC4_DBG_IO4 = 8U, - PC5_SDC1_D2 = 2U, - PC5_LCD_D0 = 3U, - PC5_UART2_RTS = 4U, - PC5_UART3_TX = 5U, - PC5_JTAG_CK = 6U, - PC5_PWM5 = 7U, - PC5_DBG_IO5 = 8U, - PC6_SDC1_DET = 2U, - PC6_CLK_OUT0 = 3U, - PC6_DE_TE = 4U, - PC6_UART3_RX = 5U, - PC6_PWM6 = 7U, - PC7_UART3_RTS = 5U, - PC7_PWM7 = 7U, - PC7_EPHY_LEDIN1 = 8U, - PD0_LCD_D0 = 2U, - PD0_SPI2_CLK = 3U, - PD0_PBUS_AD0 = 6U, - PD0_PWM0 = 7U, - PD0_GMAC1_MDIO = 8U, - PD1_LCD_D1 = 2U, - PD1_SPI2_CS = 3U, - PD1_PBUS_AD1 = 6U, - PD1_PWM1 = 7U, - PD1_EPHY_LEDIN0 = 8U, - PD2_LCD_D2 = 2U, - PD2_SPI2_MOSI = 3U, - PD2_DE_TE = 4U, - PD2_PBUS_AD2 = 6U, - PD2_PWM2 = 7U, - PD2_GMAC1_MDC = 8U, - PD3_LCD_D3 = 2U, - PD3_SPI3_CLK = 3U, - PD3_PBUS_AD3 = 6U, - PD3_PWM3 = 7U, - PD3_GMAC1_TXCTL = 8U, - PD4_LCD_D4 = 2U, - PD4_SPI3_CS = 3U, - PD4_PBUS_AD4 = 6U, - PD4_PWM4 = 7U, - PD5_LCD_D5 = 2U, - PD5_SPI3_MOSI = 3U, - PD5_PBUS_AD5 = 6U, - PD5_PWM5 = 7U, - PD5_GMAC1_TXD1 = 8U, - PD6_LCD_D6 = 2U, - PD6_SPI3_MISO = 3U, - PD6_I2C0_SCK = 4U, - PD6_UART1_TX = 5U, - PD6_PBUS_AD6 = 6U, - PD6_DBG_IO6 = 8U, - PD7_LCD_D7 = 2U, - PD7_SPI2_MISO = 3U, - PD7_I2C0_SDA = 4U, - PD7_UART1_RX = 5U, - PD7_PBUS_AD7 = 6U, - PD7_DBG_IO7 = 8U, - PD8_LCD_D8 = 2U, - PD8_LVDS1_D0N = 3U, - PD8_SPI1_HOLD = 4U, - PD8_UART2_TX = 5U, - PD8_PBUS_AD8 = 6U, - PD8_APWM0_A = 7U, - PD8_DBG_IO8 = 8U, - PD9_LCD_D9 = 2U, - PD9_LVDS1_D0P = 3U, - PD9_SPI1_WP = 4U, - PD9_UART2_RX = 5U, - PD9_PBUS_AD9 = 6U, - PD9_APWM0_B = 7U, - PD9_DBG_IO9 = 8U, - PD10_LCD_D10 = 2U, - PD10_LVDS1_D1N = 3U, - PD10_SPI1_CS = 4U, - PD10_UART3_TX = 5U, - PD10_PBUS_AD10 = 6U, - PD10_APWM1_A = 7U, - PD10_DBG_IO10 = 8U, - PD11_LCD_D11 = 2U, - PD11_LVDS1_D1P = 3U, - PD11_SPI1_MISO = 4U, - PD11_UART3_RX = 5U, - PD11_PBUS_AD11 = 6U, - PD11_APWM1_B = 7U, - PD11_DBG_IO11 = 8U, - PD12_LCD_D12 = 2U, - PD12_LVDS1_D2N = 3U, - PD12_SPI1_MOSI = 4U, - PD12_UART4_TX = 5U, - PD12_PBUS_AD12 = 6U, - PD12_APWM2_A = 7U, - PD12_DBG_IO12 = 8U, - PD13_LCD_D13 = 2U, - PD13_LVDS1_D2P = 3U, - PD13_SPI1_CLK = 4U, - PD13_UART4_RX = 5U, - PD13_PBUS_AD13 = 6U, - PD13_APWM2_B = 7U, - PD13_DBG_IO13 = 8U, - PD14_LCD_D14 = 2U, - PD14_LVDS1_CKN = 3U, - PD14_SPI3_CLK = 4U, - PD14_CAP0 = 5U, - PD14_PBUS_AD14 = 6U, - PD14_QEP0_H0 = 7U, - PD14_DBG_IO14 = 8U, - PD15_LCD_D15 = 2U, - PD15_LVDS1_CKP = 3U, - PD15_SPI3_CS = 4U, - PD15_CAP1 = 5U, - PD15_PBUS_AD15 = 6U, - PD15_QEP0_H1 = 7U, - PD15_DBG_IO15 = 8U, - PD16_LCD_D16 = 2U, - PD16_LVDS1_D3N = 3U, - PD16_SPI3_MOSI = 4U, - PD16_CAP2 = 5U, - PD16_PBUS_CLK = 6U, - PD16_QEP0_H2 = 7U, - PD16_DBG_IO16 = 8U, - PD17_LCD_D17 = 2U, - PD17_LVDS1_D3P = 3U, - PD17_SPI3_MISO = 4U, - PD17_APWM_FLT5 = 5U, - PD17_PBUS_NCS = 6U, - PD17_QEP0_A = 7U, - PD17_DBG_IO17 = 8U, - PD18_LCD_D18 = 2U, - PD18_LVDS0_D0N = 3U, - PD18_DSI_D0N = 4U, - PD18_I2C1_SCK = 5U, - PD18_PBUS_NADV = 6U, - PD18_QEP0_B = 7U, - PD18_DBG_IO18 = 8U, - PD19_LCD_D19 = 2U, - PD19_LVDS0_D0P = 3U, - PD19_DSI_D0P = 4U, - PD19_I2C1_SDA = 5U, - PD19_PBUS_NWE = 6U, - PD19_QEP0_I = 7U, - PD19_DBG_IO19 = 8U, - PD20_LCD_D20 = 2U, - PD20_LVDS0_D1N = 3U, - PD20_DSI_D1N = 4U, - PD20_UART7_TX = 5U, - PD20_PBUS_NOE = 6U, - PD20_QEP0_S = 7U, - PD20_DBG_IO20 = 8U, - PD21_LCD_D21 = 2U, - PD21_LVDS0_D1P = 3U, - PD21_DSI_D1P = 4U, - PD21_UART7_RX = 5U, - PD21_CLK_OUT0 = 6U, - PD21_APWM_FLT0 = 7U, - PD21_DBG_IO21 = 8U, - PD22_LCD_D22 = 2U, - PD22_LVDS0_D2N = 3U, - PD22_DSI_CKN = 4U, - PD22_I2C3_SCK = 5U, - PD22_UART6_TX = 6U, - PD22_APWM_FLT1 = 7U, - PD22_DBG_IO22 = 8U, - PD23_LCD_D23 = 2U, - PD23_LVDS0_D2P = 3U, - PD23_DSI_CKP = 4U, - PD23_I2C3_SDA = 5U, - PD23_UART6_RX = 6U, - PD23_APWM_FLT2 = 7U, - PD23_DBG_IO23 = 8U, - PD24_LCD_C0 = 2U, - PD24_LVDS0_CKN = 3U, - PD24_DSI_D2N = 4U, - PD24_UART5_TX = 5U, - PD24_SPI1_CLK = 6U, - PD24_APWM_FLT3 = 7U, - PD24_DBG_IO24 = 8U, - PD25_LCD_C1 = 2U, - PD25_LVDS0_CKP = 3U, - PD25_DSI_D2P = 4U, - PD25_UART5_RX = 5U, - PD25_SPI1_CS = 6U, - PD25_APWM_FLT4 = 7U, - PD25_DBG_IO25 = 8U, - PD26_LCD_C2 = 2U, - PD26_LVDS0_D3N = 3U, - PD26_DSI_D3N = 4U, - PD26_PWM6 = 5U, - PD26_SPI1_MOSI = 6U, - PD26_APWM0_SI = 7U, - PD26_DBG_CLK = 8U, - PD27_LCD_C3 = 2U, - PD27_LVDS0_D3P = 3U, - PD27_DSI_D3P = 4U, - PD27_PWM7 = 5U, - PD27_SPI1_MISO = 6U, - PD27_APWM0_SO = 7U, - PD27_RTC_32K = 8U, - PE0_DVP_D0 = 3U, - PE0_I2C0_SCK = 4U, - PE0_GMAC0_RXD1 = 6U, - PE0_APWM3_A = 7U, - PE0_PWM0 = 8U, - PE1_DVP_D1 = 3U, - PE1_I2C0_SDA = 4U, - PE1_GMAC0_RXD0 = 6U, - PE1_APWM3_B = 7U, - PE1_PWM1 = 8U, - PE2_DVP_D2 = 3U, - PE2_CAN0_TX = 4U, - PE2_UART4_TX = 5U, - PE2_GMAC0_RXCTL = 6U, - PE2_APWM4_A = 7U, - PE2_PWM2 = 8U, - PE3_DVP_D3 = 3U, - PE3_CAN0_RX = 4U, - PE3_UART4_RX = 5U, - PE3_GMAC0_CLKIN = 6U, - PE3_APWM4_B = 7U, - PE3_PWM3 = 8U, - PE4_DVP_D4 = 3U, - PE4_CAN1_TX = 4U, - PE4_UART5_TX = 5U, - PE4_GMAC0_TXD1 = 6U, - PE4_APWM5_A = 7U, - PE4_PWM4 = 8U, - PE5_DVP_D5 = 3U, - PE5_CAN1_RX = 4U, - PE5_UART5_RX = 5U, - PE5_GMAC0_TXD0 = 6U, - PE5_APWM5_B = 7U, - PE5_PWM5 = 8U, - PE6_SPK0 = 2U, - PE6_DVP_D6 = 3U, - PE6_UART5_RTS = 4U, - PE6_UART6_TX = 5U, - PE6_GMAC0_TXCK = 6U, - PE6_QEP1_H0 = 7U, - PE6_CAP0 = 8U, - PE7_SPK1 = 2U, - PE7_DVP_D7 = 3U, - PE7_UART7_RTS = 4U, - PE7_UART6_RX = 5U, - PE7_GMAC0_TXCTL = 6U, - PE7_QEP1_H1 = 7U, - PE7_CAP1 = 8U, - PE8_I2S0_MCLK = 2U, - PE8_DVP_CK = 3U, - PE8_UART6_RTS = 4U, - PE8_UART7_TX = 5U, - PE8_GMAC0_MDC = 6U, - PE8_QEP1_H2 = 7U, - PE8_CAP2 = 8U, - PE9_I2S0_BCLK = 2U, - PE9_DVP_HS = 3U, - PE9_UART6_CTS = 4U, - PE9_UART7_RX = 5U, - PE9_GMAC0_MDIO = 6U, - PE9_QEP1_A = 7U, - PE10_I2S0_LRCK = 2U, - PE10_DVP_VS = 3U, - PE10_SPK0 = 4U, - PE10_CLK_OUT2 = 6U, - PE10_QEP1_B = 7U, - PE10_EPHY_LED0 = 8U, - PE11_I2S0_DOUT = 2U, - PE11_I2S0_DIN = 3U, - PE11_SPK1 = 4U, - PE11_CLK_OUT1 = 5U, - PE11_GMAC0_RXD3 = 6U, - PE11_QEP1_I = 7U, - PE11_EPHY_LED1 = 8U, - PE12_I2S0_DIN = 2U, - PE12_SPI3_CLK = 3U, - PE12_DMIC_CLK = 4U, - PE12_I2C2_SCK = 5U, - PE12_GMAC0_RXD2 = 6U, - PE12_QEP1_S = 7U, - PE13_SPI3_CS = 3U, - PE13_DMIC_D0 = 4U, - PE13_I2C2_SDA = 5U, - PE13_GMAC0_RXCK = 6U, - PE13_CAP0 = 7U, - PE14_SPI3_MOSI = 3U, - PE14_UART3_TX = 5U, - PE14_GMAC0_TXD3 = 6U, - PE14_CAP1 = 7U, - PE15_SPI3_MISO = 3U, - PE15_UART3_RX = 5U, - PE15_GMAC0_TXD2 = 6U, - PE15_CAP2 = 7U, - PE16_SPI0_CLK = 3U, - PE16_CAN0_TX = 4U, - PE16_I2C3_SCK = 5U, - PE16_GMAC0_TRIG = 6U, - PE17_SPI0_CS = 3U, - PE17_CAN0_RX = 4U, - PE17_I2C3_SDA = 5U, - PE17_GMAC0_PPSO = 6U, - PE18_SPI0_MOSI = 3U, - PE18_CAN1_TX = 4U, - PE18_PWM6 = 5U, - PE18_GMAC1_TRIG = 6U, - PE19_SPI0_MISO = 3U, - PE19_CAN1_RX = 4U, - PE19_PWM7 = 5U, - PE19_GMAC1_PPSO = 6U, - PF0_SDC2_D1 = 2U, - PF0_SPI2_CLK = 3U, - PF0_UART5_TX = 5U, - PF0_GMAC1_RXD1 = 6U, - PF0_PBUS_AD0 = 7U, - PF0_GMAC1_RXD0 = 8U, - PF1_SDC2_D0 = 2U, - PF1_SPI2_CS = 3U, - PF1_UART5_RX = 5U, - PF1_GMAC1_RXD0 = 6U, - PF1_PBUS_AD1 = 7U, - PF2_SDC2_CLK = 2U, - PF2_SPI2_MOSI = 3U, - PF2_UART5_RTS = 5U, - PF2_GMAC1_RXCTL = 6U, - PF2_PBUS_AD2 = 7U, - PF2_GMAC1_RXD1 = 8U, - PF3_SDC2_CMD = 2U, - PF3_SPI2_MISO = 3U, - PF3_UART5_CTS = 5U, - PF3_GMAC1_CLKIN = 6U, - PF3_PBUS_AD3 = 7U, - PF4_SDC2_D3 = 2U, - PF4_UART6_TX = 5U, - PF4_GMAC1_TXD1 = 6U, - PF4_PBUS_AD4 = 7U, - PF4_DBG_IO26 = 8U, - PF5_SDC2_D2 = 2U, - PF5_UART6_RX = 5U, - PF5_GMAC1_TXD0 = 6U, - PF5_PBUS_AD5 = 7U, - PF5_DBG_IO27 = 8U, - PF6_UART7_TX = 5U, - PF6_GMAC1_TXCK = 6U, - PF6_PBUS_AD6 = 7U, - PF6_DBG_IO28 = 8U, - PF7_UART7_RX = 5U, - PF7_GMAC1_TXCTL = 6U, - PF7_PBUS_AD7 = 7U, - PF7_DBG_IO29 = 8U, - PF8_UART7_RTS = 5U, - PF8_GMAC1_MDC = 6U, - PF8_PBUS_AD8 = 7U, - PF8_DBG_IO30 = 8U, - PF9_UART7_CTS = 5U, - PF9_GMAC1_MDIO = 6U, - PF9_PBUS_AD9 = 7U, - PF9_DBG_IO31 = 8U, - PF10_I2S1_MCLK = 2U, - PF10_I2S1_DIN = 3U, - PF10_UART3_CTS = 5U, - PF10_CLK_OUT3 = 6U, - PF10_PBUS_AD10 = 7U, - PF10_GMAC1_CLKIN = 8U, - PF11_I2S1_BCLK = 2U, - PF11_PBUS_AD11 = 4U, - PF11_UART3_TX = 5U, - PF11_GMAC1_RXD3 = 6U, - PF11_PBUS_CLK = 7U, - PF12_I2S1_LRCK = 2U, - PF12_UART4_RTS = 4U, - PF12_UART3_RX = 5U, - PF12_GMAC1_RXD2 = 6U, - PF12_PBUS_NCS = 7U, - PF12_GMAC1_TXD0 = 8U, - PF13_I2S1_DOUT = 2U, - PF13_I2S1_DIN = 3U, - PF13_UART4_CTS = 4U, - PF13_UART3_RTS = 5U, - PF13_GMAC1_RXCK = 6U, - PF13_PBUS_NADV = 7U, - PF13_GMAC1_RXCTL = 8U, - PF14_I2S1_DIN = 2U, - PF14_SPK0 = 3U, - PF14_DMIC_D0 = 4U, - PF14_UART4_TX = 5U, - PF14_GMAC1_TXD3 = 6U, - PF14_PBUS_NWE = 7U, - PF15_DE_TE = 2U, - PF15_SPK1 = 3U, - PF15_DMIC_CLK = 4U, - PF15_UART4_RX = 5U, - PF15_GMAC1_TXD2 = 6U, - PF15_PBUS_NOE = 7U, - PG0_USB0_DM = 2U, - PG0_UART0_RX = 4U, - PG0_UART1_RX = 5U, - PG1_USB0_DP = 2U, - PG1_UART0_TX = 4U, - PG1_UART1_TX = 5U, - PG2_USB1_DM = 2U, - PG2_UART0_RX = 4U, - PG2_UART2_RX = 5U, - PG3_USB1_DP = 2U, - PG3_UART0_TX = 4U, - PG3_UART2_TX = 5U, + PA0_GPAI0 = 2U, + PA0_IR_TX = 3U, + PA0_I2C0_SCL = 4U, + PA0_UART0_TX = 5U, + PA0_PSADC0 = 7U, + PA0_CPU_NMI = 8U, + PA1_GPAI1 = 2U, + PA1_IR_RX = 3U, + PA1_I2C0_SDA = 4U, + PA1_UART0_RX = 5U, + PA1_PSADC1 = 7U, + PA1_DE_TE = 8U, + PA2_GPAI2 = 2U, + PA2_I2C1_SCL = 4U, + PA2_UART1_TX = 5U, + PA2_EPWM_FLT2 = 6U, + PA2_PSADC2 = 7U, + PA2_UART2_CTS = 8U, + PA3_GPAI3 = 2U, + PA3_I2C1_SDA = 4U, + PA3_UART1_RX = 5U, + PA3_EPWM_FLT3 = 6U, + PA3_PSADC3 = 7U, + PA3_UART2_RTS = 8U, + PA4_GPAI4 = 2U, + PA4_CAN0_TX = 4U, + PA4_UART2_TX = 5U, + PA4_SDFM0_DAT = 6U, + PA4_PSADC4 = 7U, + PA5_GPAI5 = 2U, + PA5_CAN0_RX = 4U, + PA5_UART2_RX = 5U, + PA5_SDFM0_CLK = 6U, + PA5_PSADC5 = 7U, + PA5_RTC_32K = 8U, + PA6_GPAI6 = 2U, + PA6_CAN1_TX = 4U, + PA6_UART3_TX = 5U, + PA6_SDFM1_DAT = 6U, + PA6_PSADC6 = 7U, + PA7_GPAI7 = 2U, + PA7_CAN1_RX = 4U, + PA7_UART3_RX = 5U, + PA7_SDFM1_CLK = 6U, + PA7_PSADC7 = 7U, + PA8_RTP_XP = 2U, + PA8_I2C2_SCL = 4U, + PA8_PSADC8 = 7U, + PA9_RTP_YP = 2U, + PA9_I2C2_SDA = 4U, + PA9_PSADC_TRIG = 6U, + PA9_PSADC9 = 7U, + PA10_RTP_XN = 2U, + PA10_IR_RX = 3U, + PA10_EPWM_FLT4 = 6U, + PA10_PSADC10 = 7U, + PA10_JTAG_MS = 8U, + PA11_RTP_YN = 2U, + PA11_IR_TX = 3U, + PA11_EPWM_FLT5 = 6U, + PA11_PSADC11 = 7U, + PA11_JTAG_CK = 8U, + PA12_SDFM2_DAT = 6U, + PA12_PSADC12 = 7U, + PA13_SDFM2_CLK = 6U, + PA13_PSADC13 = 7U, + PA14_SDFM3_DAT = 6U, + PA14_PSADC14 = 7U, + PA15_SDFM3_CLK = 6U, + PA15_PSADC15 = 7U, + PB0_SPI0_WP = 2U, + PB0_SPI1_WP = 3U, + PB0_UART4_TX = 5U, + PB1_SPI0_MISO = 2U, + PB1_SPI1_MISO = 3U, + PB1_UART6_TX = 5U, + PB2_SPI0_CS0 = 2U, + PB2_SPI1_CS = 3U, + PB2_UART6_RX = 5U, + PB3_SPI0_HOLD = 2U, + PB3_SPI1_HOLD = 3U, + PB3_UART4_RX = 5U, + PB4_SPI0_CLK = 2U, + PB4_SPI1_CLK = 3U, + PB4_UART6_RTS = 5U, + PB5_SPI0_MOSI = 2U, + PB5_SPI1_MOSI = 3U, + PB5_UART4_RTS = 5U, + PB5_UART6_CTS = 6U, + PB6_SDC0_CMD = 2U, + PB6_SPI2_CS = 3U, + PB6_UART5_TX = 5U, + PB6_CPM_HP = 7U, + PB6_FLASH_CS = 8U, + PB7_SDC0_CLK = 2U, + PB7_SPI2_MISO = 3U, + PB7_UART5_RX = 5U, + PB7_CPM_HN = 7U, + PB7_FLASH_MISO = 8U, + PB8_SDC0_D3 = 2U, + PB8_SPI2_MOSI = 3U, + PB8_UART5_RTS = 5U, + PB8_UART7_CTS = 6U, + PB8_CPM_LP = 7U, + PB8_FLASH_MOSI = 8U, + PB9_SDC0_D0 = 2U, + PB9_SPI2_CLK = 3U, + PB9_UART7_RTS = 5U, + PB9_CPM_LN = 7U, + PB9_FLASH_CLK = 8U, + PB10_SDC0_D1 = 2U, + PB10_SPI2_HOLD = 3U, + PB10_UART7_TX = 5U, + PB10_CPM0_COHL = 6U, + PB10_CPM0_COH = 7U, + PB10_CPM1_COL = 8U, + PB11_SDC0_D2 = 2U, + PB11_SPI2_WP = 3U, + PB11_SPI0_CS1 = 4U, + PB11_UART7_RX = 5U, + PB11_CPM1_COHL = 6U, + PB11_CPM0_COL = 7U, + PB11_CPM1_COH = 8U, + PB12_FLASH_IO0 = 8U, + PB13_FLASH_IO1 = 8U, + PB14_FLASH_IO2 = 8U, + PB15_FLASH_IO3 = 8U, + PB16_FLASH_IO4 = 8U, + PB17_FLASH_IO5 = 8U, + PC0_SDC1_D1 = 2U, + PC0_I2C2_SCL = 4U, + PC0_UART3_RTS = 5U, + PC0_JTAG_MS = 8U, + PC1_SDC1_D0 = 2U, + PC2_SDC1_CLK = 2U, + PC2_UART0_TX = 8U, + PC3_SDC1_CMD = 2U, + PC4_SDC1_D3 = 2U, + PC4_I2C1_SCL = 4U, + PC4_UART3_TX = 5U, + PC4_UART0_RX = 8U, + PC5_SDC1_D2 = 2U, + PC5_I2C1_SDA = 4U, + PC5_UART3_RX = 5U, + PC5_JTAG_CK = 8U, + PC6_SDC1_DET = 2U, + PC6_CAP0 = 3U, + PC6_I2C2_SDA = 4U, + PC6_UART3_CTS = 5U, + PC6_DE_TE = 6U, + PC6_CLK_OUT3 = 7U, + PC6_DBG_IO0 = 8U, + PC7_CAP1 = 3U, + PC7_EPWM_SO0 = 7U, + PC7_DBG_IO1 = 8U, + PC8_SPI3_CLK = 2U, + PC8_CAP2 = 3U, + PC8_CAN0_TX = 4U, + PC8_UART4_TX = 5U, + PC8_EPWM_FLT0 = 6U, + PC8_EPWM_SO1 = 7U, + PC8_EPWM_TO0 = 8U, + PC9_SPI3_CS = 2U, + PC9_CAP3 = 3U, + PC9_CAN0_RX = 4U, + PC9_UART4_RX = 5U, + PC9_EPWM_FLT1 = 6U, + PC9_EPWM_SO2 = 7U, + PC9_EPWM_TO3 = 8U, + PC10_SPI3_MOSI = 2U, + PC10_CAP4 = 3U, + PC10_CAN1_TX = 4U, + PC10_UART5_TX = 5U, + PC10_EPWM_SI0 = 6U, + PC10_EPWM_SO3 = 7U, + PC10_EPWM_TO6 = 8U, + PC11_SPI3_MISO = 2U, + PC11_CAP5 = 3U, + PC11_CAN1_RX = 4U, + PC11_UART5_RX = 5U, + PC11_EPWM_SI1 = 6U, + PC11_EPWM_SO4 = 7U, + PC11_EPWM_TO9 = 8U, + PD0_LCD_D0 = 2U, + PD0_SPI3_CLK = 3U, + PD0_I2C0_SCL = 4U, + PD0_UART0_TX = 5U, + PD0_PBUS_AD0 = 6U, + PD0_EPWM11_B = 7U, + PD0_DBG_IO2 = 8U, + PD1_LCD_D1 = 2U, + PD1_SPI3_CS = 3U, + PD1_I2C0_SDA = 4U, + PD1_UART0_RX = 5U, + PD1_PBUS_AD1 = 6U, + PD1_EPWM11_A = 7U, + PD1_DBG_IO3 = 8U, + PD2_LCD_D2 = 2U, + PD2_SPI3_MOSI = 3U, + PD2_I2C1_SCL = 4U, + PD2_UART1_TX = 5U, + PD2_PBUS_AD2 = 6U, + PD2_EPWM10_B = 7U, + PD2_DBG_IO4 = 8U, + PD3_LCD_D3 = 2U, + PD3_SPI3_MISO = 3U, + PD3_I2C1_SDA = 4U, + PD3_UART1_RX = 5U, + PD3_PBUS_AD3 = 6U, + PD3_EPWM10_A = 7U, + PD3_DBG_IO5 = 8U, + PD4_LCD_D4 = 2U, + PD4_SPI1_CS = 3U, + PD4_I2C2_SCL = 4U, + PD4_UART2_TX = 5U, + PD4_PBUS_AD4 = 6U, + PD4_QOUT_A0 = 7U, + PD4_DBG_IO6 = 8U, + PD5_LCD_D5 = 2U, + PD5_SPI1_MISO = 3U, + PD5_I2C2_SDA = 4U, + PD5_UART2_RX = 5U, + PD5_PBUS_AD5 = 6U, + PD5_QOUT_B0 = 7U, + PD5_DBG_IO7 = 8U, + PD6_LCD_D6 = 2U, + PD6_SPI1_MOSI = 3U, + PD6_PWM0_A = 4U, + PD6_DSPK0 = 5U, + PD6_PBUS_AD6 = 6U, + PD6_QOUT_A1 = 7U, + PD6_DBG_IO8 = 8U, + PD7_LCD_D7 = 2U, + PD7_SPI1_CLK = 3U, + PD7_PWM0_B = 4U, + PD7_DSPK1 = 5U, + PD7_PBUS_AD7 = 6U, + PD7_QOUT_B1 = 7U, + PD7_DBG_IO9 = 8U, + PD8_LCD_D8 = 2U, + PD8_SPI1_HOLD = 3U, + PD8_PWM1_A = 4U, + PD8_ENC0_IO0 = 5U, + PD8_PBUS_CLK = 6U, + PD8_EPWM9_B = 7U, + PD8_QOUT_Z0 = 8U, + PD9_LCD_D9 = 2U, + PD9_SPI1_WP = 3U, + PD9_ENC0_IO1 = 5U, + PD9_PBUS_NCS = 6U, + PD9_EPWM9_A = 7U, + PD9_QOUT_Z1 = 8U, + PD10_LCD_D10 = 2U, + PD10_CAP5 = 3U, + PD10_QEP2_A = 5U, + PD10_PBUS_NADV = 6U, + PD10_EPWM8_B = 7U, + PD11_LCD_D11 = 2U, + PD11_CAP4 = 3U, + PD11_I2S0_DIN = 4U, + PD11_QEP2_B = 5U, + PD11_PBUS_NWE = 6U, + PD11_EPWM8_A = 7U, + PD12_LCD_D12 = 2U, + PD12_CAP3 = 3U, + PD12_I2S0_DOUT = 4U, + PD12_QEP2_I = 5U, + PD12_PBUS_NOE = 6U, + PD12_EPWM7_B = 7U, + PD13_LCD_D13 = 2U, + PD13_CAP2 = 3U, + PD13_I2S0_LRCK = 4U, + PD13_QEP3_A = 5U, + PD13_CLK_OUT0 = 6U, + PD13_EPWM7_A = 7U, + PD14_LCD_D14 = 2U, + PD14_CAP1 = 3U, + PD14_I2S0_BCLK = 4U, + PD14_QEP3_B = 5U, + PD14_PBUS_AD8 = 6U, + PD14_EPWM6_B = 7U, + PD15_LCD_D15 = 2U, + PD15_CAP0 = 3U, + PD15_I2S0_MCLK = 4U, + PD15_QEP3_I = 5U, + PD15_PBUS_AD9 = 6U, + PD15_EPWM6_A = 7U, + PD16_LCD_D16 = 2U, + PD16_PWM1_B = 3U, + PD16_DMIC_CLK = 4U, + PD16_UART2_TX = 5U, + PD16_PBUS_AD10 = 6U, + PD16_EPWM5_B = 7U, + PD16_DBG_IO10 = 8U, + PD17_LCD_D17 = 2U, + PD17_PWM2_A = 3U, + PD17_DMIC_D0 = 4U, + PD17_UART2_RX = 5U, + PD17_PBUS_AD11 = 6U, + PD17_EPWM5_A = 7U, + PD17_DBG_IO11 = 8U, + PD18_LCD_D18 = 2U, + PD18_LVDS0_D0N = 3U, + PD18_DSI_D0N = 4U, + PD18_ENC1_IO0 = 5U, + PD18_PBUS_AD12 = 6U, + PD18_EPWM4_B = 7U, + PD18_DBG_IO12 = 8U, + PD19_LCD_D19 = 2U, + PD19_LVDS0_D0P = 3U, + PD19_DSI_D0P = 4U, + PD19_ENC1_IO1 = 5U, + PD19_PBUS_AD13 = 6U, + PD19_EPWM4_A = 7U, + PD19_DBG_IO13 = 8U, + PD20_LCD_D20 = 2U, + PD20_LVDS0_D1N = 3U, + PD20_DSI_D1N = 4U, + PD20_QEP4_A = 5U, + PD20_PBUS_AD14 = 6U, + PD20_EPWM3_B = 7U, + PD20_DBG_IO14 = 8U, + PD21_LCD_D21 = 2U, + PD21_LVDS0_D1P = 3U, + PD21_DSI_D1P = 4U, + PD21_QEP4_B = 5U, + PD21_PBUS_AD15 = 6U, + PD21_EPWM3_A = 7U, + PD21_DBG_IO15 = 8U, + PD22_LCD_D22 = 2U, + PD22_LVDS0_D2N = 3U, + PD22_DSI_CKN = 4U, + PD22_QEP5_A = 5U, + PD22_EPWM2_B = 7U, + PD22_DBG_IO16 = 8U, + PD23_LCD_D23 = 2U, + PD23_LVDS0_D2P = 3U, + PD23_DSI_CKP = 4U, + PD23_QEP5_B = 5U, + PD23_EPWM2_A = 7U, + PD23_DBG_IO17 = 8U, + PD24_LCD_DCLK = 2U, + PD24_LVDS0_CKN = 3U, + PD24_DSI_D2N = 4U, + PD24_QEP6_A = 5U, + PD24_EPWM1_B = 7U, + PD24_DBG_IO18 = 8U, + PD25_LCD_HS = 2U, + PD25_LVDS0_CKP = 3U, + PD25_DSI_D2P = 4U, + PD25_QEP7_A = 5U, + PD25_PWM2_B = 6U, + PD25_EPWM1_A = 7U, + PD25_DBG_IO19 = 8U, + PD26_LCD_VS = 2U, + PD26_LVDS0_D3N = 3U, + PD26_DSI_D3N = 4U, + PD26_QEP8_A = 5U, + PD26_PWM3_A = 6U, + PD26_EPWM0_B = 7U, + PD26_DBG_CLK = 8U, + PD27_LCD_DE = 2U, + PD27_LVDS0_D3P = 3U, + PD27_DSI_D3P = 4U, + PD27_QEP9_A = 5U, + PD27_PWM3_B = 6U, + PD27_EPWM0_A = 7U, + PD27_CMU_CKT = 8U, + PE0_GMAC0_RXD1 = 2U, + PE0_DVP_D0 = 3U, + PE0_PWM0_A = 4U, + PE0_UART3_TX = 5U, + PE0_ENC0_IO0 = 7U, + PE0_DBG_IO20 = 8U, + PE1_GMAC0_RXD0 = 2U, + PE1_DVP_D1 = 3U, + PE1_PWM0_B = 4U, + PE1_UART3_RX = 5U, + PE1_ENC0_IO1 = 7U, + PE1_DBG_IO21 = 8U, + PE2_GMAC0_RXCTL = 2U, + PE2_DVP_D2 = 3U, + PE2_UART4_TX = 5U, + PE2_QEP2_A = 6U, + PE2_ENC0_IO2 = 7U, + PE2_DBG_IO22 = 8U, + PE3_GMAC0_CLKIN = 2U, + PE3_DVP_D3 = 3U, + PE3_I2S0_MCLK = 4U, + PE3_UART4_RX = 5U, + PE3_QEP2_B = 6U, + PE3_QEP0_H0 = 7U, + PE3_DBG_IO23 = 8U, + PE4_GMAC0_TXD1 = 2U, + PE4_DVP_D4 = 3U, + PE4_UART5_TX = 5U, + PE4_QEP3_A = 6U, + PE4_QEP0_H1 = 7U, + PE4_DBG_IO24 = 8U, + PE5_GMAC0_TXD0 = 2U, + PE5_DVP_D5 = 3U, + PE5_UART5_RX = 5U, + PE5_QEP3_B = 6U, + PE5_QEP0_H2 = 7U, + PE5_DBG_IO25 = 8U, + PE6_GMAC0_TXCK = 2U, + PE6_DVP_D6 = 3U, + PE6_UART6_TX = 5U, + PE6_ENC1_IO0 = 7U, + PE6_DBG_IO26 = 8U, + PE7_GMAC0_TXCTL = 2U, + PE7_DVP_D7 = 3U, + PE7_UART6_RX = 5U, + PE7_ENC1_IO1 = 7U, + PE7_DBG_IO27 = 8U, + PE8_GMAC0_MDC = 2U, + PE8_DVP_CK = 3U, + PE8_UART7_TX = 5U, + PE8_QEP4_A = 6U, + PE8_ENC1_IO2 = 7U, + PE8_DBG_IO28 = 8U, + PE9_GMAC0_MDIO = 2U, + PE9_DVP_HS = 3U, + PE9_UART7_RX = 5U, + PE9_QEP4_B = 6U, + PE9_QEP1_H0 = 7U, + PE9_DBG_IO29 = 8U, + PE10_CLK_OUT2 = 2U, + PE10_DVP_VS = 3U, + PE10_I2S0_DIN = 4U, + PE10_DMIC_CLK = 5U, + PE10_QEP5_A = 6U, + PE10_QEP1_H1 = 7U, + PE10_DBG_IO30 = 8U, + PE11_CLK_OUT1 = 2U, + PE11_PWM1_A = 3U, + PE11_I2S0_LRCK = 4U, + PE11_DMIC_D0 = 5U, + PE11_QEP5_B = 6U, + PE11_QEP1_H2 = 7U, + PE11_DBG_IO31 = 8U, + PE12_SPI2_CLK = 2U, + PE12_PWM1_B = 3U, + PE12_I2S0_BCLK = 4U, + PE12_DSPK1 = 5U, + PE12_QEP6_A = 6U, + PE12_QEP0_S = 7U, + PE12_CPM0_COH = 8U, + PE13_SPI2_CS = 2U, + PE13_PWM2_A = 3U, + PE13_I2S0_DOUT = 4U, + PE13_DSPK0 = 5U, + PE13_QEP7_A = 6U, + PE13_QEP1_S = 7U, + PE13_CPM0_COL = 8U, + PE14_SPI2_MOSI = 2U, + PE14_I2S0_MCLK = 3U, + PE14_I2C0_SCL = 4U, + PE14_UART6_TX = 5U, + PE14_QEP8_A = 6U, + PE14_CPM1_COH = 8U, + PE15_SPI2_MISO = 2U, + PE15_PWM2_B = 3U, + PE15_I2C0_SDA = 4U, + PE15_UART6_RX = 5U, + PE15_QEP9_A = 6U, + PE15_CPM1_COL = 8U, + PE16_SPI2_HOLD = 2U, + PE16_PWM3_A = 3U, + PE16_UART7_TX = 5U, + PE16_GMAC0_TRIG = 8U, + PE17_SPI2_WP = 2U, + PE17_PWM3_B = 3U, + PE17_UART7_RX = 5U, + PE17_GMAC0_PPSO = 8U, + PU0_USB0_DM = 2U, + PU0_UART0_RX = 4U, + PU0_UART1_RX = 5U, + PU1_USB0_DP = 2U, + PU1_UART0_TX = 4U, + PU1_UART1_TX = 5U, - PIN_FUNC_DISABLED = 0U, - PIN_FUNC_GPIO = 1U, + PIN_FUNC_DISABLED = 0U, + PIN_FUNC_GPIO = 1U, } pin_func_t; #ifdef __cplusplus diff --git a/bsp/artinchip/sys/d13x/include/boot_param.h b/bsp/artinchip/sys/d13x/include/boot_param.h index 819f3151..e9852d34 100644 --- a/bsp/artinchip/sys/d13x/include/boot_param.h +++ b/bsp/artinchip/sys/d13x/include/boot_param.h @@ -85,6 +85,7 @@ enum boot_controller aic_get_boot_controller(void); int aic_get_boot_image_id(void); unsigned long aic_timer_get_us(void); void *aic_get_boot_resource(void); +void aic_set_boot_resource(void *res_addr); void *aic_get_boot_resource_from_nand(void *dev, unsigned long pagesize, nand_read fn); void *aic_get_boot_args(void); diff --git a/bsp/artinchip/sys/d13x/startup_gcc.S b/bsp/artinchip/sys/d13x/startup_gcc.S index 496c9577..84351712 100644 --- a/bsp/artinchip/sys/d13x/startup_gcc.S +++ b/bsp/artinchip/sys/d13x/startup_gcc.S @@ -223,6 +223,10 @@ e907_tcm_init: bltu a0, a1, 1b 2: + /* Reloc private params */ + la a5, reloc_private_params + jalr a5 + #ifndef __NO_SYSTEM_INIT la a5, SystemInit jalr a5 diff --git a/bsp/artinchip/sys/d21x/Kconfig.chip b/bsp/artinchip/sys/d21x/Kconfig.chip index 3ab05b27..9b0209f8 100644 --- a/bsp/artinchip/sys/d21x/Kconfig.chip +++ b/bsp/artinchip/sys/d21x/Kconfig.chip @@ -32,6 +32,16 @@ config CPU_BASE default 0x4000000000 if QEMU_RUN depends on AIC_CHIP_D21X +config CPU_DRAM_BASE + hex + default 0x40000000 + depends on AIC_CHIP_D21X + +config CPU_SRAM_BASE + hex + default 0x00100000 + depends on AIC_CHIP_D21X + #-------------------------------------------- # cmu driver global option #-------------------------------------------- diff --git a/bsp/artinchip/sys/d21x/aic_gpio_id.c b/bsp/artinchip/sys/d21x/aic_gpio_id.c new file mode 100644 index 00000000..59575ff8 --- /dev/null +++ b/bsp/artinchip/sys/d21x/aic_gpio_id.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +const int aic_gpio_groups_list[] = { + PA_GROUP, + PB_GROUP, + PC_GROUP, + PD_GROUP, + PE_GROUP, + PF_GROUP, + PG_GROUP, + PU_GROUP, +}; + +const int aic_gpio_group_size = sizeof(aic_gpio_groups_list) / sizeof(aic_gpio_groups_list[0]); diff --git a/bsp/artinchip/sys/d21x/boot_param.c b/bsp/artinchip/sys/d21x/boot_param.c index f051e001..62fb6d28 100644 --- a/bsp/artinchip/sys/d21x/boot_param.c +++ b/bsp/artinchip/sys/d21x/boot_param.c @@ -67,6 +67,11 @@ void *aic_get_boot_resource(void) return (void *)(boot_params_stash.r.a[1]); } +void aic_set_boot_resource(void *res_addr) +{ + boot_params_stash.r.a[1] = (u32)(uintptr_t)res_addr; +} + int aic_get_boot_image_id(void) { return get_boot_image_id(boot_params_stash.r.a[0]); diff --git a/bsp/artinchip/sys/d21x/include/aic_gpio_id.h b/bsp/artinchip/sys/d21x/include/aic_gpio_id.h index 6ee8c6a5..6574912c 100644 --- a/bsp/artinchip/sys/d21x/include/aic_gpio_id.h +++ b/bsp/artinchip/sys/d21x/include/aic_gpio_id.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,10 +19,13 @@ enum { PE_GROUP, PF_GROUP, PG_GROUP, - PO_GROUP = 14, + PU_GROUP = 14, GPIO_GROUP_MAX, }; +extern const int aic_gpio_groups_list[]; +extern const int aic_gpio_group_size; + #define PA_BASE 0 #define PB_BASE 32 #define PC_BASE 64 @@ -37,7 +40,7 @@ enum { #define PL_BASE 352 #define PM_BASE 384 #define PN_BASE 416 -#define PO_BASE 448 +#define PU_BASE 448 #define GPIOA(n) (PA_BASE + (n)) #define GPIOB(n) (PB_BASE + (n)) #define GPIOC(n) (PC_BASE + (n)) @@ -52,7 +55,7 @@ enum { #define GPIOL(n) (PL_BASE + (n)) #define GPIOM(n) (PM_BASE + (n)) #define GPION(n) (PN_BASE + (n)) -#define GPIOO(n) (PO_BASE + (n)) +#define GPIOU(n) (PU_BASE + (n)) typedef enum { PA0 = GPIOA(0), diff --git a/bsp/artinchip/sys/d21x/include/boot_param.h b/bsp/artinchip/sys/d21x/include/boot_param.h index 819f3151..e9852d34 100644 --- a/bsp/artinchip/sys/d21x/include/boot_param.h +++ b/bsp/artinchip/sys/d21x/include/boot_param.h @@ -85,6 +85,7 @@ enum boot_controller aic_get_boot_controller(void); int aic_get_boot_image_id(void); unsigned long aic_timer_get_us(void); void *aic_get_boot_resource(void); +void aic_set_boot_resource(void *res_addr); void *aic_get_boot_resource_from_nand(void *dev, unsigned long pagesize, nand_read fn); void *aic_get_boot_args(void); diff --git a/bsp/artinchip/sys/d21x/startup_gcc.S b/bsp/artinchip/sys/d21x/startup_gcc.S index 96432da5..9b6342e7 100644 --- a/bsp/artinchip/sys/d21x/startup_gcc.S +++ b/bsp/artinchip/sys/d21x/startup_gcc.S @@ -95,6 +95,10 @@ save_boot_params_ret: bltu a0, a1, 1b 2: + /* Reloc private params */ + la a5, reloc_private_params + jalr a5 + #ifndef __NO_SYSTEM_INIT la a5, SystemInit jalr a5 diff --git a/bsp/artinchip/sys/g73x/Kconfig.chip b/bsp/artinchip/sys/g73x/Kconfig.chip index 01c7d396..80176574 100644 --- a/bsp/artinchip/sys/g73x/Kconfig.chip +++ b/bsp/artinchip/sys/g73x/Kconfig.chip @@ -36,6 +36,16 @@ config CPU_BASE default 0xE0000000 if QEMU_RUN depends on AIC_CHIP_G73X +config CPU_PSRAM_BASE + hex + default 0x40000000 + depends on AIC_CHIP_G73X + +config CPU_SRAM_BASE + hex + default 0x30040000 + depends on AIC_CHIP_G73X + #-------------------------------------------- # interrupt global option #-------------------------------------------- diff --git a/bsp/artinchip/sys/g73x/aic_gpio_id.c b/bsp/artinchip/sys/g73x/aic_gpio_id.c new file mode 100644 index 00000000..59575ff8 --- /dev/null +++ b/bsp/artinchip/sys/g73x/aic_gpio_id.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +const int aic_gpio_groups_list[] = { + PA_GROUP, + PB_GROUP, + PC_GROUP, + PD_GROUP, + PE_GROUP, + PF_GROUP, + PG_GROUP, + PU_GROUP, +}; + +const int aic_gpio_group_size = sizeof(aic_gpio_groups_list) / sizeof(aic_gpio_groups_list[0]); diff --git a/bsp/artinchip/sys/g73x/boot_param.c b/bsp/artinchip/sys/g73x/boot_param.c index bc5f56a8..71f768db 100644 --- a/bsp/artinchip/sys/g73x/boot_param.c +++ b/bsp/artinchip/sys/g73x/boot_param.c @@ -67,6 +67,11 @@ void *aic_get_boot_resource(void) return (void *)(boot_params_stash.r.a[1]); } +void aic_set_boot_resource(void *res_addr) +{ + boot_params_stash.r.a[1] = (u32)(uintptr_t)res_addr; +} + int aic_get_boot_image_id(void) { return get_boot_image_id(boot_params_stash.r.a[0]); diff --git a/bsp/artinchip/sys/g73x/g73x.pbp b/bsp/artinchip/sys/g73x/g73x.pbp index 04b01ec2..20e3e875 100644 Binary files a/bsp/artinchip/sys/g73x/g73x.pbp and b/bsp/artinchip/sys/g73x/g73x.pbp differ diff --git a/bsp/artinchip/sys/g73x/include/aic_gpio_id.h b/bsp/artinchip/sys/g73x/include/aic_gpio_id.h index 6ee8c6a5..6574912c 100644 --- a/bsp/artinchip/sys/g73x/include/aic_gpio_id.h +++ b/bsp/artinchip/sys/g73x/include/aic_gpio_id.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,10 +19,13 @@ enum { PE_GROUP, PF_GROUP, PG_GROUP, - PO_GROUP = 14, + PU_GROUP = 14, GPIO_GROUP_MAX, }; +extern const int aic_gpio_groups_list[]; +extern const int aic_gpio_group_size; + #define PA_BASE 0 #define PB_BASE 32 #define PC_BASE 64 @@ -37,7 +40,7 @@ enum { #define PL_BASE 352 #define PM_BASE 384 #define PN_BASE 416 -#define PO_BASE 448 +#define PU_BASE 448 #define GPIOA(n) (PA_BASE + (n)) #define GPIOB(n) (PB_BASE + (n)) #define GPIOC(n) (PC_BASE + (n)) @@ -52,7 +55,7 @@ enum { #define GPIOL(n) (PL_BASE + (n)) #define GPIOM(n) (PM_BASE + (n)) #define GPION(n) (PN_BASE + (n)) -#define GPIOO(n) (PO_BASE + (n)) +#define GPIOU(n) (PU_BASE + (n)) typedef enum { PA0 = GPIOA(0), diff --git a/bsp/artinchip/sys/g73x/include/boot_param.h b/bsp/artinchip/sys/g73x/include/boot_param.h index 819f3151..e9852d34 100644 --- a/bsp/artinchip/sys/g73x/include/boot_param.h +++ b/bsp/artinchip/sys/g73x/include/boot_param.h @@ -85,6 +85,7 @@ enum boot_controller aic_get_boot_controller(void); int aic_get_boot_image_id(void); unsigned long aic_timer_get_us(void); void *aic_get_boot_resource(void); +void aic_set_boot_resource(void *res_addr); void *aic_get_boot_resource_from_nand(void *dev, unsigned long pagesize, nand_read fn); void *aic_get_boot_args(void); diff --git a/bsp/artinchip/sys/g73x/rtconfig.py b/bsp/artinchip/sys/g73x/rtconfig.py index 3ac4126f..6e7f5506 100644 --- a/bsp/artinchip/sys/g73x/rtconfig.py +++ b/bsp/artinchip/sys/g73x/rtconfig.py @@ -1,3 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2022-2024, ArtInChip Technology Co., Ltd + import os import platform @@ -31,11 +35,25 @@ if os.getenv('RTT_EXEC_PATH'): # BUILD = 'debug' BUILD = 'release' if BUILD == 'debug': - CFLAGS_DBG = ' -O0 -gdwarf-2' - AFLAGS_DBG = ' -gdwarf-2' + CFLAGS_DBG = ' -O0 -gdwarf-2 ' + AFLAGS_DBG = ' -gdwarf-2 ' + B_AFLAGS = '' + B_CFLAGS = '' + LFLAGS = '' + B_AFLAGS += ' -D_ENABLE_BACK_TRACE_STACK_ ' + CFLAGS_DBG += ' -fno-omit-frame-pointer ' + B_AFLAGS += ' -D_NO_OMIT_FRAME_POINT_ ' + #B_CFLAGS += ' -fstack-protector-all ' + #LFLAGS += ' -Wl,--wrap=__stack_chk_fail ' else: CFLAGS_DBG = ' -O2 -g2' AFLAGS_DBG = '' + B_AFLAGS = '' + B_CFLAGS = '' + LFLAGS = '' + B_AFLAGS += ' -D_ENABLE_BACK_TRACE_STACK_ ' + #CFLAGS_DBG += ' -fno-omit-frame-pointer ' + #B_AFLAGS += ' -D_NO_OMIT_FRAME_POINT_ ' prj_out_dir = '' if os.environ.get('PRJ_OUT_DIR'): @@ -73,8 +91,8 @@ if PLATFORM == 'gcc': if CPUNAME == 'e906' or CPUNAME == 'e907': DEVICE = ' -march=rv32imac_xtheade -mabi=ilp32' - B_CFLAGS = ' -c -g -ffunction-sections -fdata-sections -Wall -mcmodel=medlow' - B_AFLAGS = ' -c' + ' -x assembler-with-cpp' + ' -D__ASSEMBLY__' + B_CFLAGS += ' -c -g -ffunction-sections -fdata-sections -Wall -mcmodel=medany ' + B_AFLAGS += ' -c' + ' -x assembler-with-cpp' + ' -D__ASSEMBLY__' CFLAGS = DEVICE + B_CFLAGS + CFLAGS_DBG AFLAGS = DEVICE + B_AFLAGS + AFLAGS_DBG CXXFLAGS = CFLAGS diff --git a/bsp/artinchip/sys/g73x/startup_gcc.S b/bsp/artinchip/sys/g73x/startup_gcc.S index 496c9577..84351712 100644 --- a/bsp/artinchip/sys/g73x/startup_gcc.S +++ b/bsp/artinchip/sys/g73x/startup_gcc.S @@ -223,6 +223,10 @@ e907_tcm_init: bltu a0, a1, 1b 2: + /* Reloc private params */ + la a5, reloc_private_params + jalr a5 + #ifndef __NO_SYSTEM_INIT la a5, SystemInit jalr a5 diff --git a/bsp/artinchip/sys/g73x/trap_c.c b/bsp/artinchip/sys/g73x/trap_c.c index 776f70c6..30d140d6 100644 --- a/bsp/artinchip/sys/g73x/trap_c.c +++ b/bsp/artinchip/sys/g73x/trap_c.c @@ -8,6 +8,11 @@ #include #include #include + +#ifdef KERNEL_RTTHREAD +#include +#endif + #include void (*trap_c_callback)(void); @@ -37,12 +42,106 @@ void trap_c(uint32_t *regs) printf("mtval : %08lx\n", __get_MTVAL()); printf("mepc : %08lx\n", regs[31]); printf("mstatus: %08lx\n", regs[32]); + printf("\n"); - if (trap_c_callback) - { + if (trap_c_callback) { trap_c_callback(); } - while (1); + //while (1); } + +#ifdef KERNEL_RTTHREAD + +#define CMB_CALL_STACK_MAX_DEPTH 32 +extern size_t __stext; +extern size_t __etext; +extern rt_ubase_t g_base_irqstack; +extern rt_ubase_t g_top_irqstack; + +void print_stack(uint32_t *stack_point,uint32_t*stack_point1,uint32_t epc) +{ + int i = 0; + uint32_t sp = (uint32_t)stack_point; + uint32_t pc; + uint32_t base_irqstack = (uint32_t)&g_base_irqstack; + uint32_t top_irqstack = (uint32_t)&g_top_irqstack; + uint32_t stack_addr = (uint32_t) rt_thread_self()->stack_addr; + uint32_t stack_size = rt_thread_self()->stack_size; + + printf("__stext:%p __etext:%p,stack:\n", &__stext, &__etext); + if (sp >= base_irqstack && sp <= top_irqstack) { + //printf("[%s:%d]base_irqstack::0x%08lx top_irqstack::0x%08lx\n",__FUNCTION__,__LINE__, base_irqstack, top_irqstack); + printf("base_irqstack::0x%08lx top_irqstack::0x%08lx\n", base_irqstack, top_irqstack); + for (; sp < top_irqstack; sp += sizeof(uint32_t)) { + pc = *((uint32_t *)sp); + printf("0x%08lx ", pc); + if ((i % 4) == 3) { + printf("\n"); + } + i++; + } + sp = (uint32_t)stack_point1; + printf("\n"); + } + + //printf("[%s:%d]stack_addr:0x%08lx stack_addr_end:0x%08lx\n",__FUNCTION__,__LINE__, stack_addr, stack_addr + stack_size); + printf("stack_addr:0x%08lx stack_addr_end:0x%08lx\n",stack_addr, stack_addr + stack_size); + for (i = 0; sp < stack_addr + stack_size; sp += sizeof(uint32_t)) { + pc = *((uint32_t *)sp); + printf("0x%08lx ", pc); + if ((i % 4) == 3) { + printf("\n"); + } + i++; + } + printf("\n\n"); +} + +void print_back_trace(int32_t n,rt_ubase_t *regs) +{ + int i = 0; + printf("back_trace:\n"); + for(i = 0; i < n; i++) { + printf("0x%08lx\n", regs[i]); + } +} + +void backtrace_call_stack(rt_ubase_t *stack_point,rt_ubase_t*stack_point1,rt_ubase_t epc) +{ + int depth = 0; + rt_ubase_t sp = (rt_ubase_t)stack_point; + rt_ubase_t pc; + size_t code_start_addr = (size_t)&__stext; + size_t code_end_addr = (size_t)&__etext; + rt_ubase_t base_irqstack = (rt_ubase_t)&g_base_irqstack; + rt_ubase_t top_irqstack = (rt_ubase_t)&g_top_irqstack; + rt_ubase_t stack_addr = (rt_ubase_t) rt_thread_self()->stack_addr; + rt_ubase_t stack_size = rt_thread_self()->stack_size; + + printf("[%s:%d]__stext:%p __etext:%p\r\n",__FUNCTION__,__LINE__, &__stext, &__etext); + + printf("%08lx\n", epc); + + if (sp >= base_irqstack && sp <= top_irqstack) { + for (; sp < top_irqstack; sp += sizeof(rt_ubase_t)) { + pc = *((rt_ubase_t *)sp); + if((pc >= code_start_addr) && (pc <= code_end_addr) && (depth < CMB_CALL_STACK_MAX_DEPTH)) { + printf("%08lx\n", pc); + depth++; + } + } + sp = (rt_ubase_t)stack_point1; + } + + depth = 0; + for (; sp < stack_addr + stack_size; sp += sizeof(rt_ubase_t)) { + pc = *((rt_ubase_t *)sp); + if((pc >= code_start_addr) && (pc <= code_end_addr) && (depth < CMB_CALL_STACK_MAX_DEPTH)) { + printf("%08lx\n", pc); + depth++; + } + } +} +#endif diff --git a/bsp/artinchip/sys/g73x/vectors.S b/bsp/artinchip/sys/g73x/vectors.S index 4c610b7f..eaa90339 100644 --- a/bsp/artinchip/sys/g73x/vectors.S +++ b/bsp/artinchip/sys/g73x/vectors.S @@ -51,6 +51,14 @@ Default_IRQHandler: .long 0x0040000b #endif +#if defined(_ENABLE_BACK_TRACE_STACK_) && defined(_NO_OMIT_FRAME_POINT_) + addi sp,sp,-8 + STORE s0,(sp) + csrr a0, mepc + STORE a0, 4(sp) + addi s0, sp, 8 +#endif + #ifdef ARCH_RISCV_FPU addi sp, sp, -(20 * FREGBYTES) @@ -138,6 +146,12 @@ Default_IRQHandler: addi sp, sp, (20 * FREGBYTES) #endif + +#if defined(_ENABLE_BACK_TRACE_STACK_) && defined(_NO_OMIT_FRAME_POINT_) +lw s0, (sp) +addi sp, sp, 8 +#endif + #ifdef __riscv_xthead ipop #else @@ -159,8 +173,8 @@ trap: csrr t0, mcause blt t0, x0, .Lirq addi sp, sp, 4 - la t0, g_trap_sp - + //la t0, g_trap_sp + mv t0, sp addi t0, t0, -132 sw x1, 0(t0) @@ -207,6 +221,96 @@ trap: la a5, trap_c jalr a5 +#ifdef KERNEL_RTTHREAD + mv a0, sp + addi a0, a0, 132 + csrr a1, mscratch + csrr a2, mepc + la a5, print_stack + jalr a5 +#endif + + +#if defined(_ENABLE_BACK_TRACE_STACK_) && defined(KERNEL_RTTHREAD) +#define CALL_STACK_MAX_DEPTH 32 + la a0, rt_current_thread + beqz a0, . +#ifdef _NO_OMIT_FRAME_POINT_ + mv t0, sp + la t1, CALL_STACK_MAX_DEPTH + slli t1, t1, 2 + sub t0, t0, t1 + csrr a1, mepc + STORE a1, (t0) + mv a1, s0 + li t1, 1 +1: + // check sram addr + li t2, 0x30000000 + la t3, AIC_SRAM_TOTAL_SIZE + add t3, t2, t3 + + blt a1, t2, 2f + bge a1, t3, 2f + + addi a2, a1, -(4) + blt a2, t2, 2f + bge a2, t3, 2f + + addi a2, a1, -(8) + blt a2, t2, 2f + bge a2, t3, 2f + + j 3f +2: + // check psram addr + li t2, 0x40000000 + la t3, AIC_PSRAM_SIZE + add t3, t2, t3 + + blt a1, t2, 4f + bge a1, t3, 4f + + addi a2, a1, -(4) + blt a2, t2, 4f + bge a2, t3, 4f + + addi a2, a1, -(8) + blt a2, t2, 4f + bge a2, t3, 4f +3: + // get ra + LOAD a2, -4(a1) + slli t2, t1, 2 + add t2, t2, t0 + STORE a2, (t2) + // get next fp + LOAD a1, -8(a1) + //inc call depth + addi t1, t1, 1 + // check end + li a2, 0xdeadbeef + beq a1, a2, 4f + la a2, CALL_STACK_MAX_DEPTH + blt t1, a2, 1b +4: + mv a0, t1 + mv a1, t0 + mv sp, t0 + la a5, print_back_trace + jalr a5 +#else + mv a0, sp + addi a0, a0, 132 + csrr a1, mscratch + csrr a2, mepc + la a5, backtrace_call_stack + jalr a5 +#endif +#endif + + + j . .Lirq: lw t0, 0x0(sp) diff --git a/bsp/common/include/aic_common.h b/bsp/common/include/aic_common.h index 3e82cdcc..8c5ac7c7 100644 --- a/bsp/common/include/aic_common.h +++ b/bsp/common/include/aic_common.h @@ -19,7 +19,7 @@ extern "C" { /* Luban-Lite version information */ #define LL_VERSION 1 /**< major version number */ #define LL_SUBVERSION 1 /**< minor version number */ -#define LL_REVISION 0 /**< revise version number */ +#define LL_REVISION 1 /**< revise version number */ typedef __signed__ char s8; typedef unsigned char u8; @@ -384,6 +384,9 @@ typedef enum { #endif #ifdef AIC_DRAM_CMA_EN MEM_DRAM_CMA, +#endif +#ifdef AIC_BOOTLOADER + MEM_RESERVED, #endif MAX_MEM_REGION, } aic_mem_region_t; diff --git a/bsp/common/private_param/private_param.c b/bsp/common/private_param/private_param.c index 1fb9c51c..47762c89 100644 --- a/bsp/common/private_param/private_param.c +++ b/bsp/common/private_param/private_param.c @@ -1,12 +1,37 @@ /* - * Copyright (c) 2020-2021 Artinchip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Wu Dehuang */ + #include #include #include #include +#include #include +char private_params_stash[1024]; + +void reloc_private_params(void) +{ + void *res_addr; + int i; + + res_addr = aic_get_boot_resource(); + if (res_addr) { + for (i = 0; i < sizeof(private_params_stash); i += 4) { + memcpy(&private_params_stash[i], res_addr, 4); + if (*(u32 *)res_addr == DATA_SECT_TYPE_END) + break; + res_addr += 4; + } + aic_set_boot_resource(private_params_stash); + } +} + static u32 *find_section(void *start, u32 type) { u32 *p = start, data_type, data_len; diff --git a/bsp/common/utils/pinmux_utils.c b/bsp/common/utils/pinmux_utils.c index ff28167f..dcd3d021 100644 --- a/bsp/common/utils/pinmux_utils.c +++ b/bsp/common/utils/pinmux_utils.c @@ -21,45 +21,31 @@ #include #endif +extern const int aic_gpio_groups_list[]; + int list_pinmux(int argc, char *argv[]) { - unsigned int group, pin, func, i; + unsigned int group, pin, func, i, j; pin_name_t pin_name, pin_name_max; - for (i = 0; i < GPIO_GROUP_MAX; i++) - { - switch (i) - { - case PA_GROUP: - case PB_GROUP: - case PC_GROUP: - case PD_GROUP: - case PE_GROUP: - #ifndef AIC_CHIP_D12X - case PF_GROUP: - case PG_GROUP: - case PO_GROUP: - #endif - pin_name = PA_BASE + i * GPIO_GROUP_SIZE; - pin_name_max = pin_name + GPIO_GROUP_SIZE; + for (i = 0, j = 0; i < GPIO_GROUP_MAX && j < aic_gpio_group_size; i++) { + if (i == aic_gpio_groups_list[j]) { + pin_name = PA_BASE + i * GPIO_GROUP_SIZE; + pin_name_max = pin_name + GPIO_GROUP_SIZE; - while (pin_name < pin_name_max) - { - group = GPIO_GROUP(pin_name); - pin = GPIO_GROUP_PIN(pin_name); - func = 0; + while (pin_name < pin_name_max) { + group = GPIO_GROUP(pin_name); + pin = GPIO_GROUP_PIN(pin_name); + func = 0; - hal_gpio_get_func(group, pin, &func); - if (func) - { - printf("P%c%d: function: %d\n", group + 'A', pin, func); - } + hal_gpio_get_func(group, pin, &func); + if (func) + printf("P%c%u: function: %u\n", group + 'A', pin, func); - pin_name++; - } - break; - default: - break; + pin_name++; + } + + j++; } } diff --git a/bsp/examples/test-camera/SConscript b/bsp/examples/test-camera/SConscript new file mode 100644 index 00000000..4dc34f79 --- /dev/null +++ b/bsp/examples/test-camera/SConscript @@ -0,0 +1,13 @@ +Import('AIC_ROOT') +Import('PRJ_KERNEL') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [] +src = [] +if GetDepend('AIC_CAMERA_DRV_TEST') and GetDepend('RT_USING_FINSH'): + src = Glob('*.c') + +group = DefineGroup('test-camera', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/examples/test-camera/test_camera.c b/bsp/examples/test-camera/test_camera.c new file mode 100644 index 00000000..8adc24f0 --- /dev/null +++ b/bsp/examples/test-camera/test_camera.c @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: matteo + */ +#include +#include +#include + +#include "aic_common.h" +#include "aic_core.h" +#include "drv_camera.h" + +struct camera_cmd { + char *name; + int (*handle1)(rt_device_t dev, u32 arg); + int (*handle2)(rt_device_t dev, bool arg); +}; + +static struct camera_cmd g_camera_cmds[] = { + {"channel", camera_set_channel}, + {"fps", camera_set_fps}, + {"contrast", camera_set_contrast}, + {"brightness", camera_set_brightness}, + {"saturation", camera_set_saturation}, + {"hue", camera_set_hue}, + {"sharpness", camera_set_sharpness}, + {"denoise", camera_set_denoise}, + {"quality", camera_set_quality}, + {"autogain", camera_set_autogain}, + {"aec_val", camera_set_aec_val}, + {"exposure", camera_set_exposure}, + + {"gain_ctrl", NULL, camera_set_gain_ctrl}, + {"whitebal", NULL, camera_set_whitebal}, + {"awb", NULL, camera_set_awb}, + {"aec2", NULL, camera_set_aec2}, + {"dcw", NULL, camera_set_dcw}, + {"bpc", NULL, camera_set_bpc}, + {"wpc", NULL, camera_set_wpc}, + {"h_flip", NULL, camera_set_h_flip}, + {"v_flip", NULL, camera_set_v_flip}, + {"colorbar", NULL, camera_set_colorbar}, + {NULL, NULL}, +}; + +static const char sopts[] = "c:v:lh"; +static const struct option lopts[] = { + {"command", required_argument, NULL, 'c'}, + {"value", required_argument, NULL, 'v'}, + {"list", no_argument, NULL, 'l'}, + {"usage", no_argument, NULL, 'h'}, + {0, 0, 0, 0} +}; + +static void usage(char *program) +{ + printf("Usage: %s [options]: \n", program); + printf("\t -c, --command\t\tioctl command of Camera device\n"); + printf("\t -v, --value\t\tthe value of the command argument\n"); + printf("\t -l, --list\t\tList all the supported command\n"); + printf("\t -h, --usage \n"); + printf("\n"); + printf("Example: %s -f nv16 -c 1\n", program); +} + +struct camera_cmd *camera_scan_cmd(char *arg) +{ + struct camera_cmd *cmd = g_camera_cmds; + int i; + + for (i = 0; i < ARRAY_SIZE(g_camera_cmds); i++, cmd++) { + if (cmd->name && !strncasecmp(cmd->name, arg, strlen(cmd->name))) + return cmd; + } + printf("Invalid command: %s\n", arg); + return NULL; +} + +void camera_list_cmds(void) +{ + struct camera_cmd *cmd = g_camera_cmds; + int i; + + printf("Supported Camera ioctl commands:\n"); + for (i = 0; i < ARRAY_SIZE(g_camera_cmds); i++, cmd++) { + if (cmd->name) + printf("%2d. %s\n", i, cmd->name); + } + printf("\n"); +} + +static rt_err_t cmd_test_camera(int argc, char **argv) +{ + struct camera_cmd *cmd = NULL; + rt_device_t dev = NULL; + u32 val = 0; + int c, ret = 0; + + optind = 0; + while ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) { + switch (c) { + case 'c': + cmd = camera_scan_cmd(optarg); + break; + + case 'v': + val = atoi(optarg); + break; + + case 'l': + camera_list_cmds(); + return 0; + + case 'h': + usage(argv[0]); + return 0; + + default: + break; + } + } + if (!cmd) + return -RT_EINVAL; + + dev = rt_device_find(CAMERA_DEV_NAME); + if (!dev) { + pr_err("Failed to find camera device\n"); + return -RT_ERROR; + } + if (rt_device_open(dev, RT_DEVICE_FLAG_RDWR) < 0) { + pr_err("Failed to open camera device\n"); + return -RT_EBUSY; + } + + printf("Try to set %s %d\n", cmd->name, val); + if (cmd->handle1) + ret = cmd->handle1(dev, val); + else if (cmd->handle2) + ret = cmd->handle2(dev, (bool)val); + + if (ret) + pr_err("Failed to set %s %ld, return %d\n", cmd->name, val, ret); + + rt_device_close(dev); + return RT_EOK; +} +MSH_CMD_EXPORT_ALIAS(cmd_test_camera, test_camera, test Camera); diff --git a/bsp/examples/test-dce/SConscript b/bsp/examples/test-dce/SConscript new file mode 100644 index 00000000..5673edd6 --- /dev/null +++ b/bsp/examples/test-dce/SConscript @@ -0,0 +1,13 @@ +Import('AIC_ROOT') +Import('PRJ_KERNEL') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [] +src = [] +if GetDepend('AIC_DCE_DRV_TEST') and GetDepend('RT_USING_FINSH'): + src = Glob('*.c') + +group = DefineGroup('test-dce', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/examples/test-dce/test_dce.c b/bsp/examples/test-dce/test_dce.c new file mode 100644 index 00000000..8367d916 --- /dev/null +++ b/bsp/examples/test-dce/test_dce.c @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-09-29 junlong.chen first implementation. + * 2024-09-29 junlong.chen ArtInChip + */ +#include +#include +#include +#include +#include "aic_core.h" +#include "aic_log.h" +#include "hal_dce.h" +#include "aic_crc32.h" +#include +#include + +u8 default_data[] = "It is test data"; + +static int software_checksum(u8 *buf, u32 size) +{ + u32 i, val, sum, rest, cnt; + u8 *p; + u32 *p32, *pe32; + + p = buf; + i = 0; + sum = 0; + cnt = size >> 2; + + if ((unsigned long)buf & 0x3) { + for (i = 0; i < cnt; i++) { + p = &buf[i * 4]; + val = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; + sum += val; + } + } else { + p32 = (u32 *)buf; + pe32 = p32 + cnt; + while (p32 < pe32) { + sum += *p32; + p32++; + } + } + + /* Calculate not 32 bit aligned part */ + rest = size - (cnt << 2); + p = &buf[cnt * 4]; + val = 0; + for (i = 0; i < rest; i++) + val += (p[i] << (i * 8)); + sum += val; + + return sum; +} + +static int hardware_checksum(u8 *data, int len) +{ + int ret; + + hal_dce_checksum_start(data, len); + ret = hal_dce_checksum_wait(); + if (!ret) + return hal_dce_checksum_result(); + else + printf("\t%s error: time out\n", __func__); + return 0; +} + +static int hardware_crc32(u8 *data, int len) +{ + int ret; + + hal_dce_crc32_start(0, data, len); + ret = hal_dce_crc32_wait(); + if (!ret) + return hal_dce_crc32_result(); + else + printf("\t%s error: time out\n", __func__); + return 0; +} + +static int hardware_rtt_crc32(u8 *data, int len) +{ + struct rt_hwcrypto_ctx *ctx; + int result = 0; + struct hwcrypto_crc_cfg cfg = { + .last_val = 0, + .poly = 0x04C11DB7, + .width = 32, + .xorout = 0, + .flags = 0, + }; + + ctx = rt_hwcrypto_crc_create(rt_hwcrypto_dev_default(), HWCRYPTO_CRC_CRC32); + rt_hwcrypto_crc_cfg(ctx, &cfg); + result = rt_hwcrypto_crc_update(ctx, data, len); + rt_hwcrypto_crc_destroy(ctx); + return result; +} + +void int_to_bcd(int num, int *bcd) { + int index = 0; + while (num != 0) { + bcd[index] = num % 16; + num /= 16; + index++; + } +} + +static void usage(char *program) +{ + printf("Usage: %s [options]: \n", program); + printf("\tParameter 1 is the address of the data to be verified,"); + printf("\n\tparameter 2 is the length of the data to be verified \n"); + printf("\n"); + printf("Example: \n"); + printf("\t%s 0x80040000 0x100 (test data from ram)\n", program); + printf("\t%s (test default data)\n", program); +} + +static void cmd_test_dce(int argc, char **argv) +{ + int sw_check_sum, sw_crc32, hw_check_sum, hw_crc32, hw_rtt_crc32, data_len; + int version[3] = {0}; + u8 *data; + + if (!(argc == 1 || argc == 3)) { + printf("Usage error\n"); + usage(argv[0]); + return; + } + + if (argc == 3) { + data = (u8 *)strtoul(argv[1], NULL, 0); + data_len = strtoul(argv[2], NULL, 0); + } else { + data = default_data; + data_len = sizeof(default_data); + } + + if ((u32)data % 4 || data_len % 4) { + printf("data and data_len need 4 byte alignment\n"); + return; + } + + hal_dce_init(); + + int_to_bcd(hal_get_version(), version); + printf("\tDCE version: %d.%d.%d\n", version[2], version[1], version[0]); + if (argc == 3) + printf("\tdata_addr: 0x%08x, data_len: 0x%08x\n", (int)data, data_len); + else + printf("\tdata:%s, data_len: 0x%08x\n", data, data_len); + sw_check_sum = software_checksum(data, data_len); + sw_crc32 = (int)crc32(0, data, data_len); + printf("\tsoftware: check_sum 0x%08x, crc32 0x%08x\n", sw_check_sum, + sw_crc32); + + hw_check_sum = hardware_checksum(data, data_len); + hw_crc32 = hardware_crc32(data, data_len); + hw_rtt_crc32 = hardware_rtt_crc32(data, data_len); + printf("\thardware: check_sum 0x%08x, crc32 0x%08x, rtt_crc32 0x%08x\n", + hw_check_sum, hw_crc32, hw_rtt_crc32); + + if (sw_check_sum != hw_check_sum || sw_crc32 != hw_crc32 || + sw_crc32 != hw_rtt_crc32) + printf("\tDCE calculate failed\n"); + else + printf("\tDCE calculate OK\n"); + + hal_dce_deinit(); + return; +} + +MSH_CMD_EXPORT_ALIAS(cmd_test_dce, test_dce, test Dce); diff --git a/bsp/examples/test-dvp/test_dvp.c b/bsp/examples/test-dvp/test_dvp.c index cab55dae..e1762891 100644 --- a/bsp/examples/test-dvp/test_dvp.c +++ b/bsp/examples/test-dvp/test_dvp.c @@ -106,7 +106,7 @@ int get_fb_info(void) ret = mpp_fb_ioctl(g_fb, AICFB_GET_SCREENINFO, &g_fb_info); if (ret < 0) - pr_err("ioctl() failed! errno: -%d\n", -ret); + pr_err("Failed to get screen info! errno: -%d\n", -ret); #endif pr_info("Screen width: %d, height %d\n", g_fb_info.width, g_fb_info.height); @@ -125,7 +125,7 @@ int set_ui_layer_alpha(int val) alpha.value = val; ret = mpp_fb_ioctl(g_fb, AICFB_UPDATE_ALPHA_CONFIG, &alpha); if (ret < 0) - pr_err("ioctl() failed! errno: -%d\n", -ret); + pr_err("Failed to update alpha! errno: -%d\n", -ret); #endif return ret; } @@ -137,7 +137,7 @@ int sensor_get_fmt(void) ret = mpp_dvp_ioctl(DVP_IN_G_FMT, &f); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("Failed to get sensor format! err -%d\n", -ret); // return -1; } @@ -155,7 +155,7 @@ int dvp_subdev_set_fmt(void) ret = mpp_dvp_ioctl(DVP_IN_S_FMT, &g_vdata.src_fmt); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("Failed to set DVP in-format! err -%d\n", -ret); return -1; } @@ -174,7 +174,7 @@ int dvp_cfg(int width, int height, int format) ret = mpp_dvp_ioctl(DVP_OUT_S_FMT, &f); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("Failed to set DVP out-format! err -%d\n", -ret); return -1; } @@ -183,10 +183,10 @@ int dvp_cfg(int width, int height, int format) int dvp_request_buf(struct vin_video_buf *vbuf) { - int i; + int i, min_num = 3; if (mpp_dvp_ioctl(DVP_REQ_BUF, (void *)vbuf) < 0) { - pr_err("ioctl() failed!\n"); + pr_err("Failed to request buf!\n"); return -1; } @@ -199,6 +199,16 @@ int dvp_request_buf(struct vin_video_buf *vbuf) vbuf->planes[i * vbuf->num_planes + 1].len); } +#ifdef SUPPORT_ROTATION + if (g_vdata.rotation) + min_num++; +#endif + + if (vbuf->num_buffers < min_num) { + pr_err("The number of video buf must >= %d!\n", min_num); + return -1; + } + return 0; } @@ -221,7 +231,7 @@ void dvp_release_buf(int num) int dvp_queue_buf(int index) { if (mpp_dvp_ioctl(DVP_Q_BUF, (void *)(ptr_t)index) < 0) { - pr_err("ioctl() failed!\n"); + pr_err("Q failed! Maybe buf state is invalid.\n"); return -1; } @@ -234,7 +244,7 @@ int dvp_dequeue_buf(int *index) ret = mpp_dvp_ioctl(DVP_DQ_BUF, (void *)index); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("DQ failed! Maybe cannot receive data from Camera. err -%d\n", -ret); return -1; } @@ -247,7 +257,7 @@ int dvp_start(void) ret = mpp_dvp_ioctl(DVP_STREAM_ON, NULL); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("Failed to start streaming! err -%d\n", -ret); return -1; } @@ -260,7 +270,7 @@ int dvp_stop(void) ret = mpp_dvp_ioctl(DVP_STREAM_OFF, NULL); if (ret < 0) { - pr_err("ioctl() failed! err -%d\n", -ret); + pr_err("Failed to stop streaming! err -%d\n", -ret); return -1; } @@ -277,7 +287,7 @@ int video_layer_disable(void) layer.enable = 0; ret = mpp_fb_ioctl(g_fb, AICFB_UPDATE_LAYER_CONFIG, &layer); if (ret < 0) - pr_err("g_fb ioctl AICFB_UPDATE_LAYER_CONFIG failed !"); + pr_err("Failed to disable video layer!"); #endif return ret; @@ -403,7 +413,7 @@ int video_layer_set(struct aic_dvp_data *vdata, int index) } if (mpp_fb_ioctl(g_fb, AICFB_UPDATE_LAYER_CONFIG, &layer) < 0) { - pr_err("ioctl() failed!\n"); + pr_err("Failed to update layer config!\n"); return -1; } #endif diff --git a/bsp/examples/test-qspi/SConscript b/bsp/examples/test-qspi/SConscript index 4433291f..932185ff 100644 --- a/bsp/examples/test-qspi/SConscript +++ b/bsp/examples/test-qspi/SConscript @@ -8,6 +8,7 @@ src = [] if GetDepend('AIC_QSPI_DRV_TEST') and GetDepend('RT_USING_FINSH'): src = Glob('test_qspidev.c') src += Glob('test_spibit.c') + src += Glob('test_spi.c') src += Glob('test_spi_async.c') if GetDepend('AIC_QSPI_DRV_V11') and GetDepend('AIC_CHIP_D13X'): src += Glob('test_spislave*.c') diff --git a/bsp/examples/test-qspi/test_spi.c b/bsp/examples/test-qspi/test_spi.c new file mode 100644 index 00000000..2e8b26a3 --- /dev/null +++ b/bsp/examples/test-qspi/test_spi.c @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Jiji Chen + */ + +#include +#include +#include +#include + +#define USAGE \ + "test_spi help : Get this information.\n" \ + "test_spi attach : Attach device to SPI bus.\n" \ + "test_spi init : Initialize SPI for device.\n" \ + "test_spi send : Send data.\n" \ + "example:\n" \ + "test_spi attach spi3 spidev\n" \ + "test_spi init spidev 0 50000000\n" \ + "test_spi send 32\n" \ + "test_spi transfer 32\n" \ + "test_spi send_recv 33 128\n" \ + + +static void spi_usage(void) +{ + printf("%s", USAGE); +} + +static void show_speed(char *msg, u32 len, u32 us) +{ + u32 tmp, speed; + + /* Split to serval step to avoid overflow */ + tmp = 1000 * len; + tmp = tmp / us; + tmp = 1000 * tmp; + speed = tmp / 1024; + + printf("%s: %d byte, %d us -> %d KB/s\n", msg, len, us, speed); +} + +static void hex_dump(uint8_t *data, unsigned long len) +{ + unsigned long i = 0; + printf("\n"); + for (i = 0; i < len; i++) { + if (i && (i % 16) == 0) + printf("\n"); + printf("%02x ", data[i]); + } + printf("\n"); +} + +static struct rt_spi_device *g_spi; + + +static int test_spi_attach(int argc, char **argv) +{ + struct rt_spi_device *spi_device = RT_NULL; + char *bus_name, *dev_name; + rt_err_t result = RT_EOK; + + if (argc != 3) { + spi_usage(); + return -1; + } + bus_name = argv[1]; + dev_name = argv[2]; + + RT_ASSERT(bus_name != RT_NULL); + RT_ASSERT(dev_name != RT_NULL); + + spi_device = + (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); + if (spi_device == RT_NULL) { + printf("malloc failed.\n"); + return -RT_ERROR; + } + + result = rt_spi_bus_attach_device(spi_device, dev_name, + bus_name, RT_NULL); + + if (result != RT_EOK && spi_device != NULL) + rt_free(spi_device); + + return result; +} + +static int test_spi_init(int argc, char **argv) +{ + struct rt_spi_configuration spi_cfg; + struct rt_device *dev; + char *name; + int ret = 0; + + if (argc != 4) { + printf("Argument error, please see help information.\n"); + return -1; + } + name = argv[1]; + + g_spi = (struct rt_spi_device *)rt_device_find(name); + if (!g_spi) { + printf("Failed to get device in name %s\n", name); + return -1; + } + + dev = (struct rt_device *)g_spi; + if (dev->type != RT_Device_Class_SPIDevice) { + g_spi = NULL; + printf("%s is not SPI device.\n", name); + return -1; + } + rt_memset(&spi_cfg, 0, sizeof(spi_cfg)); + spi_cfg.mode = atol(argv[2]); + spi_cfg.max_hz = atol(argv[3]); + ret = rt_spi_configure(g_spi, &spi_cfg); + if (ret < 0) { + printf("qspi configure failure.\n"); + return ret; + } + return 0; +} + +static void test_spi_send_recv(int argc, char **argv) +{ + unsigned long send_len, recv_len, align_len, start_us; + uint8_t *send_buf, *recv_buf; + rt_err_t ret; + + if (!g_spi) { + printf("SPI device is not init yet.\n"); + return; + } + if (argc < 3) { + printf("Argument is not correct, please see help for more information.\n"); + return; + } + + send_len = 0; + send_len = strtoul(argv[1], NULL, 0); + recv_len = strtoul(argv[2], NULL, 0); + + /* transfer len can not be 0 */ + if (!send_len || !recv_len) + return; + + align_len = roundup(send_len, CACHE_LINE_SIZE); + send_buf = aicos_malloc_align(0, align_len, CACHE_LINE_SIZE); + u8 *temp = send_buf; + int k; + for (k = 0; k < send_len; k++) { + *temp = k & 0xff; + temp++; + } + align_len = roundup(recv_len, CACHE_LINE_SIZE); + recv_buf = aicos_malloc_align(0, align_len, CACHE_LINE_SIZE); + rt_memset(recv_buf, 0xee, recv_len); + + if (send_buf == NULL || recv_buf == NULL) { + printf("Low memory!\n"); + return; + } else { + printf("send len %ld, recv len %ld\n", send_len, recv_len); + } + + rt_spi_take_bus((struct rt_spi_device *)g_spi); + start_us = aic_get_time_us(); + ret = rt_spi_send_then_recv(g_spi, (void *)send_buf, send_len, (void *)recv_buf, recv_len); + show_speed("spi send recv speed", send_len + recv_len, aic_get_time_us() - start_us); + if (ret != 0) { + printf("Send_recv data failed. ret = %ld\n", ret); + } + rt_spi_release_bus((struct rt_spi_device *)g_spi); + if (send_buf) + aicos_free_align(0, send_buf); + if (recv_buf) { + printf("receive data:\n"); + hex_dump(recv_buf, recv_len); + printf("\n"); + aicos_free_align(0, recv_buf); + } +} + +static void test_spi_send(int argc, char **argv) +{ + unsigned long data_len, align_len, start_us; + uint8_t *data; + rt_size_t ret; + + if (!g_spi) { + printf("SPI device is not init yet.\n"); + return; + } + if (argc < 2) { + printf("Argument is not correct, please see help for more information.\n"); + return; + } + + data_len = 0; + data_len = strtoul(argv[1], NULL, 0); + data = RT_NULL; + if (data_len) { + align_len = roundup(data_len, CACHE_LINE_SIZE); + data = aicos_malloc_align(0, align_len, CACHE_LINE_SIZE); + u8 *temp = data; + int k; + for (k = 0; k < data_len; k++) { + *temp = k & 0xff; + temp++; + } + } + if (data == NULL) { + printf("Low memory!\n"); + return; + } else { + printf("data len %ld\n", data_len); + } + + rt_spi_take_bus((struct rt_spi_device *)g_spi); + start_us = aic_get_time_us(); + ret = rt_spi_transfer(g_spi, (void *)data, NULL, data_len); + show_speed("spi send speed", data_len, aic_get_time_us() - start_us); + if (ret != data_len) { + printf("Send data failed. ret 0x%x\n", (int)ret); + } + rt_spi_release_bus((struct rt_spi_device *)g_spi); + if (data) + aicos_free_align(0, data); +} + +static void test_spi_treansfer(int argc, char **argv) +{ + unsigned long data_len, align_len, start_us; + uint8_t *data, *recv; + rt_size_t ret; + + if (!g_spi) { + printf("SPI device is not init yet.\n"); + return; + } + if (argc < 2) { + printf("Argument is not correct, please see help for more information.\n"); + return; + } + + data_len = 0; + data_len = strtoul(argv[1], NULL, 0); + data = RT_NULL; + if (data_len) { + align_len = roundup(data_len, CACHE_LINE_SIZE); + data = aicos_malloc_align(0, align_len, CACHE_LINE_SIZE); + recv = aicos_malloc_align(0, align_len, CACHE_LINE_SIZE); + u8 *temp = data; + int k; + for (k = 0; k < data_len; k++) { + *temp = k & 0xff; + temp++; + } + rt_memset(recv, 0xee, align_len); + } + if (data == NULL) { + printf("Low memory!\n"); + return; + } else { + printf("data len %ld\n", data_len); + } + + rt_spi_take_bus((struct rt_spi_device *)g_spi); + start_us = aic_get_time_us(); + ret = rt_spi_transfer(g_spi, (void *)data, (void *)recv, data_len); + show_speed("spi transfer speed", data_len, aic_get_time_us() - start_us); + if (ret != data_len) { + printf("Transfer data failed. ret 0x%x\n", (int)ret); + } + rt_spi_release_bus((struct rt_spi_device *)g_spi); + if (data) + aicos_free_align(0, data); + + if (recv) { + printf("receive data:\n"); + hex_dump(recv, data_len); + printf("\n"); + aicos_free_align(0, recv); + } +} + +static void cmd_test_spi(int argc, char **argv) +{ + if (argc < 2) + goto help; + + if (!rt_strcmp(argv[1], "help")) { + goto help; + } else if (!rt_strcmp(argv[1], "attach")) { + test_spi_attach(argc - 1, &argv[1]); + return; + } else if (!rt_strcmp(argv[1], "init")) { + test_spi_init(argc - 1, &argv[1]); + return; + } else if (!rt_strcmp(argv[1], "send_recv")) { + test_spi_send_recv(argc - 1, &argv[1]); + return; + } else if (!rt_strcmp(argv[1], "send")) { + test_spi_send(argc - 1, &argv[1]); + return; + } else if (!rt_strcmp(argv[1], "transfer")) { + test_spi_treansfer(argc - 1, &argv[1]); + return; + } + +help: + spi_usage(); +} + +MSH_CMD_EXPORT_ALIAS(cmd_test_spi, test_spi, Test SPI); diff --git a/bsp/examples/test-qspi/test_spislave.h b/bsp/examples/test-qspi/test_spislave.h index f541653d..e1ecf157 100644 --- a/bsp/examples/test-qspi/test_spislave.h +++ b/bsp/examples/test-qspi/test_spislave.h @@ -32,8 +32,8 @@ /* All data should be 4 bytes aligned. */ #define CMD_SIZE 4 #define STATUS_SIZE 4 -#define PKT_SIZE TEST_BUF_SIZE -// #define PKT_SIZE 256 +// #define PKT_SIZE TEST_BUF_SIZE +#define PKT_SIZE 256 int test_qspi_slave_controller_init(u32 id, u32 bus_width, qspi_slave_async_cb cb, void *priv, diff --git a/bsp/examples/test-qspi/test_spislave_receiver.c b/bsp/examples/test-qspi/test_spislave_receiver.c index 3b8aabcd..f2a06f61 100644 --- a/bsp/examples/test-qspi/test_spislave_receiver.c +++ b/bsp/examples/test-qspi/test_spislave_receiver.c @@ -28,27 +28,38 @@ struct qspirecv_state { u32 bus_width; qspi_slave_handle handle; u8 *work_buf; + u8 *tx_buf; + u32 data_len; }; static struct qspirecv_state g_state; extern void slave_dump_data(char *msg, u8 *buf, u32 len); +#define USAGE \ + "spirecv help : Get this information.\n" \ + "spirecv start \n" \ + " rxtx: 0(default) - rx only; 1 - tx only; 2 - full duplex transfer, bus_width should be 1.\n" \ + " data_len: 256 as default, the len master transfer should be 4 align, if not, you have to set it.\n" \ + "spirecv stop : stop the spi slave using.\n" \ + "example:\n" \ + "spirecv start 3 1 2 2048\n" \ + "spirecv stop\n" \ + static void qspi_usage(void) { + printf("%s", USAGE); } - -static int recv_new_data(struct qspirecv_state *state, u8 *buf, u32 len) +static int recv_new_data(struct qspirecv_state *state, u8 *tx, u8 *rx, u32 len) { struct qspi_transfer t; int ret; memset(&t, 0, sizeof(t)); - t.rx_data = buf; + t.tx_data = tx; + t.rx_data = rx; t.data_len = len; - // memset(buf, 0, len); - // printf("%s, reset rx fifo\n", __func__); hal_qspi_slave_fifo_reset(&state->handle, HAL_QSPI_RX_FIFO); ret = hal_qspi_slave_transfer_async(&state->handle, &t); if (ret < 0) @@ -61,6 +72,7 @@ static void qspirecv_slave_async_callback(qspi_slave_handle *h, void *priv) struct qspirecv_state *state = priv; int status, cnt; u32 *p32, cksum; + u8 *p; status = hal_qspi_slave_get_status(&state->handle); cnt = 0; @@ -69,18 +81,43 @@ static void qspirecv_slave_async_callback(qspi_slave_handle *h, void *priv) * status OK: * TRANSFER DONE or CS INVALID */ - // p = state->work_buf; + p = state->work_buf; cnt = hal_qspi_slave_transfer_count(&state->handle); printf("%s, status %d, cnt %d\n", __func__, status, cnt); - p32 = (void *)state->work_buf; - cksum = 0; - for (int i = 0; iwork_buf) { + p32 = (void *)state->work_buf; + cksum = 0; + for (int i = 0; iwork_buf, PKT_SIZE); - // slave_dump_data("Data", p, cnt); + + if (g_state.work_buf) { + aicos_free_align(0, g_state.work_buf); + g_state.work_buf = aicos_malloc_align(0, g_state.data_len, CACHE_LINE_SIZE); + + if (g_state.work_buf == NULL) { + printf("malloc failure.\n"); + return; + } + rt_memset(g_state.work_buf, 0x2E, g_state.data_len); + } + if (g_state.tx_buf) { + aicos_free_align(0, g_state.tx_buf); + g_state.tx_buf = aicos_malloc_align(0, g_state.data_len, CACHE_LINE_SIZE); + + if (g_state.tx_buf == NULL) { + printf("malloc failure.\n"); + return; + } + rt_memset(g_state.tx_buf, 0x2E, g_state.data_len); + rt_memset(g_state.tx_buf, 0xA4, 16); + } + + recv_new_data(state, state->tx_buf, state->work_buf, g_state.data_len); } else { /* Error process */ printf("%s, status %d\n", __func__, status); @@ -89,7 +126,7 @@ static void qspirecv_slave_async_callback(qspi_slave_handle *h, void *priv) static int test_qspirecv_start(int argc, char **argv) { - unsigned long val; + unsigned long val, rxtx = 0; int ret; if (argc < 2) { @@ -99,13 +136,45 @@ static int test_qspirecv_start(int argc, char **argv) val = strtol(argv[1], NULL, 10); g_state.qspi_id = val; g_state.bus_width = 1; // Default is 1 - if (g_state.work_buf == NULL) - g_state.work_buf = - aicos_malloc_align(0, TEST_BUF_SIZE, CACHE_LINE_SIZE); if (argc >= 3) { val = strtol(argv[2], NULL, 10); g_state.bus_width = val; } + + if (argc >= 4) { + rxtx = strtol(argv[3], NULL, 10); + } + + if (argc >= 5) + g_state.data_len = strtol(argv[4], NULL, 10); + else + g_state.data_len = PKT_SIZE; + + /* rx or Full duplex mode */ + if (rxtx == 0 || rxtx == 2) { + if (g_state.work_buf == NULL) + g_state.work_buf = aicos_malloc_align(0, g_state.data_len, CACHE_LINE_SIZE); + + if (g_state.work_buf == NULL) { + printf("malloc failure.\n"); + return -1; + } + rt_memset(g_state.work_buf, 0x2E, g_state.data_len); + } + + /* tx or Full duplex mode */ + if (rxtx == 1 || rxtx == 2) { + if (g_state.tx_buf == NULL) + g_state.tx_buf = aicos_malloc_align(0, g_state.data_len, CACHE_LINE_SIZE); + + if (g_state.tx_buf == NULL) { + printf("malloc failure.\n"); + return -1; + } + rt_memset(g_state.tx_buf, 0x2E, g_state.data_len); + rt_memset(g_state.tx_buf, 0xA4, 16); + } + ret = test_qspi_slave_controller_init(g_state.qspi_id, g_state.bus_width, qspirecv_slave_async_callback, &g_state, &g_state.handle); @@ -115,7 +184,7 @@ static int test_qspirecv_start(int argc, char **argv) } /* Start with waiting command */ - recv_new_data(&g_state, g_state.work_buf, PKT_SIZE); + recv_new_data(&g_state, g_state.tx_buf, g_state.work_buf, g_state.data_len); return 0; } @@ -126,6 +195,10 @@ static int test_qspirecv_stop(int argc, char **argv) aicos_free_align(0, g_state.work_buf); g_state.work_buf = NULL; } + if (g_state.tx_buf) { + aicos_free_align(0, g_state.tx_buf); + g_state.tx_buf = NULL; + } return 0; } @@ -147,5 +220,4 @@ help: qspi_usage(); } - MSH_CMD_EXPORT_ALIAS(cmd_test_qspislave_receiver, spirecv, Test QSPI Slave); diff --git a/bsp/examples_bare/test-dce/SConscript b/bsp/examples_bare/test-dce/SConscript new file mode 100644 index 00000000..e01117c1 --- /dev/null +++ b/bsp/examples_bare/test-dce/SConscript @@ -0,0 +1,13 @@ +Import('AIC_ROOT') +Import('PRJ_KERNEL') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [] +src = [] +if GetDepend('AIC_DCE_DRV_TEST') and GetDepend('KERNEL_BAREMETAL'): + src = Glob('*.c') + +group = DefineGroup('test-dce', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/examples_bare/test-dce/test_dce.c b/bsp/examples_bare/test-dce/test_dce.c new file mode 100644 index 00000000..7f0144b2 --- /dev/null +++ b/bsp/examples_bare/test-dce/test_dce.c @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-09-29 junlong.chen first implementation. + * 2024-09-29 junlong.chen ArtInChip + */ +#include +#include +#include +#include +#include "aic_core.h" +#include "aic_log.h" +#include "hal_dce.h" +#include "aic_crc32.h" + +u8 default_data[] = "It is test data"; + +static int software_checksum(u8 *buf, u32 size) +{ + u32 i, val, sum, rest, cnt; + u8 *p; + u32 *p32, *pe32; + + p = buf; + i = 0; + sum = 0; + cnt = size >> 2; + + if ((unsigned long)buf & 0x3) { + for (i = 0; i < cnt; i++) { + p = &buf[i * 4]; + val = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; + sum += val; + } + } else { + p32 = (u32 *)buf; + pe32 = p32 + cnt; + while (p32 < pe32) { + sum += *p32; + p32++; + } + } + + /* Calculate not 32 bit aligned part */ + rest = size - (cnt << 2); + p = &buf[cnt * 4]; + val = 0; + for (i = 0; i < rest; i++) + val += (p[i] << (i * 8)); + sum += val; + + return sum; +} + +static int hardware_checksum(u8 *data, int len) +{ + int ret; + + hal_dce_checksum_start(data, len); + ret = hal_dce_checksum_wait(); + if (!ret) + return hal_dce_checksum_result(); + else + printf("\t%s error: time out\n", __func__); + return 0; +} + +static int hardware_crc32(u8 *data, int len) +{ + int ret; + + hal_dce_crc32_start(0, data, len); + ret = hal_dce_crc32_wait(); + if (!ret) + return hal_dce_crc32_result(); + else + printf("\t%s error: time out\n", __func__); + return 0; +} + +void int_to_bcd(int num, int *bcd) { + int index = 0; + while (num != 0) { + bcd[index] = num % 16; + num /= 16; + index++; + } +} + +static void usage(char *program) +{ + printf("Usage: %s [options]: \n", program); + printf("\tParameter 1 is the address of the data to be verified,"); + printf("\n\tparameter 2 is the length of the data to be verified \n"); + printf("\n"); + printf("Example: \n"); + printf("\t%s 0x80040000 0x100 (test data from ram)\n", program); + printf("\t%s (test default data)\n", program); +} + +static void cmd_test_dce(int argc, char **argv) +{ + int sw_check_sum, sw_crc32, hw_check_sum, hw_crc32, data_len, + version[3] = {0}; + u8 *data; + + if (!(argc == 1 || argc == 3)) { + printf("Usage error\n"); + usage(argv[0]); + return; + } + + if (argc == 3) { + data = (u8 *)strtoul(argv[1], NULL, 0); + data_len = strtoul(argv[2], NULL, 0); + } else { + data = default_data; + data_len = sizeof(default_data); + } + + if ((u32)data % 4 || data_len % 4) { + printf("data and data_len need 4 byte alignment\n"); + return; + } + + hal_dce_init(); + + int_to_bcd(hal_get_version(), version); + printf("\tDCE version: %d.%d.%d\n", version[2], version[1], version[0]); + if (argc == 3) + printf("\tdata_addr: 0x%08x, data_len: 0x%08x\n", (int)data, data_len); + else + printf("\tdata:%s, data_len: 0x%08x\n", data, data_len); + sw_check_sum = software_checksum(data, data_len); + sw_crc32 = (int)crc32(0, data, data_len); + printf("\tsoftware: check_sum 0x%08x, crc32 0x%08x\n", sw_check_sum, + sw_crc32); + + hw_check_sum = hardware_checksum(data, data_len); + hw_crc32 = hardware_crc32(data, data_len); + printf("\thardware: check_sum 0x%08x, crc32 0x%08x\n", hw_check_sum, + hw_crc32); + + if (sw_check_sum != hw_check_sum || sw_crc32 != hw_crc32) + printf("\tDCE calculate failed\n"); + else + printf("\tDCE calculate OK\n"); + + hal_dce_deinit(); + return; +} + +CONSOLE_CMD(test_dce, cmd_test_dce, "test DCE"); diff --git a/bsp/examples_bare/test-gpai/test_gpai.c b/bsp/examples_bare/test-gpai/test_gpai.c index 9de4eb4c..5a0bae15 100644 --- a/bsp/examples_bare/test-gpai/test_gpai.c +++ b/bsp/examples_bare/test-gpai/test_gpai.c @@ -14,7 +14,6 @@ #include "hal_adcim.h" #include "hal_gpai.h" -#include "test_gpai.h" /* The default voltages are set to D21x->3.0V, D31x、D12x->2.5V */ #define AIC_GPAI_DEFAULT_VOLTAGE 3 diff --git a/bsp/examples_bare/test-i2c/test_i2c.c b/bsp/examples_bare/test-i2c/test_i2c.c index ece161af..3ddc889d 100644 --- a/bsp/examples_bare/test-i2c/test_i2c.c +++ b/bsp/examples_bare/test-i2c/test_i2c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,10 +18,14 @@ #ifdef SE_I2C_BASE #define I2C_REG_BASE(x) (SE_I2C_BASE) +#define I2C_CLK_ID CLK_SE_I2C #else #define I2C_REG_BASE(x) (I2C0_BASE + (x * I2C_BASE_OFFSET)) +#define I2C_CLK_ID (CLK_I2C0 + x) #endif +#define I2C_RATE 400000 + aic_i2c_ctrl g_i2c_ctrl; static void i2c_usage(void) @@ -126,8 +130,9 @@ static int test_i2c_example(int argc, char *argv[]) g_i2c_ctrl.reg_base = I2C_REG_BASE(bus_id); g_i2c_ctrl.msg = msgs; g_i2c_ctrl.addr_bit = I2C_7BIT_ADDR; - g_i2c_ctrl.speed_mode = I2C_400K_SPEED; + g_i2c_ctrl.target_rate = I2C_RATE; g_i2c_ctrl.bus_mode = I2C_MASTER_MODE; + g_i2c_ctrl.clk_id = I2C_CLK_ID; hal_i2c_init(&g_i2c_ctrl); diff --git a/bsp/examples_bare/test-spi/SConscript b/bsp/examples_bare/test-spi/SConscript new file mode 100644 index 00000000..dd7a8f8d --- /dev/null +++ b/bsp/examples_bare/test-spi/SConscript @@ -0,0 +1,13 @@ +Import('AIC_ROOT') +Import('PRJ_KERNEL') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [] +src = [] +if GetDepend('KERNEL_BAREMETAL') and GetDepend('AIC_QSPI_DRV_TEST'): + src += Glob('test_spi.c') + +group = DefineGroup('test-spi', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/examples_bare/test-spi/test_spi.c b/bsp/examples_bare/test-spi/test_spi.c new file mode 100644 index 00000000..91ed28df --- /dev/null +++ b/bsp/examples_bare/test-spi/test_spi.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: jiji.chen + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPI_HELP \ + "test_spi command:\n" \ + " test_spi init [spi bus id]\n" \ + " test_spi send [addr] [size]\n" \ + " test_spi recv \n" \ + "e.g.: \n" \ + " test_spi init 0\n" \ + " mtd alloc 4096\n" \ + " Alloc buffer: 0x300422c0\n" \ + " mtd_gendata 0x300422c0 0x100 0xA0\n"\ + " test_spi send 0x300422c0 0x100\n" \ + " test_spi recv 0x100\n" + +extern struct aic_qspi_bus *qspi_probe(u32 spi_bus); +extern int spi_write_read(struct aic_qspi_bus *qspi, + const uint8_t *write_buf, size_t write_size, + uint8_t *read_buf, size_t read_size); + +static void spi_help(void) +{ + puts(SPI_HELP); +} + +struct aic_qspi_bus *g_spi_device; + +static void hex_dump(uint8_t *data, unsigned long len) +{ + unsigned long i = 0; + printf("\n"); + for (i = 0; i < len; i++) { + if (i && (i % 16) == 0) + printf("\n"); + printf("%02x ", data[i]); + } + printf("\n"); +} + + + +static int do_qspi_init(int argc, char *argv[]) +{ + unsigned long id; + struct aic_qspi_bus *qspi; + + if (argc < 2) { + spi_help(); + return 0; + } + id = strtol(argv[1], NULL, 0); + + qspi = qspi_probe(id); + if (qspi == NULL) { + printf("Failed to probe spinor flash.\n"); + return -1; + } + + printf("probe qspi device success.\n"); + + g_spi_device = qspi; + return 0; +} + +static int test_spi_send(int argc, char **argv) +{ + int ret = 0; + u32 send_buf; + size_t send_len; + + if (argc < 3) { + spi_help(); + return 0; + } + + if (!g_spi_device) { + printf("init spi device first\n"); + return -1; + } + send_buf = strtoul(argv[1], NULL, 0); + send_len = strtoul(argv[2], NULL, 0); + + ret = spi_write_read(g_spi_device, (u8 *)send_buf, send_len, NULL, 0); + + if (send_buf) + hex_dump((u8 *)send_buf, send_len); + + + return ret; +} + +static int test_spi_recv(int argc, char **argv) +{ + int ret = 0; + u8 *data; + size_t recv_len; + + if (argc < 2) { + spi_help(); + return 0; + } + + if (!g_spi_device) { + printf("init spi device first\n"); + return -1; + } + recv_len = strtoul(argv[1], NULL, 0); + data = aicos_malloc_align(0, roundup(recv_len, CACHE_LINE_SIZE), CACHE_LINE_SIZE); + if (data == NULL) { + printf("[Error]: malloc failed.\n"); + return -1; + } else { + memset(data, 0x77, recv_len); + } + + ret = spi_write_read(g_spi_device, NULL, 0, data, recv_len); + + if (data) + hex_dump(data, recv_len); + + return ret; +} + +static int spi_do_test(int argc, char *argv[]) +{ + if (argc < 3) { + spi_help(); + return 0; + } + + if (!strncmp(argv[1], "init", 4)) + return do_qspi_init(argc - 1, &argv[1]); + if (!strncmp(argv[1], "send", 4)) + return test_spi_send(argc - 1, &argv[1]); + if (!strncmp(argv[1], "recv", 4)) + return test_spi_recv(argc - 1, &argv[1]); + + spi_help(); + return 0; +} + +CONSOLE_CMD(test_spi, spi_do_test, "spi send, receive test"); diff --git a/bsp/peripheral/camera/common/camera.c b/bsp/peripheral/camera/common/camera.c index 1a0bdc2f..0c006c42 100644 --- a/bsp/peripheral/camera/common/camera.c +++ b/bsp/peripheral/camera/common/camera.c @@ -8,6 +8,13 @@ #include "aic_core.h" #include "aic_hal_clk.h" +#include "drv_camera.h" + +#ifdef RT_USING_DEVICE_OPS +#define DEV_IOCTL dev->ops->control +#else +#define DEV_IOCTL dev->control +#endif struct rt_i2c_bus_device *camera_i2c_get(void) { @@ -68,3 +75,211 @@ u32 camera_pwdn_pin_get(void) return pin; } + +void camera_pin_set_high(u32 pin) +{ + if (!pin) + return; + + rt_pin_write(pin, PIN_HIGH); +} + +void camera_pin_set_low(u32 pin) +{ + if (!pin) + return; + + rt_pin_write(pin, PIN_LOW); +} + +int camera_get_fmt(struct rt_device *dev, void *fmt) +{ + if (!dev || !DEV_IOCTL || !fmt) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_GET_FMT, fmt); +} + +int camera_set_fmt(struct rt_device *dev, void *fmt) +{ + if (!dev || !DEV_IOCTL || !fmt) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_FMT, fmt); +} + +int camera_set_fps(struct rt_device *dev, u32 fps) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_FPS, &fps); +} + +int camera_set_channel(struct rt_device *dev, u32 chan) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_CHANNEL, &chan); +} + +int camera_set_brightness(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_BRIGHTNESS, &percent); +} + +int camera_set_contrast(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_CONTRAST, &percent); +} + +int camera_set_saturation(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_SATURATION, &percent); +} + +int camera_set_hue(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_HUE, &percent); +} + +int camera_set_sharpness(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_SHARPNESS, &percent); +} + +int camera_set_denoise(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_DENOISE, &percent); +} + +int camera_set_quality(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_QUALITY, &percent); +} + +int camera_set_aec_val(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_AEC_VAL, &percent); +} + +int camera_set_autogain(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_AUTOGAIN, &percent); +} + +int camera_set_exposure(struct rt_device *dev, u32 percent) +{ + if (!dev || !DEV_IOCTL || percent > 100) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_EXPOSURE, &percent); +} + +int camera_set_gain_ctrl(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_GAIN_CTRL, &enable); +} + +int camera_set_whitebal(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_WHITEBAL, (void *)enable); +} + +int camera_set_awb(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_AWB, &enable); +} + +int camera_set_aec2(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_AEC2, &enable); +} + +int camera_set_dcw(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_DCW, &enable); +} + +int camera_set_bpc(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_BPC, &enable); +} + +int camera_set_wpc(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_WPC, &enable); +} + +int camera_set_h_flip(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_H_FLIP, &enable); +} + +int camera_set_v_flip(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_V_FLIP, &enable); +} + +int camera_set_colorbar(struct rt_device *dev, bool enable) +{ + if (!dev || !DEV_IOCTL) + return -1; + + return DEV_IOCTL(dev, CAMERA_CMD_SET_COLORBAR, &enable); +} diff --git a/bsp/peripheral/camera/common/camera_inner.h b/bsp/peripheral/camera/common/camera_inner.h index 954c47fd..1b4f4cdc 100644 --- a/bsp/peripheral/camera/common/camera_inner.h +++ b/bsp/peripheral/camera/common/camera_inner.h @@ -15,6 +15,12 @@ extern "C" { #include "rtdef.h" +#define REG8_ADDR_INVALID 0xFF +#define REG16_ADDR_INVALID 0xFFFF + +#define PERCENT_TO_INT(min, max, p) ((min) + ((max) - (min)) * (p) / 100) +#define PERCENT_IS_INVALID(p) (p > 100) + struct rt_i2c_bus_device *camera_i2c_get(void); u32 camera_xclk_rate_get(void); @@ -23,6 +29,8 @@ void camera_xclk_disable(void); u32 camera_rst_pin_get(void); u32 camera_pwdn_pin_get(void); +void camera_pin_set_high(u32 pin); +void camera_pin_set_low(u32 pin); struct reg8_info { u8 reg; diff --git a/bsp/peripheral/camera/drv_camera.h b/bsp/peripheral/camera/drv_camera.h index 75b8096d..caf2127a 100644 --- a/bsp/peripheral/camera/drv_camera.h +++ b/bsp/peripheral/camera/drv_camera.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -17,10 +17,66 @@ extern "C" { #define CAMERA_DEV_NAME "camera" -#define CAMERA_CMD_START (RT_DEVICE_CTRL_BASE(CAMERA) + 0x01) -#define CAMERA_CMD_STOP (RT_DEVICE_CTRL_BASE(CAMERA) + 0x02) -/* Argument type: struct mpp_video_fmt * */ -#define CAMERA_CMD_GET_FMT (RT_DEVICE_CTRL_BASE(CAMERA) + 0x03) +/* ioctl command of Camera device */ + +#define CAMERA_CMD_START (RT_DEVICE_CTRL_BASE(CAMERA) + 0x01) +#define CAMERA_CMD_STOP (RT_DEVICE_CTRL_BASE(CAMERA) + 0x02) +/* Argument type: (struct mpp_video_fmt *) */ +#define CAMERA_CMD_GET_FMT (RT_DEVICE_CTRL_BASE(CAMERA) + 0x03) +#define CAMERA_CMD_SET_FMT (RT_DEVICE_CTRL_BASE(CAMERA) + 0x05) +/* Argument type: unsigned int */ +#define CAMERA_CMD_SET_CHANNEL (RT_DEVICE_CTRL_BASE(CAMERA) + 0x08) +#define CAMERA_CMD_SET_FPS (RT_DEVICE_CTRL_BASE(CAMERA) + 0x09) +/* Argument type: unsigned int,percent, [0, 100] */ +#define CAMERA_CMD_SET_BRIGHTNESS (RT_DEVICE_CTRL_BASE(CAMERA) + 0x10) +#define CAMERA_CMD_SET_CONTRAST (RT_DEVICE_CTRL_BASE(CAMERA) + 0x11) +#define CAMERA_CMD_SET_SATURATION (RT_DEVICE_CTRL_BASE(CAMERA) + 0x12) +#define CAMERA_CMD_SET_HUE (RT_DEVICE_CTRL_BASE(CAMERA) + 0x13) +#define CAMERA_CMD_SET_SHARPNESS (RT_DEVICE_CTRL_BASE(CAMERA) + 0x14) +#define CAMERA_CMD_SET_DENOISE (RT_DEVICE_CTRL_BASE(CAMERA) + 0x15) +#define CAMERA_CMD_SET_QUALITY (RT_DEVICE_CTRL_BASE(CAMERA) + 0x16) +#define CAMERA_CMD_SET_AUTOGAIN (RT_DEVICE_CTRL_BASE(CAMERA) + 0x17) +#define CAMERA_CMD_SET_AEC_VAL (RT_DEVICE_CTRL_BASE(CAMERA) + 0x18) +#define CAMERA_CMD_SET_EXPOSURE (RT_DEVICE_CTRL_BASE(CAMERA) + 0x19) +/* Argument type: bool, 0, disable; 1, enable */ +#define CAMERA_CMD_SET_GAIN_CTRL (RT_DEVICE_CTRL_BASE(CAMERA) + 0x20) +#define CAMERA_CMD_SET_WHITEBAL (RT_DEVICE_CTRL_BASE(CAMERA) + 0x21) +#define CAMERA_CMD_SET_AWB (RT_DEVICE_CTRL_BASE(CAMERA) + 0x22) +#define CAMERA_CMD_SET_AEC2 (RT_DEVICE_CTRL_BASE(CAMERA) + 0x23) +#define CAMERA_CMD_SET_DCW (RT_DEVICE_CTRL_BASE(CAMERA) + 0x24) +#define CAMERA_CMD_SET_BPC (RT_DEVICE_CTRL_BASE(CAMERA) + 0x25) +#define CAMERA_CMD_SET_WPC (RT_DEVICE_CTRL_BASE(CAMERA) + 0x26) +#define CAMERA_CMD_SET_H_FLIP (RT_DEVICE_CTRL_BASE(CAMERA) + 0x27) +#define CAMERA_CMD_SET_V_FLIP (RT_DEVICE_CTRL_BASE(CAMERA) + 0x28) +#define CAMERA_CMD_SET_COLORBAR (RT_DEVICE_CTRL_BASE(CAMERA) + 0x2F) + +int camera_get_fmt(struct rt_device *dev, void *fmt); +int camera_set_fmt(struct rt_device *dev, void *fmt); + +int camera_set_channel(struct rt_device *dev, u32 chan); +int camera_set_fps(struct rt_device *dev, u32 fps); + +int camera_set_brightness(struct rt_device *dev, u32 percent); +int camera_set_contrast(struct rt_device *dev, u32 percent); +int camera_set_saturation(struct rt_device *dev, u32 percent); +int camera_set_hue(struct rt_device *dev, u32 percent); +int camera_set_sharpness(struct rt_device *dev, u32 percent); +int camera_set_denoise(struct rt_device *dev, u32 percent); +int camera_set_quality(struct rt_device *dev, u32 percent); +int camera_set_autogain(struct rt_device *dev, u32 percent); +int camera_set_aec_val(struct rt_device *dev, u32 percent); +int camera_set_exposure(struct rt_device *dev, u32 percent); + +int camera_set_gain_ctrl(struct rt_device *dev, bool enable); +int camera_set_whitebal(struct rt_device *dev, bool enable); +int camera_set_awb(struct rt_device *dev, bool enable); +int camera_set_aec2(struct rt_device *dev, bool enable); +int camera_set_dcw(struct rt_device *dev, bool enable); +int camera_set_bpc(struct rt_device *dev, bool enable); +int camera_set_wpc(struct rt_device *dev, bool enable); +int camera_set_h_flip(struct rt_device *dev, bool enable); +int camera_set_v_flip(struct rt_device *dev, bool enable); +int camera_set_colorbar(struct rt_device *dev, bool enable); #ifdef __cplusplus } diff --git a/bsp/peripheral/camera/gc0308/drv_gc0308.c b/bsp/peripheral/camera/gc0308/drv_gc0308.c index ab47403d..31332c78 100644 --- a/bsp/peripheral/camera/gc0308/drv_gc0308.c +++ b/bsp/peripheral/camera/gc0308/drv_gc0308.c @@ -295,18 +295,7 @@ static struct gc03_dev g_gc03_dev = {0}; static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) { - u8 buf[2]; - struct rt_i2c_msg msgs; - - buf[0] = reg; - buf[1] = val; - - msgs.addr = GC03_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 2; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg(i2c, GC03_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -316,20 +305,7 @@ static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) static int gc03_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf = reg; - - msg[0].addr = GC03_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = &buf; - msg[0].len = 1; - - msg[1].addr = GC03_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg(i2c, GC03_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -377,9 +353,9 @@ static void gc0308_power_on(struct gc03_dev *sensor) if (sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_LOW); + camera_pin_set_low(sensor->pwdn_pin); aicos_udelay(1); - rt_pin_write(sensor->rst_pin, 1); + camera_pin_set_high(sensor->rst_pin); sensor->on = true; } @@ -390,7 +366,7 @@ static void gc0308_power_off(struct gc03_dev *sensor) if (!sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_HIGH); + camera_pin_set_high(sensor->pwdn_pin); sensor->on = false; #endif diff --git a/bsp/peripheral/camera/gc032a/drv_gc032a.c b/bsp/peripheral/camera/gc032a/drv_gc032a.c index 12404d51..7e2a9c37 100644 --- a/bsp/peripheral/camera/gc032a/drv_gc032a.c +++ b/bsp/peripheral/camera/gc032a/drv_gc032a.c @@ -28,12 +28,7 @@ #define GC03_I2C_SLAVE_ID 0x21 #define GC032A_CHIP_ID 0x232A -struct reginfo { - u8 reg; - u8 val; -}; - -static const struct reginfo sensor_init_data[] = { +static const struct reg8_info sensor_init_data[] = { /* System */ {0xf3, 0xff}, {0xf5, 0x06}, @@ -358,18 +353,7 @@ static struct gc03_dev g_gc03_dev = {0}; static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) { - u8 buf[2]; - struct rt_i2c_msg msgs; - - buf[0] = reg; - buf[1] = val; - - msgs.addr = GC03_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 2; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg(i2c, GC03_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -379,20 +363,7 @@ static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) static int gc03_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf = reg; - - msg[0].addr = GC03_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = &buf; - msg[0].len = 1; - - msg[1].addr = GC03_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg(i2c, GC03_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -408,7 +379,7 @@ static void gc032a_reset(struct gc03_dev *sensor) static int gc032a_init(struct gc03_dev *sensor) { int i = 0; - const struct reginfo *info = sensor_init_data; + const struct reg8_info *info = sensor_init_data; gc032a_reset(sensor); aicos_udelay(1000); @@ -441,11 +412,11 @@ static void gc032a_power_on(struct gc03_dev *sensor) if (sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_LOW); + camera_pin_set_low(sensor->pwdn_pin); aicos_udelay(1); - rt_pin_write(sensor->pwdn_pin, PIN_HIGH); + camera_pin_set_high(sensor->pwdn_pin); aicos_udelay(2); - rt_pin_write(sensor->pwdn_pin, PIN_LOW); + camera_pin_set_low(sensor->pwdn_pin); sensor->on = true; } @@ -456,9 +427,9 @@ static void gc032a_power_off(struct gc03_dev *sensor) if (!sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_HIGH); + camera_pin_set_high(sensor->pwdn_pin); aicos_udelay(1); - rt_pin_write(sensor->pwdn_pin, PIN_LOW); + camera_pin_set_low(sensor->pwdn_pin); sensor->on = false; #endif diff --git a/bsp/peripheral/camera/gm7150/drv_gm7150.c b/bsp/peripheral/camera/gm7150/drv_gm7150.c index c5d28324..c3291eeb 100644 --- a/bsp/peripheral/camera/gm7150/drv_gm7150.c +++ b/bsp/peripheral/camera/gm7150/drv_gm7150.c @@ -17,6 +17,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" /* Default format configuration of GM7150 */ #define GM7150_DFT_WIDTH PAL_WIDTH @@ -27,6 +28,11 @@ #define GM7150_I2C_SLAVE_ID 0x5C // or 0x5D #define GM7150_CHIP_ID 0x7150 +#define GM7150_BRIGHTNESS_REG 0x09 +#define GM7150_SATURATION_REG 0x0A +#define GM7150_HUE_REG 0x0B +#define GM7150_CONTRAST_REG 0x0C + struct gm7150_dev { struct rt_device dev; struct rt_i2c_bus_device *i2c; @@ -40,20 +46,21 @@ struct gm7150_dev { static struct gm7150_dev g_gm7150_dev = {0}; +static struct reg8_info gm7150_bt656_regs[] = { + {0x03, 0x0D}, + {0x11, 0x04}, + {0x12, 0x00}, + {0x13, 0x04}, + {0x14, 0x00}, + {0xA0, 0x55}, + {0xA1, 0xAA}, + {0x69, 0x40}, + {0x6D, 0x90}, +}; + static int gm7150_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) { - u8 buf[2]; - struct rt_i2c_msg msgs; - - buf[0] = reg; - buf[1] = val; - - msgs.addr = GM7150_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 2; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg(i2c, GM7150_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -63,20 +70,7 @@ static int gm7150_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) static int gm7150_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf = reg; - - msg[0].addr = GM7150_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = &buf; - msg[0].len = 1; - - msg[1].addr = GM7150_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg(i2c, GM7150_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -94,15 +88,11 @@ static void gm7150_select_ch(struct gm7150_dev *sensor, u32 ch) static void gm7150_out_bt656(struct gm7150_dev *sensor) { - gm7150_write_reg(sensor->i2c, 0x03, 0x0D); - gm7150_write_reg(sensor->i2c, 0x11, 0x04); - gm7150_write_reg(sensor->i2c, 0x12, 0x00); - gm7150_write_reg(sensor->i2c, 0x13, 0x04); - gm7150_write_reg(sensor->i2c, 0x14, 0x00); - gm7150_write_reg(sensor->i2c, 0xA0, 0x55); - gm7150_write_reg(sensor->i2c, 0xA1, 0xAA); - gm7150_write_reg(sensor->i2c, 0x69, 0x40); - gm7150_write_reg(sensor->i2c, 0x6D, 0x90); + struct reg8_info *info = gm7150_bt656_regs; + int i; + + for (i = 0; i < ARRAY_SIZE(gm7150_bt656_regs); i++, info++) + gm7150_write_reg(sensor->i2c, info->reg, info->val); } static void gm7150_cur_status(struct gm7150_dev *sensor) @@ -131,9 +121,9 @@ static int gm7150_probe(struct gm7150_dev *sensor) u8 id_h = 0, id_l = 0; aicos_msleep(30); - rt_pin_write(sensor->pwdn_pin, 0); //SET PDN LOW BY GPIO OF MCU + camera_pin_set_low(sensor->pwdn_pin); aicos_msleep(10); - rt_pin_write(sensor->pwdn_pin, 1); //SET PDN HIGH BY GPIO OF MCU + camera_pin_set_high(sensor->pwdn_pin); aicos_msleep(30); @@ -152,27 +142,13 @@ static int gm7150_probe(struct gm7150_dev *sensor) return 0; } -static int gm7150_i2c_init(struct gm7150_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->i2c = rt_i2c_bus_device_find(name); - if (sensor->i2c == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - return 0; -} - static rt_err_t gm7150_init(rt_device_t dev) { int ret = 0; struct gm7150_dev *sensor = &g_gm7150_dev; - ret = gm7150_i2c_init(sensor); - if (ret != 0) + sensor->i2c = camera_i2c_get(); + if (!sensor->i2c) return -RT_EINVAL; sensor->fmt.code = GM7150_DFT_CODE; @@ -184,8 +160,9 @@ static rt_err_t gm7150_init(rt_device_t dev) MEDIA_SIGNAL_PCLK_SAMPLE_RISING | MEDIA_SIGNAL_INTERLACED_MODE; - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->pwdn_pin) + return -RT_EINVAL; ret = gm7150_probe(sensor); if (ret) @@ -205,10 +182,8 @@ static rt_err_t gm7150_close(rt_device_t dev) return RT_EOK; } -static int gm7150_get_fmt(rt_device_t dev, struct mpp_video_fmt *cfg) +static int gm7150_get_fmt(struct gm7150_dev *sensor, struct mpp_video_fmt *cfg) { - struct gm7150_dev *sensor = (struct gm7150_dev *)dev; - cfg->code = sensor->fmt.code; cfg->width = sensor->fmt.width; cfg->height = sensor->fmt.height; @@ -227,15 +202,53 @@ static int gm7150_stop(rt_device_t dev) return 0; } +static int gm7150_set_brightness(struct gm7150_dev *sensor, u32 percent) +{ + u8 val = PERCENT_TO_INT(0, 255, percent); + + return gm7150_write_reg(sensor->i2c, GM7150_BRIGHTNESS_REG, val); +} + +static int gm7150_set_saturation(struct gm7150_dev *sensor, u32 percent) +{ + u8 val = PERCENT_TO_INT(0, 255, percent); + + return gm7150_write_reg(sensor->i2c, GM7150_SATURATION_REG, val); +} + +static int gm7150_set_hue(struct gm7150_dev *sensor, u32 percent) +{ + s8 val = PERCENT_TO_INT((s8)0x80, (s8)0x7F, percent); + + return gm7150_write_reg(sensor->i2c, GM7150_HUE_REG, val); +} + +static int gm7150_set_contrast(struct gm7150_dev *sensor, u32 percent) +{ + u8 val = PERCENT_TO_INT(0, 255, percent); + + return gm7150_write_reg(sensor->i2c, GM7150_CONTRAST_REG, val); +} + static rt_err_t gm7150_control(rt_device_t dev, int cmd, void *args) { + struct gm7150_dev *sensor = (struct gm7150_dev *)dev; + switch (cmd) { case CAMERA_CMD_START: return gm7150_start(dev); case CAMERA_CMD_STOP: return gm7150_stop(dev); case CAMERA_CMD_GET_FMT: - return gm7150_get_fmt(dev, (struct mpp_video_fmt *)args); + return gm7150_get_fmt(sensor, (struct mpp_video_fmt *)args); + case CAMERA_CMD_SET_CONTRAST: + return gm7150_set_contrast(sensor, *(u32 *)args); + case CAMERA_CMD_SET_BRIGHTNESS: + return gm7150_set_brightness(sensor, *(u32 *)args); + case CAMERA_CMD_SET_HUE: + return gm7150_set_hue(sensor, *(u32 *)args); + case CAMERA_CMD_SET_SATURATION: + return gm7150_set_saturation(sensor, *(u32 *)args); default: LOG_I("Unsupported cmd: 0x%x", cmd); return -RT_EINVAL; diff --git a/bsp/peripheral/camera/ov2640/drv_ov2640.c b/bsp/peripheral/camera/ov2640/drv_ov2640.c index 6c5d8c94..c56c7c48 100644 --- a/bsp/peripheral/camera/ov2640/drv_ov2640.c +++ b/bsp/peripheral/camera/ov2640/drv_ov2640.c @@ -18,6 +18,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" /* Default format configuration of OV2640 */ #define OV2640_DFT_WIN OV2640_WIN_VGA @@ -287,16 +288,11 @@ enum ov2640_win_type { OV2640_WIN_UXGA, }; -struct regval_list { - u8 reg_num; - u8 value; -}; - struct ov2640_win_size { char *name; u32 width; u32 height; - const struct regval_list *regs; + const struct reg8_info *regs; }; struct ov2640_dev { @@ -320,7 +316,7 @@ static struct ov2640_dev g_ov2640_dev = {0}; #define ENDMARKER { 0xff, 0xff } -static const struct regval_list ov2640_init_regs[] = { +static const struct reg8_info ov2640_init_regs[] = { { BANK_SEL, BANK_SEL_DSP }, { 0x2c, 0xff }, { 0x2e, 0xdf }, @@ -502,7 +498,7 @@ static const struct regval_list ov2640_init_regs[] = { * The preamble, setup the internal DSP to input an UXGA (1600x1200) image. * Then the different zooming configurations will setup the output image size. */ -static const struct regval_list ov2640_size_change_preamble_regs[] = { +static const struct reg8_info ov2640_size_change_preamble_regs[] = { { BANK_SEL, BANK_SEL_DSP }, { RESET, RESET_DVP }, { SIZEL, SIZEL_HSIZE8_11_SET(UXGA_WIDTH) | @@ -531,45 +527,45 @@ static const struct regval_list ov2640_size_change_preamble_regs[] = { { R_DVP_SP, pclk_div }, \ { RESET, 0x00 } -static const struct regval_list ov2640_qcif_regs[] = { +static const struct reg8_info ov2640_qcif_regs[] = { PER_SIZE_REG_SEQ(QCIF_WIDTH, QCIF_HEIGHT, 3, 3, 4), ENDMARKER, }; -static const struct regval_list ov2640_qvga_regs[] = { +static const struct reg8_info ov2640_qvga_regs[] = { PER_SIZE_REG_SEQ(QVGA_WIDTH, QVGA_HEIGHT, 2, 2, 4), ENDMARKER, }; -static const struct regval_list ov2640_cif_regs[] = { +static const struct reg8_info ov2640_cif_regs[] = { PER_SIZE_REG_SEQ(CIF_WIDTH, CIF_HEIGHT, 2, 2, 8), ENDMARKER, }; -static const struct regval_list ov2640_vga_regs[] = { +static const struct reg8_info ov2640_vga_regs[] = { PER_SIZE_REG_SEQ(VGA_WIDTH, VGA_HEIGHT, 0, 0, 2), ENDMARKER, }; -static const struct regval_list ov2640_svga_regs[] = { +static const struct reg8_info ov2640_svga_regs[] = { PER_SIZE_REG_SEQ(SVGA_WIDTH, SVGA_HEIGHT, 1, 1, 2), ENDMARKER, }; -static const struct regval_list ov2640_xga_regs[] = { +static const struct reg8_info ov2640_xga_regs[] = { PER_SIZE_REG_SEQ(XGA_WIDTH, XGA_HEIGHT, 0, 0, 2), { CTRLI, 0x00 }, ENDMARKER, }; -static const struct regval_list ov2640_sxga_regs[] = { +static const struct reg8_info ov2640_sxga_regs[] = { PER_SIZE_REG_SEQ(SXGA_WIDTH, SXGA_HEIGHT, 0, 0, 2), { CTRLI, 0x00 }, { R_DVP_SP, 2 | R_DVP_SP_AUTO_MODE }, ENDMARKER, }; -static const struct regval_list ov2640_uxga_regs[] = { +static const struct reg8_info ov2640_uxga_regs[] = { PER_SIZE_REG_SEQ(UXGA_WIDTH, UXGA_HEIGHT, 0, 0, 0), { CTRLI, 0x00 }, { R_DVP_SP, 0 | R_DVP_SP_AUTO_MODE }, @@ -591,13 +587,13 @@ static const struct ov2640_win_size ov2640_supported_win_sizes[] = { }; /* Register settings for pixel formats */ -static const struct regval_list ov2640_format_change_preamble_regs[] = { +static const struct reg8_info ov2640_format_change_preamble_regs[] = { { BANK_SEL, BANK_SEL_DSP }, { R_BYPASS, R_BYPASS_USE_DSP }, ENDMARKER, }; -static const struct regval_list ov2640_yuyv_regs[] = { +static const struct reg8_info ov2640_yuyv_regs[] = { { IMAGE_MODE, IMAGE_MODE_YUV422 }, { 0xd7, 0x03 }, { 0x33, 0xa0 }, @@ -608,7 +604,7 @@ static const struct regval_list ov2640_yuyv_regs[] = { ENDMARKER, }; -static const struct regval_list ov2640_uyvy_regs[] = { +static const struct reg8_info ov2640_uyvy_regs[] = { { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_YUV422 }, { 0xd7, 0x01 }, { 0x33, 0xa0 }, @@ -618,7 +614,7 @@ static const struct regval_list ov2640_uyvy_regs[] = { ENDMARKER, }; -static const struct regval_list ov2640_rgb565_be_regs[] = { +static const struct reg8_info ov2640_rgb565_be_regs[] = { { IMAGE_MODE, IMAGE_MODE_RGB565 }, { 0xd7, 0x03 }, { RESET, 0x00 }, @@ -626,7 +622,7 @@ static const struct regval_list ov2640_rgb565_be_regs[] = { ENDMARKER, }; -static const struct regval_list ov2640_rgb565_le_regs[] = { +static const struct reg8_info ov2640_rgb565_le_regs[] = { { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_RGB565 }, { 0xd7, 0x03 }, { RESET, 0x00 }, @@ -636,18 +632,7 @@ static const struct regval_list ov2640_rgb565_le_regs[] = { static int ov2640_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) { - u8 buf[2]; - struct rt_i2c_msg msgs; - - buf[0] = reg; - buf[1] = val; - - msgs.addr = OV2640_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 2; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg(i2c, OV2640_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -657,20 +642,7 @@ static int ov2640_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) static int ov2640_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf = reg; - - msg[0].addr = OV2640_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = &buf; - msg[0].len = 1; - - msg[1].addr = OV2640_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg(i2c, OV2640_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -679,14 +651,13 @@ static int ov2640_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) } static int ov2640_write_array(struct rt_i2c_bus_device *i2c, - const struct regval_list *vals) + const struct reg8_info *vals) { int ret; - while ((vals->reg_num != 0xff) || (vals->value != 0xff)) { - ret = ov2640_write_reg(i2c, - vals->reg_num, vals->value); - LOG_D("array: 0x%02x, 0x%02x", vals->reg_num, vals->value); + while ((vals->reg != 0xff) || (vals->val != 0xff)) { + ret = ov2640_write_reg(i2c, vals->reg, vals->val); + LOG_D("array: 0x%02x, 0x%02x", vals->reg, vals->val); if (ret < 0) return ret; @@ -715,7 +686,7 @@ static int ov2640_mask_set(struct rt_i2c_bus_device *i2c, static int ov2640_reset(struct rt_i2c_bus_device *i2c) { int ret = 0; - static const struct regval_list reset_seq[] = { + static const struct reg8_info reset_seq[] = { {BANK_SEL, BANK_SEL_SENS}, {COM7, COM7_SRST}, ENDMARKER, @@ -736,13 +707,16 @@ static void ov2640_set_power(struct ov2640_dev *sensor, int on) if (sensor->power_count == on) return; - if (sensor->pwdn_pin) - rt_pin_write(sensor->pwdn_pin, !on); + if (on) + camera_pin_set_low(sensor->pwdn_pin); + else + camera_pin_set_high(sensor->pwdn_pin); + if (on && sensor->rst_pin) { /* Active the reset pin to perform a reset pulse */ - rt_pin_write(sensor->rst_pin, PIN_LOW); + camera_pin_set_low(sensor->rst_pin); rt_thread_mdelay(5); - rt_pin_write(sensor->rst_pin, PIN_HIGH); + camera_pin_set_high(sensor->rst_pin); } sensor->power_count += on ? 1 : -1; @@ -753,7 +727,7 @@ static void ov2640_set_power(struct ov2640_dev *sensor, int on) static int ov2640_set_params(struct rt_i2c_bus_device *i2c, const struct ov2640_win_size *win, u32 code) { - const struct regval_list *selected_cfmt_regs; + const struct reg8_info *selected_cfmt_regs; u8 val; int ret; @@ -876,37 +850,20 @@ done: return ret; } -static int ov2640_i2c_init(struct ov2640_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->i2c = rt_i2c_bus_device_find(name); - if (sensor->i2c == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - return 0; -} - -static int ov2640_set_xclk(u32 freq) -{ - g_ov2640_dev.xclk_freq = freq; - return 0; -} - static rt_err_t ov2640_init(rt_device_t dev) { int ret = 0; struct ov2640_dev *sensor = &g_ov2640_dev; - ret = ov2640_i2c_init(sensor); - if (ret != 0) + sensor->i2c = camera_i2c_get(); + if (!sensor->i2c) return -RT_EINVAL; - if (ov2640_set_xclk(24000000)) + sensor->xclk_freq = camera_xclk_rate_get(); + if (!sensor->xclk_freq) { + LOG_E("Must set XCLK freq first!\n"); return -RT_EINVAL; + } sensor->win = &ov2640_supported_win_sizes[OV2640_DFT_WIN]; sensor->cfmt_code = OV2640_DFT_CODE; @@ -918,10 +875,10 @@ static rt_err_t ov2640_init(rt_device_t dev) MEDIA_SIGNAL_VSYNC_ACTIVE_LOW | MEDIA_SIGNAL_PCLK_SAMPLE_FALLING; - sensor->rst_pin = rt_pin_get(AIC_CAMERA_RST_PIN); - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - rt_pin_mode(sensor->rst_pin, PIN_MODE_OUTPUT); - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); + sensor->rst_pin = camera_rst_pin_get(); + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->rst_pin || !sensor->pwdn_pin) + return -RT_EINVAL; ret = ov2640_video_probe(sensor); if (ret) diff --git a/bsp/peripheral/camera/ov2659/drv_ov2659.c b/bsp/peripheral/camera/ov2659/drv_ov2659.c index 75bff853..510a5ce5 100644 --- a/bsp/peripheral/camera/ov2659/drv_ov2659.c +++ b/bsp/peripheral/camera/ov2659/drv_ov2659.c @@ -18,6 +18,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" /* Default format configuration of OV2659 */ #define OV2659_DFT_FRAMESIZE OV2659_SIZE_VGA @@ -178,16 +179,11 @@ enum ov2659_size { OV2659_SIZE_UXGA, }; -struct sensor_register { - u16 addr; - u8 value; -}; - struct ov2659_framesize { u16 width; u16 height; u16 max_exp_lines; - const struct sensor_register *regs; + const struct reg16_info *regs; }; struct ov2659_pll_ctrl { @@ -199,7 +195,7 @@ struct ov2659_pll_ctrl { struct ov2659_pixfmt { u32 code; /* Output format Register Value (REG_FORMAT_CTRL00) */ - struct sensor_register *format_ctrl_regs; + struct reg16_info *format_ctrl_regs; }; struct pll_ctrl_reg { @@ -217,7 +213,7 @@ struct ov2659_dev { u32 link_freq; struct mpp_video_fmt fmt; const struct ov2659_framesize *frame_size; - struct sensor_register *format_ctrl_regs; + struct reg16_info *format_ctrl_regs; struct ov2659_pll_ctrl pll; bool streaming; @@ -225,7 +221,7 @@ struct ov2659_dev { static struct ov2659_dev g_ov2659_dev = {0}; -static const struct sensor_register ov2659_init_regs[] = { +static const struct reg16_info ov2659_init_regs[] = { { REG_IO_CTRL00, 0x03 }, { REG_IO_CTRL01, 0xff }, { REG_IO_CTRL02, 0xe0 }, @@ -387,7 +383,7 @@ static const struct sensor_register ov2659_init_regs[] = { }; /* 1280X720 720p */ -static struct sensor_register ov2659_720p[] = { +static struct reg16_info ov2659_720p[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0xa0 }, { REG_TIMING_VS_H, 0x00 }, @@ -422,7 +418,7 @@ static struct sensor_register ov2659_720p[] = { }; /* 1600X1200 UXGA */ -static struct sensor_register ov2659_uxga[] = { +static struct reg16_info ov2659_uxga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -470,7 +466,7 @@ static struct sensor_register ov2659_uxga[] = { }; /* 1280X1024 SXGA */ -static struct sensor_register ov2659_sxga[] = { +static struct reg16_info ov2659_sxga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -518,7 +514,7 @@ static struct sensor_register ov2659_sxga[] = { }; /* 1024X768 SXGA */ -static struct sensor_register ov2659_xga[] = { +static struct reg16_info ov2659_xga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -566,7 +562,7 @@ static struct sensor_register ov2659_xga[] = { }; /* 800X600 SVGA */ -static struct sensor_register ov2659_svga[] = { +static struct reg16_info ov2659_svga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -614,7 +610,7 @@ static struct sensor_register ov2659_svga[] = { }; /* 640X480 VGA */ -static struct sensor_register ov2659_vga[] = { +static struct reg16_info ov2659_vga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -662,7 +658,7 @@ static struct sensor_register ov2659_vga[] = { }; /* 320X240 QVGA */ -static struct sensor_register ov2659_qvga[] = { +static struct reg16_info ov2659_qvga[] = { { REG_TIMING_HS_H, 0x00 }, { REG_TIMING_HS_L, 0x00 }, { REG_TIMING_VS_H, 0x00 }, @@ -785,25 +781,25 @@ static const struct ov2659_framesize ov2659_framesizes[] = { }; /* YUV422 YUYV*/ -static struct sensor_register ov2659_format_yuyv[] = { +static struct reg16_info ov2659_format_yuyv[] = { { REG_FORMAT_CTRL00, 0x30 }, { REG_NULL, 0x0 }, }; /* YUV422 UYVY */ -static struct sensor_register ov2659_format_uyvy[] = { +static struct reg16_info ov2659_format_uyvy[] = { { REG_FORMAT_CTRL00, 0x32 }, { REG_NULL, 0x0 }, }; /* Raw Bayer BGGR */ -static struct sensor_register ov2659_format_bggr[] = { +static struct reg16_info ov2659_format_bggr[] = { { REG_FORMAT_CTRL00, 0x00 }, { REG_NULL, 0x0 }, }; /* RGB565 */ -static struct sensor_register ov2659_format_rgb565[] = { +static struct reg16_info ov2659_format_rgb565[] = { { REG_FORMAT_CTRL00, 0x60 }, { REG_NULL, 0x0 }, }; @@ -826,19 +822,7 @@ static const struct ov2659_pixfmt ov2659_formats[] = { static int ov2659_write_reg(struct rt_i2c_bus_device *i2c, u16 reg, u8 val) { - u8 buf[3]; - struct rt_i2c_msg msgs; - - buf[0] = reg >> 8; - buf[1] = reg & 0xff; - buf[2] = val; - - msgs.addr = OV2659_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 3; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg16(i2c, OV2659_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -848,23 +832,7 @@ static int ov2659_write_reg(struct rt_i2c_bus_device *i2c, u16 reg, u8 val) static int ov2659_read_reg(struct rt_i2c_bus_device *i2c, u16 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf[2] = {0}; - - buf[0] = reg >> 8; - buf[1] = reg & 0xff; - - msg[0].addr = OV2659_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = buf; - msg[0].len = 2; - - msg[1].addr = OV2659_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg16(i2c, OV2659_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -873,12 +841,12 @@ static int ov2659_read_reg(struct rt_i2c_bus_device *i2c, u16 reg, u8 *val) } static int ov2659_write_array(struct rt_i2c_bus_device *i2c, - const struct sensor_register *regs) + const struct reg16_info *regs) { int i, ret = 0; - for (i = 0; ret == 0 && regs[i].addr; i++) - ret = ov2659_write_reg(i2c, regs[i].addr, regs[i].value); + for (i = 0; ret == 0 && regs[i].reg; i++) + ret = ov2659_write_reg(i2c, regs[i].reg, regs[i].val); return ret; } @@ -924,7 +892,7 @@ static void ov2659_pll_calc_params(struct ov2659_dev *sensor) static int ov2659_set_pixel_clock(struct ov2659_dev *sensor) { - struct sensor_register pll_regs[] = { + struct reg16_info pll_regs[] = { {REG_SC_PLL_CTRL1, sensor->pll.ctrl1}, {REG_SC_PLL_CTRL2, sensor->pll.ctrl2}, {REG_SC_PLL_CTRL3, sensor->pll.ctrl3}, @@ -1006,40 +974,20 @@ out: return ret; } -static int ov2659_i2c_init(struct ov2659_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->i2c = rt_i2c_bus_device_find(name); - if (sensor->i2c == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - return 0; -} - -static int ov2659_set_xclk(u32 freq) -{ - g_ov2659_dev.xclk_freq = freq; - return 0; -} - static int ov2659_power_off(struct ov2659_dev *sensor) { - rt_pin_write(sensor->pwdn_pin, 1); + camera_pin_set_high(sensor->pwdn_pin); return 0; } static int ov2659_power_on(struct ov2659_dev *sensor) { - rt_pin_write(sensor->pwdn_pin, 0); + camera_pin_set_low(sensor->pwdn_pin); if (sensor->rst_pin) { - rt_pin_write(sensor->rst_pin, PIN_LOW); + camera_pin_set_low(sensor->rst_pin); rt_thread_mdelay(1); - rt_pin_write(sensor->rst_pin, PIN_HIGH); + camera_pin_set_high(sensor->rst_pin); rt_thread_mdelay(3); } @@ -1084,17 +1032,20 @@ static rt_err_t ov2659_init(rt_device_t dev) int ret = 0; struct ov2659_dev *sensor = &g_ov2659_dev; - ret = ov2659_i2c_init(sensor); - if (ret != 0) + sensor->i2c = camera_i2c_get(); + if (!sensor->i2c) return -RT_EINVAL; - if (ov2659_set_xclk(24000000)) + sensor->xclk_freq = camera_xclk_rate_get(); + if (!sensor->xclk_freq) { + LOG_E("Must set XCLK freq first!\n"); return -RT_EINVAL; + } - sensor->rst_pin = rt_pin_get(AIC_CAMERA_RST_PIN); - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - rt_pin_mode(sensor->rst_pin, PIN_MODE_OUTPUT); - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); + sensor->rst_pin = camera_rst_pin_get(); + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->rst_pin || !sensor->pwdn_pin) + return -RT_EINVAL; ov2659_get_default_format(&sensor->fmt); sensor->frame_size = &ov2659_framesizes[OV2659_DFT_FRAMESIZE]; diff --git a/bsp/peripheral/camera/ov5640/drv_ov5640.c b/bsp/peripheral/camera/ov5640/drv_ov5640.c index f7dececb..f53cb0e2 100644 --- a/bsp/peripheral/camera/ov5640/drv_ov5640.c +++ b/bsp/peripheral/camera/ov5640/drv_ov5640.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * @@ -17,6 +17,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" /* Format configuration of OV5640 */ #define OV5640_MODE OV5640_MODE_VGA_640_480 @@ -568,20 +569,7 @@ static u32 ov5640_ilog2(u32 x) static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val) { - struct rt_i2c_bus_device *client = sensor->iic; - u8 buf[3]; - struct rt_i2c_msg msgs; - - buf[0] = reg >> 8; - buf[1] = reg & 0xff; - buf[2] = val; - - msgs.addr = OV5640_DEFAULT_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 3; - - if (rt_i2c_transfer(client, &msgs, 1) != 1) { + if (rt_i2c_write_reg16(sensor->iic, OV5640_DEFAULT_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -593,24 +581,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val) static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) { - struct rt_i2c_bus_device *client = sensor->iic; - struct rt_i2c_msg msg[2]; - u8 buf[2] = {0}; - - buf[0] = reg >> 8; - buf[1] = reg & 0xff; - - msg[0].addr = OV5640_DEFAULT_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = buf; - msg[0].len = 2; - - msg[1].addr = OV5640_DEFAULT_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(client, msg, 2) != 2) { + if (rt_i2c_read_reg16(sensor->iic, OV5640_DEFAULT_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -623,29 +594,27 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) static int ov5640_read_reg16(struct ov5640_dev *sensor, u16 reg, u16 *val) { - u8 hi = 0, lo = 0; - int ret; + u16 temp = 0; - ret = ov5640_read_reg(sensor, reg, &hi); - if (ret) - return ret; - ret = ov5640_read_reg(sensor, reg + 1, &lo); - if (ret) - return ret; + if (rt_i2c_read_reg16(sensor->iic, OV5640_DEFAULT_SLAVE_ID, reg, (u8 *)&temp, 2) != 2) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, temp); + return -1; + } + *val = (u16)(temp << 8) | (u16)(temp >> 8); - *val = ((u16)hi << 8) | (u16)lo; return 0; } static int ov5640_write_reg16(struct ov5640_dev *sensor, u16 reg, u16 val) { - int ret; + u16 temp = (u16)(val >> 8) | (u16)(val << 8); - ret = ov5640_write_reg(sensor, reg, val >> 8); - if (ret) - return ret; + if (rt_i2c_write_reg16(sensor->iic, OV5640_DEFAULT_SLAVE_ID, reg, (u8 *)&temp, 2) != 2) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); + return -1; + } - return ov5640_write_reg(sensor, reg + 1, val & 0xff); + return 0; } static int ov5640_mod_reg(struct ov5640_dev *sensor, u16 reg, u8 mask, u8 val) @@ -1910,39 +1879,27 @@ out: return ret; } -static int ov5640_iic_init(struct ov5640_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->iic = rt_i2c_bus_device_find(name); - if (sensor->iic == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - sensor->pending_mode_change = true; - return 0; -} - static void ov5640_power(struct ov5640_dev *sensor, bool enable) { #ifndef FPGA_BOARD_ARTINCHIP - rt_pin_write(sensor->pwdn_pin, enable ? 0 : 1); + if (enable) + camera_pin_set_low(sensor->pwdn_pin); + else + camera_pin_set_high(sensor->pwdn_pin); #endif } static int ov5640_set_power_on(struct ov5640_dev *sensor) { #ifndef FPGA_BOARD_ARTINCHIP - rt_pin_write(sensor->rst_pin, PIN_LOW); + camera_pin_set_low(sensor->rst_pin); ov5640_power(sensor, 0); rt_thread_mdelay(10); ov5640_power(sensor, 1); rt_thread_mdelay(10); - rt_pin_write(sensor->rst_pin, PIN_HIGH); + camera_pin_set_high(sensor->rst_pin); rt_thread_mdelay(2); pr_info("power on\n"); #endif @@ -2194,22 +2151,22 @@ power_off: return ret; } -static int ov5640_set_xclk(u32 freq) -{ - g_ov5640_dev.xclk_freq = freq; - return 0; -} - static rt_err_t ov5640_init(rt_device_t dev) { int ret = 0; struct ov5640_dev *sensor = &g_ov5640_dev; - ret = ov5640_iic_init(sensor); - if (ret != 0) + sensor->iic = camera_i2c_get(); + if (!sensor->iic) return -RT_EINVAL; - ov5640_set_xclk(24000000); + sensor->pending_mode_change = true; + + sensor->xclk_freq = camera_xclk_rate_get(); + if (!sensor->xclk_freq) { + LOG_E("Must set XCLK freq first!\n"); + return -RT_EINVAL; + } sensor->current_mode = &ov5640_mode_data[OV5640_MODE]; sensor->last_mode = sensor->current_mode; @@ -2223,10 +2180,10 @@ static rt_err_t ov5640_init(rt_device_t dev) sensor->current_fr = OV5640_FPS; sensor->ae_target = 52; - sensor->rst_pin = rt_pin_get(AIC_CAMERA_RST_PIN); - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - rt_pin_mode(sensor->rst_pin, PIN_MODE_OUTPUT); - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); + sensor->rst_pin = camera_rst_pin_get(); + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->rst_pin || !sensor->pwdn_pin) + return -RT_EINVAL; ret = ov5640_check_chip_id(sensor); if (ret) diff --git a/bsp/peripheral/camera/ov7670/drv_ov7670.c b/bsp/peripheral/camera/ov7670/drv_ov7670.c index cd0af5aa..56f6a807 100644 --- a/bsp/peripheral/camera/ov7670/drv_ov7670.c +++ b/bsp/peripheral/camera/ov7670/drv_ov7670.c @@ -18,6 +18,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" /* Default format configuration of OV7670 */ #define OV7670_DFT_WIN OV7670_WIN_VGA @@ -191,11 +192,6 @@ enum ov7670_model { MODEL_OV7675, }; -struct regval_list { - unsigned char reg_num; - unsigned char value; -}; - struct ov7670_win_size { int width; int height; @@ -204,7 +200,7 @@ struct ov7670_win_size { int hstop; /* that they do not always make complete */ int vstart; /* sense to humans, but evidently the sensor */ int vstop; /* will do the right thing... */ - struct regval_list *regs; /* Regs to tweak */ + struct reg8_info *regs; /* Regs to tweak */ }; struct ov7670_format_struct; /* coming later */ @@ -240,7 +236,7 @@ struct ov7670_devtype { static struct ov7670_dev g_ov7670_dev = {0}; -static struct regval_list ov7670_default_regs[] = { +static struct reg8_info ov7670_default_regs[] = { { REG_COM7, COM7_RESET }, /* * Clock scale: 3 = 15fps @@ -367,7 +363,7 @@ static struct regval_list ov7670_default_regs[] = { * IMPORTANT RULE: the first entry must be for COM7, see ov7670_s_fmt for why. */ -static struct regval_list ov7670_fmt_yuv422[] = { +static struct reg8_info ov7670_fmt_yuv422[] = { { REG_COM7, 0x0 }, /* Selects YUV mode */ { REG_RGB444, 0 }, /* No RGB444 please */ { REG_COM1, 0 }, /* CCIR601 */ @@ -383,7 +379,7 @@ static struct regval_list ov7670_fmt_yuv422[] = { { 0xff, 0xff }, }; -static struct regval_list ov7670_fmt_rgb565[] = { +static struct reg8_info ov7670_fmt_rgb565[] = { { REG_COM7, COM7_RGB }, /* Selects RGB mode */ { REG_RGB444, 0 }, /* No RGB444 please */ { REG_COM1, 0x0 }, /* CCIR601 */ @@ -399,7 +395,7 @@ static struct regval_list ov7670_fmt_rgb565[] = { { 0xff, 0xff }, }; -static struct regval_list ov7670_fmt_rgb444[] = { +static struct reg8_info ov7670_fmt_rgb444[] = { { REG_COM7, COM7_RGB }, /* Selects RGB mode */ { REG_RGB444, R444_ENABLE }, /* Enable xxxxrrrr ggggbbbb */ { REG_COM1, 0x0 }, /* CCIR601 */ @@ -415,7 +411,7 @@ static struct regval_list ov7670_fmt_rgb444[] = { { 0xff, 0xff }, }; -static struct regval_list ov7670_fmt_raw[] = { +static struct reg8_info ov7670_fmt_raw[] = { { REG_COM7, COM7_BAYER }, { REG_COM13, 0x08 }, /* No gamma, magic rsvd bit */ { REG_COM16, 0x3d }, /* Edge enhancement, denoise */ @@ -430,7 +426,7 @@ static struct regval_list ov7670_fmt_raw[] = { */ static struct ov7670_format_struct { u32 mbus_code; - struct regval_list *regs; + struct reg8_info *regs; int cmatrix[CMATRIX_LEN]; } ov7670_formats[] = { { @@ -466,7 +462,7 @@ static struct ov7670_format_struct { * which is allegedly provided by the sensor. So here's the weird register * settings. */ -static struct regval_list ov7670_qcif_regs[] = { +static struct reg8_info ov7670_qcif_regs[] = { { REG_COM3, COM3_SCALEEN|COM3_DCWEN }, { REG_COM3, COM3_DCWEN }, { REG_COM14, COM14_DCWEN | 0x01 }, @@ -551,58 +547,36 @@ static struct ov7670_win_size ov7675_win_sizes[] = { }; static int ov7670_read_reg(struct rt_i2c_bus_device *i2c, unsigned char reg, - unsigned char *value) + unsigned char *val) { - u8 data = reg; - struct rt_i2c_msg msg; - int ret = 0; - - msg.addr = OV7670_I2C_SLAVE_ID; - msg.flags = RT_I2C_WR; - msg.len = 1; - msg.buf = &data; - ret = rt_i2c_transfer(i2c, &msg, 1); - if (ret < 0) { - LOG_E("Error %d on register write\n", ret); - return ret; + if (rt_i2c_read_reg(i2c, OV7670_I2C_SLAVE_ID, reg, val, 1) != 1) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); + return -1; } - msg.flags = RT_I2C_RD; - ret = rt_i2c_transfer(i2c, &msg, 1); - if (ret >= 0) { - *value = data; - ret = 0; - } - return ret; + return 0; } static int ov7670_write_reg(struct rt_i2c_bus_device *i2c, unsigned char reg, - unsigned char value) + unsigned char val) { - struct rt_i2c_msg msg; - unsigned char data[2] = { reg, value }; - int ret = 0; + if (rt_i2c_write_reg(i2c, OV7670_I2C_SLAVE_ID, reg, &val, 1) != 1) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); + return -1; + } - msg.addr = OV7670_I2C_SLAVE_ID; - msg.flags = RT_I2C_WR; - msg.len = 2; - msg.buf = data; - ret = rt_i2c_transfer(i2c, &msg, 1); - if (ret > 0) - ret = 0; - - if (reg == REG_COM7 && (value & COM7_RESET)) + if (reg == REG_COM7 && (val & COM7_RESET)) aicos_msleep(5); /* Wait for reset to run */ - return ret; + + return 0; } /* Write a list of register settings; ff/ff stops the process. */ -static int ov7670_write_array(struct ov7670_dev *sensor, struct regval_list *vals) +static int ov7670_write_array(struct ov7670_dev *sensor, struct reg8_info *vals) { - while (vals->reg_num != 0xff || vals->value != 0xff) { - int ret = ov7670_write_reg(sensor->i2c, vals->reg_num, vals->value); - if (ret < 0) - return ret; + while (vals->reg != 0xff || vals->val != 0xff) { + if (ov7670_write_reg(sensor->i2c, vals->reg, vals->val)) + return -1; vals++; } return 0; @@ -700,7 +674,7 @@ static int ov7670_apply_fmt(struct ov7670_dev *sensor) * to set it absolutely here, as long as the format-specific * register sets list it first. */ - com7 = sensor->ov_fmt->regs[0].value; + com7 = sensor->ov_fmt->regs[0].val; com7 |= wsize->com7_bit; ret = ov7670_write_reg(sensor->i2c, REG_COM7, com7); if (ret) @@ -811,11 +785,11 @@ static void ov7670_power_on(struct ov7670_dev *sensor) return; if (sensor->pwdn_pin) - rt_pin_write(sensor->pwdn_pin, 0); + camera_pin_set_low(sensor->pwdn_pin); if (sensor->rst_pin) { - rt_pin_write(sensor->rst_pin, PIN_LOW); + camera_pin_set_low(sensor->rst_pin); aicos_msleep(1); - rt_pin_write(sensor->rst_pin, PIN_HIGH); + camera_pin_set_high(sensor->rst_pin); } if (sensor->pwdn_pin || sensor->rst_pin || sensor->clk) aicos_msleep(3); @@ -829,7 +803,7 @@ static void ov7670_power_off(struct ov7670_dev *sensor) return; if (sensor->pwdn_pin) - rt_pin_write(sensor->pwdn_pin, 1); + camera_pin_set_high(sensor->pwdn_pin); sensor->on = false; } @@ -863,49 +837,27 @@ static void ov7670_get_default_format(struct ov7670_dev *sensor) MEDIA_SIGNAL_PCLK_SAMPLE_FALLING; } -static int ov7670_i2c_init(struct ov7670_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->i2c = rt_i2c_bus_device_find(name); - if (sensor->i2c == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - return 0; -} - -static int ov7670_set_xclk(u32 freq) -{ - g_ov7670_dev.clock_speed = freq / 1000000; - if (g_ov7670_dev.clock_speed < 10 || g_ov7670_dev.clock_speed > 48) { - LOG_E("xclk rate %d is out of range", g_ov7670_dev.clock_speed); - return -EINVAL; - } - - return 0; -} - static rt_err_t ov7670_init(rt_device_t dev) { int ret = 0; struct ov7670_dev *sensor = &g_ov7670_dev; - ret = ov7670_i2c_init(sensor); - if (ret != 0) + sensor->i2c = camera_i2c_get(); + if (!sensor->i2c) return -RT_EINVAL; - if (ov7670_set_xclk(24000000)) - return -RT_EINVAL; + sensor->clock_speed = camera_xclk_rate_get() / 1000000; + if (sensor->clock_speed < 10 || sensor->clock_speed > 48) { + LOG_E("XCLK rate %d is out of range", sensor->clock_speed); + return -EINVAL; + } ov7670_get_default_format(sensor); - sensor->rst_pin = rt_pin_get(AIC_CAMERA_RST_PIN); - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - rt_pin_mode(sensor->rst_pin, PIN_MODE_OUTPUT); - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); + sensor->rst_pin = camera_rst_pin_get(); + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->rst_pin || !sensor->pwdn_pin) + return -RT_EINVAL; ov7670_power_on(sensor); ret = ov7670_detect(sensor); diff --git a/bsp/peripheral/camera/sc030iot/drv_sc030iot.c b/bsp/peripheral/camera/sc030iot/drv_sc030iot.c index 7d9601b3..51a7e688 100644 --- a/bsp/peripheral/camera/sc030iot/drv_sc030iot.c +++ b/bsp/peripheral/camera/sc030iot/drv_sc030iot.c @@ -31,7 +31,6 @@ #define SC030_SENSOR_ID_HIGH_REG 0xF7 #define SC030_SENSOR_ID_LOW_REG 0xF8 - // 640*480, xclk=20M, fps=50fps, xclk=10M, fps=25fps static const struct reg8_info sc030iot_init_regs[] = { {0xf0, 0x30}, @@ -257,18 +256,7 @@ static struct sc03_dev g_sc03_dev = {0}; static int sc030_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) { - u8 buf[2]; - struct rt_i2c_msg msgs; - - buf[0] = reg; - buf[1] = val; - - msgs.addr = SC030IOT_I2C_SLAVE_ID; - msgs.flags = RT_I2C_WR; - msgs.buf = buf; - msgs.len = 2; - - if (rt_i2c_transfer(i2c, &msgs, 1) != 1) { + if (rt_i2c_write_reg(i2c, SC030IOT_I2C_SLAVE_ID, reg, &val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return -1; } @@ -278,20 +266,7 @@ static int sc030_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val) static int sc030_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val) { - struct rt_i2c_msg msg[2]; - u8 buf = reg; - - msg[0].addr = SC030IOT_I2C_SLAVE_ID; - msg[0].flags = RT_I2C_WR; - msg[0].buf = &buf; - msg[0].len = 1; - - msg[1].addr = SC030IOT_I2C_SLAVE_ID; - msg[1].flags = RT_I2C_RD; - msg[1].buf = val; - msg[1].len = 1; - - if (rt_i2c_transfer(i2c, msg, 2) != 2) { + if (rt_i2c_read_reg(i2c, SC030IOT_I2C_SLAVE_ID, reg, val, 1) != 1) { LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val); return -1; } @@ -332,7 +307,7 @@ static void sc030iot_power_on(struct sc03_dev *sensor) if (sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_HIGH); + camera_pin_set_high(sensor->pwdn_pin); aicos_udelay(2); sensor->on = true; @@ -344,7 +319,7 @@ static void sc030iot_power_off(struct sc03_dev *sensor) if (!sensor->on) return; - rt_pin_write(sensor->pwdn_pin, PIN_LOW); + camera_pin_set_low(sensor->pwdn_pin); sensor->on = false; #endif diff --git a/bsp/peripheral/camera/tp2825b/tp2825bx.c b/bsp/peripheral/camera/tp2825b/tp2825bx.c index 96f46529..71bc1659 100644 --- a/bsp/peripheral/camera/tp2825b/tp2825bx.c +++ b/bsp/peripheral/camera/tp2825b/tp2825bx.c @@ -20,6 +20,7 @@ #include "mpp_vin.h" #include "drv_camera.h" +#include "camera_inner.h" #include "tp2802_def.h" #include "tp2825b.h" @@ -108,65 +109,26 @@ unsigned int ConvertACPV1Data(unsigned char dat) return tmp; } -void tp28xx_byte_write(unsigned char chip, - unsigned char reg_addr, - unsigned char value) +void tp28xx_byte_write(u8 chip, u8 reg, u8 val) { - unsigned char buf[2] = {0}; - struct rt_i2c_bus_device *client = tp28xx_client0; - struct rt_i2c_msg msg = {0}; - int ret = 0; - - // if (id[chip] == 0xffff) return; - - msg.addr = tp2802_i2c_addr[chip]; - msg.flags = RT_I2C_WR; - msg.len = 2; - msg.buf = buf; - - buf[0] = reg_addr; - buf[1] = value; - - ret = rt_i2c_transfer(client, &msg, 1); - if (ret < 0) { - LOG_E("Failed to write I2C. reg 0x%02x, val 0x%x\n", reg_addr, value); + if (rt_i2c_write_reg(tp28xx_client0, tp2802_i2c_addr[chip], reg, &val, 1) != 1) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); return; } + aicos_udelay(300); } -unsigned char tp28xx_byte_read(unsigned char chip, unsigned char reg_addr) +unsigned char tp28xx_byte_read(u8 chip, u8 reg) { - struct rt_i2c_bus_device *client = tp28xx_client0; - struct rt_i2c_msg msg[2] = {{0}}; - unsigned int data_width = 1; - unsigned char buffer[2] = {0}; - unsigned char ret_data = 0xFF; - int ret = 0; + unsigned char val = 0xFF; - //if (id[chip] == 0xffff) return 0xff; - - buffer[0] = reg_addr & 0xFF; - - msg[0].addr = tp2802_i2c_addr[chip]; - msg[0].flags = RT_I2C_WR; - msg[0].len = 1; - msg[0].buf = buffer; - - msg[1].addr = tp2802_i2c_addr[chip]; - msg[1].flags = RT_I2C_RD; - msg[1].len = 1; - msg[1].buf = buffer; - - ret = rt_i2c_transfer(client, msg, 2); - if (ret != 2) { - LOG_E("[%s %d] hi_i2c_transfer error, ret=%d.\n", __FUNCTION__, __LINE__, ret); - return 0xff; + if (rt_i2c_read_reg(tp28xx_client0, tp2802_i2c_addr[chip], reg, &val, 1) != 1) { + LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val); + return 0xFF; } - memcpy(&ret_data, buffer, data_width); - - return ret_data; + return val; } static void tp2802_write_table(unsigned char chip, @@ -2551,38 +2513,24 @@ static int tp2825_s_stream(struct tp2825_dev *sensor, int enable) return SUCCESS; } -static int tp2825_i2c_init(struct tp2825_dev *sensor) -{ - char name[8] = ""; - - snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN); - sensor->i2c = rt_i2c_bus_device_find(name); - if (sensor->i2c == RT_NULL) { - LOG_E("Failed to open %s", name); - return -ENODEV; - } - - return SUCCESS; -} - static rt_err_t tp2825_init(rt_device_t dev) { struct tp2825_dev *sensor = (struct tp2825_dev *)dev; struct mpp_video_fmt *fmt = &sensor->fmt; int ret = 0; - ret = tp2825_i2c_init(sensor); - if (ret != 0) + sensor->i2c = camera_i2c_get(); + if (!sensor->i2c) return -RT_EINVAL; tp28xx_client0 = sensor->i2c; /* request optional power down pin */ - sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN); - if (sensor->pwdn_pin > 0) { - rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT); - rt_pin_write(sensor->pwdn_pin, 1); - } + sensor->pwdn_pin = camera_pwdn_pin_get(); + if (!sensor->pwdn_pin) + return -RT_EINVAL; + + camera_pin_set_high(sensor->pwdn_pin); ret = tp2802_module_init(); if (ret) diff --git a/bsp/peripheral/spinand/xtx.c b/bsp/peripheral/spinand/xtx.c index 1de78228..787f2e09 100644 --- a/bsp/peripheral/spinand/xtx.c +++ b/bsp/peripheral/spinand/xtx.c @@ -51,10 +51,12 @@ const struct aic_spinand_info xtx_spinand_table[] = { /*XT26G01B device*/ { DEVID(0xF1), PAGESIZE(2048), OOBSIZE(64), BPL(1024), PPB(64), PLANENUM(1), DIE(0), "XTX 128MB: 2048+64@64@1024", cmd_cfg_table }, - /*XT26G04D device + /*XT26G04D device */ { DEVID(0x33), PAGESIZE(4096), OOBSIZE(256), BPL(2048), PPB(64), PLANENUM(1), DIE(0), "XTX 512MB: 4096+256@64@2048", cmd_cfg_table, xt26g01c_ecc_get_status}, - */ + /*XT26G02D device */ + { DEVID(0x32), PAGESIZE(2048), OOBSIZE(128), BPL(2048), PPB(64), PLANENUM(1), + DIE(0), "XTX 256MB: 2048+128@64@2048", cmd_cfg_table, xt26g01c_ecc_get_status}, }; const struct aic_spinand_info *xtx_spinand_detect(struct aic_spinand *flash) diff --git a/bsp/peripheral/touch/Kconfig b/bsp/peripheral/touch/Kconfig index e7cbce68..9a0819b4 100644 --- a/bsp/peripheral/touch/Kconfig +++ b/bsp/peripheral/touch/Kconfig @@ -53,22 +53,32 @@ config AIC_TOUCH_PANEL_INT_PIN depends on AIC_USING_CTP config AIC_TOUCH_X_COORDINATE_RANGE - int "Touch x coordinate range" + int "Touch real x coordinate range" default 1024 depends on AIC_USING_CTP config AIC_TOUCH_Y_COORDINATE_RANGE - int "Touch y coordinate range" + int "Touch real y coordinate range" default 600 depends on AIC_USING_CTP -config AIC_TOUCH_X_FILP - bool "Touch filp x coordinate" +config AIC_SCREEN_REAL_X_RESOLUTION + int "Screen real x coordinate range" + default 1024 + depends on AIC_USING_CTP + +config AIC_SCREEN_REAL_Y_RESOLUTION + int "Screen real y coordinate range" + default 600 + depends on AIC_USING_CTP + +config AIC_TOUCH_X_FLIP + bool "Touch flip x coordinate" default n depends on AIC_USING_CTP -config AIC_TOUCH_Y_FILP - bool "Touch filp y coordinate" +config AIC_TOUCH_Y_FLIP + bool "Touch flip y coordinate" default n depends on AIC_USING_CTP @@ -82,17 +92,49 @@ config AIC_TOUCH_270_DEGREE_ROTATION default n depends on AIC_USING_CTP +config AIC_TOUCH_CROP + bool "Enable touch crop" + default n + help + Some Touch need to be cropped, the effective area displayed is less + than the timing signal. + If unsure select "N". + +if AIC_TOUCH_CROP + config AIC_TOUCH_CROP_POS_X + int "Touch crop x position of pixels" + default 0 + + config AIC_TOUCH_CROP_POS_Y + int "Touch crop y position of pixels" + default 0 + + config AIC_TOUCH_CROP_WIDTH + int "Touch crop width" + default 1024 + + config AIC_TOUCH_CROP_HEIGHT + int "Touch crop height" + default 600 +endif + config AIC_TOUCH_REPORT_X_COORDINATE int + default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_90_DEGREE_ROTATION && AIC_TOUCH_CROP + default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_270_DEGREE_ROTATION && AIC_TOUCH_CROP default AIC_TOUCH_Y_COORDINATE_RANGE if AIC_TOUCH_90_DEGREE_ROTATION default AIC_TOUCH_Y_COORDINATE_RANGE if AIC_TOUCH_270_DEGREE_ROTATION + default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_CROP default AIC_TOUCH_X_COORDINATE_RANGE depends on AIC_USING_CTP config AIC_TOUCH_REPORT_Y_COORDINATE int + default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_90_DEGREE_ROTATION && AIC_TOUCH_CROP + default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_270_DEGREE_ROTATION && AIC_TOUCH_CROP default AIC_TOUCH_X_COORDINATE_RANGE if AIC_TOUCH_90_DEGREE_ROTATION default AIC_TOUCH_X_COORDINATE_RANGE if AIC_TOUCH_270_DEGREE_ROTATION + default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_CROP default AIC_TOUCH_Y_COORDINATE_RANGE depends on AIC_USING_CTP diff --git a/bsp/peripheral/touch/SConscript b/bsp/peripheral/touch/SConscript index df5ce022..942bf682 100644 --- a/bsp/peripheral/touch/SConscript +++ b/bsp/peripheral/touch/SConscript @@ -6,6 +6,11 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [] +if GetDepend('AIC_USING_CTP'): + CPPPATH.append(cwd) + CPPPATH.append(cwd + '/common') + src += Glob('common/*.c') + if GetDepend('AIC_TOUCH_PANEL_GT911'): CPPPATH.append(cwd + '/gt911/inc') src += Glob('gt911/src/*.c') diff --git a/bsp/peripheral/touch/common/touch_common.c b/bsp/peripheral/touch/common/touch_common.c new file mode 100644 index 00000000..e3ff1ca2 --- /dev/null +++ b/bsp/peripheral/touch/common/touch_common.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Notes + * 2024-10-18 the first version + */ + +#include "touch_common.h" + +void aic_touch_flip(int16_t *x_coordinate, int16_t *y_coordinate) +{ +#ifdef AIC_TOUCH_X_FLIP + *x_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - *x_coordinate; +#endif +#ifdef AIC_TOUCH_Y_FLIP + *y_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - *y_coordinate; +#endif +} + +void aic_touch_rotate(int16_t *x_coordinate, int16_t *y_coordinate) +{ + rt_uint16_t temp = 0; + temp = temp; +#ifdef AIC_TOUCH_90_DEGREE_ROTATION + temp = *x_coordinate; + *x_coordinate = *y_coordinate; + *y_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - temp; +#endif +#ifdef AIC_TOUCH_270_DEGREE_ROTATION + temp = *x_coordinate; + *x_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - *y_coordinate; + *y_coordinate = temp; +#endif +} + +void aic_touch_scale(int16_t *x_coordinate, int16_t *y_coordinate) +{ +#ifdef AIC_TOUCH_CROP + rt_int32_t temp_x; + rt_int32_t temp_y; + + temp_x = (*x_coordinate) * AIC_SCREEN_REAL_X_RESOLUTION * 10 / AIC_TOUCH_X_COORDINATE_RANGE / 10; + temp_y = (*y_coordinate) * AIC_SCREEN_REAL_Y_RESOLUTION * 10 / AIC_TOUCH_Y_COORDINATE_RANGE / 10; + *x_coordinate = (int16_t)temp_x; + *y_coordinate = (int16_t)temp_y; +#endif +} + + +rt_int8_t aic_touch_crop(int16_t *x_coordinate, int16_t *y_coordinate) +{ +#ifdef AIC_TOUCH_CROP + if (*x_coordinate < AIC_TOUCH_CROP_POS_X || *y_coordinate < AIC_TOUCH_CROP_POS_Y + || *x_coordinate > (AIC_TOUCH_CROP_POS_X + AIC_TOUCH_CROP_WIDTH) + || *y_coordinate > (AIC_TOUCH_CROP_POS_Y + AIC_TOUCH_CROP_HEIGHT)) { + return RT_FALSE; + } + + *x_coordinate -= AIC_TOUCH_CROP_POS_X; + *y_coordinate -= AIC_TOUCH_CROP_POS_Y; +#endif + return RT_TRUE; +} + diff --git a/bsp/peripheral/touch/common/touch_common.h b/bsp/peripheral/touch/common/touch_common.h new file mode 100644 index 00000000..db410382 --- /dev/null +++ b/bsp/peripheral/touch/common/touch_common.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Notes + * 2024-10-18 the first version + */ + +#ifndef __TOUCH_COMMON_H__ +#define __TOUCH_COMMON_H__ + +#include +#include + +void aic_touch_flip(int16_t *x_coordinate, int16_t *y_coordinate); +void aic_touch_rotate(int16_t *x_coordinate, int16_t *y_coordinate); +void aic_touch_scale(int16_t *x_coordinate, int16_t *y_coordinate); +rt_int8_t aic_touch_crop(int16_t *x_coordinate, int16_t *y_coordinate); +#endif diff --git a/bsp/peripheral/touch/gt911/src/gt911.c b/bsp/peripheral/touch/gt911/src/gt911.c index d5bb9e19..2d0993ef 100644 --- a/bsp/peripheral/touch/gt911/src/gt911.c +++ b/bsp/peripheral/touch/gt911/src/gt911.c @@ -17,7 +17,7 @@ #define DBG_TAG "gt911" #define DBG_LVL DBG_INFO #include - +#include "../../common/touch_common.h" #include "gt911.h" static struct rt_i2c_client gt911_client; @@ -318,6 +318,11 @@ static rt_size_t gt911_read_point(struct rt_touch_device *touch, void *buf, input_w = read_buf[off_set + 5] | (read_buf[off_set + 6] << 8); /* size */ + aic_touch_flip(&input_x, &input_y); + aic_touch_rotate(&input_x, &input_y); + aic_touch_scale(&input_x, &input_y); + if (!aic_touch_crop(&input_x, &input_y)) + continue; gt911_touch_down(buf, read_id, input_x, input_y, input_w); } } else if (pre_touch) { diff --git a/bsp/peripheral/wireless/realtek/Kconfig b/bsp/peripheral/wireless/realtek/Kconfig index 7c549054..9cbcd99c 100644 --- a/bsp/peripheral/wireless/realtek/Kconfig +++ b/bsp/peripheral/wireless/realtek/Kconfig @@ -48,4 +48,9 @@ menu "realtek wlan Parameter" config AIC_DEV_REALTEK_DEBUG bool "Enable Realtek driver debug information" default y + + config REALTEK_FULL_FNC_MODE + bool "Enabl Realtek driver full function" + default n + endmenu diff --git a/bsp/peripheral/wireless/realtek/SConscript b/bsp/peripheral/wireless/realtek/SConscript index 2c9abbeb..f62ebe0a 100644 --- a/bsp/peripheral/wireless/realtek/SConscript +++ b/bsp/peripheral/wireless/realtek/SConscript @@ -20,6 +20,10 @@ CPPPATH.append(cwd + '/os/wlan_lwip/') CPPPATH.append(cwd + '/platform/include/') CPPPATH.append(cwd + '/platform/rtwlan_bsp/') +if GetDepend('REALTEK_FULL_FNC_MODE'): + CPPPATH.append(cwd + '/api/wifi/rtw_wpa_supplicant/src/') + CPPPATH.append(cwd + '/api/wifi/rtw_wpa_supplicant/wpa_supplicant/') + if GetDepend('REALTEK_WLAN_INTF_SDIO'): CPPPATH.append(cwd + '/platform/sdio/include/') CPPPATH.append(cwd + '/platform/sdio/') @@ -27,6 +31,9 @@ if GetDepend('REALTEK_WLAN_INTF_SDIO'): src += Glob('api/*.c') src += Glob('api/wifi/*.c') +if GetDepend('REALTEK_FULL_FNC_MODE'): + src += Glob('api/wifi/rtw_wpa_supplicant/wpa_supplicant/*.c') + src += Glob('os/customer_rtos/customer_rtt_service.c') src += Glob('os/os_dep/*.c') src += Glob('os/wlan_lwip/*.c') @@ -44,7 +51,11 @@ if GetDepend('AIC_USING_RTL8733_WLAN0'): if GetDepend('AIC_USING_RTL8189_WLAN0'): wifi_name = 'rtl8189' -lib_name = 'wlan_' + wifi_name + '_'+ rtconfig.CPUNAME +if GetDepend('REALTEK_FULL_FNC_MODE'): + lib_name = 'wlan_' + wifi_name + '_full_'+ rtconfig.CPUNAME +else: + lib_name = 'wlan_' + wifi_name + '_'+ rtconfig.CPUNAME + LIBS = [lib_name] LIBPATH = [cwd + "/wlan_lib/"] diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/os.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/os.h new file mode 100644 index 00000000..9d0b0c73 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/os.h @@ -0,0 +1,592 @@ +/* + * OS specific functions + * Copyright (c) 2005-2009, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef OS_H +#define OS_H + +//#include "basic_types.h" +#include +#include "osdep_service.h" +//#include "customer_rtos/wrapper.h" +#include "utils/rom/rom_wps_os.h" + + +typedef void* xqueue_handle_t; + +typedef long os_time_t; + +typedef _timer os_timer; + +/** + * os_sleep - Sleep (sec, usec) + * @sec: Number of seconds to sleep + * @usec: Number of microseconds to sleep + */ +void os_sleep(os_time_t sec, os_time_t usec); + +struct os_time { + os_time_t sec; + os_time_t usec; +}; + +struct os_reltime { + os_time_t sec; + os_time_t usec; +}; + +/** + * os_get_time - Get current time (sec, usec) + * @t: Pointer to buffer for the time + * Returns: 0 on success, -1 on failure + */ +int os_get_time(struct os_time *t); + +int os_get_reltime(struct os_reltime *t); +/* Helper macros for handling struct os_time */ +/* (&timeout->time, &tmp->time) */ +#define os_time_before(a, b) \ + ((a)->sec < (b)->sec || \ + ((a)->sec == (b)->sec && (a)->usec < (b)->usec)) + +#define os_time_sub(a, b, res) do { \ + (res)->sec = (a)->sec - (b)->sec; \ + (res)->usec = (a)->usec - (b)->usec; \ + if ((res)->usec < 0) { \ + (res)->sec--; \ + (res)->usec += 1000000; \ + } \ +} while (0) + +/** + * os_mktime - Convert broken-down time into seconds since 1970-01-01 + * @year: Four digit year + * @month: Month (1 .. 12) + * @day: Day of month (1 .. 31) + * @hour: Hour (0 .. 23) + * @min: Minute (0 .. 59) + * @sec: Second (0 .. 60) + * @t: Buffer for returning calendar time representation (seconds since + * 1970-01-01 00:00:00) + * Returns: 0 on success, -1 on failure + * + * Note: The result is in seconds from Epoch, i.e., in UTC, not in local time + * which is used by POSIX mktime(). + */ +int os_mktime(int year, int month, int day, int hour, int min, int sec, + os_time_t *t); + +struct os_tm { + int sec; /* 0..59 or 60 for leap seconds */ + int min; /* 0..59 */ + int hour; /* 0..23 */ + int day; /* 1..31 */ + int month; /* 1..12 */ + int year; /* Four digit year */ +}; + +int os_gmtime(os_time_t t, struct os_tm *tm); + +/* Helpers for handling struct os_time */ + +/* Helpers for handling struct os_reltime */ + +static inline int os_reltime_before(struct os_reltime *a, + struct os_reltime *b) +{ + return os_time_before(a,b); +} + + +static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b, + struct os_reltime *res) +{ + os_time_sub(a,b,res); +} + + +static inline void os_reltime_age(struct os_reltime *start, + struct os_reltime *age) +{ + struct os_reltime now; + + os_get_time((struct os_time *)&now); + os_reltime_sub(&now, start, age); +} + + +static inline int os_reltime_expired(struct os_reltime *now, + struct os_reltime *ts, + os_time_t timeout_secs) +{ + struct os_reltime age; + + os_reltime_sub(now, ts, &age); + return (age.sec > timeout_secs) || + (age.sec == timeout_secs && age.usec > 0); +} + +/** + * os_daemonize - Run in the background (detach from the controlling terminal) + * @pid_file: File name to write the process ID to or %NULL to skip this + * Returns: 0 on success, -1 on failure + */ +int os_daemonize(const char *pid_file); + +/** + * os_daemonize_terminate - Stop running in the background (remove pid file) + * @pid_file: File name to write the process ID to or %NULL to skip this + */ +void os_daemonize_terminate(const char *pid_file); + +/** + * os_get_random - Get cryptographically strong pseudo random data + * @buf: Buffer for pseudo random data + * @len: Length of the buffer + * Returns: 0 on success, -1 on failure + */ +int os_get_random(unsigned char *buf, size_t len); + +/** + * os_random - Get pseudo random value (not necessarily very strong) + * Returns: Pseudo random value + */ +unsigned long os_random(void); + +/** + * os_rel2abs_path - Get an absolute path for a file + * @rel_path: Relative path to a file + * Returns: Absolute path for the file or %NULL on failure + * + * This function tries to convert a relative path of a file to an absolute path + * in order for the file to be found even if current working directory has + * changed. The returned value is allocated and caller is responsible for + * freeing it. It is acceptable to just return the same path in an allocated + * buffer, e.g., return strdup(rel_path). This function is only used to find + * configuration files when os_daemonize() may have changed the current working + * directory and relative path would be pointing to a different location. + */ +char * os_rel2abs_path(const char *rel_path); + +/** + * os_program_init - Program initialization (called at start) + * Returns: 0 on success, -1 on failure + * + * This function is called when a programs starts. If there are any OS specific + * processing that is needed, it can be placed here. It is also acceptable to + * just return 0 if not special processing is needed. + */ +int os_program_init(void); + +/** + * os_program_deinit - Program deinitialization (called just before exit) + * + * This function is called just before a program exists. If there are any OS + * specific processing, e.g., freeing resourced allocated in os_program_init(), + * it should be done here. It is also acceptable for this function to do + * nothing. + */ +void os_program_deinit(void); + +/** + * os_setenv - Set environment variable + * @name: Name of the variable + * @value: Value to set to the variable + * @overwrite: Whether existing variable should be overwritten + * Returns: 0 on success, -1 on error + * + * This function is only used for wpa_cli action scripts. OS wrapper does not + * need to implement this if such functionality is not needed. + */ +int os_setenv(const char *name, const char *value, int overwrite); + +/** + * os_unsetenv - Delete environent variable + * @name: Name of the variable + * Returns: 0 on success, -1 on error + * + * This function is only used for wpa_cli action scripts. OS wrapper does not + * need to implement this if such functionality is not needed. + */ +int os_unsetenv(const char *name); + +/** + * os_readfile - Read a file to an allocated memory buffer + * @name: Name of the file to read + * @len: For returning the length of the allocated buffer + * Returns: Pointer to the allocated buffer or %NULL on failure + * + * This function allocates memory and reads the given file to this buffer. Both + * binary and text files can be read with this function. The caller is + * responsible for freeing the returned buffer with os_free(). + */ +char * os_readfile(const char *name, size_t *len); + +//#if 0 +/** + * os_zalloc - Allocate and zero memory + * @size: Number of bytes to allocate + * Returns: Pointer to allocated and zeroed memory or %NULL on failure + * + * Caller is responsible for freeing the returned buffer with os_free(). + */ +void * os_zalloc(size_t size); + +/** + * os_calloc - Allocate and zero memory for an array + * @nmemb: Number of members in the array + * @size: Number of bytes in each member + * Returns: Pointer to allocated and zeroed memory or %NULL on failure + * + * This function can be used as a wrapper for os_zalloc(nmemb * size) when an + * allocation is used for an array. The main benefit over os_zalloc() is in + * having an extra check to catch integer overflows in multiplication. + * + * Caller is responsible for freeing the returned buffer with os_free(). + */ +static inline void * os_calloc(size_t nmemb, size_t size) +{ + if (size && nmemb > (~(size_t) 0) / size) + return NULL; + return os_zalloc(nmemb * size); +} +//#endif + + +static inline int os_memcmp_const(const void *a, const void *b, size_t len) +{ + const u8 *aa = a; + const u8 *bb = b; + size_t i; + u8 res; + + for (res = 0, i = 0; i < len; i++) + res |= aa[i] ^ bb[i]; + + return res; +} + +/* + * The following functions are wrapper for standard ANSI C or POSIX functions. + * By default, they are just defined to use the standard function name and no + * os_*.c implementation is needed for them. This avoids extra function calls + * by allowing the C pre-processor take care of the function name mapping. + * + * If the target system uses a C library that does not provide these functions, + * build_config.h can be used to define the wrappers to use a different + * function name. This can be done on function-by-function basis since the + * defines here are only used if build_config.h does not define the os_* name. + * If needed, os_*.c file can be used to implement the functions that are not + * included in the C library on the target system. Alternatively, + * OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case + * these functions need to be implemented in os_*.c file for the target system. + */ + +#ifdef OS_NO_C_LIB_DEFINES + +/** + * os_malloc - Allocate dynamic memory + * @size: Size of the buffer to allocate + * Returns: Allocated buffer or %NULL on failure + * + * Caller is responsible for freeing the returned buffer with os_free(). + */ +void * os_malloc(size_t size); + +/** + * os_realloc - Re-allocate dynamic memory + * @ptr: Old buffer from os_malloc() or os_realloc() + * @size: Size of the new buffer + * Returns: Allocated buffer or %NULL on failure + * + * Caller is responsible for freeing the returned buffer with os_free(). + * If re-allocation fails, %NULL is returned and the original buffer (ptr) is + * not freed and caller is still responsible for freeing it. + */ +void * os_realloc(void *ptr, size_t size); + +/** + * os_free - Free dynamic memory + * @ptr: Old buffer from os_malloc() or os_realloc(); can be %NULL + */ +void os_free(void *ptr); + +/** + * os_memcpy - Copy memory area + * @dest: Destination + * @src: Source + * @n: Number of bytes to copy + * Returns: dest + * + * The memory areas src and dst must not overlap. os_memmove() can be used with + * overlapping memory. + */ +void * os_memcpy(void *dest, const void *src, size_t n); + +/** + * os_memmove - Copy memory area + * @dest: Destination + * @src: Source + * @n: Number of bytes to copy + * Returns: dest + * + * The memory areas src and dst may overlap. + */ +void *os_memmove(void *dest, const void *src, size_t n); + +/** + * os_memset - Fill memory with a constant byte + * @s: Memory area to be filled + * @c: Constant byte + * @n: Number of bytes started from s to fill with c + * Returns: s + */ +void *os_memset(void *s, int c, size_t n); + +/** + * os_memcmp - Compare memory areas + * @s1: First buffer + * @s2: Second buffer + * @n: Maximum numbers of octets to compare + * Returns: An integer less than, equal to, or greater than zero if s1 is + * found to be less than, to match, or be greater than s2. Only first n + * characters will be compared. + */ +int os_memcmp(const void *s1, const void *s2, size_t n); + +/** + * os_strdup - Duplicate a string + * @s: Source string + * Returns: Allocated buffer with the string copied into it or %NULL on failure + * + * Caller is responsible for freeing the returned buffer with os_free(). + */ +char *os_strdup(const char *s); + +/** + * os_strlen - Calculate the length of a string + * @s: '\0' terminated string + * Returns: Number of characters in s (not counting the '\0' terminator) + */ +size_t os_strlen(const char *s); + +/** + * os_strcasecmp - Compare two strings ignoring case + * @s1: First string + * @s2: Second string + * Returns: An integer less than, equal to, or greater than zero if s1 is + * found to be less than, to match, or be greatred than s2 + */ +int os_strcasecmp(const char *s1, const char *s2); + +/** + * os_strncasecmp - Compare two strings ignoring case + * @s1: First string + * @s2: Second string + * @n: Maximum numbers of characters to compare + * Returns: An integer less than, equal to, or greater than zero if s1 is + * found to be less than, to match, or be greater than s2. Only first n + * characters will be compared. + */ +int os_strncasecmp(const char *s1, const char *s2, size_t n); + +/** + * os_strchr - Locate the first occurrence of a character in string + * @s: String + * @c: Character to search for + * Returns: Pointer to the matched character or %NULL if not found + */ +char *os_strchr(const char *s, int c); + +/** + * os_strrchr - Locate the last occurrence of a character in string + * @s: String + * @c: Character to search for + * Returns: Pointer to the matched character or %NULL if not found + */ +char *os_strrchr(const char *s, int c); + +/** + * os_strcmp - Compare two strings + * @s1: First string + * @s2: Second string + * Returns: An integer less than, equal to, or greater than zero if s1 is + * found to be less than, to match, or be greatred than s2 + */ +int os_strcmp(const char *s1, const char *s2); + +/** + * os_strncmp - Compare two strings + * @s1: First string + * @s2: Second string + * @n: Maximum numbers of characters to compare + * Returns: An integer less than, equal to, or greater than zero if s1 is + * found to be less than, to match, or be greater than s2. Only first n + * characters will be compared. + */ +int os_strncmp(const char *s1, const char *s2, size_t n); + +/** + * os_strncpy - Copy a string + * @dest: Destination + * @src: Source + * @n: Maximum number of characters to copy + * Returns: dest + */ +char *os_strncpy(char *dest, const char *src, size_t n); + +/** + * os_strstr - Locate a substring + * @haystack: String (haystack) to search from + * @needle: Needle to search from haystack + * Returns: Pointer to the beginning of the substring or %NULL if not found + */ +char *os_strstr(const char *haystack, const char *needle); + +/** + * os_snprintf - Print to a memory buffer + * @str: Memory buffer to print into + * @size: Maximum length of the str buffer + * @format: printf format + * Returns: Number of characters printed (not including trailing '\0'). + * + * If the output buffer is truncated, number of characters which would have + * been written is returned. Since some C libraries return -1 in such a case, + * the caller must be prepared on that value, too, to indicate truncation. + * + * Note: Some C library implementations of snprintf() may not guarantee null + * termination in case the output is truncated. The OS wrapper function of + * os_snprintf() should provide this guarantee, i.e., to null terminate the + * output buffer if a C library version of the function is used and if that + * function does not guarantee null termination. + * + * If the target system does not include snprintf(), see, e.g., + * http://www.ijs.si/software/snprintf/ for an example of a portable + * implementation of snprintf. + */ +int os_snprintf(char *str, size_t size, const char *format, ...); + +#else /* OS_NO_C_LIB_DEFINES */ + +#ifdef CONFIG_MEM_MONITOR + u8* os_malloc(u32 sz); + void os_mfree(u8 *pbuf, u32 sz); + #ifndef os_free + #define os_free(p, sz) os_mfree(((u8*)(p)), (sz)) + #endif +#else + #ifndef os_malloc + #define os_malloc(sz) _rtw_malloc(sz) + #endif + #ifndef os_free + #define os_free(p, sz) _rtw_mfree(((u8*)(p)), (sz)) + #endif +#endif + extern void *os_zalloc(size_t size); + extern char *os_strdup(const char *string_copy_from); + + #ifndef os_sleep + #define os_sleep(s, us) rtw_mdelay_os((s)*1000 + (us)/1000) + #endif + #ifndef os_memcpy + #define os_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n)) + #endif + #ifndef os_memmove + #define os_memmove(d, s, n) memmove((d), (s), (n)) + #endif + #ifndef os_memset + #define os_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz) + #endif + #ifndef os_memcmp + #define os_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n)) + #endif + #ifndef os_memcmp_p2p + #define os_memcmp_p2p(s1, s2, n) memcmp((s1), (s2), (n)) + #endif + #ifndef os_get_random_bytes + #define os_get_random_bytes(d,sz) rtw_get_random_bytes(((void*)(d)), (sz)) + #endif + #ifndef os_strlen + #define os_strlen(s) strlen(s) + #endif + #ifndef os_strcasecmp + #ifdef _MSC_VER + #define os_strcasecmp(s1, s2) _stricmp((s1), (s2)) + #else + #define os_strcasecmp(s1, s2) strcasecmp((s1), (s2)) + #endif + #endif + #ifndef os_strncasecmp + #ifdef _MSC_VER + #define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n)) + #else + #define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n)) + #endif + #endif + #ifndef os_init_timer + #define os_init_timer(t, p, f, x, n) rtw_init_timer((t), (p), (f), (x), (n)) + #endif + #ifndef os_set_timer + #define os_set_timer(t, d) rtw_set_timer((t), (d)) + #endif + #ifndef os_cancel_timer + #define os_cancel_timer(t) rtw_cancel_timer(t) + #endif + #ifndef os_del_timer + #define os_del_timer(t) rtw_del_timer(t) + #endif + #ifndef os_atoi + #define os_atoi(s) rtw_atoi(s) + #endif + +#ifndef os_strchr +#define os_strchr(s, c) strchr((s), (c)) +#endif +#ifndef os_strcmp +#define os_strcmp(s1, s2) strcmp((s1), (s2)) +#endif +#ifndef os_strncmp +#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n)) +#endif +#ifndef os_strncpy +#define os_strncpy(d, s, n) strncpy((d), (s), (n)) +#endif +#ifndef os_strrchr +#define os_strrchr(s, c) strrchr((s), (c)) +#endif +#ifndef os_strstr +#define os_strstr(h, n) strstr((h), (n)) +#endif + +#ifndef os_snprintf + #ifdef _MSC_VER + #define os_snprintf _snprintf + #else + #define os_snprintf snprintf + #endif +#endif + +#endif /* OS_NO_C_LIB_DEFINES */ + + +static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size) +{ + if (size && nmemb > (~(size_t) 0) / size) + return NULL; + return os_realloc(ptr, nmemb * size, nmemb * size); +} + +void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize) ; + +int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait); + +void os_xqueue_delete(xqueue_handle_t xQueue ); + +int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait); + + +#endif /* OS_H */ diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/rom/rom_wps_os.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/rom/rom_wps_os.h new file mode 100644 index 00000000..b1d668e3 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/utils/rom/rom_wps_os.h @@ -0,0 +1,15 @@ +/* + * OS specific functions + * Copyright (c) 2005-2009, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef ROM_WPS_OS_H +#define ROM_WPS_OS_H + +extern u8 *WPS_realloc(u8 *old_buf, u32 old_sz, u32 new_sz); +#define os_realloc(p, os, ns) WPS_realloc(((u8*)(p)),(os),(ns)) + +#endif /* ROM_WPS_OS_H */ diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/wps/wps_defs.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/wps/wps_defs.h new file mode 100644 index 00000000..3f0c15c7 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/src/wps/wps_defs.h @@ -0,0 +1,324 @@ + +/* + * Wi-Fi Protected Setup - message definitions + * Copyright (c) 2008, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef WPS_DEFS_H +#define WPS_DEFS_H + +#if CONFIG_WPS2 +#define WPS_VERSION 0x20 +#else /* CONFIG_WPS2 */ +#define WPS_VERSION 0x10 +#endif /* CONFIG_WPS2 */ + +/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */ +#define WPS_DH_GROUP (5) + +#define WPS_UUID_LEN (16) +#define WPS_NONCE_LEN (16) +#define WPS_AUTHENTICATOR_LEN (8) +#define WPS_AUTHKEY_LEN (32) +#define WPS_KEYWRAPKEY_LEN (16) +#define WPS_EMSK_LEN (32) +#define WPS_PSK_LEN (16) +#define WPS_SECRET_NONCE_LEN (16) +#define WPS_HASH_LEN (32) +#define WPS_KWA_LEN (8) +#define WPS_MGMTAUTHKEY_LEN (32) +#define WPS_MGMTENCKEY_LEN (16) +#define WPS_MGMT_KEY_ID_LEN (16) +#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN (16) +#define WPS_OOB_DEVICE_PASSWORD_LEN (32) +#define WPS_OOB_PUBKEY_HASH_LEN (20) + +/* Attribute Types */ +enum wps_attribute { + ATTR_AP_CHANNEL = 0x1001, + ATTR_ASSOC_STATE = 0x1002, + ATTR_AUTH_TYPE = 0x1003, + ATTR_AUTH_TYPE_FLAGS = 0x1004, + ATTR_AUTHENTICATOR = 0x1005, + ATTR_CONFIG_METHODS = 0x1008, + ATTR_CONFIG_ERROR = 0x1009, + ATTR_CONFIRM_URL4 = 0x100a, + ATTR_CONFIRM_URL6 = 0x100b, + ATTR_CONN_TYPE = 0x100c, + ATTR_CONN_TYPE_FLAGS = 0x100d, + ATTR_CRED = 0x100e, + ATTR_ENCR_TYPE = 0x100f, + ATTR_ENCR_TYPE_FLAGS = 0x1010, + ATTR_DEV_NAME = 0x1011, + ATTR_DEV_PASSWORD_ID = 0x1012, + ATTR_E_HASH1 = 0x1014, + ATTR_E_HASH2 = 0x1015, + ATTR_E_SNONCE1 = 0x1016, + ATTR_E_SNONCE2 = 0x1017, + ATTR_ENCR_SETTINGS = 0x1018, + ATTR_ENROLLEE_NONCE = 0x101a, + ATTR_FEATURE_ID = 0x101b, + ATTR_IDENTITY = 0x101c, + ATTR_IDENTITY_PROOF = 0x101d, + ATTR_KEY_WRAP_AUTH = 0x101e, + ATTR_KEY_ID = 0x101f, + ATTR_MAC_ADDR = 0x1020, + ATTR_MANUFACTURER = 0x1021, + ATTR_MSG_TYPE = 0x1022, + ATTR_MODEL_NAME = 0x1023, + ATTR_MODEL_NUMBER = 0x1024, + ATTR_NETWORK_INDEX = 0x1026, + ATTR_NETWORK_KEY = 0x1027, + ATTR_NETWORK_KEY_INDEX = 0x1028, + ATTR_NEW_DEVICE_NAME = 0x1029, + ATTR_NEW_PASSWORD = 0x102a, + ATTR_OOB_DEVICE_PASSWORD = 0x102c, + ATTR_OS_VERSION = 0x102d, + ATTR_POWER_LEVEL = 0x102f, + ATTR_PSK_CURRENT = 0x1030, + ATTR_PSK_MAX = 0x1031, + ATTR_PUBLIC_KEY = 0x1032, + ATTR_RADIO_ENABLE = 0x1033, + ATTR_REBOOT = 0x1034, + ATTR_REGISTRAR_CURRENT = 0x1035, + ATTR_REGISTRAR_ESTABLISHED = 0x1036, + ATTR_REGISTRAR_LIST = 0x1037, + ATTR_REGISTRAR_MAX = 0x1038, + ATTR_REGISTRAR_NONCE = 0x1039, + ATTR_REQUEST_TYPE = 0x103a, + ATTR_RESPONSE_TYPE = 0x103b, + ATTR_RF_BANDS = 0x103c, + ATTR_R_HASH1 = 0x103d, + ATTR_R_HASH2 = 0x103e, + ATTR_R_SNONCE1 = 0x103f, + ATTR_R_SNONCE2 = 0x1040, + ATTR_SELECTED_REGISTRAR = 0x1041, + ATTR_SERIAL_NUMBER = 0x1042, + ATTR_WPS_STATE = 0x1044, + ATTR_SSID = 0x1045, + ATTR_TOTAL_NETWORKS = 0x1046, + ATTR_UUID_E = 0x1047, + ATTR_UUID_R = 0x1048, + ATTR_VENDOR_EXT = 0x1049, + ATTR_VERSION = 0x104a, + ATTR_X509_CERT_REQ = 0x104b, + ATTR_X509_CERT = 0x104c, + ATTR_EAP_IDENTITY = 0x104d, + ATTR_MSG_COUNTER = 0x104e, + ATTR_PUBKEY_HASH = 0x104f, + ATTR_REKEY_KEY = 0x1050, + ATTR_KEY_LIFETIME = 0x1051, + ATTR_PERMITTED_CFG_METHODS = 0x1052, + ATTR_SELECTED_REGISTRAR_CONFIG_METHODS = 0x1053, + ATTR_PRIMARY_DEV_TYPE = 0x1054, + ATTR_SECONDARY_DEV_TYPE_LIST = 0x1055, + ATTR_PORTABLE_DEV = 0x1056, + ATTR_AP_SETUP_LOCKED = 0x1057, + ATTR_APPLICATION_EXT = 0x1058, + ATTR_EAP_TYPE = 0x1059, + ATTR_IV = 0x1060, + ATTR_KEY_PROVIDED_AUTO = 0x1061, + ATTR_802_1X_ENABLED = 0x1062, + ATTR_APPSESSIONKEY = 0x1063, + ATTR_WEPTRANSMITKEY = 0x1064, + ATTR_REQUESTED_DEV_TYPE = 0x106a, + ATTR_EXTENSIBILITY_TEST = 0x10fa /* _NOT_ defined in the spec */ +}; + +#define WPS_VENDOR_ID_WFA 14122 + +/* WFA Vendor Extension subelements */ +enum { + WFA_ELEM_VERSION2 = 0x00, + WFA_ELEM_AUTHORIZEDMACS = 0x01, + WFA_ELEM_NETWORK_KEY_SHAREABLE = 0x02, + WFA_ELEM_REQUEST_TO_ENROLL = 0x03, + WFA_ELEM_SETTINGS_DELAY_TIME = 0x04 +}; + +/* Device Password ID */ +enum wps_dev_password_id { + DEV_PW_DEFAULT = 0x0000, + DEV_PW_USER_SPECIFIED = 0x0001, + DEV_PW_MACHINE_SPECIFIED = 0x0002, + DEV_PW_REKEY = 0x0003, + DEV_PW_PUSHBUTTON = 0x0004, + DEV_PW_REGISTRAR_SPECIFIED = 0x0005 +}; + +/* Message Type */ +enum wps_msg_type { + WPS_START = 0x00, + WPS_Beacon = 0x01, + WPS_ProbeRequest = 0x02, + WPS_ProbeResponse = 0x03, + WPS_M1 = 0x04, + WPS_M2 = 0x05, + WPS_M2D = 0x06, + WPS_M3 = 0x07, + WPS_M4 = 0x08, + WPS_M5 = 0x09, + WPS_M6 = 0x0a, + WPS_M7 = 0x0b, + WPS_M8 = 0x0c, + WPS_WSC_ACK = 0x0d, + WPS_WSC_NACK = 0x0e, + WPS_WSC_DONE = 0x0f +}; + +/* Authentication Type Flags */ +#define WPS_AUTH_OPEN 0x0001 +#define WPS_AUTH_WPAPSK 0x0002 +#define WPS_AUTH_SHARED 0x0004 +#define WPS_AUTH_WPA 0x0008 +#define WPS_AUTH_WPA2 0x0010 +#define WPS_AUTH_WPA2PSK 0x0020 +#define WPS_AUTH_TYPES (WPS_AUTH_OPEN | WPS_AUTH_WPAPSK | WPS_AUTH_SHARED | \ + WPS_AUTH_WPA | WPS_AUTH_WPA2 | WPS_AUTH_WPA2PSK) + +/* Encryption Type Flags */ +#define WPS_ENCR_NONE 0x0001 +#define WPS_ENCR_WEP 0x0002 +#define WPS_ENCR_TKIP 0x0004 +#define WPS_ENCR_AES 0x0008 +#define WPS_ENCR_TYPES (WPS_ENCR_NONE | WPS_ENCR_WEP | WPS_ENCR_TKIP | \ + WPS_ENCR_AES) + +/* Configuration Error */ +enum wps_config_error { + WPS_CFG_NO_ERROR = 0, + WPS_CFG_OOB_IFACE_READ_ERROR = 1, + WPS_CFG_DECRYPTION_CRC_FAILURE = 2, + WPS_CFG_24_CHAN_NOT_SUPPORTED = 3, + WPS_CFG_50_CHAN_NOT_SUPPORTED = 4, + WPS_CFG_SIGNAL_TOO_WEAK = 5, + WPS_CFG_NETWORK_AUTH_FAILURE = 6, + WPS_CFG_NETWORK_ASSOC_FAILURE = 7, + WPS_CFG_NO_DHCP_RESPONSE = 8, + WPS_CFG_FAILED_DHCP_CONFIG = 9, + WPS_CFG_IP_ADDR_CONFLICT = 10, + WPS_CFG_NO_CONN_TO_REGISTRAR = 11, + WPS_CFG_MULTIPLE_PBC_DETECTED = 12, + WPS_CFG_ROGUE_SUSPECTED = 13, + WPS_CFG_DEVICE_BUSY = 14, + WPS_CFG_SETUP_LOCKED = 15, + WPS_CFG_MSG_TIMEOUT = 16, + WPS_CFG_REG_SESS_TIMEOUT = 17, + WPS_CFG_DEV_PASSWORD_AUTH_FAILURE = 18 +}; + +/* RF Bands */ +#define WPS_RF_24GHZ (0x01) +#define WPS_RF_50GHZ (0x02) + +/* Config Methods */ +#define WPS_CONFIG_USBA (0x0001) +#define WPS_CONFIG_ETHERNET (0x0002) +#define WPS_CONFIG_LABEL (0x0004) +#define WPS_CONFIG_DISPLAY (0x0008) +#define WPS_CONFIG_EXT_NFC_TOKEN (0x0010) +#define WPS_CONFIG_INT_NFC_TOKEN (0x0020) +#define WPS_CONFIG_NFC_INTERFACE (0x0040) +#define WPS_CONFIG_PUSHBUTTON (0x0080) +#define WPS_CONFIG_KEYPAD (0x0100) + +#if CONFIG_WPS2 +#define WPS_CONFIG_VIRT_PUSHBUTTON (0x0280) +#define WPS_CONFIG_PHY_PUSHBUTTON (0x0480) +#define WPS_CONFIG_VIRT_DISPLAY (0x2008) +#define WPS_CONFIG_PHY_DISPLAY (0x4008) +#endif /* CONFIG_WPS2 */ + +/* Connection Type Flags */ +#define WPS_CONN_ESS (0x01) +#define WPS_CONN_IBSS (0x02) + +/* Wi-Fi Protected Setup State */ +enum wps_state { + WPS_STATE_NOT_CONFIGURED = 1, + WPS_STATE_CONFIGURED = 2 +}; + +/* Association State */ +enum wps_assoc_state { + WPS_ASSOC_NOT_ASSOC = 0, + WPS_ASSOC_CONN_SUCCESS = 1, + WPS_ASSOC_CFG_FAILURE = 2, + WPS_ASSOC_FAILURE = 3, + WPS_ASSOC_IP_FAILURE = 4 +}; + + +#define WPS_DEV_OUI_WFA (0x0050f204) + +enum wps_dev_categ { + WPS_DEV_COMPUTER = 1, + WPS_DEV_INPUT = 2, + WPS_DEV_PRINTER = 3, + WPS_DEV_CAMERA = 4, + WPS_DEV_STORAGE = 5, + WPS_DEV_NETWORK_INFRA = 6, + WPS_DEV_DISPLAY = 7, + WPS_DEV_MULTIMEDIA = 8, + WPS_DEV_GAMING = 9, + WPS_DEV_PHONE = 10 +}; + +enum wps_dev_subcateg { + WPS_DEV_COMPUTER_PC = 1, + WPS_DEV_COMPUTER_SERVER = 2, + WPS_DEV_COMPUTER_MEDIA_CENTER = 3, + + WPS_DEV_PRINTER_PRINTER = 1, + WPS_DEV_PRINTER_SCANNER = 2, + + WPS_DEV_CAMERA_DIGITAL_STILL_CAMERA = 1, + + WPS_DEV_STORAGE_NAS = 1, + + WPS_DEV_NETWORK_INFRA_AP = 1, + WPS_DEV_NETWORK_INFRA_ROUTER = 2, + WPS_DEV_NETWORK_INFRA_SWITCH = 3, + + WPS_DEV_DISPLAY_TV = 1, + WPS_DEV_DISPLAY_PICTURE_FRAME = 2, + WPS_DEV_DISPLAY_PROJECTOR = 3, + + WPS_DEV_MULTIMEDIA_DAR = 1, + WPS_DEV_MULTIMEDIA_PVR = 2, + WPS_DEV_MULTIMEDIA_MCX = 3, + + WPS_DEV_GAMING_XBOX = 1, + WPS_DEV_GAMING_XBOX360 = 2, + WPS_DEV_GAMING_PLAYSTATION = 3, + + WPS_DEV_PHONE_WINDOWS_MOBILE = 1 +}; + + +/* Request Type */ +enum wps_request_type { + WPS_REQ_ENROLLEE_INFO = 0, + WPS_REQ_ENROLLEE = 1, + WPS_REQ_REGISTRAR = 2, + WPS_REQ_WLAN_MANAGER_REGISTRAR = 3 +}; + +/* Response Type */ +enum wps_response_type { + WPS_RESP_ENROLLEE_INFO = 0, + WPS_RESP_ENROLLEE = 1, + WPS_RESP_REGISTRAR = 2, + WPS_RESP_AP = 3 +}; + +/* Walk Time for push button configuration (in seconds) */ +#define WPS_PBC_WALK_TIME (120) + +#define WPS_MAX_AUTHORIZED_MACS (5) + +#endif /* WPS_DEFS_H */ + diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.c b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.c new file mode 100644 index 00000000..dce6cdd0 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.c @@ -0,0 +1,310 @@ +//#include "FreeRTOS.h" +//#include "task.h" + +#include "utils/os.h" +#include +#include +#include "wps/wps_defs.h" +#include "wps_protocol_handler.h" + +#if CONFIG_ENABLE_P2P +enum p2p_wps_method { + WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC +}; +#include "wifi_p2p_supplicant.h" +/*NETMASK*/ +#define P2P_NETMASK_ADDR0 255 +#define P2P_NETMASK_ADDR1 255 +#define P2P_NETMASK_ADDR2 255 +#define P2P_NETMASK_ADDR3 0 + +/*Gateway Address*/ +#define P2P_GW_ADDR0 192 +#define P2P_GW_ADDR1 168 +#define P2P_GW_ADDR2 42 +#define P2P_GW_ADDR3 1 + +#define P2P_GO_NEGO_RESULT_SIZE 376//256 + +xqueue_handle_t queue_for_p2p_nego; + +extern void dhcps_init(struct netif * pnetif); + +static int hex2num(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + return -1; +} + +/** + * hwaddr_aton - Convert ASCII string to MAC address (colon-delimited format) + * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") + * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) + * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) + */ +int hwaddr_aton(const char *txt, u8 *addr) +{ + int i; + + for (i = 0; i < 6; i++) { + int a, b; + + a = hex2num(*txt++); + if (a < 0) + return -1; + b = hex2num(*txt++); + if (b < 0) + return -1; + *addr++ = (a << 4) | b; + if (i < 5 && *txt++ != ':') + return -1; + } + + return 0; +} + +int wifi_start_p2p_go(char *ssid, char *passphrase, u8 channel) +{ + extern struct netif xnetif[NET_IF_NUM]; +#if CONFIG_LWIP_LAYER +#if !defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) + struct netif * pnetif = &xnetif[0]; + struct ip_addr ipaddr; + struct ip_addr netmask; + struct ip_addr gw; +#endif +#endif + +#if CONFIG_LWIP_LAYER +#if defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) + //TODO +#else +#if LWIP_VERSION_MAJOR >= 2 + IP4_ADDR(ip_2_ip4(&ipaddr), P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3); + IP4_ADDR(ip_2_ip4(&netmask), P2P_NETMASK_ADDR0, P2P_NETMASK_ADDR1 , P2P_NETMASK_ADDR2, P2P_NETMASK_ADDR3); + IP4_ADDR(ip_2_ip4(&gw), P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3); + netif_set_addr(pnetif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask),ip_2_ip4(&gw)); +#else + IP4_ADDR(&ipaddr, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3); + IP4_ADDR(&netmask, P2P_NETMASK_ADDR0, P2P_NETMASK_ADDR1 , P2P_NETMASK_ADDR2, P2P_NETMASK_ADDR3); + IP4_ADDR(&gw, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3); + netif_set_addr(pnetif, &ipaddr, &netmask,&gw); +#endif +#endif +#endif + // start ap + if(wifi_start_ap(ssid, + RTW_SECURITY_WPA2_AES_PSK, + passphrase, + strlen(ssid), + strlen(passphrase), + channel + ) != RTW_SUCCESS) { + printf("\n\rERROR: Operation failed!"); + return -1; + } + + //netif_set_default(pnetif); + +#if CONFIG_LWIP_LAYER +#if defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) + //TODO +#else + // start dhcp server + dhcps_init(pnetif); +#endif +#endif + + return 0; +} + +void app_callback(char *msg) +{ + //From Application +} + +void cmd_wifi_p2p_start(int argc, char **argv) +{ + extern struct netif xnetif[NET_IF_NUM]; + int listen_ch = 1; + int op_ch = 5; + int go_intent = 1; + u32 r = 0; + os_get_random((u8 *) &r, sizeof(r)); + go_intent = r%15+1; /*1-15*/ + + os_get_random((u8 *) &r, sizeof(r)); + listen_ch = 1 + (r % 3) * 5; + +#if CONFIG_CUSTOMER_P2P_5G + op_ch = 40;// 1 6 11 for 2.4G / 36 40 44 48for 5G +#else + os_get_random((u8 *) &r, sizeof(r)); + op_ch = 1 + (r % 3) * 5; +#endif + wifi_off(); + os_sleep(0, 20000); + wifi_on(RTW_MODE_P2P); + wifi_p2p_init(xnetif[0].hwaddr, go_intent, listen_ch, op_ch); +} + +void cmd_wifi_p2p_auto_go_start(int argc, char **argv) +{ + u8 *passphrase = "12345678"; +#if CONFIG_CUSTOMER_P2P_5G //for 5G channel + u8 channel = 40; // 36, 40, 44, 48 +#else + u8 channel = 1; // 1, 6, 11 +#endif + const char *ssid_in = "DIRECT-34-Ameba"; + const char *dev_name = "Ameba1234"; // max strlen 32 + const char *manufacturer = "by customer"; // max strlen 64 + const char *model_name = "customer"; // max strlen 32 + const char *model_number = "v2.0"; // max strlen 32 + const char *serial_number = "9"; // max strlen 32 +#if CONFIG_WFD + const u8 pri_dev_type[8] = {0x00,0x07,0x00,0x50,0xF2,0x04,0x00,0x01}; // category ID:0x00,0x07; sub category ID:0x00,0x01 +#else + const u8 pri_dev_type[8] = {0x00,0x0A,0x00,0x50,0xF2,0x04,0x00,0x01}; // category ID:0x00,0x0A; sub category ID:0x00,0x01 +#endif + u8 res[P2P_GO_NEGO_RESULT_SIZE]; +#if CONFIG_WFD + u16 config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_PUSHBUTTON; +#else + u16 config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD | WPS_CONFIG_PUSHBUTTON; +#endif + if(!is_wifi_p2p_initialized()){ + printf("\r\n%s(): p2p inital fail\n", __func__); + return; + } + wifi_p2p_set_dev_name(dev_name); + wifi_p2p_set_manufacturer(manufacturer); + wifi_p2p_set_model_name(model_name); + wifi_p2p_set_model_number(model_number); + wifi_p2p_set_serial_number(serial_number); + wifi_p2p_set_pri_dev_type(pri_dev_type); + wifi_p2p_set_ssid(ssid_in); + wifi_p2p_set_config_methods(config_methods); + wifi_p2p_init_auto_go_params(res, passphrase, channel); + wifi_p2p_start_auto_go(res); + //return; +} +void cmd_wifi_p2p_stop(int argc, char **argv) +{ + wifi_p2p_deinit(); + wifi_off(); +} + +void cmd_p2p_listen(int argc, char **argv) +{ + u32 timeout = 0; + + if(argc == 2){ + timeout = os_atoi((u8*)argv[1]); + printf("\r\n%s(): timeout=%d\n", __func__, timeout); + if(timeout > 3600) + timeout = 3600; + } + wifi_cmd_p2p_listen(timeout); +} + +void cmd_p2p_find(int argc, char **argv) +{ + wifi_cmd_p2p_find(); +} + +void cmd_p2p_peers(int argc, char **argv) +{ + wifi_cmd_p2p_peers(); +} + +void cmd_p2p_info(int argc, char **argv) +{ + u8 p2p_state; + + p2p_state = wifi_cmd_p2p_info(); + + printf("\r\np2p state : %d",p2p_state); +} + +void cmd_p2p_disconnect(int argc, char **argv) +{ + wifi_cmd_p2p_disconnect(); +} + +void cmd_p2p_connect(int argc, char **argv) +{ + enum p2p_wps_method config_method = WPS_PBC; + char *pin = NULL; + u8 dest[ETH_ALEN] = {0x44, 0x6d, 0x57, 0xd7, 0xce, 0x41}; + u8 res[P2P_GO_NEGO_RESULT_SIZE]; + int ret = 0, result = 0; + +#if 1 + if((argc != 2) && (argc != 3) && (argc != 4)) { + printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n"); + printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n"); + return; + } + if (hwaddr_aton(argv[1], dest)){ + printf("\r\nP2P_CONNECT: dest address is not correct!\n"); + return; + } + + printf("\r\nDEST: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dest[0], dest[1], dest[2], dest[3], dest[4], dest[5]); + config_method = WPS_PBC; + if(argc == 3) { + if(os_strncmp(argv[2], "pbc", 3) == 0) + config_method = WPS_PBC; + else if(os_strncmp(argv[2], "pin", 3) == 0){ + config_method = WPS_PIN_DISPLAY; + }else{ + printf("\n\rUnknown config method!\n"); + printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] \n"); + printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin\n"); + return; + } + } + else if(argc == 4) { + if(os_strncmp(argv[2], "pin", 3) == 0){ + config_method = WPS_PIN_KEYPAD; + pin = argv[3]; + }else{ + printf("\n\rUnknown config method!\n"); + printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n"); + printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n"); + return; + } + } +#else //For test + u8 dest1[ETH_ALEN] = {0xea, 0x92, 0xa4, 0x9b, 0x61, 0xd6}; //NEXUS 4 + //u8 dest1[ETH_ALEN] = {0x0e, 0x37, 0xdc, 0xfc, 0xc4, 0x12}; //HUAWEI U9508_c001 + //u8 dest1[ETH_ALEN] = {0x42, 0xcb, 0xa8, 0xd3, 0x2c, 0x50}; //HUAWEI G610-T00 + os_memcpy(dest, dest1, ETH_ALEN); + config_method = WPS_PBC; +#endif + + if (queue_for_p2p_nego!= NULL) { + os_xqueue_delete(queue_for_p2p_nego); + queue_for_p2p_nego = NULL; + } + queue_for_p2p_nego = os_xqueue_create(1, P2P_GO_NEGO_RESULT_SIZE); + if(queue_for_p2p_nego != NULL) { + ret = wifi_cmd_p2p_connect(dest, config_method, pin); + if(ret == 0) + result = os_xqueue_receive(queue_for_p2p_nego, res, 15); + + os_xqueue_delete(queue_for_p2p_nego); + queue_for_p2p_nego = NULL; + + if((ret == 0) && (result == 0)) + wifi_p2p_start_wps(res); + } +} + +#endif //CONFIG_ENABLE_P2P diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.h new file mode 100644 index 00000000..3a97b34d --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_config.h @@ -0,0 +1,193 @@ +/** + ****************************************************************************** + * @file wifi_p2p_config.h + * @author + * @version + * @brief This file provides user interfaces for Wi-Fi Direct functionality. + * @note To use the APIs in this file, please enable CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P in platform_opts.h. + ****************************************************************************** + * @attention + * + * This module is a confidential and proprietary property of RealTek and + * possession or use of this module requires written permission of RealTek. + * + * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved. + ****************************************************************************** + */ + +/** @addtogroup wpsp2p WPS/P2P + * @ingroup wlan + * @brief WPS/P2P functions + * @{ + */ + +/** + * @brief Initialize P2P data. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P). + * @param[in] dev_addr: The device address. + * @param[in] go_intent: The GO intent. + * @param[in] listen_ch: The listen channel. + * @param[in] op_ch: The operation channel. + * @return 0 on success, otherwise return -1. + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.\n + * You can reference @ref cmd_wifi_p2p_start() to understand the process of starting P2P mode. + */ +int wifi_p2p_init(u8 *dev_addr, int go_intent, u8 listen_ch, u8 op_ch); + +/** + * @brief Deinitialize P2P data. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P). + * @param None + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_deinit(); + +/** + * @brief Command to start WiFi Direct mode for commonly use. Can refer to ATWG in atcmd_wifi.c.\n + * After executing this command, P2P resource will be allocated and the driver enter P2P mode. + * @warning If the started Wi-Fi Direct mode is no longer needed, please make sure to invoke @ref cmd_wifi_p2p_stop() before doing other procedures. + * @param[in] argc: Command line argument. Argument count. Just let it be NULL. + * @param[in] argv: Command line argument. Argument vector. Just let it be NULL. + * @return None + * @note Command style: + * - cmd_wifi_p2p_start + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void cmd_wifi_p2p_start(int argc, char **argv); + +/** + * @brief Command to stop WiFi Direct mode for commonly use. Can refer to ATWH in atcmd_wifi.c.\n + * After execute this command, WLAN driver will release P2P resources and turn off Wi-Fi. + * @warning This command must be invoked if the enabled Wi-Fi Direct mode is no longer used. + * @param[in] argc: Command line argument. Argument count. Just let it be NULL. + * @param[in] argv: Command line argument. Argument vector. Just let it be NULL. + * @return None + * @note Command style: + * - cmd_wifi_p2p_stop + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void cmd_wifi_p2p_stop(int argc, char **argv); + +/** + * @brief Command to show P2P role, P2P group information, and memory usage. Can refer to ATWN in atcmd_wifi.c. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] argc: Command line argument. Argument count. Just let it be NULL. + * @param[in] argv: Command line argument. Argument vector. Just let it be NULL. + * @return None + * @note Command style: + * - cmd_p2p_info + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void cmd_p2p_info(int argc, char **argv); + +/** + * @brief Set the device name in WPS ie and P2P ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] dev_name: Device name to be set. The max string length is 32 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_dev_name(const char *dev_name); + +/** + * @brief Set the manufacturer in WPS ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] manufacturer: Manufacturer to be set. The max string length is 64 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_manufacturer(const char *manufacturer); + +/** + * @brief Set the model name in WPS ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] model_name: Model name to be set. The max string length is 32 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_model_name(const char *model_name); + +/** + * @brief Set the model number in WPS ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] model_number: Model number to be set. The max string length is 32 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_model_number(const char *model_number); + +/** + * @brief Set the serial number in WPS ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] serial_number: Serial number to be set. The max string length is 32 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_serial_number(const char *serial_number); + +/** + * @brief Set the primary device type in WPS ie and P2P ie. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] pri_dev_type: Primary device type to be set. The string length is 8 bytes.\n + * The first two bytes are category ID, and the last two bytes are subcategory ID. + * The middle four bytes are 0x 00-50-F2-04. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_pri_dev_type(const u8 *pri_dev_type); + +/** + * @brief Set the GO SSID. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] ssid_in: Ssid_in will be set as GO SSID. The string length is between 1 byte and 32 bytes. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_set_ssid(const char *ssid_in); + +/** + * @brief Initialize the Wi-Fi Direct GO parameters. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[out] res: The location where the set parameters will be stored. (@ref p2p_go_neg_results) + * @param[in] passphrase: The GO passphrase. + * @param[in] channel: The operation channel. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void wifi_p2p_init_auto_go_params(void *res, u8 *passphrase,u8 channel); + +/** + * @brief Start Wi-Fi Direct GO. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] res: The parameters for GO negotiation. (@ref p2p_go_neg_results) + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.\n + * You can reference @ref cmd_wifi_p2p_auto_go_start() to understand the process of opening the P2P automatic GO. + */ +int wifi_p2p_start_auto_go(void *res); + +/** + * @brief Command to start WiFi Direct GO mode for commonly use. Can refer to ATWg in atcmd_wifi.c. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init(). + * @warning You can reference @ref cmd_wifi_p2p_start() to initialize them. + * @param[in] argc: Command line argument. Argument count. Just let it be NULL. + * @param[in] argv: Command line argument. Argument vector. Just let it be NULL. + * @return 0 if success, otherwise return -1. + * @note Command style: + * - cmd_wifi_p2p_auto_go_start + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h. + */ +void cmd_wifi_p2p_auto_go_start(int argc, char **argv); + +/*\@}*/ diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_supplicant.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_supplicant.h new file mode 100644 index 00000000..aec670e9 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_p2p_supplicant.h @@ -0,0 +1,124 @@ +#ifndef _WIFI_P2P_SUPPLICANT_H_ +#define _WIFI_P2P_SUPPLICANT_H_ + +enum p2p_group_removal_reason { + P2P_GROUP_REMOVAL_UNKNOWN, + P2P_GROUP_REMOVAL_SILENT, + P2P_GROUP_REMOVAL_FORMATION_FAILED, + P2P_GROUP_REMOVAL_REQUESTED, + P2P_GROUP_REMOVAL_IDLE_TIMEOUT, + P2P_GROUP_REMOVAL_UNAVAILABLE, + P2P_GROUP_REMOVAL_GO_ENDING_SESSION +}; + +/** + * struct wpa_scan_res - Scan result for an BSS/IBSS + * @flags: information flags about the BSS/IBSS (WPA_SCAN_*) + * @bssid: BSSID + * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1) + * @beacon_int: beacon interval in TUs (host byte order) + * @caps: capability information field in host byte order + * @qual: signal quality + * @noise: noise level + * @level: signal level + * @tsf: Timestamp + * @age: Age of the information in milliseconds (i.e., how many milliseconds + * ago the last Beacon or Probe Response frame was received) + * @ie_len: length of the following IE field in octets + * @beacon_ie_len: length of the following Beacon IE field in octets + * + * This structure is used as a generic format for scan results from the + * driver. Each driver interface implementation is responsible for converting + * the driver or OS specific scan results into this format. + * + * If the driver does not support reporting all IEs, the IE data structure is + * constructed of the IEs that are available. This field will also need to + * include SSID in IE format. All drivers are encouraged to be extended to + * report all IEs to make it easier to support future additions. + */ +struct wpa_scan_res { + unsigned int flags; + u8 bssid[ETH_ALEN]; + int freq; + u16 beacon_int; + u16 caps; + int qual; + int noise; + int level; + u64 tsf; + unsigned int age; + size_t ie_len; + size_t beacon_ie_len; + u8 *ie; + /* + * Followed by ie_len octets of IEs from Probe Response frame (or if + * the driver does not indicate source of IEs, these may also be from + * Beacon frame). After the first set of IEs, another set of IEs may + * follow (with beacon_ie_len octets of data) if the driver provides + * both IE sets. + */ +}; + +/** P2P device scanned (only basic information) */ +#define P2P_EVENT_DEVICE_SCANNED "P2P-DEVICE-SCANNED " + +/** P2P device found */ +#define P2P_EVENT_DEVICE_FOUND "P2P-DEVICE-FOUND " + +/** P2P device lost */ +#define P2P_EVENT_DEVICE_LOST "P2P-DEVICE-LOST " + +/** P2P find stopped */ +#define P2P_EVENT_FIND_STOPPED "P2P-FIND-STOPPED " + +/** A P2P device requested GO negotiation, but we were not ready to start the + * negotiation */ +#define P2P_EVENT_GO_NEG_REQUEST "P2P-GO-NEG-REQUEST " +#define P2P_EVENT_GO_NEG_SUCCESS "P2P-GO-NEG-SUCCESS " +#define P2P_EVENT_GO_NEG_FAILURE "P2P-GO-NEG-FAILURE " +#define P2P_EVENT_GROUP_FORMATION_SUCCESS "P2P-GROUP-FORMATION-SUCCESS " +#define P2P_EVENT_GROUP_FORMATION_FAILURE "P2P-GROUP-FORMATION-FAILURE " + +/* P2P Group started or removed */ +#define P2P_EVENT_GROUP_STARTED "P2P-GROUP-STARTED " +#define P2P_EVENT_GROUP_REMOVED "P2P-GROUP-REMOVED " + +#define AP_STA_CONNECTED "AP-STA-CONNECTED " +#define AP_STA_DISCONNECTED "AP-STA-DISCONNECTED " + +int wifi_p2p_rx_mgnt(u8 *data, u16 len, u8 channel); +int wifi_p2p_connect(const u8 *peer_addr, + const char *pin, enum p2p_wps_method wps_method, + int persistent_group, int auto_join, int join, int auth, + int go_intent, int freq, int persistent_id, int pd, + int ht40); +void wifi_p2p_scan_res_handler(void); +int wifi_p2p_start_wps(void *res); +void wifi_p2p_set_state(u8 p2p_state); +int wifi_p2p_group_notify_assoc(u8 *buf, u16 buf_len); +int wifi_p2p_group_notify_disassoc(u8 *addr); + +int wifi_cmd_p2p_listen(unsigned int timeout); +void wifi_cmd_p2p_find(void); +void wifi_cmd_p2p_peers(void); +u8 wifi_cmd_p2p_info(void); +int wifi_cmd_p2p_connect(u8 *dest, enum p2p_wps_method config_method, char *pin); +void wifi_cmd_p2p_disconnect(void); + +int wifi_p2p_init(u8 *dev_addr, int go_intent, u8 listen_ch, u8 op_ch); +void wifi_p2p_deinit(void); +int is_wifi_p2p_initialized(); +void wifi_p2p_set_dev_name(const char *dev_name); +void wifi_p2p_set_manufacturer(const char *manufacturer); +void wifi_p2p_set_model_name(const char *model_name); +void wifi_p2p_set_model_number(const char *model_number); +void wifi_p2p_set_serial_number(const char *serial_number); +void wifi_p2p_set_pri_dev_type(const u8 *pri_dev_type); +void wifi_p2p_set_ssid(const char *ssid_in); +void wifi_p2p_set_config_methods(u16 config_methods); +void wifi_p2p_init_auto_go_params(void *res, u8 *passphrase,u8 channel); +int wifi_p2p_start_auto_go(void *res); +unsigned int wifi_p2p_group_is_intfaddr_connected(u8 *dev_addr); +unsigned int wifi_p2p_group_is_client_connected(u8 *dev_addr); +#endif //_WIFI_P2P_SUPPLICANT_H_ + diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.c b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.c new file mode 100644 index 00000000..b0ed8f04 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.c @@ -0,0 +1,1140 @@ +#include +#include +#include +#if !defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) +//#include "FreeRTOS.h" +//#include "task.h" +//#include "wlan_network.h" +//#include "queue.h" +//#include +//#include +#endif +#include "utils/os.h" +#include "wifi/wifi_conf.h" +#include "wps/wps_defs.h" +#include +#include "wps_protocol_handler.h" +// The maximum number of WPS credentials. The value should be in range of 1~10. +int wps_max_cred_count = 1; + +/* + * @brief struct wps_credential - WPS Credential + */ +struct dev_credential { + u8 ssid[32]; /**< SSID */ + size_t ssid_len; /**< Length of SSID */ + u16 auth_type; /**< Authentication Type (WPS_AUTH_OPEN, .. flags) */ + u16 encr_type; /**< Encryption Type (WPS_ENCR_NONE, .. flags) */ + u8 key_idx; /**< Key index */ + u8 key[65]; /**< Key */ + size_t key_len; /**< Key length in octets */ + u8 mac_addr[6]; /**< MAC address of the Credential receiver */ + const u8 *cred_attr; /**< Unparsed Credential attribute data (used only in cred_cb()). + This may be NULL, if not used. */ + size_t cred_attr_len; /**< Length of cred_attr in octets */ + u16 ap_channel; /**< AP channel */ +}; + +typedef struct { + char *target_ssid; + u16 config_method; + _sema scan_sema; + int isoverlap; + int isoverlap_5G; +} internal_wps_scan_handler_arg_t; + +#define WLAN0_NAME "wlan0" +#ifndef ENABLE +#define ENABLE (1) +#endif +#ifndef DISABLE +#define DISABLE (0) +#endif +#define STACKSIZE 512 + + +//static xSemaphoreHandle wps_reconnect_semaphore; +//static struct _WIFI_NETWORK wifi_get_from_certificate = {0}; + +#define WPS_AUTH_TYPE_OPEN (0x0001) +#define WPS_AUTH_TYPE_WPA_PERSONAL (0x0002) +#define WPS_AUTH_TYPE_SHARED (0x0004) +#define WPS_AUTH_TYPE_WPA_ENTERPRISE (0x0008) +#define WPS_AUTH_TYPE_WPA2_PERSONAL (0x0010) +#define WPS_AUTH_TYPE_WPA2_ENTERPRISE (0x0020) + +#define WPS_ENCR_TYPE_NONE (0x0001) +#define WPS_ENCR_TYPE_WEP (0x0002) +#define WPS_ENCR_TYPE_TKIP (0x0004) +#define WPS_ENCR_TYPE_AES (0x0008) + +#define SCAN_BUFFER_LENGTH (4096) + +#if CONFIG_ENABLE_P2P +extern void _wifi_p2p_wps_success(const u8 *peer_addr, int registrar); +extern void _wifi_p2p_wps_failed(); +#endif +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP +extern u32 _wps_registrar_process_msg(void *priv, u32 op_code, const void *pmsg); +extern void * _wps_registrar_get_msg(void *priv, u32 *op_code); +extern void * _wps_registrar_init(void *priv, const void* pcfg); +extern void _wps_registrar_deinit(void *priv); +extern void *_wps_registrar_alloc(); +extern int _wps_registrar_add_pin(void *priv, const u8 *addr, + const u8 *uuid, const u8 *pin, size_t pin_len, + int timeout); +extern int _wps_registrar_button_pushed(void *priv, + const u8 *p2p_dev_addr); +extern int _wps_registrar_wps_cancel(void *priv); +extern void _wpas_wsc_ap_send_eap_reqidentity(void *priv, u8 *rx_buf); +extern void _wpas_wsc_ap_check_eap_rspidentity(void *priv, u8 *rx_buf); +extern void _wpas_wsc_registrar_send_eap_fail(void *priv); +extern void _wpas_wsc_registrar_handle_recvd(void *priv, u8 *rx_buf); +extern void * _eap_wsc_server_process_hdl(void *priv, void* req, u8 id); +extern void _eap_wsc_server_reset(void *priv); +#endif +extern void wpas_wsc_sta_wps_start_hdl(char *buf, int buf_len, int flags, void *userdata); +extern void wpas_wsc_wps_finish_hdl(char *buf, int buf_len, int flags, void *userdata); +extern void wpas_wsc_server_wps_finish_hdl(char *buf, int buf_len, int flags, void *userdata); +extern void wpas_wsc_eapol_recvd_hdl(char *buf, int buf_len, int flags, void *userdata); + +void wifi_p2p_wps_success(const u8 *peer_addr, int registrar) +{ +#if CONFIG_ENABLE_P2P + _wifi_p2p_wps_success(peer_addr, registrar); +#endif +} + +void wifi_p2p_wps_failed() +{ +#if CONFIG_ENABLE_P2P + _wifi_p2p_wps_failed(); +#endif +} + +void * wps_registrar_init(void *priv, void *pcfg) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_init(priv, pcfg); +#else + return NULL; +#endif +} + +void wps_registrar_deinit(void *priv) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _wps_registrar_deinit(priv); +#endif +} + +void *wps_registrar_alloc() +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_alloc(); +#else + return NULL; +#endif +} + +u32 wps_registrar_process_msg(void *priv, u32 op_code, const void *pmsg) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_process_msg(priv, op_code, pmsg); +#else + return 0; +#endif +} + +void * wps_registrar_get_msg(void *priv, u32 *op_code) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_get_msg(priv, op_code); +#else + return NULL; +#endif +} + + +int wps_registrar_add_pin(void *priv, const u8 *addr, + const u8 *uuid, const u8 *pin, size_t pin_len, + int timeout) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_add_pin(priv, NULL,NULL,pin,pin_len,0); +#else + return 0; +#endif +} + +int wps_registrar_button_pushed(void *priv, + const u8 *p2p_dev_addr) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_button_pushed(priv, p2p_dev_addr); +#else + return 0; +#endif +} + +int wps_registrar_wps_cancel(void *priv) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _wps_registrar_wps_cancel(priv); +#else + return 0; +#endif + +} + +void wpas_wsc_ap_send_eap_reqidentity(void *priv, u8 *rx_buf) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _wpas_wsc_ap_send_eap_reqidentity(priv, rx_buf); +#endif +} + +void wpas_wsc_ap_check_eap_rspidentity(void *priv, u8 *rx_buf) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _wpas_wsc_ap_check_eap_rspidentity(priv, rx_buf); +#endif +} + +void wpas_wsc_registrar_send_eap_fail(void *priv) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _wpas_wsc_registrar_send_eap_fail(priv); +#endif +} + +void wpas_wsc_registrar_handle_recvd(void *priv, u8 *rx_buf) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _wpas_wsc_registrar_handle_recvd(priv, rx_buf); +#endif +} + +void * eap_wsc_server_process_hdl(void *priv, void* req, u8 id) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + return _eap_wsc_server_process_hdl(priv, req, id); +#else + return NULL; +#endif +} + +void eap_wsc_server_reset(void *priv) +{ +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP + _eap_wsc_server_reset(priv); +#endif +} + +#if CONFIG_ENABLE_WPS +xqueue_handle_t queue_for_credential; +char wps_pin_code[32]; +u16 config_method; +u8 wps_password_id; +//static TaskHandle_t ap_wps_task = NULL; +static struct task_struct ap_wps_task = {0}; +static unsigned char wps_stop_notified = 0; + +void wps_check_and_show_connection_info(void) +{ + rtw_wifi_setting_t setting; +#if CONFIG_LWIP_LAYER +#if defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) + //TODO +#else + /* Start DHCP Client */ + LwIP_DHCP(0, DHCP_START); +#endif +#endif + wifi_get_setting(WLAN0_NAME, &setting); + wifi_show_setting(WLAN0_NAME, &setting); + +} + +static void wps_config_wifi_setting(rtw_network_info_t *wifi, struct dev_credential *dev_cred) +{ + printf("\r\nwps_config_wifi_setting\n"); + //memcpy((void *)wifi->ssid, (void *)dev_cred->ssid, dev_cred->ssid_len); + strcpy((char*)wifi->ssid.val, (char*)&dev_cred->ssid[0]); + printf("\r\nwps_wifi.ssid = %s\n", wifi->ssid.val); + wifi->ssid.len = dev_cred->ssid_len; + printf("\r\nwps_wifi.ssid_len = %d\n", wifi->ssid.len); + + if(dev_cred->auth_type & (WPS_AUTH_TYPE_WPA2_PERSONAL | WPS_AUTH_TYPE_WPA2_ENTERPRISE)) { + if((dev_cred->encr_type & WPS_ENCR_TYPE_AES) && (dev_cred->encr_type & WPS_ENCR_TYPE_TKIP)) { + printf("\r\nsecurity_type = RTW_SECURITY_WPA2_MIXED_PSK\n"); + wifi->security_type = RTW_SECURITY_WPA2_MIXED_PSK; + } + else if(dev_cred->encr_type & WPS_ENCR_TYPE_AES) { + printf("\r\nsecurity_type = RTW_SECURITY_WPA2_AES_PSK\n"); + wifi->security_type = RTW_SECURITY_WPA2_AES_PSK; + } + else if(dev_cred->encr_type & WPS_ENCR_TYPE_TKIP) { + printf("\r\nsecurity_type = RTW_SECURITY_WPA2_TKIP_PSK\n"); + wifi->security_type = RTW_SECURITY_WPA2_TKIP_PSK; + } + } + else if(dev_cred->auth_type & (WPS_AUTH_TYPE_WPA_PERSONAL | WPS_AUTH_TYPE_WPA_ENTERPRISE)) { + if(dev_cred->encr_type & WPS_ENCR_TYPE_AES) { + printf("\r\nsecurity_type = RTW_SECURITY_WPA_AES_PSK\n"); + wifi->security_type = RTW_SECURITY_WPA_AES_PSK; + } + else if(dev_cred->encr_type & WPS_ENCR_TYPE_TKIP) { + printf("\r\nsecurity_type = RTW_SECURITY_WPA_TKIP_PSK\n"); + wifi->security_type = RTW_SECURITY_WPA_TKIP_PSK; + } + } + else if(dev_cred->auth_type & (WPS_AUTH_TYPE_OPEN | WPS_AUTH_TYPE_SHARED)) { + if(dev_cred->encr_type & WPS_ENCR_TYPE_WEP) { + printf("\r\nsecurity_type = RTW_SECURITY_WEP_PSK\n"); + wifi->security_type = RTW_SECURITY_WEP_PSK; + wifi->key_id = dev_cred->key_idx - 1; + } + else { + printf("\r\nsecurity_type = RTW_SECURITY_OPEN\n"); + wifi->security_type = RTW_SECURITY_OPEN; + } + } + + printf("\r\nwps_wifi.security_type = %x\n", wifi->security_type); + + //memcpy(wifi->password, dev_cred->key, dev_cred->key_len); + wifi->password = dev_cred->key; + printf("\r\nwps_wifi.password = %s\n", wifi->password); + wifi->password_len = dev_cred->key_len; + printf("\r\nwps_wifi.password_len = %d", wifi->password_len); + //xSemaphoreGive(wps_reconnect_semaphore); + //printf("\r\nrelease wps_reconnect_semaphore"); +} + +static int wps_connect_to_AP_by_certificate(rtw_network_info_t *wifi) +{ + int retry_count = WPS_CONNECT_RETRY_COUNT, ret; + + printf("\r\n=============== wifi_certificate_info ===============\n"); + printf("\r\nwps_wifi.ssid = %s\n", wifi->ssid.val); + printf("\r\nsecurity_type = %d\n", wifi->security_type); + printf("\r\nwps_wifi.password = %s\n", wifi->password); + printf("\r\nssid_len = %d\n", wifi->ssid.len); + printf("\r\npassword_len = %d\n", wifi->password_len); + while (1) { + ret = wifi_connect((char*)wifi->ssid.val, + wifi->security_type, + (char*)wifi->password, + wifi->ssid.len, + wifi->password_len, + wifi->key_id, + NULL); + if (ret == RTW_SUCCESS) { + if(retry_count == WPS_CONNECT_RETRY_COUNT) + rtw_msleep_os(1000); //When start wps with OPEN AP, AP will send a disassociate frame after STA connected, need reconnect here. + if(RTW_SUCCESS == wifi_is_connected_to_ap( )){ + //printf("\r\n[WPS]Ready to tranceive!!\n"); + wps_check_and_show_connection_info(); + break; + } + } + if (retry_count == 0) { + printf("\r\n[WPS]Join bss failed\n"); + ret = -1; + break; + } + retry_count --; + rtw_msleep_os(WPS_CONNECT_RETRY_INTERVAL); + } + return ret; +} + +static int wps_connect_to_AP_by_open_system(char *target_ssid) +{ + int retry_count = 3, ret; + + if (target_ssid != NULL) { + rtw_msleep_os(500); //wait scan complete. + while (1) { + ret = wifi_connect(target_ssid, + RTW_SECURITY_OPEN, + NULL, + strlen(target_ssid), + 0, + 0, + NULL); + if (ret == RTW_SUCCESS) { + //wps_check_and_show_connection_info(); + break; + } + if (retry_count == 0) { + printf("\r\n[WPS]Join bss failed\n"); + return -1; + } + retry_count --; + } + // + } else { + printf("\r\n[WPS]Target SSID is NULL\n"); + } + + return 0; +} + +static void process_wps_scan_result( rtw_scan_result_t* record, void * user_data ) +{ + u8 zero_mac[ETH_ALEN] = {0}; + internal_wps_scan_handler_arg_t *wps_arg = (internal_wps_scan_handler_arg_t *)user_data; + + if ((record->wps_type != 0xff) && (record->channel != 0) && + (memcmp(&record->BSSID, zero_mac, 6) != 0) && (!(record->security & WEP_ENABLED))) { + // ignore hidden ssid + if(record->SSID.len == 0) { + return; + } + else { + int i; + u8 is_hidden_ssid = 1; + + for(i = 0; i < record->SSID.len; i ++) { + if(record->SSID.val[i] != 0) { + is_hidden_ssid = 0; + break; + } + } + + if(is_hidden_ssid) + return; + } + + if (wps_arg->config_method == WPS_CONFIG_PUSHBUTTON) { + if (record->wps_type == 0x04) { + wps_password_id = record->wps_type; + if (record->channel > 14) { + if (++wps_arg->isoverlap_5G == 0) { + memcpy(&wps_arg->target_ssid[0], record->SSID.val, record->SSID.len); + wps_arg->target_ssid[record->SSID.len] = '\0'; + printf("\r\n[pbc]Record first triger wps 5G AP = %s\n", wps_arg->target_ssid); + } + } + else { + if ((++wps_arg->isoverlap == 0) && (wps_arg->isoverlap_5G == -1)) { + memcpy(&wps_arg->target_ssid[0], record->SSID.val, record->SSID.len); + wps_arg->target_ssid[record->SSID.len] = '\0'; + printf("\r\n[pbc]Record first triger wps AP = %s\n", wps_arg->target_ssid); + } + } + } + } else if (wps_arg->config_method == WPS_CONFIG_DISPLAY || wps_arg->config_method == WPS_CONFIG_KEYPAD) { + if (record->wps_type == 0x00) { + wps_arg->isoverlap = 0; + wps_password_id = record->wps_type; + memcpy(&wps_arg->target_ssid[0], record->SSID.val, record->SSID.len); + wps_arg->target_ssid[record->SSID.len] = '\0'; + printf("\r\n[pin]find out first triger wps AP = %s\n", wps_arg->target_ssid); + } + } + } +} + +#ifndef CONFIG_ENABLE_WPS_DISCOVERY +#define CONFIG_ENABLE_WPS_DISCOVERY 0 +#endif +#if CONFIG_ENABLE_WPS_DISCOVERY +#define DISCOVERED_SSIDS_NUM 10 +static char *discovered_ssids[DISCOVERED_SSIDS_NUM]; +static char discovery_ssid[64]; + +static void reset_discovery_phase(void) +{ + memset(discovered_ssids, 0, sizeof(discovered_ssids)); + memset(discovery_ssid, 0, sizeof(discovery_ssid)); +} + +static void reset_discovery_ssid(void) +{ + memset(discovery_ssid, 0, sizeof(discovery_ssid)); +} + +static void clean_discovered_ssids(void) +{ + int i; + + for(i = 0; i < DISCOVERED_SSIDS_NUM; i ++) { + if(discovered_ssids[i]) { + free(discovered_ssids[i]); + discovered_ssids[i] = NULL; + } + } +} + +static void update_discovered_ssids(char *ssid) +{ + int i; + + for(i = 0; i < DISCOVERED_SSIDS_NUM; i ++) { + if(discovered_ssids[i] != NULL) { + if(strcmp(discovered_ssids[i], ssid) == 0) + break; + } + else { + if(strlen(discovery_ssid) == 0) { + discovered_ssids[i] = malloc(strlen(ssid) + 1); + strcpy(discovered_ssids[i], ssid); + strcpy(discovery_ssid, ssid); + break; + } + } + } +} + +static int start_discovery_phase(u16 wps_config) +{ + struct dev_credential *dev_cred; + rtw_network_info_t wifi = {0}; + int ret = 0; + + + if(strlen(discovery_ssid) == 0) { + //clean_discovered_ssids(); + return -1; + } + + printf("\ndiscovery_ssid=%s\n", discovery_ssid); + + if (queue_for_credential != NULL) { + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + } + queue_for_credential = os_xqueue_create(wps_max_cred_count, sizeof(struct dev_credential)); + if(!queue_for_credential) + return -1; + + wifi_reg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_wps_finish_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl, NULL); + + wpas_wps_enrollee_init_probe_ie(wps_config); + wpas_wps_enrollee_init_assoc_ie(); + wifi_set_wps_phase(ENABLE); + + if(wps_stop_notified) { + ret = -1; + goto exit; + } + + ret = wps_connect_to_AP_by_open_system(discovery_ssid); + if(ret < 0){ + goto exit; + } + + dev_cred = (struct dev_credential *)os_zalloc(sizeof(struct dev_credential) * wps_max_cred_count); + if(!dev_cred){ + printf("\n\rWPS: dev_credential allocate fail\n"); + goto exit; + } + + for(int i=0; i< wps_max_cred_count; i++){ + os_xqueue_receive(queue_for_credential, &dev_cred[i], 20); + + // ssid == 0: no more credential + if(dev_cred[i].ssid[0] == 0) + break; + } + + // choose first credential as default + if (dev_cred[0].ssid[0] != 0 && dev_cred[0].ssid_len <= 32) { + wps_config_wifi_setting(&wifi, &dev_cred[0]); + wifi_set_wps_phase(DISABLE); +#if defined(CONFIG_WIFI_IND_USE_THREAD) && CONFIG_WIFI_IND_USE_THREAD + //vTaskDelay(10); //Wait WIFI_DISCONNECT_EVENT and WIFI_EVENT_WPS_FINISH to be processed which sent by OnDeauth + rt_thread_delay(10); +#endif + ret = wps_connect_to_AP_by_certificate(&wifi); + os_free(dev_cred,0); + goto exit1; + } else { + ret = -1; + } + + os_free(dev_cred,0); +exit: + wifi_set_wps_phase(DISABLE); +exit1: + if (queue_for_credential != NULL) { + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + } + + wifi_unreg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl); + wifi_unreg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_wps_finish_hdl); + wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl); + + wpas_wps_deinit(); + //vTaskDelay(10); + rt_thread_delay(10); + return ret; +} +#endif /* CONFIG_ENABLE_WPS_DISCOVERY */ + +static rtw_result_t wps_scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result ) +{ + internal_wps_scan_handler_arg_t *wps_arg = (internal_wps_scan_handler_arg_t *)malloced_scan_result->user_data; + if (malloced_scan_result->scan_complete != RTW_TRUE) + { + rtw_scan_result_t* record = &malloced_scan_result->ap_details; + record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */ + + process_wps_scan_result(record, malloced_scan_result->user_data); + +#if CONFIG_ENABLE_WPS_DISCOVERY + if(((wps_arg->config_method == WPS_CONFIG_DISPLAY) || (wps_arg->config_method == WPS_CONFIG_KEYPAD)) + && (record->wps_type == 0x07)) { + + update_discovered_ssids(record->SSID.val); + } +#endif + } + else + { + printf("\r\nWPS scan done!\r\n"); + rtw_up_sema(&wps_arg->scan_sema); + } + return RTW_SUCCESS; +} + +extern void wifi_scan_each_report_hdl( char* buf, int buf_len, int flags, void* userdata); +extern void wifi_scan_done_hdl( char* buf, int buf_len, int flags, void* userdata); + +static int wps_find_out_triger_wps_AP(char *target_ssid, u16 config_method) +{ + int isoverlap = -1; + internal_wps_scan_handler_arg_t wps_arg = {0}; + + wps_password_id = 0xFF; + + wps_arg.isoverlap = -1; + wps_arg.isoverlap_5G = -1; + wps_arg.config_method = config_method; + wps_arg.target_ssid = target_ssid; + rtw_init_sema(&wps_arg.scan_sema, 0); + if(wps_arg.scan_sema == NULL) return RTW_ERROR; + + if(wifi_scan_networks(wps_scan_result_handler, &wps_arg ) != RTW_SUCCESS){ + printf("\n\rERROR: wifi scan failed"); + goto exit; + } + if(rtw_down_timeout_sema(&wps_arg.scan_sema, SCAN_LONGEST_WAIT_TIME) == RTW_FALSE){ + printf("\r\nWPS scan done early!\r\n"); + } + wifi_unreg_event_handler(WIFI_EVENT_SCAN_RESULT_REPORT, wifi_scan_each_report_hdl); + wifi_unreg_event_handler(WIFI_EVENT_SCAN_DONE, wifi_scan_done_hdl); + +exit: + rtw_free_sema(&wps_arg.scan_sema); + + if((wps_arg.isoverlap >= 0) && (wps_arg.isoverlap_5G >= 0)) + isoverlap = wps_arg.isoverlap + wps_arg.isoverlap_5G; + else if(wps_arg.isoverlap_5G >= 0) + isoverlap = wps_arg.isoverlap_5G; + else if(wps_arg.isoverlap >= 0) + isoverlap = wps_arg.isoverlap; + + return isoverlap; +} + +static u8 wps_scan_cred_ssid(struct dev_credential *dev_cred) +{ + u8 ssid_found = 0; + scan_buf_arg scan_buf; + + scan_buf.buf_len = 1000; + scan_buf.buf = malloc(scan_buf.buf_len); + + if(scan_buf.buf) { + memset(scan_buf.buf, 0, scan_buf.buf_len); + *((int *) scan_buf.buf) = dev_cred->ssid_len; + memcpy(scan_buf.buf + sizeof(int), dev_cred->ssid, dev_cred->ssid_len); + + if(wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf) > 0) { + uint8_t *pos = (uint8_t *) scan_buf.buf; + + while(pos <= ((uint8_t *) scan_buf.buf + scan_buf.buf_len)) { + uint8_t len = *pos; + uint8_t ssid_len = len - 14; + uint8_t *ssid = pos + 14; + uint8_t ssid_len_p2p = len - 15; + uint8_t *ssid_p2p = pos + 15; + + if((len <= 0) || ((pos + len) > ((uint8_t *) scan_buf.buf + scan_buf.buf_len))) + break; + + if(((ssid_len == dev_cred->ssid_len) && (memcmp(ssid, dev_cred->ssid, dev_cred->ssid_len) == 0)) || + ((ssid_len_p2p == dev_cred->ssid_len) && (memcmp(ssid_p2p, dev_cred->ssid, dev_cred->ssid_len) == 0))) { + + ssid_found = 1; + break; + } + + pos += len; + } + } + + free(scan_buf.buf); + } + else { + // if cannot scan, suppose it can be found + ssid_found = 1; + } + + return ssid_found; +} + +static void wps_filter_cred_by_scan(struct dev_credential *dev_cred, int cred_cnt) +{ + u8 ssid_found_count = 0; + u8 *ssid_found_flags = (u8 *) malloc(cred_cnt); + + if(ssid_found_flags) { + int i, times; + + for(times = 0; times < (WPS_CONNECT_RETRY_COUNT + 1); times ++) { + memset(ssid_found_flags, 0, cred_cnt); + ssid_found_count = 0; + + for(i = 0; i < cred_cnt; i ++) { + ssid_found_flags[i] = wps_scan_cred_ssid(&dev_cred[i]); + ssid_found_count += ssid_found_flags[i]; + } + + if(ssid_found_count) + break; + else + rtw_msleep_os(WPS_CONNECT_RETRY_INTERVAL); + } + + for(i = 0; i < cred_cnt; i ++) { + if(ssid_found_flags[i] == 0) + memset(&dev_cred[i], 0, sizeof(struct dev_credential)); + } + + free(ssid_found_flags); + } +} + +int wps_start(u16 wps_config, char *pin, u8 channel, char *ssid) +{ + struct dev_credential *dev_cred; + rtw_network_info_t wifi = {0}; + char target_ssid[64]; + int is_overlap = -1; + u32 start_time = rtw_get_current_time(); + int ret = 0; + // for multiple credentials + int cred_cnt = 0; + int select_index = 0; + u32 select_security = 0; + + if(wps_max_cred_count < 1 || wps_max_cred_count > 10){ + printf("\n\rWPS: wps_max_cred_count should be in range 1~10\n"); + return -1; + } + + memset(target_ssid, 0, 64); + wps_stop_notified = 0; + + if((wps_config != WPS_CONFIG_PUSHBUTTON) + && (wps_config != WPS_CONFIG_DISPLAY) + && (wps_config != WPS_CONFIG_KEYPAD)){ + printf("\n\rWPS: Wps method(%d) is wrong. Not triger WPS.\n", wps_config); + return -1; + } + config_method = wps_config; + + if(wps_config == WPS_CONFIG_DISPLAY + || wps_config == WPS_CONFIG_KEYPAD) { + if(pin) + strcpy(wps_pin_code, pin); + else{ + printf("\n\rWPS: PIN is NULL. Not triger WPS.\n"); + return -1; + } + } + + if(!ssid) { +#if CONFIG_ENABLE_WPS_DISCOVERY + reset_discovery_phase(); +#endif + while (1) { + unsigned int current_time = rtw_get_current_time(); + if ((rtw_systime_to_sec(current_time - start_time) < 120) && !wps_stop_notified) { +#if CONFIG_ENABLE_WPS_DISCOVERY + reset_discovery_ssid(); +#endif + wpas_wps_enrollee_init_probe_ie(wps_config); + is_overlap = wps_find_out_triger_wps_AP(&target_ssid[0], wps_config); + if ((is_overlap == 0) || (is_overlap > 0)) + break; +#if CONFIG_ENABLE_WPS_DISCOVERY + if((wps_config == WPS_CONFIG_DISPLAY) || (wps_config == WPS_CONFIG_KEYPAD)) { + if(start_discovery_phase(wps_config) == 0) { + clean_discovered_ssids(); + return 0; + } + } +#endif + } else { + printf("\r\nWPS: WPS Walking Time Out\n"); + return -2; + } + } +#if CONFIG_ENABLE_WPS_DISCOVERY + clean_discovered_ssids(); +#endif + if (is_overlap > 0) { + printf("\r\nWPS: WPS session overlap. Not triger WPS.\n"); + return -2; + } + }else{ + rtw_memcpy(target_ssid, ssid, strlen(ssid)); + } + + if (queue_for_credential != NULL) { + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + } + queue_for_credential = os_xqueue_create(wps_max_cred_count, sizeof(struct dev_credential)); + if(!queue_for_credential) + return -1; + + wifi_reg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_wps_finish_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl, NULL); + + wpas_wps_enrollee_init_probe_ie(wps_config); + wpas_wps_enrollee_init_assoc_ie(); + wifi_set_wps_phase(ENABLE); + ret = wps_connect_to_AP_by_open_system(target_ssid); + if(ret < 0){ + printf("\n\rWPS: WPS Fail!!\n"); + goto exit; + } + + dev_cred = (struct dev_credential *)os_zalloc(sizeof(struct dev_credential) * wps_max_cred_count); + if(!dev_cred){ + printf("\n\rWPS: dev_credential allocate fail\n"); + goto exit; + } + + for(int i=0; i< wps_max_cred_count; i++){ + os_xqueue_receive(queue_for_credential, &dev_cred[i], 60); + + // ssid == 0: no more credential + if(dev_cred[i].ssid[0] == 0) + break; + else + cred_cnt++; + } + + // filter 5G rf_band cred + if(cred_cnt > 1) + wps_filter_cred_by_scan(dev_cred, cred_cnt); + + // check got credentials and select the most secure one to connect + for(int cur_index = 0; cur_index < cred_cnt; cur_index++){ + u32 cur_security = 0; + //printf("\r\nWPS: check %d th cred\n", cur_index+1); + if(dev_cred[cur_index].ssid_len == 0) + continue; + + if(dev_cred[cur_index].auth_type & (WPS_AUTH_TYPE_WPA2_PERSONAL | WPS_AUTH_TYPE_WPA2_ENTERPRISE)) { + if((dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_AES) && (dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_TKIP)) + cur_security = RTW_SECURITY_WPA2_MIXED_PSK; + else if(dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_AES) + cur_security = RTW_SECURITY_WPA2_AES_PSK; + else if(dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_TKIP) + cur_security = RTW_SECURITY_WPA2_TKIP_PSK; + } + else if(dev_cred[cur_index].auth_type & (WPS_AUTH_TYPE_WPA_PERSONAL | WPS_AUTH_TYPE_WPA_ENTERPRISE)) { + if(dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_AES) + cur_security = RTW_SECURITY_WPA_AES_PSK; + else if(dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_TKIP) + cur_security = RTW_SECURITY_WPA_TKIP_PSK; + } + else if(dev_cred[cur_index].auth_type & (WPS_AUTH_TYPE_OPEN | WPS_AUTH_TYPE_SHARED)) { + if(dev_cred[cur_index].encr_type & WPS_ENCR_TYPE_WEP) + cur_security = RTW_SECURITY_WEP_PSK; + else + cur_security = RTW_SECURITY_OPEN; + } + //printf("\r\nWPS: cur_security: %d\n", cur_security); + if(cur_security >= select_security){ + //printf("\r\nWPS: update index to %d of security type %d\n", cur_index, cur_security); + select_security = cur_security; + select_index = cur_index; + } + } + + // choose first credential as default + if (dev_cred[select_index].ssid[0] != 0 && dev_cred[select_index].ssid_len <= 32) { + wps_config_wifi_setting(&wifi, &dev_cred[select_index]); + wifi_set_wps_phase(DISABLE); +#if defined(CONFIG_WIFI_IND_USE_THREAD) && CONFIG_WIFI_IND_USE_THREAD + //vTaskDelay(10); //Wait WIFI_DISCONNECT_EVENT and WIFI_EVENT_WPS_FINISH to be processed which sent by OnDeauth + rt_thread_delay(10); +#endif + ret = wps_connect_to_AP_by_certificate(&wifi); + os_free(dev_cred,0); + goto exit1; + } else { + printf("\n\rWPS: WPS FAIL!!!\n"); + printf("\n\rWPS: WPS FAIL!!!\n"); + printf("\n\rWPS: WPS FAIL!!!\n"); + ret = -1; + } + os_free(dev_cred,0); +exit: + wifi_set_wps_phase(DISABLE); +exit1: + if (queue_for_credential != NULL) { + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + } + + wifi_unreg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl); + wifi_unreg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_wps_finish_hdl); + wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl); + + wpas_wps_deinit(); + return ret; +} + +void wps_stop(void) +{ + wps_stop_notified = 1; + wpas_wsc_wps_finish_hdl(NULL, 0, 0, NULL); +} + +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP +static int ap_wps_start(u16 wps_config, char *pin) +{ + u8 authorized_mac[ETH_ALEN]; + int ret = 0; + u32 pin_val = 0; + + if (queue_for_credential != NULL) { + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + } + + queue_for_credential = os_xqueue_create(1, sizeof(authorized_mac)); + if(!queue_for_credential) + return -1; + + wifi_reg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_server_wps_finish_hdl, NULL); + wifi_reg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl, NULL); + + wifi_set_wps_phase(ENABLE); + + if(wps_config == WPS_CONFIG_KEYPAD) + { + pin_val = atoi(pin); + if (!wps_pin_valid(pin_val)) { + printf("\n\rWPS-AP: Enter pin code is unvalid."); + goto exit; + } + ret = wpas_wps_registrar_add_pin((unsigned char const*)pin, strlen(pin)); + } + else if(wps_config == WPS_CONFIG_DISPLAY) + ret = wpas_wps_registrar_add_pin((unsigned char const*)pin, strlen(pin)); + else + ret = wpas_wps_registrar_button_pushed(); + + if(ret<0) + goto exit; + + printf("\n\rWPS-AP: wait for STA connect!\n"); + os_xqueue_receive(queue_for_credential, authorized_mac, 120); //max wait 2min + + if(!wpas_wps_registrar_check_done()) + { + ret = -1; + wpas_wps_registrar_wps_cancel(); + } + +exit: + wifi_set_wps_phase(0); + os_xqueue_delete(queue_for_credential); + queue_for_credential = NULL; + printf("\n\rWPS-AP: Finished!\n"); + + wifi_unreg_event_handler(WIFI_EVENT_STA_WPS_START, wpas_wsc_sta_wps_start_hdl); + wifi_unreg_event_handler(WIFI_EVENT_WPS_FINISH, wpas_wsc_server_wps_finish_hdl); + wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, wpas_wsc_eapol_recvd_hdl); + + return ret; +} + +static void wifi_start_ap_wps_thread_hdl( void *param) +{ + ap_wps_start(config_method, wps_pin_code); //Not support WPS_CONFIG_KEYPAD + + //vTaskDelete(NULL); + rtw_delete_task(&ap_wps_task); +} + +void wifi_start_ap_wps_thread(u16 config_methods, char *pin) +{ + u8 zero_mac[ETH_ALEN] = {0}; + + if((config_methods != WPS_CONFIG_PUSHBUTTON) + && (config_methods != WPS_CONFIG_DISPLAY) + && (config_methods != WPS_CONFIG_KEYPAD)){ + printf("\n\rWPS-AP: Wps method(%d) is wrong. Not triger WPS.\n", config_methods); + return; + } + config_method = config_methods; + if(config_methods == WPS_CONFIG_DISPLAY + || config_methods == WPS_CONFIG_KEYPAD) { + if(pin) + strcpy(wps_pin_code, pin); + else{ + printf("\n\rWPS-AP: PIN is NULL. Not triger WPS.\n"); + return; + } + } + + if(ap_wps_task.task != NULL){ //push item to wait queue to finish last ap_wps task + printf("\n\rWPS-AP: Wait for last ap_wps task exiting...\n"); + if(queue_for_credential) + os_xqueue_send(queue_for_credential, &zero_mac, 0); + while(ap_wps_task.task != NULL) + //vTaskDelay(1); + rt_thread_delay(1); + //vTaskDelay(20); + rt_thread_delay(20); + printf("\n\rLast ap_wps task completed.\n"); + } + //if(xTaskCreate(wifi_start_ap_wps_thread_hdl, ((const char*)"ap_wps"), 512, NULL, tskIDLE_PRIORITY + 3, &ap_wps_task) != pdPASS) + if(!rtw_create_task(&ap_wps_task, ((const char*)"ap_wps"), 512, /*tskIDLE_PRIORITY*/ + 3, wifi_start_ap_wps_thread_hdl, NULL)) + printf("\n\r%s xTaskCreate(ap_wps thread) failed", __FUNCTION__); +} + +#endif //CONFIG_ENABLE_WPS_AP + +void wps_judge_staion_disconnect(void) +{ + int mode = 0; + unsigned char ssid[33]; + + wext_get_mode(WLAN0_NAME, &mode); + + switch(mode) { + case IW_MODE_MASTER: //In AP mode +// rltk_wlan_deinit(); +// rltk_wlan_init(0,RTW_MODE_STA); +// rltk_wlan_start(0); + //modified by Chris Yang for iNIC + wifi_off(); + //vTaskDelay(20); + rt_thread_delay(20); + wifi_on(RTW_MODE_STA); + break; + case IW_MODE_INFRA: //In STA mode + if(wext_get_ssid(WLAN0_NAME, ssid) > 0) + wifi_disconnect(); + } +} + +void cmd_wps(int argc, char **argv) +{ + int ret = -1; + wps_judge_staion_disconnect(); + + if((argc == 2 || argc == 3 ) && (argv[1] != NULL)){ + if(strcmp(argv[1],"pin") == 0){ + unsigned int pin_val = 0; + /* start pin */ + if(argc == 2){ + char device_pin[10]; + pin_val = wps_generate_pin(); + sprintf(device_pin, "%08d", pin_val); + /* Display PIN 3 times to prevent to be overwritten by logs from other tasks */ + printf("\n\rWPS: Start WPS PIN Display. PIN: [%s]\n\r", device_pin); + printf("\n\rWPS: Start WPS PIN Display. PIN: [%s]\n\r", device_pin); + printf("\n\rWPS: Start WPS PIN Display. PIN: [%s]\n\r", device_pin); + ret = wps_start(WPS_CONFIG_DISPLAY, (char*)device_pin, 0, NULL); + }else{ + pin_val = atoi(argv[2]); + if (!wps_pin_valid(pin_val)) { + printf("\n\rWPS: Device pin code is invalid. Not triger WPS.\n"); + goto exit; + } + printf("\n\rWPS: Start WPS PIN Keypad.\n\r"); + ret = wps_start(WPS_CONFIG_KEYPAD, argv[2], 0, NULL); + } + }else if(strcmp(argv[1],"pbc") == 0){ + /* start pbc */ + printf("\n\rWPS: Start WPS PBC.\n\r"); + ret = wps_start(WPS_CONFIG_PUSHBUTTON, NULL, 0, NULL); + }else{ + printf("\n\rWPS: Wps Method is wrong. Not triger WPS.\n"); + goto exit; + } + } +exit: + return; +} + +#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP +/* +cmd_ap_wps for AP WSC setting. command style: +cmd_ap_wps pbc or cmd_ap_wps pin 12345678 +*/ +void cmd_ap_wps(int argc, char **argv) +{ + int mode = 0; + if(rltk_wlan_running(WLAN1_IDX)){ + printf("\n\rNot support con-current softAP WSC!\n\r"); + return; + } + wext_get_mode(WLAN0_NAME, &mode); + if(mode != IW_MODE_MASTER){ + printf("\n\rOnly valid for IW_MODE_MASTER!\n\r"); + return; + } + + if((argc == 2 || argc == 3) && (argv[1] != NULL)) { + if (strcmp(argv[1],"pin") == 0 ) { + unsigned int pin_val = 0; + if(argc == 3){ + pin_val = atoi(argv[2]); + if (!wps_pin_valid(pin_val)) { + printf("\n\rWPS-AP: Device pin code is invalid. Not trigger WPS.\n\r"); + return; + } + printf("\n\rWPS-AP: Start AP WPS PIN Keypad.\n"); + wifi_start_ap_wps_thread(WPS_CONFIG_KEYPAD, argv[2]); + }else{ + char device_pin[10]; + pin_val = wps_generate_pin(); + sprintf(device_pin, "%08d", pin_val); + printf("\n\rWPS: Start WPS PIN Display. PIN: %s\n\r", device_pin); + wifi_start_ap_wps_thread(WPS_CONFIG_DISPLAY, (char*)device_pin); + } + }else if (strcmp(argv[1],"pbc") == 0) { + printf("\n\rWPS-AP: Start AP WPS PBC\n"); + wifi_start_ap_wps_thread(WPS_CONFIG_PUSHBUTTON, NULL); + }else{ + printf("\n\rWPS-AP Usage:\"wifi_ap_wps pin [pin_code]\" or \"wifi_ap_wps pbc\"\n"); + return; + } + } else { + printf("\n\rWPS-AP Usage:\"wifi_ap_wps pin [pin_code]\" or \"wifi_ap_wps pbc\"\n"); + } + return; +} +#endif //CONFIG_ENABLE_WPS_AP +#endif //CONFIG_ENABLE_WPS diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.h new file mode 100644 index 00000000..0d8f59e0 --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_wps_config.h @@ -0,0 +1,75 @@ +/** + ****************************************************************************** + * @file wifi_wps_config.h + * @author + * @version + * @brief This file provides user interfaces for WPS functionality. + ****************************************************************************** + * @attention + * + * This module is a confidential and proprietary property of RealTek and + * possession or use of this module requires written permission of RealTek. + * + * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved. + ****************************************************************************** + */ + +/** @addtogroup wpsp2p WPS/P2P + * @ingroup wlan + * @brief WPS/P2P functions + * @{ + */ + +/** + * @brief Start WPS enrollee process. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(). + * @param[in] wps_config: WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON. + * @param[in] pin: PIN number. Can be set to NULL if using WPS_CONFIG_PUSHBUTTON. + * @param[in] channel: Channel. Currently un-used, can be set to 0. + * @param[in] ssid: Target network SSID. Can be set to NULL if no target network specified. + * @return 0 on success. + * @note Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h.\n + * You can reference @ref cmd_wps() to know how to choose input parameters. + */ +int wps_start(u16 wps_config, char *pin, u8 channel, char *ssid); + +/** + * @brief Command to start WPS enrollee process for commonly use. Can refer to ATWW in atcmd_wifi.c. + * @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(). + * @param[in] argc: Command line argument. Argument count. + * @param[in] argv: Command line argument. Argument vector. + * @return 0 on success. + * @note Command style for example: + * - cmd_wps pbc + * - cmd_wps pin + * - cmd_wps pin 12345678 + * @note Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h. + */ +void cmd_wps(int argc, char **argv); + +/** + * @brief Start a WPS registrar thread. + * @warning Before invoking this function, the Wi-Fi should be in SoftAP mode. + * @param[in] config_methods: WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON. + * @param[in] pin: PIN number. Can be set to NULL. + * @return None + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h.\n + * You can reference @ref cmd_ap_wps() to know how to choose input parameters. + */ +void wifi_start_ap_wps_thread(u16 config_methods, char *pin); + +/** + * @brief Command to start WPS registrar process for commonly use. Can refer to ATWw in atcmd_wifi.c. + * @warning Before invoking this function, the Wi-Fi should be in SoftAP mode. + * @param[in] argc: Command line argument. Argument count. + * @param[in] argv: Command line argument. Argument vector. + * @return 0 on success + * @note Command style for example: + * - cmd_ap_wps pbc + * - cmd_ap_wps pin + * - cmd_ap_wps pin 12345678 + * @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h. + */ +void cmd_ap_wps(int argc, char **argv); + +/*\@}*/ diff --git a/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wps_protocol_handler.h b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wps_protocol_handler.h new file mode 100644 index 00000000..14e506be --- /dev/null +++ b/bsp/peripheral/wireless/realtek/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wps_protocol_handler.h @@ -0,0 +1,150 @@ +/* + * Header files of wps_protocol_handler + * + */ + +#ifndef _WPS_PROTOCOL_HANDLER_H_ +#define _WPS_PROTOCOL_HANDLER_H_ + +#define KEY_NONCE_LEN 32 +#define KEY_RC_LEN 8 +#define KEY_IV_LEN 16 +#define KEY_RSC_LEN 8 +#define KEY_ID_LEN 8 +#define KEY_MIC_LEN 16 +#define KEY_MATERIAL_LEN 2 + +#define ETHER_HDRLEN 14 +#define LIB1X_EAPOL_HDRLEN 4 +#define LIB1X_EAPOL_MESSAGE_HDRLEN 5 + +#define LIB1X_ETHER_EAPOL_TYPE 0x888E + +#define LIB1X_EAPOL_VER 1 //0000 0001B +#define LIB1X_EAPOL_EAPPKT 0 //0000 0000B +#define LIB1X_EAPOL_START 1 //0000 0001B +#define LIB1X_EAPOL_LOGOFF 2 //0000 0010B +#define LIB1X_EAPOL_KEY 3 //0000 0011B +#define LIB1X_EAPOL_ENCASFALERT 4 //0000 0100B + +#define LIB1X_EAP_CODE_REQUEST (1) +#define LIB1X_EAP_CODE_RESPONSE (2) +#define LIB1X_EAP_CODE_FAIL (4) + +#define LIB1X_EAP_TYPE_IDENTITY (1) +#define LIB1X_EAP_TYPE_NOTIFICATION (2) +#define LIB1X_EAP_TYPE_NAK (3) +#define LIB1X_EAP_TYPE_EXPANDED (254) /* Wi-Fi Simple Configuation(WSC) */ + +#define LIB1X_EAP_OPCODE_WSC_START (0x01) +#define LIB1X_EAP_OPCODE_WSC_ACK (0x02) +#define LIB1X_EAP_OPCODE_WSC_NACK (0x03) +#define LIB1X_EAP_OPCODE_WSC_MSG (0x04) +#define LIB1X_EAP_OPCODE_WSC_DONE (0x05) +#define LIB1X_EAP_OPCODE_WSC_FRAG_ACK (0x06) + +#define WPS_START_DELAY_TIME 1000 +#define WPS_START_RESEND_TIME 10000 + +struct rtw_wps_context +{ + /* WPS State Machine */ + unsigned char clientWpsDone; + unsigned char clientWpsProcessing; + + /* Avoid handle duplicated message */ + unsigned char record_last_message_type; + + /* For handling fragmented messages */ + unsigned char last_message_has_more_frag; + + unsigned char pad_aligned; + unsigned char identifier; + + /* AP passphrase */ + char passphrase[65]; + + /* Keep wps process info */ + struct eap_wsc_data *wsc_data; + struct wps_context * wps; + + /* timer to delay send eapol start */ + _timer wps_start_timer; +}; + +struct _LIB1X_EAPOL_WSC +{ + unsigned char Code; + unsigned char Identifier; + unsigned short Length; + + unsigned char Type; + unsigned char Vendor_Id[3]; + + unsigned int Vendor_Type; + + unsigned char OpCode; + unsigned char Flags; + unsigned short Message_Length; + + unsigned char *Message_Data; +}; + +struct lib1x_eapol_message_hdr +{ + unsigned char Code; + unsigned char Identifier; + unsigned short Length; + unsigned char Type; +}; + +typedef struct _LIB1X_EAPOL_KEY +{ + unsigned char key_desc_ver; + unsigned char key_info[2]; + unsigned char key_len[2]; + unsigned char key_replay_counter[KEY_RC_LEN]; + unsigned char key_nounce[KEY_NONCE_LEN]; + unsigned char key_iv[KEY_IV_LEN]; + unsigned char key_rsc[KEY_RSC_LEN]; + unsigned char key_id[KEY_ID_LEN]; + unsigned char key_mic[KEY_MIC_LEN]; + unsigned char key_data_len[KEY_MATERIAL_LEN]; + unsigned char *key_data; +} lib1x_eapol_key; + +struct lib1x_eapol +{ + unsigned char protocol_version; + unsigned char packet_type; // This makes it odd in number ! + unsigned short packet_body_length; +}; + +struct wlan_ethhdr_t +{ + unsigned char daddr[ETH_ALEN]; + unsigned char saddr[ETH_ALEN]; + unsigned short type; +}; + +extern struct rtw_wps_context g_wps_context; + +extern xqueue_handle_t queue_for_credential; + +int wpas_wps_dev_config(u8 *dev_addr, u8 bregistrar); +int wpas_wps_init(const char* ifname); +void wpas_wps_deinit(void); +int wpas_wps_registrar_button_pushed(void); +int wpas_wps_registrar_check_done(void); +int wpas_wps_registrar_add_pin(const u8 *pin, size_t pin_len); +int wpas_wps_registrar_wps_cancel(void); +int wpas_wps_enrollee_init_assoc_ie(void); +int wpas_wps_enrollee_init_probe_ie(u16 config_methods); +void wpas_wsc_sta_wps_start_hdl(char *buf, int buf_len, int flags, void *userdata); +void wpas_wsc_wps_finish_hdl(char *buf, int buf_len, int flags, void *userdata); +void wpas_wsc_eapol_recvd_hdl(char *buf, int buf_len, int flags, void *userdata); + +unsigned int wps_pin_valid(unsigned int pin); +unsigned int wps_generate_pin(void); +//#endif //CONFIG_WPS +#endif //_WPS_PROTOCOL_HANDLER_H_ diff --git a/bsp/peripheral/wireless/realtek/api/wifi_interactive_mode.c b/bsp/peripheral/wireless/realtek/api/wifi_interactive_mode.c index 30a8b19e..74edfa02 100644 --- a/bsp/peripheral/wireless/realtek/api/wifi_interactive_mode.c +++ b/bsp/peripheral/wireless/realtek/api/wifi_interactive_mode.c @@ -367,7 +367,13 @@ static void cmd_wifi_ap(int argc, char **argv) } #endif #if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP +#if CONFIG_LWIP_LAYER +#if !defined(CONFIG_PLATFOMR_CUSTOMER_RTOS) wpas_wps_dev_config(pnetif->hwaddr, 1); +#else + //TODO +#endif +#endif #endif if(argc == 4) { diff --git a/bsp/peripheral/wireless/realtek/platform/include/rtwlan_config.h b/bsp/peripheral/wireless/realtek/platform/include/rtwlan_config.h index b2420192..d2543f09 100644 --- a/bsp/peripheral/wireless/realtek/platform/include/rtwlan_config.h +++ b/bsp/peripheral/wireless/realtek/platform/include/rtwlan_config.h @@ -1,6 +1,13 @@ +#include "aic_common.h" + #define CONFIG_PLATFOMR_CUSTOMER_RTOS #define DRV_NAME "RTL8733BS" + +#ifdef REALTEK_FULL_FNC_MODE +#define DRIVERVERSION "460653b8f542ceeb2c9019ac6c38cd8ec20a4424" +#else #define DRIVERVERSION "57999b1af4f228855793e1801ce9bbea4565e7a8" +#endif #define CONFIG_DEBUG 1 @@ -11,6 +18,14 @@ #define CONFIG_NO_REFERENCE_FOR_COMPILER 1 #define MAX_TX_SKB_DATA_NUM 100 +#ifdef REALTEK_FULL_FNC_MODE +#define CONFIG_AP_MODE 1 +//20240904_v1.4 +#define CONFIG_CONCURRENT_MODE 1 +#define CONFIG_PROMISC 1 +#define CONFIG_WPS 1 +#define CONFIG_ENABLE_P2P 1 +#endif #ifndef CONFIG_WLAN #define CONFIG_WLAN 1 diff --git a/bsp/peripheral/wireless/realtek/wlan_lib/libwlan_rtl8189_full_c906fd.a b/bsp/peripheral/wireless/realtek/wlan_lib/libwlan_rtl8189_full_c906fd.a new file mode 100644 index 00000000..eb57f1f8 Binary files /dev/null and b/bsp/peripheral/wireless/realtek/wlan_lib/libwlan_rtl8189_full_c906fd.a differ diff --git a/kernel/rt-thread/components/drivers/Kconfig b/kernel/rt-thread/components/drivers/Kconfig index 6b9865d6..493019df 100644 --- a/kernel/rt-thread/components/drivers/Kconfig +++ b/kernel/rt-thread/components/drivers/Kconfig @@ -39,6 +39,11 @@ menuconfig RT_USING_SERIAL bool "Enable serial DMA mode" default y + config RT_SERIAL_USING_FLOWCTRL + bool "Enable serial flow control mode" + depends on AIC_SERIAL_USING_FLOWCTRL + default y + config RT_SERIAL_RB_BUFSZ int "Set RX buffer size" depends on !RT_USING_SERIAL_V2 @@ -123,7 +128,7 @@ config RT_USING_ADC config RT_USING_DAC bool "Using DAC device drivers" default n - + config RT_USING_PWM bool "Using PWM device drivers" default n @@ -261,23 +266,23 @@ config RT_USING_SPI config RT_SFUD_USING_SFDP bool "Using auto probe flash JEDEC SFDP parameter" default y - + config RT_SFUD_USING_FLASH_INFO_TABLE bool "Using defined supported flash chip information table" default y - + config RT_SFUD_USING_QSPI bool "Using QSPI mode support" select RT_USING_QSPI default n - + config RT_SFUD_SPI_MAX_HZ int "Default spi maximum speed(HZ)" range 0 50000000 default 50000000 help Read the JEDEC SFDP command must run at 50 MHz or less,and you also can use rt_spi_configure(); to config spi speed. - + config RT_DEBUG_SFUD bool "Show more SFUD debug information" default n @@ -301,7 +306,7 @@ config RT_USING_WDT config RT_USING_AUDIO bool "Using Audio device drivers" default n - + if RT_USING_AUDIO config RT_AUDIO_REPLAY_MP_BLOCK_SIZE int "Replay memory pool block size" diff --git a/kernel/rt-thread/components/drivers/i2c/i2c-bit-ops.c b/kernel/rt-thread/components/drivers/i2c/i2c-bit-ops.c index 08fa5a83..be72e570 100644 --- a/kernel/rt-thread/components/drivers/i2c/i2c-bit-ops.c +++ b/kernel/rt-thread/components/drivers/i2c/i2c-bit-ops.c @@ -366,9 +366,9 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, return RT_EOK; } -static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus, - struct rt_i2c_msg msgs[], - rt_uint32_t num) +rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus, + struct rt_i2c_msg msgs[], + rt_uint32_t num) { struct rt_i2c_msg *msg; struct rt_i2c_bit_ops *ops = (struct rt_i2c_bit_ops *)bus->priv; diff --git a/kernel/rt-thread/components/drivers/i2c/i2c_core.c b/kernel/rt-thread/components/drivers/i2c/i2c_core.c index a6a0b4fa..501d168b 100644 --- a/kernel/rt-thread/components/drivers/i2c/i2c_core.c +++ b/kernel/rt-thread/components/drivers/i2c/i2c_core.c @@ -168,19 +168,24 @@ rt_size_t rt_i2c_write_reg(struct rt_i2c_bus_device *bus, rt_uint8_t *buf, rt_uint32_t count) { + rt_size_t ret = 0; rt_uint8_t cmd[AIC_I2C_CMD_BUF_LEN] = {0}; RT_ASSERT(bus != RT_NULL); RT_ASSERT(buf != RT_NULL); if (count == 0 || count > (AIC_I2C_CMD_BUF_LEN - 1)) { LOG_E("rt_i2c_write_reg: write buf len out of range\n"); - return -RT_EINVAL; + return 0; } cmd[0] = reg; rt_memcpy(&cmd[1], buf, count); - return rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 1); + ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 1); + if (ret != (count + 1)) + return 0; + + return count; } rt_size_t rt_i2c_write_reg16(struct rt_i2c_bus_device *bus, @@ -189,20 +194,25 @@ rt_size_t rt_i2c_write_reg16(struct rt_i2c_bus_device *bus, rt_uint8_t *buf, rt_uint32_t count) { + rt_size_t ret = 0; rt_uint8_t cmd[AIC_I2C_CMD_BUF_LEN] = {0}; RT_ASSERT(bus != RT_NULL); RT_ASSERT(buf != RT_NULL); if (count == 0 || count > (AIC_I2C_CMD_BUF_LEN - 2)) { LOG_E("rt_i2c_write_reg16: write buf len out of range\n"); - return -RT_EINVAL; + return 0; } cmd[0] = (rt_uint8_t)(reg >> 8); cmd[1] = (rt_uint8_t)(reg & 0xff); rt_memcpy(&cmd[2], buf, count); - return rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 2); + ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 2); + if (ret != (count + 2)) + return 0; + + return count; } rt_size_t rt_i2c_read_reg(struct rt_i2c_bus_device *bus, @@ -217,7 +227,7 @@ rt_size_t rt_i2c_read_reg(struct rt_i2c_bus_device *bus, if (count == 0) { LOG_E("rt_i2c_read_reg: read buf len out of range\n"); - return -RT_EINVAL; + return 0; } ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, ®, 1); @@ -240,7 +250,7 @@ rt_size_t rt_i2c_read_reg16(struct rt_i2c_bus_device *bus, if (count == 0) { LOG_E("rt_i2c_read_reg16: read buf len out of range\n"); - return -RT_EINVAL; + return 0; } cmd[0] = (rt_uint8_t)(reg >> 8); diff --git a/kernel/rt-thread/components/drivers/include/drivers/i2c-bit-ops.h b/kernel/rt-thread/components/drivers/include/drivers/i2c-bit-ops.h index 0d94de11..038e26cd 100644 --- a/kernel/rt-thread/components/drivers/include/drivers/i2c-bit-ops.h +++ b/kernel/rt-thread/components/drivers/include/drivers/i2c-bit-ops.h @@ -29,6 +29,10 @@ struct rt_i2c_bit_ops rt_uint32_t timeout; /* in tick */ }; +rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus, + struct rt_i2c_msg msgs[], + rt_uint32_t num); + rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus, const char *bus_name); diff --git a/kernel/rt-thread/components/drivers/ipc/waitqueue.c b/kernel/rt-thread/components/drivers/ipc/waitqueue.c index a543b2fd..15c62fd8 100644 --- a/kernel/rt-thread/components/drivers/ipc/waitqueue.c +++ b/kernel/rt-thread/components/drivers/ipc/waitqueue.c @@ -134,8 +134,6 @@ void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key) queue_list = &(queue->waiting_list); level = rt_hw_interrupt_disable(); - /* set wakeup flag in the queue */ - queue->flag = RT_WQ_FLAG_WAKEUP; if (!(rt_list_isempty(queue_list))) { @@ -159,6 +157,8 @@ void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key) LOG_D("%s: Thread resume failed", __func__); } node = node->next; + + rt_wqueue_remove(entry); } else { @@ -211,12 +211,6 @@ int rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec) /* reset thread error */ tid->error = RT_EOK; - if (queue->flag == RT_WQ_FLAG_WAKEUP) - { - /* already wakeup */ - goto __exit_wakeup; - } - rt_wqueue_add(queue, &__wait); rt_thread_suspend(tid); @@ -233,13 +227,5 @@ int rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec) rt_schedule(); - level = rt_hw_interrupt_disable(); - -__exit_wakeup: - queue->flag = RT_WQ_FLAG_CLEAN; - rt_hw_interrupt_enable(level); - - rt_wqueue_remove(&__wait); - return tid->error; } diff --git a/kernel/rt-thread/components/drivers/sdio/block_dev.c b/kernel/rt-thread/components/drivers/sdio/block_dev.c index 76fcaa97..36807c6d 100644 --- a/kernel/rt-thread/components/drivers/sdio/block_dev.c +++ b/kernel/rt-thread/components/drivers/sdio/block_dev.c @@ -23,7 +23,7 @@ #include #ifdef AIC_AB_SYSTEM_INTERFACE -#include +#include #include #endif @@ -622,7 +622,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) rt_snprintf(dname, sizeof(dname), "mmc%d", host_id); else rt_snprintf(dname, sizeof(dname), "sd%d", host_id); - blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, &part); + blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, NULL); if ( blk_dev == RT_NULL ) { err = -RT_ENOMEM; diff --git a/kernel/rt-thread/components/drivers/serial/serial.c b/kernel/rt-thread/components/drivers/serial/serial.c index a4fafc0c..a3866dca 100644 --- a/kernel/rt-thread/components/drivers/serial/serial.c +++ b/kernel/rt-thread/components/drivers/serial/serial.c @@ -305,6 +305,7 @@ rt_inline int _serial_int_rx(struct rt_serial_device *serial, rt_uint8_t *data, ch = rx_fifo->buffer[rx_fifo->get_index]; rx_fifo->get_index += 1; +#ifdef RT_SERIAL_USING_FLOWCTRL if (serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL ) @@ -314,9 +315,7 @@ rt_inline int _serial_int_rx(struct rt_serial_device *serial, rt_uint8_t *data, rt_flowctrl_low_detect(serial, 1, RT_SERIAL_INT_FCL_BUFFER); } } - - - +#endif if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0; if (rx_fifo->is_full == RT_TRUE) @@ -411,6 +410,7 @@ static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial) } #endif /* RT_USING_POSIX_STDIO || RT_SERIAL_USING_DMA */ +#ifdef RT_SERIAL_USING_FLOWCTRL /** * Flow control high level detect. * @@ -486,6 +486,7 @@ void rt_flowctrl_low_detect(struct rt_serial_device *serial, rt_size_t len, rt_s } } } +#endif #ifdef RT_SERIAL_USING_DMA /** @@ -624,7 +625,7 @@ rt_inline int _serial_dma_rx(struct rt_serial_device *serial, rt_uint8_t *data, rt_memcpy(data + serial->config.bufsz - rx_fifo->get_index, rx_fifo->buffer, recv_len + rx_fifo->get_index - serial->config.bufsz); } - +#ifdef RT_SERIAL_USING_FLOWCTRL if (serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL) @@ -634,7 +635,7 @@ rt_inline int _serial_dma_rx(struct rt_serial_device *serial, rt_uint8_t *data, rt_flowctrl_low_detect(serial, recv_len, RT_SERIAL_DMA_FCL_BUFFER); } } - +#endif rt_dma_recv_update_get_index(serial, recv_len); rt_hw_interrupt_enable(level); return recv_len; @@ -1444,6 +1445,7 @@ void rt_serial_rx_ind(struct rt_serial_device *serial) rx_fifo->put_index += 1; if (rx_fifo->put_index >= serial->config.bufsz) rx_fifo->put_index = 0; +#ifdef RT_SERIAL_USING_FLOWCTRL if ((serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL) && @@ -1458,7 +1460,7 @@ void rt_serial_rx_ind(struct rt_serial_device *serial) { serial->ops->control(serial, RT_SERIAL_SW_RECEIVE_ON_OFF, &ch); } - +#endif /* if the next position is read index, discard this 'read char' */ if (rx_fifo->put_index == rx_fifo->get_index) { @@ -1562,7 +1564,7 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event) { /* disable interrupt */ level = rt_hw_interrupt_disable(); - +#ifdef RT_SERIAL_USING_FLOWCTRL /* flow control high level detect */ if ((serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL || serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL || @@ -1571,6 +1573,7 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event) { rt_flowctrl_high_detect(serial, length, RT_SERIAL_DMA_FCH_BUFFER); } +#endif /* update fifo put index */ rt_dma_recv_update_put_index(serial, length); /* calculate received total length */ diff --git a/kernel/rt-thread/components/drivers/touch/touch.c b/kernel/rt-thread/components/drivers/touch/touch.c index b6f7514d..8978e23b 100644 --- a/kernel/rt-thread/components/drivers/touch/touch.c +++ b/kernel/rt-thread/components/drivers/touch/touch.c @@ -126,9 +126,6 @@ static rt_size_t rt_touch_read(rt_device_t dev, rt_off_t pos, void *buf, rt_size { rt_touch_t touch; rt_size_t result = 0; - rt_uint8_t index; - rt_uint16_t temp = 0; - struct rt_touch_data *read_data = RT_NULL; RT_ASSERT(dev != RT_NULL); touch = (rt_touch_t)dev; @@ -138,32 +135,6 @@ static rt_size_t rt_touch_read(rt_device_t dev, rt_off_t pos, void *buf, rt_size } result = touch->ops->touch_readpoint(touch, buf, len); - - read_data = (struct rt_touch_data *)buf; - - for (index = 0; index < len; index++) { -#ifdef AIC_TOUCH_X_FILP - read_data[index].x_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - - read_data[index].x_coordinate; -#endif -#ifdef AIC_TOUCH_Y_FILP - read_data[index].y_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - - read_data[index].y_coordinate; -#endif -#ifdef AIC_TOUCH_90_DEGREE_ROTATION - temp = read_data[index].x_coordinate; - read_data[index].x_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - - read_data[index].y_coordinate; - read_data[index].y_coordinate = temp; -#endif -#ifdef AIC_TOUCH_270_DEGREE_ROTATION - temp = read_data[index].x_coordinate; - read_data[index].x_coordinate = read_data[index].y_coordinate; - read_data[index].y_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - temp; -#endif - (void)read_data; - (void)temp; - } return result; } diff --git a/kernel/rt-thread/tools/menuconfig.py b/kernel/rt-thread/tools/menuconfig.py index c67a7ee7..8b3935c3 100644 --- a/kernel/rt-thread/tools/menuconfig.py +++ b/kernel/rt-thread/tools/menuconfig.py @@ -44,6 +44,58 @@ def is_pkg_special_config(config_str): return True return False + +def get_config_val(src, name): + try: + config = open(src, 'r') + except: + print('open config:%s failed' % src) + return None + + for line in config: + line = line.lstrip(' ').replace('\n', '').replace('\r', '') + + if len(line) == 0: + continue + + if line[0] == '#': + continue + else: + setting = line.split('=') + if len(setting) >= 2: + if setting[0] == name: + return setting[1] + return None + + +def get_heap_base(filename): + heap_size = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_HEAP_SIZE') + if get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE') and \ + int(get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE'), 16) > 0: + ram_base = get_config_val(filename, 'CONFIG_CPU_PSRAM_BASE') + ram_size = get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE') + elif get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE') and \ + int(get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE'), 16) > 0: + ram_base = get_config_val(filename, 'CONFIG_CPU_DRAM_BASE') + ram_size = get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE') + elif get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE') and \ + int(get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE'), 16) > 0: + ram_base = get_config_val(filename, 'CONFIG_CPU_SRAM_BASE') + ram_size = get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE') + elif get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE') and \ + int(get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE'), 16) > 0: + ram_base = get_config_val(filename, 'CONFIG_CPU_SRAM_BASE') + ram_size = get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE') + + return (int(ram_base, 16) + int(ram_size, 16) - int(heap_size, 16)) + + +def get_text_base(filename): + text_size = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_TEXT_SIZE') + heap_base = get_heap_base(filename) + return (heap_base - int(text_size, 16)) + + def mk_rtconfig(filename): try: config = open(filename, 'r') @@ -98,6 +150,24 @@ def mk_rtconfig(filename): if os.path.isfile('rtconfig_project.h'): rtconfig.write('#include "rtconfig_project.h"\n') + # Auto calc bootloader memory + val = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_MEM_AUTO') + if val == 'y': + heap_base = get_heap_base(filename) + text_base = get_text_base(filename) + + comment = '\n/* Automatically calc generated */\n\n' + heap_base_def = '#define AIC_BOOTLOADER_HEAP_BASE (0x%x)\n' % (heap_base) + text_base_def = '#define AIC_BOOTLOADER_TEXT_BASE (0x%x)\n' % (text_base) + + rtconfig.write(comment) + rtconfig.write(heap_base_def) + rtconfig.write(text_base_def) + + print('Insert macro definition into rtconfig.h\n') + print(heap_base_def) + print(text_base_def) + rtconfig.write('\n') rtconfig.write('#endif\n') rtconfig.close() @@ -257,6 +327,7 @@ def menuconfig(RTT_ROOT): fn_old = '.config.old' kconfig_cmd = os.path.join(RTT_ROOT, 'tools', 'kconfig-frontends', 'kconfig-mconf') + print(kconfig_cmd + ' Kconfig') os.system(kconfig_cmd + ' Kconfig') if os.path.isfile(fn): diff --git a/packages/artinchip/Kconfig b/packages/artinchip/Kconfig index baaa4849..d6f73228 100644 --- a/packages/artinchip/Kconfig +++ b/packages/artinchip/Kconfig @@ -8,5 +8,6 @@ source "packages/artinchip/ota/Kconfig" source "packages/artinchip/burn-in/Kconfig" source "packages/artinchip/aic-authorization/Kconfig" source "packages/artinchip/ipmanager/Kconfig" +source "packages/artinchip/barcode/Kconfig" endmenu diff --git a/packages/artinchip/SConscript b/packages/artinchip/SConscript index 6ec3efc3..d2fa9a98 100644 --- a/packages/artinchip/SConscript +++ b/packages/artinchip/SConscript @@ -7,7 +7,7 @@ cwd = GetCurrentDir() objs = [] list = os.listdir(cwd) -prio = ['ota', 'aic-startup-ui', 'lvgl-ui'] +prio = ['env', 'aic-startup-ui', 'lvgl-ui'] remain_dirs = [d for d in list if d not in prio] for d in prio: diff --git a/packages/artinchip/aic-startup-ui/assets/image0.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image0.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image0.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image0.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image1.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image1.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image1.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image1.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image10.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image10.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image10.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image10.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image11.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image11.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image11.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image11.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image12.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image12.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image12.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image12.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image2.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image2.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image2.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image2.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image3.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image3.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image3.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image3.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image4.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image4.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image4.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image4.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image5.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image5.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image5.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image5.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image6.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image6.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image6.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image6.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image7.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image7.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image7.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image7.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image8.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image8.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image8.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image8.jpg diff --git a/packages/artinchip/aic-startup-ui/assets/image9.jpg b/packages/artinchip/aic-startup-ui/assets_1080x600/image9.jpg similarity index 100% rename from packages/artinchip/aic-startup-ui/assets/image9.jpg rename to packages/artinchip/aic-startup-ui/assets_1080x600/image9.jpg diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image0.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image0.jpg new file mode 100644 index 00000000..fdf904b8 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image0.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image1.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image1.jpg new file mode 100644 index 00000000..785a2503 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image1.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image10.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image10.jpg new file mode 100644 index 00000000..a9b15366 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image10.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image11.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image11.jpg new file mode 100644 index 00000000..075724f5 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image11.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image12.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image12.jpg new file mode 100644 index 00000000..28f587f5 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image12.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image2.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image2.jpg new file mode 100644 index 00000000..f29da593 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image2.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image3.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image3.jpg new file mode 100644 index 00000000..72849cba Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image3.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image4.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image4.jpg new file mode 100644 index 00000000..85e28e69 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image4.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image5.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image5.jpg new file mode 100644 index 00000000..f7bc45e8 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image5.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image6.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image6.jpg new file mode 100644 index 00000000..a6203b0d Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image6.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image7.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image7.jpg new file mode 100644 index 00000000..432de531 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image7.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image8.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image8.jpg new file mode 100644 index 00000000..ba699ec4 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image8.jpg differ diff --git a/packages/artinchip/aic-startup-ui/assets_480x272/image9.jpg b/packages/artinchip/aic-startup-ui/assets_480x272/image9.jpg new file mode 100644 index 00000000..74f4dee9 Binary files /dev/null and b/packages/artinchip/aic-startup-ui/assets_480x272/image9.jpg differ diff --git a/packages/artinchip/aic-startup-ui/startup_ui.c b/packages/artinchip/aic-startup-ui/startup_ui.c index 046f71dc..37ba33cb 100644 --- a/packages/artinchip/aic-startup-ui/startup_ui.c +++ b/packages/artinchip/aic-startup-ui/startup_ui.c @@ -29,9 +29,24 @@ #include "stddef.h" #define PATH_MAX 1024 + +#ifdef LPKG_CHERRYUSB_DEVICE_DISPLAY_TEMPLATE +#define AIC_STARTUP_UI_SHOW_LVGL_LOGO + +#ifdef AIC_LVGL_USB_OSD_DEMO +#error "Not support turn on LVGL USB OSD DEMO and Startup UI at the same time" +#endif +#endif + +#ifdef AIC_STARTUP_UI_SHOW_LVGL_LOGO +#define IMAGE_EXTENSION ".png" +#define IMAGE_CATALOG "/data/lvgl_data" +#define IMAGE_PATH_ROOT "/data/lvgl_data/logo.png" +#else #define IMAGE_EXTENSION ".jpg" #define IMAGE_CATALOG "/data" #define IMAGE_PATH_ROOT "/data/image" +#endif #ifdef AIC_STARTUP_UI_POS_X #define IMAGE_SCREEN_POS_X AIC_STARTUP_UI_POS_X @@ -132,7 +147,6 @@ static struct frame_allocator *allocator_open(u8 *buf, u32 x, u32 y) } #endif -#ifndef USE_VE_FILL_FB static int ge_bitblt(struct ge_bitblt *blt) { int ret = 0; @@ -164,11 +178,13 @@ static int ge_bitblt(struct ge_bitblt *blt) return 0; } -#endif -#if defined (AIC_PAN_DISPLAY) && !defined(USE_VE_FILL_FB) +#ifdef AIC_PAN_DISPLAY +static u32 fb_copy_index = 0; +#ifndef USE_VE_FILL_FB static u32 startup_fb_buf_index = 0; #endif +#endif static struct aicfb_screeninfo *get_screen_info(void) { @@ -263,6 +279,52 @@ static void render_frame(struct mpp_fb* fb, struct mpp_frame* frame, } #endif +#ifdef AIC_PAN_DISPLAY +static void framebuffer_copy(int buffer_index) +{ + struct ge_bitblt blt; + struct aicfb_screeninfo *info = NULL;; + + info = get_screen_info(); + if (info == NULL) + return; + + u32 fb0_buf_addr0 = (u32)(unsigned long)info->framebuffer;; + u32 fb0_buf_addr1 = fb0_buf_addr0 + info->smem_len;; + + memset(&blt, 0, sizeof(struct ge_bitblt)); + + if (buffer_index == 0) { + blt.src_buf.phy_addr[0] = fb0_buf_addr0; + } else { + blt.src_buf.phy_addr[0] = fb0_buf_addr1; + } + blt.src_buf.buf_type = MPP_PHY_ADDR; + blt.src_buf.format = info->format; + blt.src_buf.stride[0] = info->stride; + blt.src_buf.size.width = info->width; + blt.src_buf.size.height = info->height; + blt.src_buf.crop_en = 0; + + if (buffer_index == 0) { + blt.dst_buf.phy_addr[0] = fb0_buf_addr1; + } else { + blt.dst_buf.phy_addr[0] = fb0_buf_addr0; + } + blt.dst_buf.buf_type = MPP_PHY_ADDR; + blt.dst_buf.format = info->format; + blt.dst_buf.stride[0] = info->stride; + blt.dst_buf.size.width = info->width; + blt.dst_buf.size.height = info->height; + blt.dst_buf.crop_en = 0; + + logi("phy_addr: %x, stride: %d", blt.src_buf.phy_addr[0], blt.src_buf.stride[0]); + logi("width: %d, height: %d, format: %d", blt.src_buf.size.width, blt.src_buf.size.height, blt.src_buf.format); + + ge_bitblt(&blt); +} +#endif + static int decode_pic_from_path(const char *path, u32 offset_x, u32 offset_y, u32 width, u32 height, u32 layer_id, bool is_first_img) { @@ -308,11 +370,18 @@ static int decode_pic_from_path(const char *path, u32 offset_x, u32 offset_y, #ifdef USE_VE_FILL_FB config.pix_fmt = info->format; #else - config.pix_fmt = MPP_FMT_RGB_565; + config.pix_fmt = MPP_FMT_NV12; #endif if (pic[0] == 0xff && pic[1] == 0xd8) { dec = mpp_decoder_create(MPP_CODEC_VIDEO_DECODER_MJPEG); + } else if (pic[1] == 'P' || pic[2] == 'N' || pic[3] == 'G') { + if (config.pix_fmt == MPP_FMT_RGB_565 || config.pix_fmt == MPP_FMT_BGR_565) { + loge("PNG decode does nor support RGB565\n"); + free(pic); + return -1; + } + dec = mpp_decoder_create(MPP_CODEC_VIDEO_DECODER_PNG); } else { loge("Unsupported or invalid image format\n"); free(pic); @@ -398,7 +467,12 @@ static int count_images(const char *directoryPath) static void construct_imagepath(char *outputBuffer, int image_number) { +#ifdef AIC_STARTUP_UI_SHOW_LVGL_LOGO + (void)image_number; + snprintf(outputBuffer, PATH_MAX, "%s", IMAGE_PATH_ROOT); +#else snprintf(outputBuffer, PATH_MAX, "%s%d%s", IMAGE_PATH_ROOT, image_number, IMAGE_EXTENSION); +#endif } int startup_ui_show(void) @@ -437,6 +511,15 @@ int startup_ui_show(void) decode_pic_from_path(image_path, IMAGE_SCREEN_POS_X, IMAGE_SCREEN_POS_Y, 0, 0, AICFB_LAYER_TYPE_UI, false); } } +#ifdef AIC_PAN_DISPLAY + if ((image_count % 2) == 0) { + /* frame buffer copy */ + framebuffer_copy(!fb_copy_index); + /* switch to frame buffer 0 */ + mpp_fb_ioctl(startup_ui->startup_fb, AICFB_PAN_DISPLAY, &fb_copy_index); + mpp_fb_ioctl(startup_ui->startup_fb, AICFB_WAIT_FOR_VSYNC, NULL); + } +#endif free(startup_ui); return 0; diff --git a/packages/artinchip/barcode/Kconfig b/packages/artinchip/barcode/Kconfig new file mode 100644 index 00000000..e4024777 --- /dev/null +++ b/packages/artinchip/barcode/Kconfig @@ -0,0 +1,3 @@ +menuconfig AIC_USING_BARCODE_DEMO + bool "ArtInChip Barcode Demo" + default n diff --git a/packages/artinchip/barcode/SConscript b/packages/artinchip/barcode/SConscript new file mode 100755 index 00000000..a33b80b6 --- /dev/null +++ b/packages/artinchip/barcode/SConscript @@ -0,0 +1,17 @@ +Import('AIC_ROOT') +Import('PRJ_KERNEL') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [] +src = [] + +LIBS = ['decoder.a'] +LIBPATH = [cwd + "/lib/"] + +if GetDepend('AIC_USING_BARCODE_DEMO'): + src = Glob('*.c') + +group = DefineGroup('aic_barcode_demo', src, depend = ['AIC_USING_BARCODE_DEMO'], CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH) + +Return('group') diff --git a/packages/artinchip/barcode/barcode.c b/packages/artinchip/barcode/barcode.c new file mode 100644 index 00000000..03edb4a9 --- /dev/null +++ b/packages/artinchip/barcode/barcode.c @@ -0,0 +1,525 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: matteo + */ +#include +#include +#include +#include + +#include +#include + +#include "aic_core.h" +#include "aic_log.h" +#include "aic_osal.h" +#include "aic_drv_gpio.h" +#include "include/yydecoder.h" +#include "include/video_font_data.h" + +#include "mpp_vin.h" +#include "drv_camera.h" +#include "artinchip_fb.h" +#include "mpp_fb.h" +#include "mpp_ge.h" + +#define BARCODE_DEMO_SUCCESS 1 +#define BUFFER_SIZE 180 * 1024 +#define VID_BUF_NUM 3 +#define VID_BUF_PLANE_NUM 2 +#define VID_SCALE_OFFSET 0 +#define VIDEO_FONT_HEIGHT 32 + +#define ALIGN_DOWM(x, align) ((x) & ~(align - 1)) + +struct aic_dvp_data { + int w; + int h; + int frame_size; + int frame_cnt; + int rotation; + int dst_fmt; // output format + struct mpp_video_fmt src_fmt; + uint32_t num_buffers; + struct vin_video_buf binfo; +}; + +struct aic_decode_data { + bool dready; + int w; + int h; + unsigned char *in_buffer; + unsigned char out_buffer[256]; +}; + +static struct mpp_fb *g_fb = NULL; +static struct aicfb_screeninfo g_fb_info = {0}; + +static struct aic_dvp_data g_vdata = {0}; +static struct aic_decode_data g_ddata = {0}; +static bool g_dvp_running = true; +static bool g_running = true; +unsigned char g_last_barcode[128] = {0}; + +static int dvp_cfg(int width, int height, int format) +{ + int ret = 0; + struct dvp_out_fmt f = {0}; + + f.width = g_vdata.src_fmt.width; + f.height = g_vdata.src_fmt.height; + f.pixelformat = format; + f.num_planes = VID_BUF_PLANE_NUM; + + ret = mpp_dvp_ioctl(DVP_OUT_S_FMT, &f); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + return -1; + } + + return 0; +} + +static int dvp_subdev_set_fmt(void) +{ + int ret = 0; + + ret = mpp_dvp_ioctl(DVP_IN_S_FMT, &g_vdata.src_fmt); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + return -1; + } + + return 0; +} + +static int sensor_get_fmt(void) +{ + int ret = 0; + struct mpp_video_fmt f = {0}; + + ret = mpp_dvp_ioctl(DVP_IN_G_FMT, &f); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + // return -1; + } + + g_vdata.src_fmt = f; + g_vdata.w = g_vdata.src_fmt.width; + g_vdata.h = g_vdata.src_fmt.height; + pr_info("Sensor format: w %d h %d, code 0x%x, bus 0x%x, colorspace 0x%x\n", + f.width, f.height, f.code, f.bus_type, f.colorspace); + return 0; +} + +static int dvp_request_buf(struct vin_video_buf *vbuf) +{ + int i; + + if (mpp_dvp_ioctl(DVP_REQ_BUF, (void *)vbuf) < 0) { + pr_err("ioctl() failed!\n"); + return -1; + } + + pr_info("Buf Plane[0] size Plane[1] size\n"); + for (i = 0; i < vbuf->num_buffers; i++) { + pr_info("%3d 0x%x %8d 0x%x %8d\n", i, + vbuf->planes[i * vbuf->num_planes].buf, + vbuf->planes[i * vbuf->num_planes].len, + vbuf->planes[i * vbuf->num_planes + 1].buf, + vbuf->planes[i * vbuf->num_planes + 1].len); + } + + return 0; +} + +static void dvp_release_buf(int num) +{ +#if 0 + int i; + struct video_buf_info *binfo = NULL; + + for (i = 0; i < num; i++) { + binfo = &g_vdata.binfo[i]; + if (binfo->vaddr) { + munmap(binfo->vaddr, binfo->len); + binfo->vaddr = NULL; + } + } +#endif +} + +static int dvp_queue_buf(int index) +{ + if (mpp_dvp_ioctl(DVP_Q_BUF, (void *)(ptr_t)index) < 0) { + pr_err("ioctl() failed!\n"); + return -1; + } + + return 0; +} + +static int dvp_dequeue_buf(int *index) +{ + int ret = 0; + + ret = mpp_dvp_ioctl(DVP_DQ_BUF, (void *)index); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + return -1; + } + + return 0; +} + +static int dvp_start(void) +{ + int ret = 0; + + ret = mpp_dvp_ioctl(DVP_STREAM_ON, NULL); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + return -1; + } + + return 0; +} + +static int dvp_stop(void) +{ + int ret = 0; + + ret = mpp_dvp_ioctl(DVP_STREAM_OFF, NULL); + if (ret < 0) { + pr_err("ioctl() failed! err -%d\n", -ret); + return -1; + } + + return 0; +} + +static void barcode_copy_buffer(struct aic_dvp_data *vdata, int index) +{ + struct vin_video_buf *binfo = &vdata->binfo; + unsigned long buf = binfo->planes[index * VID_BUF_PLANE_NUM].buf; + int len = binfo->planes[index * VID_BUF_PLANE_NUM].len; + + aicos_memcpy(g_ddata.in_buffer, (void *)buf, len); + g_ddata.dready = true; +} + +static int barcode_showvideo_tolcd(struct aic_dvp_data *vdata, int index) +{ + int i; + struct aicfb_layer_data layer = {0}; + struct vin_video_buf *binfo = &vdata->binfo; + + layer.layer_id = AICFB_LAYER_TYPE_VIDEO; + layer.enable = 1; + + layer.scale_size.width = g_fb_info.width - VID_SCALE_OFFSET * 2; + layer.scale_size.height = g_fb_info.height - VID_SCALE_OFFSET * 2; + layer.pos.x = VID_SCALE_OFFSET; + layer.pos.y = VID_SCALE_OFFSET; + + layer.buf.size.width = vdata->w; + layer.buf.size.height = vdata->h; + layer.buf.format = MPP_FMT_NV12; + + layer.buf.buf_type = MPP_PHY_ADDR; + + for (i = 0; i < VID_BUF_PLANE_NUM; i++) { + layer.buf.stride[i] = layer.buf.size.width; + layer.buf.phy_addr[i] = binfo->planes[index * VID_BUF_PLANE_NUM + i].buf; + } + + if (mpp_fb_ioctl(g_fb, AICFB_UPDATE_LAYER_CONFIG, &layer) < 0) { + pr_err("ioctl() failed!\n"); + return -1; + } + return 0; +} + +static void aicfb_lcd_putc(unsigned int x, unsigned int y, char ch) +{ + unsigned long dcache_size, dcache_start; + int pbytes = g_fb_info.bits_per_pixel / 8; + int i, row; + void *line; + + line = (unsigned char *)(g_fb_info.framebuffer + y * g_fb_info.stride + x * pbytes); + dcache_start = ALIGN_DOWM((unsigned long)line, ARCH_DMA_MINALIGN); + + for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { + unsigned int idx = (ch - 32) * VIDEO_FONT_HEIGHT + row; + uint32_t bits = video_fontdata[idx]; + + uint16_t *dst = line; + + for (i = 0; i < VIDEO_FONT_WIDTH; i++) { + *dst++ = (bits & 0x80000000) ? 0xFFFF : 0x0000; + bits <<= 1; + } + + line += g_fb_info.stride; + } + + dcache_size = ALIGN_UP((unsigned long)line - dcache_start, + ARCH_DMA_MINALIGN); + aicos_dcache_clean_range((unsigned long *)dcache_start, dcache_size); +} + +static int barcode_set_ui_layer_alpha(int val) +{ + int ret = BARCODE_DEMO_SUCCESS; + struct aicfb_alpha_config alpha = {0}; + + alpha.layer_id = AICFB_LAYER_TYPE_UI; + alpha.enable = 1; + alpha.mode = 1; + alpha.value = val; + ret = mpp_fb_ioctl(g_fb, AICFB_UPDATE_ALPHA_CONFIG, &alpha); + if (ret < 0) + pr_err("ioctl() failed! errno: -%d\n", -ret); + return BARCODE_DEMO_SUCCESS; +} + +static int show_barcode_tolcd(int len) +{ + int font_width = 32; + int i,startx; + startx = 10; + if(strcmp((char *)g_last_barcode, (char *)(g_ddata.out_buffer)) == 0){ + //pr_info("same, not shshow !\n"); + return -1; + } + + memset(g_fb_info.framebuffer,0, g_fb_info.smem_len); + aicos_dcache_clean_range(g_fb_info.framebuffer, g_fb_info.smem_len); + + for (i = 0; i < len; i ++) + aicfb_lcd_putc(startx + (i * font_width), 60, g_ddata.out_buffer[i]); + + strcpy((char *)g_last_barcode, (char *)(g_ddata.out_buffer)); + + pr_info("GetDecoderResult %d [%s] \n", len, g_ddata.out_buffer); + return BARCODE_DEMO_SUCCESS; +} + +static void show_duration_tolcd(char* buf, int len) +{ + int font_width = 30; + int i,startx; + startx = 10; + + for (i = 0; i < len -1; i ++) + aicfb_lcd_putc(startx + (i * font_width), 150, buf[i]); + + pr_info("duration %d [%s] \n", buf); +} + +static void barcode_shotting_thread() +{ + int index = 0; + int i; + + if (dvp_request_buf(&g_vdata.binfo) < 0) + return; + + for (i = 0; i < VID_BUF_NUM; i++) { + if (dvp_queue_buf(i) < 0) + return; + } + + if (dvp_start() < 0) + return; + + g_dvp_running = true; + while (g_dvp_running) { + if (dvp_dequeue_buf(&index) < 0) + break; + + barcode_showvideo_tolcd(&g_vdata, index); + + if( !g_ddata.dready) + barcode_copy_buffer(&g_vdata, index); + + dvp_queue_buf(index); + } + + g_running = false; + dvp_stop(); + dvp_release_buf(g_vdata.binfo.num_buffers); + mpp_vin_deinit(); +} + +static void barcode_decode_thread() +{ + int ret; + int len = 0; + struct timespec begin, end; + char str_duration[64] = {0}; + float diff_duration; + g_running = true; + + while(g_running){ + + if( g_ddata.dready){ + gettimespec(&begin); + ret = Decoding_Image(g_ddata.in_buffer, g_ddata.w, g_ddata.h); + //pr_info("Decoding_Image with %d [%d, %d] \n", ret, g_ddata.w, g_ddata.h); + + len = GetResultLength(); + //pr_info("GetResultLength with %d\n", len); + + ret = GetDecoderResult(g_ddata.out_buffer); + //pr_info("GetDecoderResult with %d \n", ret); + if(len > 0){ + gettimespec(&end); + //show_timespec_diff("decode", NULL, &begin, &end); + if(show_barcode_tolcd(len) == BARCODE_DEMO_SUCCESS){ + diff_duration = timespec_diff(&begin, &end); + sprintf(str_duration, "Time: %d ms\n", (u32)(diff_duration * MS_PER_SEC) % MS_PER_SEC); + show_duration_tolcd(str_duration, strlen(str_duration)); + memset(str_duration, 0, sizeof(str_duration)); + } + } + } + g_ddata.dready = false; + aicos_msleep(500); + } + + if (g_fb) { + mpp_fb_close(g_fb); + g_fb = NULL; + } + aicos_free(MEM_CMA, g_ddata.in_buffer); + ret = 0; + pr_info("exit with ret = %d \n", ret); +} + +static int init_dvp_device() +{ + memset(&g_vdata, 0, sizeof(struct aic_dvp_data)); + g_vdata.dst_fmt = MPP_FMT_NV12; + g_vdata.frame_cnt = 1; + + if (mpp_vin_init(CAMERA_DEV_NAME)) + return -1; + + if (sensor_get_fmt() < 0) + goto error_out; + + if (dvp_subdev_set_fmt() < 0) + goto error_out; + + g_vdata.frame_size = (g_vdata.w * g_vdata.h * 3) >> 1; + + if (dvp_cfg(g_vdata.w, g_vdata.h, g_vdata.dst_fmt) < 0) + goto error_out; + + g_vdata.num_buffers = VID_BUF_NUM; + + return BARCODE_DEMO_SUCCESS; + +error_out: + mpp_vin_deinit(); + return -1; +} + +static int init_screen_fb() +{ + int ret = 0; + g_fb = mpp_fb_open(); + + ret = mpp_fb_ioctl(g_fb, AICFB_GET_SCREENINFO, &g_fb_info); + if (ret < 0){ + pr_err("ioctl() failed! errno: -%d\n", -ret); + return -1; + } + + memset(g_fb_info.framebuffer,0, g_fb_info.smem_len); + aicos_dcache_clean_range(g_fb_info.framebuffer, g_fb_info.smem_len); + + ret = mpp_fb_ioctl(g_fb, AICFB_POWERON, &g_fb_info); + if (ret < 0){ + pr_err("ioctl() failed! errno: -%d\n", -ret); + return -1; + } + + pr_info("Screen width: %d, height %d\n", g_fb_info.width, g_fb_info.height); + + return BARCODE_DEMO_SUCCESS; +} + +static void cmd_barcode_demo(int argc, char **argv) +{ + int ret; + aicos_thread_t thid = NULL; + + ret = init_screen_fb(); + if(ret != BARCODE_DEMO_SUCCESS){ + pr_info("init_screen_fb failed with %d \n", ret); + return; + } + + ret = barcode_set_ui_layer_alpha(64); + if(ret != BARCODE_DEMO_SUCCESS){ + pr_info("set_ui_layer_alpha failed with %d \n", ret); + goto error_out; + } + + ret = init_dvp_device(); + if(ret != BARCODE_DEMO_SUCCESS){ + pr_info("init_dvp_device failed with %d \n", ret); + return; + } + + g_ddata.w = g_vdata.w; + g_ddata.h = g_vdata.h; + g_ddata.dready = false; + g_running = true; + + g_ddata.in_buffer = aicos_malloc(MEM_CMA, g_ddata.w * g_ddata.w * 2); + + ret = Initial_Decoder(); + if(ret != BARCODE_DEMO_SUCCESS){ + pr_info("Initial_Decoder failed with %d \n", ret); + goto error_out; + } + + for (size_t i = 0; i <= 13; i++) { + Set_Donfig_Decoder(i, 1); + } + + + thid = aicos_thread_create("shoting_thead", 8192, 0, barcode_shotting_thread, NULL); + if (thid == NULL) { + pr_err("Failed to create DVP thread\n"); + goto error_out; + } + + thid = aicos_thread_create("barcode_thread", 1024 * 32, 0, barcode_decode_thread, NULL); + if (thid == NULL) { + pr_err("Failed to create decode thread\n"); + goto error_out; + } + return; + +error_out: + if (g_fb) { + mpp_fb_close(g_fb); + g_fb = NULL; + } + aicos_free(MEM_CMA, g_ddata.in_buffer); +} +static int barcode_demo() +{ + cmd_barcode_demo(0, NULL); + return 0; +} +INIT_LATE_APP_EXPORT (barcode_demo); + diff --git a/packages/artinchip/barcode/include/video_font_data.h b/packages/artinchip/barcode/include/video_font_data.h new file mode 100644 index 00000000..d872dc0d --- /dev/null +++ b/packages/artinchip/barcode/include/video_font_data.h @@ -0,0 +1,9818 @@ +/* + * Copyright (c) 2024, Artinchip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +#ifndef _VIDEO_FONT_DATA_ +#define _VIDEO_FONT_DATA_ + +#define VIDEO_FONT_CHARS 96 +#define VIDEO_FONT_WIDTH 32 +#define VIDEO_FONT_HEIGHT 32 +#define VIDEO_FONT_SIZE (VIDEO_FONT_CHARS * VIDEO_FONT_HEIGHT) + +/** + * ASCII 32 - 127 + */ +static uint32_t video_fontdata[VIDEO_FONT_SIZE] = { +#if (AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE == 90) + /* 0x20 ' ' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x21 '!' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffc00f0, + 0x3ffffcf0, + 0x3ffffcf0, + 0x3ffffcf0, + 0x3ffc00f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x22 '"' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x23 '#' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00180000, + 0x00183800, + 0x00183800, + 0x1fd83800, + 0x1fffb800, + 0x1ffffe00, + 0x03fffff0, + 0x001ffff0, + 0x00183ff0, + 0x10183800, + 0x1fd83800, + 0x1fffb800, + 0x1fffff80, + 0x01fffff0, + 0x0019fff0, + 0x00183bf0, + 0x00183800, + 0x00183800, + 0x00003800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x24 '$' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001e00, + 0x01807f80, + 0x0780ffc0, + 0x0f81ffe0, + 0x0f81fff0, + 0x1e01e070, + 0x1c03c070, + 0x1c03c030, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0x38070030, + 0x1c0f0070, + 0x1e0f0070, + 0x1ffe01f0, + 0x0ffe0fe0, + 0x07fc0fe0, + 0x03f80fc0, + 0x00000f00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x25 '%' */ + 0x00000000, + 0x00000fc0, + 0x00001ff0, + 0x00003ff0, + 0x00007878, + 0x00007038, + 0x00007018, + 0x08007018, + 0x0c007038, + 0x0f007878, + 0x07c03ff0, + 0x01f03ff0, + 0x00fc1fe0, + 0x003f0380, + 0x000f8000, + 0x0003e000, + 0x0000f800, + 0x00607e00, + 0x01fc1f80, + 0x03fe07c0, + 0x07ff01f0, + 0x0f0f0078, + 0x0e070038, + 0x0e030008, + 0x0e030000, + 0x0e070000, + 0x0f0f0000, + 0x07ff0000, + 0x07fe0000, + 0x01fc0000, + 0x00600000, + 0x00000000, + + /* 0x26 '&' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000010, + 0x00000030, + 0x00008070, + 0x0000f0f0, + 0x0000fff0, + 0x0000ffe0, + 0x0180ffc0, + 0x0fe01fc0, + 0x1ff07fe0, + 0x1ff8fce0, + 0x3ffdf870, + 0x3c3ff070, + 0x381fe030, + 0x381fc030, + 0x3c3f0030, + 0x1fff8070, + 0x1fffc070, + 0x0ffbe0f0, + 0x07e1fff0, + 0x0001ffe0, + 0x0000ffc0, + 0x00003f80, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x27 ''' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x28 '(' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x3c000001, + 0x3f000007, + 0x1fe0003f, + 0x07ffffff, + 0x03fffffc, + 0x00fffff0, + 0x001fffc0, + 0x0000fc00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x29 ')' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000f000, + 0x000fff80, + 0x007ffff0, + 0x01fffffc, + 0x07ffffff, + 0x0ff0007f, + 0x3f80000f, + 0x3c000001, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2a '*' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x06000000, + 0x06300000, + 0x07700000, + 0x03f00000, + 0x3fe00000, + 0x3fc00000, + 0x3fe00000, + 0x03f00000, + 0x07700000, + 0x06300000, + 0x06000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2b '+' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x003ffff0, + 0x003ffff0, + 0x003ffff0, + 0x003ffff0, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2c ',' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000fc, + 0x000000ff, + 0x000000ff, + 0x000000f3, + 0x000000f1, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2d '-' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2e '.' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2f '/' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x3f000000, + 0x3fe00000, + 0x0ffc0000, + 0x01ff8000, + 0x003ff000, + 0x0007fe00, + 0x0000ffc0, + 0x00000ff0, + 0x000001f0, + 0x00000030, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x30 '0' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0007e000, + 0x007ffe00, + 0x03ffff80, + 0x07ffffc0, + 0x0fffffe0, + 0x0fc003f0, + 0x1f0000f0, + 0x1c000070, + 0x1c000030, + 0x1c000030, + 0x1c000030, + 0x1c000070, + 0x1e0000f0, + 0x1f8003f0, + 0x0fffffe0, + 0x07ffffc0, + 0x03ffff80, + 0x00fffe00, + 0x000fe000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x31 '1' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x07c00000, + 0x03c00000, + 0x01c00000, + 0x01c00000, + 0x00c00000, + 0x00c00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x32 '2' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01fc0070, + 0x07fe0070, + 0x0fff0070, + 0x0fff8070, + 0x1f0fc070, + 0x1e03c070, + 0x1c01e070, + 0x1c01e070, + 0x1c00f070, + 0x1c00f070, + 0x1c007870, + 0x1e003c70, + 0x1f003e70, + 0x0ff01ff0, + 0x0ff00ff0, + 0x07f007f0, + 0x01f003f0, + 0x000000f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x33 '3' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003e00, + 0x00e07f80, + 0x07f8ffc0, + 0x0ffdffe0, + 0x0fffffe0, + 0x1fffc0f0, + 0x1e0f8070, + 0x1c078070, + 0x1c070030, + 0x1c030030, + 0x1c030030, + 0x1c030030, + 0x1e000070, + 0x1f0000f0, + 0x0fe00ff0, + 0x0fe00fe0, + 0x07e00fe0, + 0x01e00f80, + 0x00000e00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x34 '4' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001c00, + 0x00001c00, + 0x00001c00, + 0x00001c00, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x0f801c00, + 0x07e01c00, + 0x01f01c00, + 0x00fc1c00, + 0x007e1c00, + 0x001f9c00, + 0x000fdc00, + 0x0003fc00, + 0x0001fc00, + 0x0000fc00, + 0x00003c00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x35 '5' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001000, + 0x0000ff00, + 0x1c03ffc0, + 0x1c03ffc0, + 0x1c07ffe0, + 0x1c0fc1f0, + 0x1c0f00f0, + 0x1c0e0070, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0f0070, + 0x1ff700f0, + 0x1fff83f0, + 0x1fff83e0, + 0x01ff83e0, + 0x000383c0, + 0x00000300, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x36 '6' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003c00, + 0x0180ff80, + 0x0783ffc0, + 0x0f87ffe0, + 0x0f87fff0, + 0x1f0780f0, + 0x1e0f0070, + 0x1c0e0070, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1e0e0070, + 0x1f0700f0, + 0x0fc7c1f0, + 0x0fffffe0, + 0x07ffffc0, + 0x01ffff80, + 0x007fff00, + 0x0003e000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x37 '7' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x1c000000, + 0x1f000000, + 0x1f800000, + 0x1fc00000, + 0x1ff00000, + 0x1dfc0000, + 0x1c7e0000, + 0x1c3f8000, + 0x1c1ff000, + 0x1c07fe00, + 0x1c01ffe0, + 0x1c007ff0, + 0x1c001ff0, + 0x1c0003f0, + 0x1c000070, + 0x1c000000, + 0x1c000000, + 0x1c000000, + 0x1c000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x38 '8' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000800, + 0x00407f80, + 0x03f8ffc0, + 0x07fdffe0, + 0x0fffffe0, + 0x1fffc0f0, + 0x1e0f8070, + 0x1c078030, + 0x1c070030, + 0x1c070030, + 0x1c070030, + 0x1c078070, + 0x1e0f8070, + 0x1fbfc0f0, + 0x0ffffff0, + 0x0ffdffe0, + 0x03f8ffc0, + 0x00e07f80, + 0x00001e00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x39 '9' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00060000, + 0x00fff800, + 0x03ffff00, + 0x07ffff80, + 0x0fffffc0, + 0x1f87c7e0, + 0x1e01e1f0, + 0x1c00e070, + 0x1c006030, + 0x1c007030, + 0x1c007030, + 0x1c00e030, + 0x1e00e070, + 0x1f01e0f0, + 0x0fffe3f0, + 0x0fffc3e0, + 0x07ff83c0, + 0x01ff0380, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3a ':' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3b ';' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007800fc, + 0x007800ff, + 0x007800ff, + 0x007800f3, + 0x007800f1, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3c '<' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x001800e0, + 0x001c00e0, + 0x001c00e0, + 0x001e01c0, + 0x000e01c0, + 0x000e03c0, + 0x00070380, + 0x00070380, + 0x00038700, + 0x00038700, + 0x0003cf00, + 0x0001ce00, + 0x0001de00, + 0x0000fc00, + 0x0000fc00, + 0x0000f800, + 0x00007800, + 0x00007800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3d '=' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3e '>' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007800, + 0x00007800, + 0x0000f800, + 0x0000fc00, + 0x0000fc00, + 0x0001de00, + 0x0001ce00, + 0x0003ce00, + 0x00038700, + 0x00038700, + 0x00070780, + 0x00070380, + 0x000e03c0, + 0x000e01c0, + 0x001e01c0, + 0x001c00e0, + 0x001c00e0, + 0x001800e0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3f '?' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00c00000, + 0x07f00000, + 0x0ffc0000, + 0x1ffe0000, + 0x1fff0000, + 0x3c1f8000, + 0x3807c000, + 0x3803f8f0, + 0x3801f8f0, + 0x3800f8f0, + 0x380078f0, + 0x3c000000, + 0x1f000000, + 0x1fc00000, + 0x0fc00000, + 0x07c00000, + 0x01c00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x40 '@' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x003f8000, + 0x00fff100, + 0x01fff9c0, + 0x03f0fdc0, + 0x07801ee0, + 0x0f600e70, + 0x0e7e0770, + 0x1c7fe338, + 0x1c3fff18, + 0x187fff18, + 0x1878ff18, + 0x18f01e18, + 0x18e00e18, + 0x18600718, + 0x18700718, + 0x18780718, + 0x1c7e0738, + 0x1c3fff38, + 0x0e1fff70, + 0x0e0ffe70, + 0x0783fce0, + 0x07c003e0, + 0x03f80fc0, + 0x01ffff80, + 0x007ffe00, + 0x001ff800, + 0x00018000, + 0x00000000, + 0x00000000, + + /* 0x41 'A' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000070, + 0x000003f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ffe0, + 0x001fff80, + 0x007ffc00, + 0x03fff800, + 0x1fff7800, + 0x3ff87800, + 0x3fc07800, + 0x3e007800, + 0x3fc07800, + 0x3ff87800, + 0x0fff7800, + 0x01fff800, + 0x003ff800, + 0x000fff00, + 0x0001ffe0, + 0x00003ff0, + 0x00000ff0, + 0x000001f0, + 0x00000030, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x42 'B' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001c00, + 0x00007f00, + 0x03f0ffc0, + 0x0ff9ffc0, + 0x1fffffe0, + 0x1fffc1e0, + 0x1f3f80f0, + 0x3c0f80f0, + 0x3c070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x43 'C' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00c03c00, + 0x03c03f00, + 0x07c03f80, + 0x0fc03fc0, + 0x1f8007e0, + 0x1e0001e0, + 0x3c0000f0, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38000030, + 0x38000070, + 0x38000070, + 0x3c000070, + 0x3c0000f0, + 0x1e0001f0, + 0x1f8003e0, + 0x0ff01fe0, + 0x0fffffc0, + 0x03ffff80, + 0x01fffe00, + 0x007ff800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x44 'D' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x003ff000, + 0x00fffc00, + 0x03ffff00, + 0x07ffff80, + 0x0ff87fc0, + 0x0f8007e0, + 0x1f0001e0, + 0x1e0000f0, + 0x1c0000f0, + 0x3c000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x45 'E' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x46 'F' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x38000000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x47 'G' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00c3fff0, + 0x03c3fff0, + 0x07c3fff0, + 0x0fc3ffc0, + 0x1fc387c0, + 0x1f0381e0, + 0x3e0380e0, + 0x3c038070, + 0x38038070, + 0x38038070, + 0x38038030, + 0x38038030, + 0x38000030, + 0x38000070, + 0x38000070, + 0x3c000070, + 0x3e0000f0, + 0x1f0001f0, + 0x1f8007e0, + 0x0ff83fc0, + 0x07ffffc0, + 0x03ffff00, + 0x00fffe00, + 0x003ff800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x48 'H' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x49 'I' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4a 'J' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fffff80, + 0x3fffffc0, + 0x3fffffe0, + 0x3ffffff0, + 0x000001f0, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000030, + 0x00000070, + 0x00000070, + 0x00000ff0, + 0x00000fe0, + 0x00000fe0, + 0x00000fc0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4b 'K' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000010, + 0x20000030, + 0x30000070, + 0x380001f0, + 0x3c0003f0, + 0x3e0007f0, + 0x3f001fe0, + 0x1f803f80, + 0x0fc0ff00, + 0x07e1fe00, + 0x03f3f800, + 0x01fff000, + 0x00ffc000, + 0x007f8000, + 0x003f0000, + 0x001f8000, + 0x000fc000, + 0x0007e000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4c 'L' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4d 'M' */ + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3fe00000, + 0x3ffc0000, + 0x07ff8000, + 0x00fff000, + 0x001ffe00, + 0x0003ffc0, + 0x00007ff0, + 0x00000ff0, + 0x000003f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ffc0, + 0x001ffe00, + 0x00fff000, + 0x07ff8000, + 0x3ffc0000, + 0x3fe00000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4e 'N' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x000007f0, + 0x00001fe0, + 0x00003f80, + 0x0000ff00, + 0x0001fc00, + 0x0007f000, + 0x001fe000, + 0x003f8000, + 0x00ff0000, + 0x03fc0000, + 0x07f00000, + 0x1fe00000, + 0x3f800000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4f 'O' */ + 0x00000000, + 0x00030000, + 0x007ff800, + 0x01fffe00, + 0x03ffff00, + 0x07ffff80, + 0x0fe01fc0, + 0x1f8007e0, + 0x1e0001e0, + 0x3c0000f0, + 0x3c0000f0, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3c0000f0, + 0x3c0000f0, + 0x1e0001e0, + 0x1f8007e0, + 0x0ff01fc0, + 0x07ffff80, + 0x03ffff00, + 0x01fffe00, + 0x007ff800, + 0x00030000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x50 'P' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03f80000, + 0x07fe0000, + 0x0fff0000, + 0x1fff0000, + 0x1f0f8000, + 0x3c078000, + 0x3c038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x51 'Q' */ + 0x00000000, + 0x00030000, + 0x007ff818, + 0x01fffe3c, + 0x03ffff3c, + 0x07fffff8, + 0x0fe01ff0, + 0x1f8007f0, + 0x1e0001e0, + 0x3c0003f0, + 0x3c0007f0, + 0x380007f0, + 0x38000770, + 0x38000230, + 0x38000030, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3c0000f0, + 0x3c0000f0, + 0x1e0001e0, + 0x1f8007e0, + 0x0ff01fc0, + 0x07ffff80, + 0x03ffff00, + 0x01fffe00, + 0x007ff800, + 0x00030000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x52 'R' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000010, + 0x00e00010, + 0x07f83ff0, + 0x0ffcfff0, + 0x1ffefff0, + 0x1ffffff0, + 0x1e0ff000, + 0x3c07c000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x53 'S' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00403f00, + 0x03c0ffc0, + 0x0fc1ffc0, + 0x1fc1ffe0, + 0x1fc3e1f0, + 0x3e03c0f0, + 0x3c03c070, + 0x38078070, + 0x38078030, + 0x38078030, + 0x38078030, + 0x38070030, + 0x380f0070, + 0x380f0070, + 0x3c0f0070, + 0x3e1e00f0, + 0x1ffe03f0, + 0x1ffe0fe0, + 0x0ffc0fc0, + 0x03f80f80, + 0x00000f00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x54 'T' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x55 'U' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffe00, + 0x3fffff80, + 0x3fffffc0, + 0x3fffffe0, + 0x00000fe0, + 0x000001f0, + 0x000000f0, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000070, + 0x00000070, + 0x000000f0, + 0x000001f0, + 0x000007e0, + 0x3fffffe0, + 0x3fffffc0, + 0x3fffff80, + 0x3ffffe00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x56 'V' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x3e000000, + 0x3fc00000, + 0x3ff80000, + 0x3ffe0000, + 0x07ffc000, + 0x00fff800, + 0x001fff00, + 0x0003ffc0, + 0x00007ff0, + 0x00000ff0, + 0x000001f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ffc0, + 0x001fff00, + 0x00fff800, + 0x07ffc000, + 0x3ffe0000, + 0x3ff80000, + 0x3fc00000, + 0x3e000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x57 'W' */ + 0x01ffff00, + 0x001ffff0, + 0x0000fff0, + 0x00000ff0, + 0x00001ff0, + 0x0000fff0, + 0x000fffc0, + 0x00fffe00, + 0x07ffe000, + 0x3fff0000, + 0x3ff00000, + 0x3f000000, + 0x3ff00000, + 0x3ffe0000, + 0x0fffe000, + 0x00fffc00, + 0x000fffc0, + 0x0001fff0, + 0x00001ff0, + 0x00000ff0, + 0x0000fff0, + 0x000ffff0, + 0x00ffff80, + 0x1ffff800, + 0x3fff8000, + 0x3ff80000, + 0x3fc00000, + 0x3c000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x58 'X' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x20000010, + 0x30000070, + 0x3c0000f0, + 0x3e0003f0, + 0x3f8007f0, + 0x1fc00fe0, + 0x0fe03fc0, + 0x03f87f00, + 0x01fdfe00, + 0x007ff800, + 0x003ff000, + 0x001fc000, + 0x003ff000, + 0x00fff800, + 0x01fdfe00, + 0x07f87f00, + 0x0fe03fc0, + 0x3fc00fe0, + 0x3f0007f0, + 0x3e0001f0, + 0x380000f0, + 0x30000070, + 0x20000010, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x59 'Y' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x38000000, + 0x3e000000, + 0x3f800000, + 0x3fc00000, + 0x0ff00000, + 0x07f80000, + 0x01fe0000, + 0x007f0000, + 0x003ffff0, + 0x000ffff0, + 0x0003fff0, + 0x000ffff0, + 0x003ffff0, + 0x007f0000, + 0x01fe0000, + 0x07f80000, + 0x0ff00000, + 0x3fc00000, + 0x3f000000, + 0x3e000000, + 0x38000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5a 'Z' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c000070, + 0x3e000070, + 0x3f000070, + 0x3fc00070, + 0x3fe00070, + 0x3ff00070, + 0x39f80070, + 0x38fe0070, + 0x387f0070, + 0x383f8070, + 0x380fc070, + 0x3807f070, + 0x3803f870, + 0x3801fc70, + 0x38007e70, + 0x38003ff0, + 0x38001ff0, + 0x380007f0, + 0x380003f0, + 0x380001f0, + 0x000000f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5b '[' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5c '\' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000070, + 0x000003f0, + 0x00001ff0, + 0x0000ffc0, + 0x0007fe00, + 0x003ff000, + 0x01ff8000, + 0x0ffc0000, + 0x3fc00000, + 0x3e000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5d ']' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5e '^' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x02000000, + 0x0e000000, + 0x1e000000, + 0x3e000000, + 0x3c000000, + 0x30000000, + 0x38000000, + 0x3e000000, + 0x1e000000, + 0x0e000000, + 0x02000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5f '_' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x60 '`' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x06000000, + 0x1e000000, + 0x3e000000, + 0x3c000000, + 0x38000000, + 0x30000000, + 0x20000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x61 'a' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000030, + 0x00000030, + 0x000ffff0, + 0x001ffff0, + 0x003ffff0, + 0x007fffe0, + 0x0078e1e0, + 0x007060e0, + 0x00706070, + 0x00607070, + 0x00607030, + 0x00707030, + 0x00707030, + 0x007c7870, + 0x007e7ff0, + 0x003e3ff0, + 0x001e3fe0, + 0x00061fc0, + 0x00000780, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x62 'b' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00006000, + 0x0007fe00, + 0x001fff80, + 0x003fffc0, + 0x003fffe0, + 0x007c01f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x003f03e0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x63 'c' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00070700, + 0x001f07c0, + 0x003f07e0, + 0x007f07e0, + 0x007c01f0, + 0x00700070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00780070, + 0x007c00f0, + 0x003f87e0, + 0x003fffe0, + 0x001fffc0, + 0x0007ff80, + 0x0000fc00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x64 'd' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x001f83e0, + 0x003c00f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x007c01f0, + 0x003fffe0, + 0x003fffe0, + 0x001fffc0, + 0x0007ff00, + 0x0000f800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x65 'e' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x0003f300, + 0x000ff3c0, + 0x001ff3e0, + 0x003ff3f0, + 0x007c70f0, + 0x00787070, + 0x00707070, + 0x00707030, + 0x00707030, + 0x00707030, + 0x00707070, + 0x00787070, + 0x007c71f0, + 0x003fffe0, + 0x001fffe0, + 0x000fffc0, + 0x0007ff00, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x66 'f' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38700000, + 0x38700000, + 0x38700000, + 0x3ffffff0, + 0x3ffffff0, + 0x1ffffff0, + 0x0ffffff0, + 0x00700000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x67 'g' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ffffc, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x003f03e3, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x007c01f1, + 0x003fffe3, + 0x003fffc3, + 0x001fff83, + 0x0007ff03, + 0x00007000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x68 'h' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0003fff0, + 0x001ffff0, + 0x003ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x003c0000, + 0x001f8000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x69 'i' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6a 'j' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6b 'k' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000010, + 0x00400030, + 0x006000f0, + 0x007001f0, + 0x007807f0, + 0x007c1fe0, + 0x003e3fc0, + 0x001fff00, + 0x000ffc00, + 0x0007f800, + 0x0003e000, + 0x0001f000, + 0x0000f800, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6c 'l' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6d 'm' */ + 0x0007fff0, + 0x001ffff0, + 0x003ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x003ffff0, + 0x001ffff0, + 0x003ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x003c0000, + 0x003f8000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6e 'n' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0003fff0, + 0x001ffff0, + 0x003ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x003c0000, + 0x003f8000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6f 'o' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007000, + 0x0007ff00, + 0x000fff80, + 0x001fffc0, + 0x003fffe0, + 0x007c01f0, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00600030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x007c01f0, + 0x003fffe0, + 0x001fffc0, + 0x000fff80, + 0x0007ff00, + 0x0000f800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x70 'p' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00006000, + 0x0007fe00, + 0x001fff80, + 0x003fffc0, + 0x003fffe0, + 0x007c01f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x003f03e0, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x71 'q' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x001f83e0, + 0x003c00f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x007c01f0, + 0x003fffe0, + 0x003fffe0, + 0x001fffc0, + 0x0007ff00, + 0x0000f800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x72 'r' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x00780000, + 0x003e0000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x73 's' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000600, + 0x000e1fc0, + 0x001e1fe0, + 0x003e3fe0, + 0x007e3ff0, + 0x00787870, + 0x00707870, + 0x00707030, + 0x00607030, + 0x0070f030, + 0x0070f070, + 0x0070e070, + 0x007fe0f0, + 0x003fe3e0, + 0x003fc3e0, + 0x000f83c0, + 0x00000300, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x74 't' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700030, + 0x00700030, + 0x00700070, + 0x0ffffff0, + 0x0ffffff0, + 0x0ffffff0, + 0x0fffffe0, + 0x00700000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x75 'u' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007fffc0, + 0x000001e0, + 0x00000070, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000030, + 0x00000070, + 0x007ffff0, + 0x007ffff0, + 0x007fffe0, + 0x007fffc0, + 0x007fff00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x76 'v' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x007e0000, + 0x007f8000, + 0x007ff000, + 0x001ffe00, + 0x0003ff80, + 0x00007ff0, + 0x00000ff0, + 0x000001f0, + 0x000007f0, + 0x00007ff0, + 0x0003ffc0, + 0x001ffe00, + 0x007ff800, + 0x007fc000, + 0x007e0000, + 0x00700000, + 0x00400000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x77 'w' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x007f0000, + 0x007fe000, + 0x007ffe00, + 0x000fffc0, + 0x0000fff0, + 0x00000ff0, + 0x00000ff0, + 0x0000fff0, + 0x000fffe0, + 0x007ffe00, + 0x007fe000, + 0x007f0000, + 0x007fe000, + 0x007ffe00, + 0x000fffe0, + 0x0000fff0, + 0x00000ff0, + 0x00000ff0, + 0x0000fff0, + 0x000fffe0, + 0x007ffe00, + 0x007ff000, + 0x007f0000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x78 'x' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00400030, + 0x00700070, + 0x007801f0, + 0x007e03f0, + 0x007f07f0, + 0x001fdfc0, + 0x000fff80, + 0x0003fe00, + 0x0001fc00, + 0x0007fe00, + 0x000fff80, + 0x003fdfc0, + 0x007f07f0, + 0x007e03f0, + 0x007801f0, + 0x00700070, + 0x00400030, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x79 'y' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x007e0000, + 0x007fc000, + 0x007ff000, + 0x001ffe00, + 0x0003ffc0, + 0x00007ff0, + 0x00000ffc, + 0x000001ff, + 0x00000fff, + 0x00007fff, + 0x0003ffc3, + 0x001ffe00, + 0x007ff000, + 0x007fc000, + 0x007e0000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7a 'z' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000070, + 0x00780070, + 0x007c0070, + 0x007e0070, + 0x007f8070, + 0x007fc070, + 0x0077e070, + 0x0073f070, + 0x0071fc70, + 0x00707e70, + 0x00703f70, + 0x00701ff0, + 0x00700ff0, + 0x007007f0, + 0x007001f0, + 0x007000f0, + 0x00000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7b '{' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x30000000, + 0x30000000, + 0x38000001, + 0x3fff07ff, + 0x1fffcfff, + 0x1fffdfff, + 0x07fffffe, + 0x0000f800, + 0x00007000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7c '|' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7d '}' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007000, + 0x00007000, + 0x0000f800, + 0x03fffffe, + 0x1fffdfff, + 0x1fffdfff, + 0x3fff07ff, + 0x3c000001, + 0x30000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7e '~' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00002000, + 0x0000f000, + 0x0000f800, + 0x00003800, + 0x00001800, + 0x00001800, + 0x00003800, + 0x00003800, + 0x00003800, + 0x00007000, + 0x00007000, + 0x00006000, + 0x0000e000, + 0x0000e000, + 0x00007000, + 0x00007800, + 0x00003800, + 0x00001000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7f '' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff8, + 0x3ffffff8, + 0x3ffffff8, + 0x30000018, + 0x30000018, + 0x30000018, + 0x30000018, + 0x3ffffff8, + 0x3ffffff8, + 0x3ffffff8, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +#elif (AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE == 270) + /* 0x20 ' ' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x21 '!' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffc00f0, + 0x3ffffcf0, + 0x3ffffcf0, + 0x3ffffcf0, + 0x3ffc00f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x22 '"' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x23 '#' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003800, + 0x00183800, + 0x00183800, + 0x00183bf0, + 0x0019fff0, + 0x01fffff0, + 0x1fffff80, + 0x1fffb800, + 0x1fd83800, + 0x10183800, + 0x00183ff0, + 0x001ffff0, + 0x03fffff0, + 0x1ffffe00, + 0x1fffb800, + 0x1fd83800, + 0x00183800, + 0x00183800, + 0x00180000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x24 '$' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000f00, + 0x03f80fc0, + 0x07fc0fe0, + 0x0ffe0fe0, + 0x1ffe01f0, + 0x1e0f0070, + 0x1c0f0070, + 0x38070030, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0x1c03c030, + 0x1c03c070, + 0x1e01e070, + 0x0f81fff0, + 0x0f81ffe0, + 0x0780ffc0, + 0x01807f80, + 0x00001e00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x25 '%' */ + 0x00000000, + 0x00600000, + 0x01fc0000, + 0x07fe0000, + 0x07ff0000, + 0x0f0f0000, + 0x0e070000, + 0x0e030000, + 0x0e030008, + 0x0e070038, + 0x0f0f0078, + 0x07ff01f0, + 0x03fe07c0, + 0x01fc1f80, + 0x00607e00, + 0x0000f800, + 0x0003e000, + 0x000f8000, + 0x003f0380, + 0x00fc1fe0, + 0x01f03ff0, + 0x07c03ff0, + 0x0f007878, + 0x0c007038, + 0x08007018, + 0x00007018, + 0x00007038, + 0x00007878, + 0x00003ff0, + 0x00001ff0, + 0x00000fc0, + 0x00000000, + + /* 0x26 '&' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003f80, + 0x0000ffc0, + 0x0001ffe0, + 0x07e1fff0, + 0x0ffbe0f0, + 0x1fffc070, + 0x1fff8070, + 0x3c3f0030, + 0x381fc030, + 0x381fe030, + 0x3c3ff070, + 0x3ffdf870, + 0x1ff8fce0, + 0x1ff07fe0, + 0x0fe01fc0, + 0x0180ffc0, + 0x0000ffe0, + 0x0000fff0, + 0x0000f0f0, + 0x00008070, + 0x00000030, + 0x00000010, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x27 ''' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x3fe00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x28 '(' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000fc00, + 0x001fffc0, + 0x00fffff0, + 0x03fffffc, + 0x07ffffff, + 0x1fe0003f, + 0x3f000007, + 0x3c000001, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x29 ')' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x3c000001, + 0x3f80000f, + 0x0ff0007f, + 0x07ffffff, + 0x01fffffc, + 0x007ffff0, + 0x000fff80, + 0x0000f000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2a '*' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x06000000, + 0x06300000, + 0x07700000, + 0x03f00000, + 0x3fe00000, + 0x3fc00000, + 0x3fe00000, + 0x03f00000, + 0x07700000, + 0x06300000, + 0x06000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2b '+' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x003ffff0, + 0x003ffff0, + 0x003ffff0, + 0x003ffff0, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2c ',' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000f1, + 0x000000f3, + 0x000000ff, + 0x000000ff, + 0x000000fc, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2d '-' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2e '.' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x000000f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2f '/' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000030, + 0x000001f0, + 0x00000ff0, + 0x0000ffc0, + 0x0007fe00, + 0x003ff000, + 0x01ff8000, + 0x0ffc0000, + 0x3fe00000, + 0x3f000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x30 '0' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000fe000, + 0x00fffe00, + 0x03ffff80, + 0x07ffffc0, + 0x0fffffe0, + 0x1f8003f0, + 0x1e0000f0, + 0x1c000070, + 0x1c000030, + 0x1c000030, + 0x1c000030, + 0x1c000070, + 0x1f0000f0, + 0x0fc003f0, + 0x0fffffe0, + 0x07ffffc0, + 0x03ffff80, + 0x007ffe00, + 0x0007e000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x31 '1' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00c00000, + 0x00c00000, + 0x01c00000, + 0x01c00000, + 0x03c00000, + 0x07c00000, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x32 '2' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000f0, + 0x01f003f0, + 0x07f007f0, + 0x0ff00ff0, + 0x0ff01ff0, + 0x1f003e70, + 0x1e003c70, + 0x1c007870, + 0x1c00f070, + 0x1c00f070, + 0x1c01e070, + 0x1c01e070, + 0x1e03c070, + 0x1f0fc070, + 0x0fff8070, + 0x0fff0070, + 0x07fe0070, + 0x01fc0070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x33 '3' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000e00, + 0x01e00f80, + 0x07e00fe0, + 0x0fe00fe0, + 0x0fe00ff0, + 0x1f0000f0, + 0x1e000070, + 0x1c030030, + 0x1c030030, + 0x1c030030, + 0x1c070030, + 0x1c078070, + 0x1e0f8070, + 0x1fffc0f0, + 0x0fffffe0, + 0x0ffdffe0, + 0x07f8ffc0, + 0x00e07f80, + 0x00003e00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x34 '4' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003c00, + 0x0000fc00, + 0x0001fc00, + 0x0003fc00, + 0x000fdc00, + 0x001f9c00, + 0x007e1c00, + 0x00fc1c00, + 0x01f01c00, + 0x07e01c00, + 0x0f801c00, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x1ffffff0, + 0x00001c00, + 0x00001c00, + 0x00001c00, + 0x00001c00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x35 '5' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000300, + 0x000383c0, + 0x01ff83e0, + 0x1fff83e0, + 0x1fff83f0, + 0x1ff700f0, + 0x1c0f0070, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0070, + 0x1c0f00f0, + 0x1c0fc1f0, + 0x1c07ffe0, + 0x1c03ffc0, + 0x1c03ffc0, + 0x0000ff00, + 0x00001000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x36 '6' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0003e000, + 0x007fff00, + 0x01ffff80, + 0x07ffffc0, + 0x0fffffe0, + 0x0fc7c1f0, + 0x1f0700f0, + 0x1e0e0070, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0030, + 0x1c0e0070, + 0x1e0f0070, + 0x1f0780f0, + 0x0f87fff0, + 0x0f87ffe0, + 0x0783ffc0, + 0x0180ff80, + 0x00003c00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x37 '7' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x1c000000, + 0x1c000000, + 0x1c000000, + 0x1c000000, + 0x1c000070, + 0x1c0003f0, + 0x1c001ff0, + 0x1c007ff0, + 0x1c01ffe0, + 0x1c07fe00, + 0x1c1ff000, + 0x1c3f8000, + 0x1c7e0000, + 0x1dfc0000, + 0x1ff00000, + 0x1fc00000, + 0x1f800000, + 0x1f000000, + 0x1c000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x38 '8' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001e00, + 0x00e07f80, + 0x03f8ffc0, + 0x0ffdffe0, + 0x0ffffff0, + 0x1fbfc0f0, + 0x1e0f8070, + 0x1c078070, + 0x1c070030, + 0x1c070030, + 0x1c070030, + 0x1c078030, + 0x1e0f8070, + 0x1fffc0f0, + 0x0fffffe0, + 0x07fdffe0, + 0x03f8ffc0, + 0x00407f80, + 0x00000800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x39 '9' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01ff0380, + 0x07ff83c0, + 0x0fffc3e0, + 0x0fffe3f0, + 0x1f01e0f0, + 0x1e00e070, + 0x1c00e030, + 0x1c007030, + 0x1c007030, + 0x1c006030, + 0x1c00e070, + 0x1e01e1f0, + 0x1f87c7e0, + 0x0fffffc0, + 0x07ffff80, + 0x03ffff00, + 0x00fff800, + 0x00060000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3a ':' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x007800f0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3b ';' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007800f1, + 0x007800f3, + 0x007800ff, + 0x007800ff, + 0x007800fc, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3c '<' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007800, + 0x00007800, + 0x0000f800, + 0x0000fc00, + 0x0000fc00, + 0x0001de00, + 0x0001ce00, + 0x0003cf00, + 0x00038700, + 0x00038700, + 0x00070380, + 0x00070380, + 0x000e03c0, + 0x000e01c0, + 0x001e01c0, + 0x001c00e0, + 0x001c00e0, + 0x001800e0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3d '=' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00038700, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3e '>' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x001800e0, + 0x001c00e0, + 0x001c00e0, + 0x001e01c0, + 0x000e01c0, + 0x000e03c0, + 0x00070380, + 0x00070780, + 0x00038700, + 0x00038700, + 0x0003ce00, + 0x0001ce00, + 0x0001de00, + 0x0000fc00, + 0x0000fc00, + 0x0000f800, + 0x00007800, + 0x00007800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3f '?' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01c00000, + 0x07c00000, + 0x0fc00000, + 0x1fc00000, + 0x1f000000, + 0x3c000000, + 0x380078f0, + 0x3800f8f0, + 0x3801f8f0, + 0x3803f8f0, + 0x3807c000, + 0x3c1f8000, + 0x1fff0000, + 0x1ffe0000, + 0x0ffc0000, + 0x07f00000, + 0x00c00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x40 '@' */ + 0x00000000, + 0x00000000, + 0x00018000, + 0x001ff800, + 0x007ffe00, + 0x01ffff80, + 0x03f80fc0, + 0x07c003e0, + 0x0783fce0, + 0x0e0ffe70, + 0x0e1fff70, + 0x1c3fff38, + 0x1c7e0738, + 0x18780718, + 0x18700718, + 0x18600718, + 0x18e00e18, + 0x18f01e18, + 0x1878ff18, + 0x187fff18, + 0x1c3fff18, + 0x1c7fe338, + 0x0e7e0770, + 0x0f600e70, + 0x07801ee0, + 0x03f0fdc0, + 0x01fff9c0, + 0x00fff100, + 0x003f8000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x41 'A' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000030, + 0x000001f0, + 0x00000ff0, + 0x00003ff0, + 0x0001ffe0, + 0x000fff00, + 0x003ff800, + 0x01fff800, + 0x0fff7800, + 0x3ff87800, + 0x3fc07800, + 0x3e007800, + 0x3fc07800, + 0x3ff87800, + 0x1fff7800, + 0x03fff800, + 0x007ffc00, + 0x001fff80, + 0x0003ffe0, + 0x00007ff0, + 0x00000ff0, + 0x000003f0, + 0x00000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x42 'B' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x3c070070, + 0x3c0f80f0, + 0x1f3f80f0, + 0x1fffc1e0, + 0x1fffffe0, + 0x0ff9ffc0, + 0x03f0ffc0, + 0x00007f00, + 0x00001c00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x43 'C' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ff800, + 0x01fffe00, + 0x03ffff80, + 0x0fffffc0, + 0x0ff01fe0, + 0x1f8003e0, + 0x1e0001f0, + 0x3c0000f0, + 0x3c000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38000030, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3c0000f0, + 0x1e0001e0, + 0x1f8007e0, + 0x0fc03fc0, + 0x07c03f80, + 0x03c03f00, + 0x00c03c00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x44 'D' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3c000070, + 0x1c0000f0, + 0x1e0000f0, + 0x1f0001e0, + 0x0f8007e0, + 0x0ff87fc0, + 0x07ffff80, + 0x03ffff00, + 0x00fffc00, + 0x003ff000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x45 'E' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38070070, + 0x38000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x46 'F' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38070000, + 0x38000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x47 'G' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x003ff800, + 0x00fffe00, + 0x03ffff00, + 0x07ffffc0, + 0x0ff83fc0, + 0x1f8007e0, + 0x1f0001f0, + 0x3e0000f0, + 0x3c000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38038030, + 0x38038030, + 0x38038070, + 0x38038070, + 0x3c038070, + 0x3e0380e0, + 0x1f0381e0, + 0x1fc387c0, + 0x0fc3ffc0, + 0x07c3fff0, + 0x03c3fff0, + 0x00c3fff0, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x48 'H' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x00070000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x49 'I' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4a 'J' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000fc0, + 0x00000fe0, + 0x00000fe0, + 0x00000ff0, + 0x00000070, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000030, + 0x00000070, + 0x000001f0, + 0x3ffffff0, + 0x3fffffe0, + 0x3fffffc0, + 0x3fffff80, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4b 'K' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x0007e000, + 0x000fc000, + 0x001f8000, + 0x003f0000, + 0x007f8000, + 0x00ffc000, + 0x01fff000, + 0x03f3f800, + 0x07e1fe00, + 0x0fc0ff00, + 0x1f803f80, + 0x3f001fe0, + 0x3e0007f0, + 0x3c0003f0, + 0x380001f0, + 0x30000070, + 0x20000030, + 0x00000010, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4c 'L' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4d 'M' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3fe00000, + 0x3ffc0000, + 0x07ff8000, + 0x00fff000, + 0x001ffe00, + 0x0003ffc0, + 0x00007ff0, + 0x00000ff0, + 0x000003f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ffc0, + 0x001ffe00, + 0x00fff000, + 0x07ff8000, + 0x3ffc0000, + 0x3fe00000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + + /* 0x4e 'N' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3f800000, + 0x1fe00000, + 0x07f00000, + 0x03fc0000, + 0x00ff0000, + 0x003f8000, + 0x001fe000, + 0x0007f000, + 0x0001fc00, + 0x0000ff00, + 0x00003f80, + 0x00001fe0, + 0x000007f0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4f 'O' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00030000, + 0x007ff800, + 0x01fffe00, + 0x03ffff00, + 0x07ffff80, + 0x0ff01fc0, + 0x1f8007e0, + 0x1e0001e0, + 0x3c0000f0, + 0x3c0000f0, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38000070, + 0x38000070, + 0x38000070, + 0x3c0000f0, + 0x3c0000f0, + 0x1e0001e0, + 0x1f8007e0, + 0x0fe01fc0, + 0x07ffff80, + 0x03ffff00, + 0x01fffe00, + 0x007ff800, + 0x00030000, + 0x00000000, + + /* 0x50 'P' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x3c038000, + 0x3c078000, + 0x1f0f8000, + 0x1fff0000, + 0x0fff0000, + 0x07fe0000, + 0x03f80000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x51 'Q' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00030000, + 0x007ff800, + 0x01fffe00, + 0x03ffff00, + 0x07ffff80, + 0x0ff01fc0, + 0x1f8007e0, + 0x1e0001e0, + 0x3c0000f0, + 0x3c0000f0, + 0x38000070, + 0x38000070, + 0x38000070, + 0x38000030, + 0x38000230, + 0x38000770, + 0x380007f0, + 0x3c0007f0, + 0x3c0003f0, + 0x1e0001e0, + 0x1f8007f0, + 0x0fe01ff0, + 0x07fffff8, + 0x03ffff3c, + 0x01fffe3c, + 0x007ff818, + 0x00030000, + 0x00000000, + + /* 0x52 'R' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x38038000, + 0x3c07c000, + 0x1e0ff000, + 0x1ffffff0, + 0x1ffefff0, + 0x0ffcfff0, + 0x07f83ff0, + 0x00e00010, + 0x00000010, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x53 'S' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000f00, + 0x03f80f80, + 0x0ffc0fc0, + 0x1ffe0fe0, + 0x1ffe03f0, + 0x3e1e00f0, + 0x3c0f0070, + 0x380f0070, + 0x380f0070, + 0x38070030, + 0x38078030, + 0x38078030, + 0x38078030, + 0x38078070, + 0x3c03c070, + 0x3e03c0f0, + 0x1fc3e1f0, + 0x1fc1ffe0, + 0x0fc1ffc0, + 0x03c0ffc0, + 0x00403f00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x54 'T' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x55 'U' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffe00, + 0x3fffff80, + 0x3fffffc0, + 0x3fffffe0, + 0x000007e0, + 0x000001f0, + 0x000000f0, + 0x00000070, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000070, + 0x00000070, + 0x00000070, + 0x000000f0, + 0x000001f0, + 0x00000fe0, + 0x3fffffe0, + 0x3fffffc0, + 0x3fffff80, + 0x3ffffe00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x56 'V' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x3e000000, + 0x3fc00000, + 0x3ff80000, + 0x3ffe0000, + 0x07ffc000, + 0x00fff800, + 0x001fff00, + 0x0003ffc0, + 0x00007ff0, + 0x00000ff0, + 0x000001f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ffc0, + 0x001fff00, + 0x00fff800, + 0x07ffc000, + 0x3ffe0000, + 0x3ff80000, + 0x3fc00000, + 0x3e000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x57 'W' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c000000, + 0x3fc00000, + 0x3ff80000, + 0x3fff8000, + 0x1ffff800, + 0x00ffff80, + 0x000ffff0, + 0x0000fff0, + 0x00000ff0, + 0x00001ff0, + 0x0001fff0, + 0x000fffc0, + 0x00fffc00, + 0x0fffe000, + 0x3ffe0000, + 0x3ff00000, + 0x3f000000, + 0x3ff00000, + 0x3fff0000, + 0x07ffe000, + 0x00fffe00, + 0x000fffc0, + 0x0000fff0, + 0x00001ff0, + 0x00000ff0, + 0x0000fff0, + 0x001ffff0, + 0x01ffff00, + + /* 0x58 'X' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x20000010, + 0x30000070, + 0x380000f0, + 0x3e0001f0, + 0x3f0007f0, + 0x3fc00fe0, + 0x0fe03fc0, + 0x07f87f00, + 0x01fdfe00, + 0x00fff800, + 0x003ff000, + 0x001fc000, + 0x003ff000, + 0x007ff800, + 0x01fdfe00, + 0x03f87f00, + 0x0fe03fc0, + 0x1fc00fe0, + 0x3f8007f0, + 0x3e0003f0, + 0x3c0000f0, + 0x30000070, + 0x20000010, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x59 'Y' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x38000000, + 0x3e000000, + 0x3f000000, + 0x3fc00000, + 0x0ff00000, + 0x07f80000, + 0x01fe0000, + 0x007f0000, + 0x003ffff0, + 0x000ffff0, + 0x0003fff0, + 0x000ffff0, + 0x003ffff0, + 0x007f0000, + 0x01fe0000, + 0x07f80000, + 0x0ff00000, + 0x3fc00000, + 0x3f800000, + 0x3e000000, + 0x38000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5a 'Z' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000000f0, + 0x380001f0, + 0x380003f0, + 0x380007f0, + 0x38001ff0, + 0x38003ff0, + 0x38007e70, + 0x3801fc70, + 0x3803f870, + 0x3807f070, + 0x380fc070, + 0x383f8070, + 0x387f0070, + 0x38fe0070, + 0x39f80070, + 0x3ff00070, + 0x3fe00070, + 0x3fc00070, + 0x3f000070, + 0x3e000070, + 0x3c000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5b '[' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5c '\' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x3e000000, + 0x3fc00000, + 0x0ffc0000, + 0x01ff8000, + 0x003ff000, + 0x0007fe00, + 0x0000ffc0, + 0x00001ff0, + 0x000003f0, + 0x00000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5d ']' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x38000000, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x3fffffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5e '^' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x02000000, + 0x0e000000, + 0x1e000000, + 0x3e000000, + 0x38000000, + 0x30000000, + 0x3c000000, + 0x3e000000, + 0x1e000000, + 0x0e000000, + 0x02000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5f '_' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000003, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x60 '`' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x20000000, + 0x30000000, + 0x38000000, + 0x3c000000, + 0x3e000000, + 0x1e000000, + 0x06000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x61 'a' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000780, + 0x00061fc0, + 0x001e3fe0, + 0x003e3ff0, + 0x007e7ff0, + 0x007c7870, + 0x00707030, + 0x00707030, + 0x00607030, + 0x00607070, + 0x00706070, + 0x007060e0, + 0x0078e1e0, + 0x007fffe0, + 0x003ffff0, + 0x001ffff0, + 0x000ffff0, + 0x00000030, + 0x00000030, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x62 'b' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x003f03e0, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x007c01f0, + 0x003fffe0, + 0x003fffc0, + 0x001fff80, + 0x0007fe00, + 0x00006000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x63 'c' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000fc00, + 0x0007ff80, + 0x001fffc0, + 0x003fffe0, + 0x003f87e0, + 0x007c00f0, + 0x00780070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00700070, + 0x007c01f0, + 0x007f07e0, + 0x003f07e0, + 0x001f07c0, + 0x00070700, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x64 'd' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000f800, + 0x0007ff00, + 0x001fffc0, + 0x003fffe0, + 0x003fffe0, + 0x007c01f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x003c00f0, + 0x001f83e0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x65 'e' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00003000, + 0x0007ff00, + 0x000fffc0, + 0x001fffe0, + 0x003fffe0, + 0x007c71f0, + 0x00787070, + 0x00707070, + 0x00707030, + 0x00707030, + 0x00707030, + 0x00707070, + 0x00787070, + 0x007c70f0, + 0x003ff3f0, + 0x001ff3e0, + 0x000ff3c0, + 0x0003f300, + 0x00003000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x66 'f' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x00700000, + 0x0ffffff0, + 0x1ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x38700000, + 0x38700000, + 0x38700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x67 'g' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007000, + 0x0007ff03, + 0x001fff83, + 0x003fffc3, + 0x003fffe3, + 0x007c01f1, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x003f03e3, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x007ffffc, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x68 'h' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x001f8000, + 0x003c0000, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x007ffff0, + 0x007ffff0, + 0x003ffff0, + 0x001ffff0, + 0x0003fff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x69 'i' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x3c7ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6a 'j' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x3c7fffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6b 'k' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x0000f800, + 0x0001f000, + 0x0003e000, + 0x0007f800, + 0x000ffc00, + 0x001fff00, + 0x003e3fc0, + 0x007c1fe0, + 0x007807f0, + 0x007001f0, + 0x006000f0, + 0x00400030, + 0x00000010, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6c 'l' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6d 'm' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x003f8000, + 0x003c0000, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x007ffff0, + 0x007ffff0, + 0x003ffff0, + 0x001ffff0, + 0x003ffff0, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x007ffff0, + 0x007ffff0, + 0x003ffff0, + 0x001ffff0, + 0x0007fff0, + + /* 0x6e 'n' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x003f8000, + 0x003c0000, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x007ffff0, + 0x007ffff0, + 0x003ffff0, + 0x001ffff0, + 0x0003fff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6f 'o' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000f800, + 0x0007ff00, + 0x000fff80, + 0x001fffc0, + 0x003fffe0, + 0x007c01f0, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00600030, + 0x00700030, + 0x00700070, + 0x007800f0, + 0x007c01f0, + 0x003fffe0, + 0x001fffc0, + 0x000fff80, + 0x0007ff00, + 0x00007000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x70 'p' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x003f03e0, + 0x007800f0, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x007c01f0, + 0x003fffe0, + 0x003fffc0, + 0x001fff80, + 0x0007fe00, + 0x00006000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x71 'q' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000f800, + 0x0007ff00, + 0x001fffc0, + 0x003fffe0, + 0x003fffe0, + 0x007c01f0, + 0x00780070, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00700070, + 0x00780070, + 0x003c00f0, + 0x001f83e0, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x007fffff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x72 'r' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x003e0000, + 0x00780000, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x73 's' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000300, + 0x000f83c0, + 0x003fc3e0, + 0x003fe3e0, + 0x007fe0f0, + 0x0070e070, + 0x0070f070, + 0x0070f030, + 0x00607030, + 0x00707030, + 0x00707870, + 0x00787870, + 0x007e3ff0, + 0x003e3fe0, + 0x001e1fe0, + 0x000e1fc0, + 0x00000600, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x74 't' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x00700000, + 0x0fffffe0, + 0x0ffffff0, + 0x0ffffff0, + 0x0ffffff0, + 0x00700070, + 0x00700030, + 0x00700030, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x75 'u' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007fff00, + 0x007fffc0, + 0x007fffe0, + 0x007ffff0, + 0x007ffff0, + 0x00000070, + 0x00000030, + 0x00000030, + 0x00000030, + 0x00000070, + 0x00000070, + 0x000001e0, + 0x007fffc0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x007ffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x76 'v' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00400000, + 0x00700000, + 0x007e0000, + 0x007fc000, + 0x007ff800, + 0x001ffe00, + 0x0003ffc0, + 0x00007ff0, + 0x000007f0, + 0x000001f0, + 0x00000ff0, + 0x00007ff0, + 0x0003ff80, + 0x001ffe00, + 0x007ff000, + 0x007f8000, + 0x007e0000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x77 'w' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x007f0000, + 0x007ff000, + 0x007ffe00, + 0x000fffe0, + 0x0000fff0, + 0x00000ff0, + 0x00000ff0, + 0x0000fff0, + 0x000fffe0, + 0x007ffe00, + 0x007fe000, + 0x007f0000, + 0x007fe000, + 0x007ffe00, + 0x000fffe0, + 0x0000fff0, + 0x00000ff0, + 0x00000ff0, + 0x0000fff0, + 0x000fffc0, + 0x007ffe00, + 0x007fe000, + 0x007f0000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x78 'x' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00400030, + 0x00700070, + 0x007801f0, + 0x007e03f0, + 0x007f07f0, + 0x003fdfc0, + 0x000fff80, + 0x0007fe00, + 0x0001fc00, + 0x0003fe00, + 0x000fff80, + 0x001fdfc0, + 0x007f07f0, + 0x007e03f0, + 0x007801f0, + 0x00700070, + 0x00400030, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x79 'y' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00700000, + 0x007e0000, + 0x007fc000, + 0x007ff000, + 0x001ffe00, + 0x0003ffc3, + 0x00007fff, + 0x00000fff, + 0x000001ff, + 0x00000ffc, + 0x00007ff0, + 0x0003ffc0, + 0x001ffe00, + 0x007ff000, + 0x007fc000, + 0x007e0000, + 0x00700000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7a 'z' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000070, + 0x007000f0, + 0x007001f0, + 0x007007f0, + 0x00700ff0, + 0x00701ff0, + 0x00703f70, + 0x00707e70, + 0x0071fc70, + 0x0073f070, + 0x0077e070, + 0x007fc070, + 0x007f8070, + 0x007e0070, + 0x007c0070, + 0x00780070, + 0x00000070, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7b '{' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00007000, + 0x0000f800, + 0x07fffffe, + 0x1fffdfff, + 0x1fffcfff, + 0x3fff07ff, + 0x38000001, + 0x30000000, + 0x30000000, + 0x30000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7c '|' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x3ffffff0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7d '}' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x30000000, + 0x30000000, + 0x3c000001, + 0x3fff07ff, + 0x1fffdfff, + 0x1fffdfff, + 0x03fffffe, + 0x0000f800, + 0x00007000, + 0x00007000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7e '~' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001000, + 0x00003800, + 0x00007800, + 0x00007000, + 0x0000e000, + 0x0000e000, + 0x00006000, + 0x00007000, + 0x00007000, + 0x00003800, + 0x00003800, + 0x00003800, + 0x00001800, + 0x00001800, + 0x00003800, + 0x0000f800, + 0x0000f000, + 0x00002000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7f '' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x3ffffff8, + 0x3ffffff8, + 0x3ffffff8, + 0x30000018, + 0x30000018, + 0x30000018, + 0x30000018, + 0x3ffffff8, + 0x3ffffff8, + 0x3ffffff8, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +#else + /* 0x20 ' ' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x21 '!' */ + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x01C00000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x22 '"' */ + 0x00000000, + 0x00000000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x039C0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x23 '#' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x003C7000, + 0x00387000, + 0x00387000, + 0x0038F000, + 0x0078F000, + 0x0078F000, + 0x0078F000, + 0x0070E000, + 0x07FFFE00, + 0x07FFFE00, + 0x0071E000, + 0x0071E000, + 0x00F1E000, + 0x00F1E000, + 0x00E1C000, + 0x0FFFFC00, + 0x0FFFFC00, + 0x0FFFFC00, + 0x00E3C000, + 0x01E3C000, + 0x01E38000, + 0x01E38000, + 0x01C38000, + 0x01C38000, + 0x01C38000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x24 '$' */ + 0x000E0000, + 0x000E0000, + 0x001E0000, + 0x00FFC000, + 0x01FFF000, + 0x03EFF800, + 0x07CE7800, + 0x078E3C00, + 0x078E3C00, + 0x078E0000, + 0x078E0000, + 0x078E0000, + 0x07EE0000, + 0x03FE0000, + 0x01FF8000, + 0x007FF000, + 0x000FF800, + 0x000FFC00, + 0x000E7C00, + 0x000E3E00, + 0x0F0E3E00, + 0x0F0E3E00, + 0x0F0E3E00, + 0x0F8E3C00, + 0x078E3C00, + 0x07EEF800, + 0x03FFF000, + 0x00FFE000, + 0x000E0000, + 0x000E0000, + 0x000E0000, + 0x000E0000, + + /* 0x25 '%' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07E00380, + 0x1FF00700, + 0x1FF80600, + 0x3C3C0E00, + 0x381C1C00, + 0x781E1C00, + 0x781E3800, + 0x381C3800, + 0x3C3C7000, + 0x3E7C7000, + 0x1FF8E000, + 0x0FF0E000, + 0x0001C000, + 0x000383F0, + 0x00038FF8, + 0x00071FFC, + 0x00071E1E, + 0x000E1C0E, + 0x000E3C0E, + 0x001C3C0E, + 0x001C3C0E, + 0x00381E1E, + 0x00701F3C, + 0x00700FFC, + 0x00E003F0, + 0x00000000, + 0x00000000, + 0x00000000, + + + /* 0x26 '&' */ + 0x00000000, + 0x00000000, + 0x000F8000, + 0x003FE000, + 0x007FF000, + 0x00F9F000, + 0x00F0F000, + 0x00F0F800, + 0x00F0F800, + 0x00F0F000, + 0x00F9F000, + 0x007FE000, + 0x007FC000, + 0x003F8000, + 0x007F0000, + 0x01FF8000, + 0x03F7CF80, + 0x03E7EF00, + 0x07C3EF00, + 0x0781FF00, + 0x0780FE00, + 0x07807E00, + 0x07803E00, + 0x07803E00, + 0x07C07F00, + 0x03F1FF80, + 0x01FFE7C0, + 0x00FF83E0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x27 ''' */ + 0x00000000, + 0x00000000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x28 '(' */ + 0x00000000, + 0x00000000, + 0x001C0000, + 0x003C0000, + 0x00380000, + 0x00780000, + 0x00F00000, + 0x00F00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x01E00000, + 0x01E00000, + 0x00E00000, + 0x00F00000, + 0x00700000, + 0x00780000, + + /* 0x29 ')' */ + 0x00000000, + 0x00000000, + 0x07000000, + 0x07000000, + 0x03800000, + 0x03C00000, + 0x01C00000, + 0x01E00000, + 0x01E00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00780000, + 0x00780000, + 0x00780000, + 0x00780000, + 0x007C0000, + 0x007C0000, + 0x007C0000, + 0x007C0000, + 0x00780000, + 0x00780000, + 0x00780000, + 0x00780000, + 0x00780000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x01E00000, + 0x01E00000, + 0x01C00000, + 0x03C00000, + + /* 0x2A '*' */ + 0x00000000, + 0x00000000, + 0x00700000, + 0x00700000, + 0x00700000, + 0x07770000, + 0x07FF0000, + 0x01FC0000, + 0x00F80000, + 0x01FC0000, + 0x03DE0000, + 0x038E0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2B '+' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x0FFFFF00, + 0x0FFFFF00, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x000F0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2C ',' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00E00000, + 0x00E00000, + 0x01C00000, + 0x03C00000, + + /* 0x2D '-' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0FFFFF00, + 0x0FFFFF00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2E '.' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x2F '/' */ + 0x00000000, + 0x00000000, + 0x001C0000, + 0x001C0000, + 0x003C0000, + 0x00380000, + 0x00380000, + 0x00780000, + 0x00700000, + 0x00700000, + 0x00F00000, + 0x00E00000, + 0x00E00000, + 0x01E00000, + 0x01C00000, + 0x01C00000, + 0x03C00000, + 0x03800000, + 0x03800000, + 0x03800000, + 0x07000000, + 0x07000000, + 0x07000000, + 0x0E000000, + 0x0E000000, + 0x0E000000, + 0x1C000000, + 0x1C000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x30 '0' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x007F8000, + 0x00FFE000, + 0x01FFF000, + 0x03E0F800, + 0x03C0F800, + 0x07C07800, + 0x07807C00, + 0x07803C00, + 0x07803C00, + 0x0F803C00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07C07C00, + 0x03C07800, + 0x03E0F800, + 0x01F1F000, + 0x00FFE000, + 0x007FC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x31 '1' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00078000, + 0x00078000, + 0x000F8000, + 0x001F8000, + 0x007F8000, + 0x01FF8000, + 0x01FF8000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00078000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x32 '2' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x01FFF000, + 0x03FFF800, + 0x03E0F800, + 0x07C07C00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x00007C00, + 0x00007C00, + 0x0000F800, + 0x0003F000, + 0x000FE000, + 0x001FC000, + 0x007F0000, + 0x00FC0000, + 0x01F00000, + 0x03E00000, + 0x07C00000, + 0x07800000, + 0x0F800000, + 0x0FFFFC00, + 0x0FFFFC00, + 0x0FFFFC00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x33 '3' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x01FFF000, + 0x03FFF800, + 0x03E0F800, + 0x07C07800, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x00007800, + 0x0000F800, + 0x0003F000, + 0x001FE000, + 0x001FF000, + 0x0001F800, + 0x00007C00, + 0x00003E00, + 0x00003E00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x07803C00, + 0x07C07C00, + 0x03E1F800, + 0x03FFF000, + 0x00FFC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x34 '4' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x0001E000, + 0x0003E000, + 0x0007E000, + 0x0007E000, + 0x000FE000, + 0x001FE000, + 0x003DE000, + 0x003DE000, + 0x0079E000, + 0x00F1E000, + 0x00F1E000, + 0x01E1E000, + 0x03C1E000, + 0x07C1E000, + 0x0781E000, + 0x0F01E000, + 0x0FFFFE00, + 0x0FFFFE00, + 0x0FFFFE00, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x35 '5' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x01FFF800, + 0x01FFF800, + 0x01FFF800, + 0x01C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03BFC000, + 0x03FFE000, + 0x07FFF800, + 0x07E0F800, + 0x07807C00, + 0x00007C00, + 0x00003C00, + 0x00003E00, + 0x00003C00, + 0x00003C00, + 0x0F803C00, + 0x0F807C00, + 0x07C0F800, + 0x07E1F800, + 0x03FFE000, + 0x00FFC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x36 '6' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x003FC000, + 0x00FFF000, + 0x01FFF800, + 0x01F0F800, + 0x03E07C00, + 0x03C03C00, + 0x07C00000, + 0x07800000, + 0x07800000, + 0x079F8000, + 0x07FFF000, + 0x0FFFF800, + 0x0FE0F800, + 0x0FC07C00, + 0x0FC03C00, + 0x0F803E00, + 0x07803E00, + 0x07803E00, + 0x07803E00, + 0x07803C00, + 0x07C03C00, + 0x03E07C00, + 0x01F1F800, + 0x00FFF000, + 0x007FE000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x37 '7' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x0FFFFE00, + 0x0FFFFE00, + 0x0FFFFE00, + 0x00003C00, + 0x00007C00, + 0x00007800, + 0x0000F000, + 0x0001E000, + 0x0003E000, + 0x0003C000, + 0x0007C000, + 0x00078000, + 0x000F0000, + 0x000F0000, + 0x001E0000, + 0x001E0000, + 0x003E0000, + 0x003C0000, + 0x003C0000, + 0x007C0000, + 0x00780000, + 0x00780000, + 0x00F80000, + 0x00F80000, + 0x00F00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x38 '8' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x01FFE000, + 0x01FFF000, + 0x03E0F800, + 0x03C07800, + 0x07C07800, + 0x07807C00, + 0x07C07800, + 0x03C07800, + 0x03E0F800, + 0x01FFF000, + 0x00FFE000, + 0x01FFF000, + 0x03F1F800, + 0x07C07C00, + 0x07803C00, + 0x0F803C00, + 0x0F803E00, + 0x0F803C00, + 0x0F803C00, + 0x07803C00, + 0x07C07C00, + 0x03F0F800, + 0x01FFF000, + 0x00FFC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x39 '9' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x01FFE000, + 0x03FFF000, + 0x03E0F800, + 0x07C07800, + 0x07807C00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07807E00, + 0x07807E00, + 0x07C0FC00, + 0x03F1FC00, + 0x01FFFC00, + 0x00FFBC00, + 0x000C3C00, + 0x00003C00, + 0x00007800, + 0x07807800, + 0x0780F800, + 0x07C0F000, + 0x03E1E000, + 0x01FFC000, + 0x00FF8000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3A ':' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3B ';' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00E00000, + 0x00E00000, + 0x01C00000, + 0x03C00000, + + /* 0x3C '<' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00001E00, + 0x00007E00, + 0x0001FC00, + 0x000FF000, + 0x003F8000, + 0x01FE0000, + 0x07F80000, + 0x07C00000, + 0x07E00000, + 0x07F80000, + 0x00FE0000, + 0x003FC000, + 0x000FF000, + 0x0001FE00, + 0x00007E00, + 0x00000E00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3D '=' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0FFFFF00, + 0x0FFFFF00, + 0x0FFFFF00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0FFFFF00, + 0x0FFFFF00, + 0x0FFFFF00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3E '>' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07800000, + 0x07E00000, + 0x03F80000, + 0x00FF0000, + 0x001FC000, + 0x0007F800, + 0x0001FE00, + 0x00003E00, + 0x00007E00, + 0x0001FE00, + 0x000FF000, + 0x003FC000, + 0x00FE0000, + 0x07F80000, + 0x07E00000, + 0x07000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x3F '?' */ + 0x00000000, + 0x00000000, + 0x003F8000, + 0x00FFE000, + 0x01FFF000, + 0x03E0F800, + 0x03C07800, + 0x07C07800, + 0x07807C00, + 0x07807C00, + 0x00007800, + 0x0000F800, + 0x0000F000, + 0x0001F000, + 0x0003E000, + 0x0007C000, + 0x000F8000, + 0x001F0000, + 0x001E0000, + 0x001E0000, + 0x001E0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x001E0000, + 0x001E0000, + 0x001E0000, + 0x001E0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x40 '@' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x001FFC00, + 0x007FFF00, + 0x01F80F80, + 0x03E003C0, + 0x078001E0, + 0x0780C0F0, + 0x0F0FF770, + 0x0E1FFF78, + 0x1E3E7E78, + 0x1E7C3E38, + 0x1C781E38, + 0x1CF81E38, + 0x3CF01C38, + 0x3CF03C78, + 0x1CF03C70, + 0x1CF03C70, + 0x1CF078F0, + 0x1EF0F9E0, + 0x0EFFFBC0, + 0x0F7FFF80, + 0x073F3E70, + 0x078000E0, + 0x03E003E0, + 0x01F80780, + 0x007FFF00, + 0x001FFC00, + 0x00000000, + 0x00000000, + 0x00000000, + + + /* 0x41 'A' */ + 0x00000000, + 0x00000000, + 0x0007C000, + 0x0007E000, + 0x000FE000, + 0x000FE000, + 0x000FF000, + 0x001EF000, + 0x001EF000, + 0x001EF800, + 0x003C7800, + 0x003C7C00, + 0x007C7C00, + 0x00783C00, + 0x00783E00, + 0x00F83E00, + 0x00F01E00, + 0x00FFFF00, + 0x01FFFF00, + 0x01FFFF00, + 0x03FFFF80, + 0x03C00F80, + 0x03C007C0, + 0x07C007C0, + 0x078007C0, + 0x078003E0, + 0x0F8003E0, + 0x0F0001E0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x42 'B' */ + 0x00000000, + 0x00000000, + 0x03FFF000, + 0x03FFFE00, + 0x03FFFF00, + 0x03C03F00, + 0x03C00F80, + 0x03C00F80, + 0x03C00780, + 0x03C00780, + 0x03C00F80, + 0x03C00F80, + 0x03C01F00, + 0x03FFFE00, + 0x03FFFE00, + 0x03FFFF00, + 0x03C01F80, + 0x03C007C0, + 0x03C003C0, + 0x03C003E0, + 0x03C003E0, + 0x03C003E0, + 0x03C003C0, + 0x03C007C0, + 0x03C01F80, + 0x03FFFF80, + 0x03FFFE00, + 0x03FFF800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x43 'C' */ + 0x00000000, + 0x00000000, + 0x000FFC00, + 0x003FFF00, + 0x00FFFF80, + 0x00FC07C0, + 0x01F003E0, + 0x03E001E0, + 0x03E001F0, + 0x07C000F0, + 0x07C00000, + 0x07C00000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x078000F0, + 0x07C000F0, + 0x07C000F0, + 0x03C001F0, + 0x03E001E0, + 0x01F003E0, + 0x01F807C0, + 0x00FF3F80, + 0x007FFF00, + 0x001FFC00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x44 'D' */ + 0x00000000, + 0x00000000, + 0x03FFE000, + 0x03FFFC00, + 0x03FFFF00, + 0x03C03F80, + 0x03C00FC0, + 0x03C007C0, + 0x03C003E0, + 0x03C001E0, + 0x03C001F0, + 0x03C001F0, + 0x03C001F0, + 0x03C000F0, + 0x03C000F0, + 0x03C000F0, + 0x03C000F0, + 0x03C001F0, + 0x03C001F0, + 0x03C001F0, + 0x03C001E0, + 0x03C003E0, + 0x03C003C0, + 0x03C007C0, + 0x03C01F80, + 0x03FFFF00, + 0x03FFFE00, + 0x03FFF800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x45 'E' */ + 0x00000000, + 0x00000000, + 0x03FFFFC0, + 0x03FFFFC0, + 0x03FFFFC0, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03FFFF80, + 0x03FFFF80, + 0x03FFFF80, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03FFFFC0, + 0x03FFFFC0, + 0x03FFFFC0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x46 'F' */ + 0x00000000, + 0x00000000, + 0x03FFFF80, + 0x03FFFF80, + 0x03FFFF80, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03FFFE00, + 0x03FFFE00, + 0x03FFFE00, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x47 'G' */ + 0x00000000, + 0x00000000, + 0x000FFE00, + 0x003FFF80, + 0x007FFFC0, + 0x00FC07E0, + 0x01F803F0, + 0x01F001F0, + 0x03E000F8, + 0x03C000F8, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07800000, + 0x07807FF8, + 0x07807FF8, + 0x07807FF8, + 0x07800078, + 0x07C00078, + 0x07C00078, + 0x07C00078, + 0x03E000F8, + 0x03E000F8, + 0x01F001F8, + 0x00F803F8, + 0x00FF1FF8, + 0x003FFF38, + 0x001FFC38, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x48 'H' */ + 0x00000000, + 0x00000000, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03FFFFE0, + 0x03FFFFE0, + 0x03FFFFE0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x49 'I' */ + 0x00000000, + 0x00000000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4A 'J' */ + 0x00000000, + 0x00000000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0001E000, + 0x0F01E000, + 0x0F01E000, + 0x0F01E000, + 0x0F03E000, + 0x0F03E000, + 0x0FC7C000, + 0x07FF8000, + 0x01FF0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4B 'K' */ + 0x00000000, + 0x00000000, + 0x03C007E0, + 0x03C00FC0, + 0x03C01F80, + 0x03C03F00, + 0x03C07E00, + 0x03C0FC00, + 0x03C1F800, + 0x03C3F000, + 0x03C7E000, + 0x03CFC000, + 0x03DF8000, + 0x03FF8000, + 0x03FFC000, + 0x03FFE000, + 0x03FBF000, + 0x03F1F000, + 0x03E0F800, + 0x03C0FC00, + 0x03C07C00, + 0x03C03E00, + 0x03C03F00, + 0x03C01F80, + 0x03C00F80, + 0x03C007C0, + 0x03C007E0, + 0x03C003F0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4C 'L' */ + 0x00000000, + 0x00000000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03FFFE00, + 0x03FFFE00, + 0x03FFFE00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4D 'M' */ + 0x00000000, + 0x00000000, + 0x03F0007E, + 0x03F0007E, + 0x03F0007E, + 0x03F800FE, + 0x03F800FE, + 0x03F800FE, + 0x03FC01FE, + 0x03FC01FE, + 0x03FC01FE, + 0x03DE03DE, + 0x03DE03DE, + 0x03DE03DE, + 0x03CF079E, + 0x03CF079E, + 0x03CF079E, + 0x03C78F1E, + 0x03C78F1E, + 0x03C78F1E, + 0x03C3DE1E, + 0x03C3DE1E, + 0x03C3FE1E, + 0x03C1FC1E, + 0x03C1FC1E, + 0x03C1FC1E, + 0x03C0F81E, + 0x03C0F81E, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4E 'N' */ + 0x00000000, + 0x00000000, + 0x03E001E0, + 0x03F001E0, + 0x03F001E0, + 0x03F801E0, + 0x03FC01E0, + 0x03FC01E0, + 0x03FE01E0, + 0x03DE01E0, + 0x03DF01E0, + 0x03CF81E0, + 0x03C781E0, + 0x03C7C1E0, + 0x03C3C1E0, + 0x03C3E1E0, + 0x03C1F1E0, + 0x03C0F1E0, + 0x03C0F9E0, + 0x03C07DE0, + 0x03C03DE0, + 0x03C03FE0, + 0x03C01FE0, + 0x03C01FE0, + 0x03C00FE0, + 0x03C007E0, + 0x03C007E0, + 0x03C003E0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x4F 'O' */ + 0x00000000, + 0x00000000, + 0x000FFE00, + 0x003FFF80, + 0x007FFFC0, + 0x00FC07E0, + 0x01F001F0, + 0x03E000F8, + 0x03E000F8, + 0x07C0007C, + 0x07C0007C, + 0x07C0003C, + 0x0780003C, + 0x0780003C, + 0x0F80003E, + 0x0F80003E, + 0x0780003C, + 0x0780003C, + 0x0780003C, + 0x07C0007C, + 0x07C0007C, + 0x03E000F8, + 0x03E000F8, + 0x01F001F0, + 0x00FC07E0, + 0x007FBFC0, + 0x003FFF80, + 0x000FFE00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x50 'P' */ + 0x00000000, + 0x00000000, + 0x03FFF800, + 0x03FFFE00, + 0x03FFFF00, + 0x03E01F80, + 0x03E007C0, + 0x03E007C0, + 0x03E003C0, + 0x03E003C0, + 0x03E003C0, + 0x03E003C0, + 0x03E007C0, + 0x03E00F80, + 0x03FFFF80, + 0x03FFFF00, + 0x03FFFC00, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x03E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x51 'Q' */ + 0x00000000, + 0x00000000, + 0x000FFE00, + 0x003FFF80, + 0x007FFFC0, + 0x00FC07E0, + 0x01F001F0, + 0x03E000F8, + 0x03E000F8, + 0x07C0007C, + 0x07C0007C, + 0x07C0003C, + 0x0780003C, + 0x0780003C, + 0x0F80003E, + 0x0F80003E, + 0x0780003C, + 0x0780003C, + 0x0780003C, + 0x07C0007C, + 0x07C0007C, + 0x03E01CF8, + 0x03E03EF8, + 0x01F01FF0, + 0x00FC0FE0, + 0x007F9FE0, + 0x003FFFF8, + 0x000FFEFC, + 0x0000003C, + 0x00000018, + 0x00000000, + 0x00000000, + + /* 0x52 'R' */ + 0x00000000, + 0x00000000, + 0x03FFFC00, + 0x03FFFF80, + 0x03FFFFC0, + 0x03E007E0, + 0x03E003E0, + 0x03E001E0, + 0x03E001F0, + 0x03E001F0, + 0x03E001F0, + 0x03E001E0, + 0x03E003E0, + 0x03E007C0, + 0x03FFFF80, + 0x03FFFF00, + 0x03FFFFC0, + 0x03E007C0, + 0x03E003E0, + 0x03E003E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001E0, + 0x03E001F8, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x53 'S' */ + 0x00000000, + 0x00000000, + 0x003FF800, + 0x00FFFE00, + 0x01FFFF00, + 0x01F01F00, + 0x03E00F80, + 0x03C00780, + 0x03C00780, + 0x03C007C0, + 0x03C00000, + 0x03E00000, + 0x03FC0000, + 0x01FFE000, + 0x00FFFC00, + 0x001FFF00, + 0x0001FF80, + 0x00001F80, + 0x000007C0, + 0x000003C0, + 0x078003C0, + 0x078003C0, + 0x07C003C0, + 0x07C007C0, + 0x03E00F80, + 0x01FC3F80, + 0x00FFFE00, + 0x007FFC00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x54 'T' */ + 0x00000000, + 0x00000000, + 0x0FFFFF80, + 0x0FFFFF80, + 0x0FFFFF80, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x000F8000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x55 'U' */ + 0x00000000, + 0x00000000, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C001E0, + 0x03C003E0, + 0x03E003E0, + 0x03E003E0, + 0x01F007C0, + 0x01F80FC0, + 0x00FE7F80, + 0x007FFF00, + 0x001FFC00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x56 'V' */ + 0x00000000, + 0x00000000, + 0x0F8003E0, + 0x0F8003E0, + 0x078003E0, + 0x07C007C0, + 0x07C007C0, + 0x03C00780, + 0x03E00F80, + 0x03E00F80, + 0x01E00F00, + 0x01F01F00, + 0x01F01F00, + 0x00F01E00, + 0x00F83E00, + 0x00783C00, + 0x00783C00, + 0x007C7C00, + 0x003C7800, + 0x003C7800, + 0x003EF800, + 0x001EF000, + 0x001EF000, + 0x001FF000, + 0x000FE000, + 0x000FE000, + 0x0007C000, + 0x0007C000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x57 'W' */ + 0x00000000, + 0x00000000, + 0x0F003E00, + 0x0F803E00, + 0x0F807E00, + 0x0F807F00, + 0x07807F00, + 0x07807F01, + 0x07C0F781, + 0x07C0F781, + 0x03C0F781, + 0x03C0F783, + 0x03E1E3C3, + 0x01E1E3C3, + 0x01E1E3C3, + 0x01E3C3C3, + 0x01F3C1E7, + 0x00F3C1E7, + 0x00F3C1E7, + 0x00F780F7, + 0x00FF80FF, + 0x007F80FF, + 0x007F00FF, + 0x007F007F, + 0x007F007E, + 0x003F007E, + 0x003E003E, + 0x003E003E, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x58 'X' */ + 0x00000000, + 0x00000000, + 0x0FC003E0, + 0x07C007C0, + 0x03E00F80, + 0x01F00F80, + 0x01F01F00, + 0x00F83E00, + 0x007C3E00, + 0x007C7C00, + 0x003EF800, + 0x001FF000, + 0x001FF000, + 0x000FE000, + 0x0007C000, + 0x000FE000, + 0x000FE000, + 0x001FF000, + 0x003EF800, + 0x003EF800, + 0x007C7C00, + 0x00F83E00, + 0x00F83F00, + 0x01F01F00, + 0x03E00F80, + 0x07E00FC0, + 0x07C007C0, + 0x0F8003E0, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x59 'Y' */ + 0x00000000, + 0x00000000, + 0x0F8003E0, + 0x0F8003E0, + 0x07C007C0, + 0x03E00F80, + 0x03E00F80, + 0x01F01F00, + 0x00F01F00, + 0x00F83E00, + 0x007C7C00, + 0x007C7C00, + 0x003EF800, + 0x001EF000, + 0x001FF000, + 0x000FE000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x0007C000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5A 'Z' */ + 0x00000000, + 0x00000000, + 0x07FFFF80, + 0x07FFFF80, + 0x07FFFF80, + 0x00001F80, + 0x00001F00, + 0x00003E00, + 0x00007C00, + 0x0000FC00, + 0x0001F800, + 0x0001F000, + 0x0003E000, + 0x0007C000, + 0x000FC000, + 0x001F8000, + 0x001F0000, + 0x003E0000, + 0x007C0000, + 0x00FC0000, + 0x00F80000, + 0x01F00000, + 0x03E00000, + 0x07C00000, + 0x0FC00000, + 0x0FFFFF80, + 0x0FFFFF80, + 0x0FFFFF80, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5B '[' */ + 0x00000000, + 0x00000000, + 0x07F80000, + 0x07F80000, + 0x07F80000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + + /* 0x5C '\' */ + 0x00000000, + 0x00000000, + 0x1C000000, + 0x1C000000, + 0x0E000000, + 0x0E000000, + 0x0E000000, + 0x07000000, + 0x07000000, + 0x07000000, + 0x03800000, + 0x03800000, + 0x03800000, + 0x03C00000, + 0x01C00000, + 0x01C00000, + 0x01E00000, + 0x00E00000, + 0x00E00000, + 0x00F00000, + 0x00700000, + 0x00700000, + 0x00780000, + 0x00380000, + 0x00380000, + 0x003C0000, + 0x001C0000, + 0x001C0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5D ']' */ + 0x00000000, + 0x00000000, + 0x0FF00000, + 0x0FF00000, + 0x0FF00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + + /* 0x5E '^' */ + 0x00000000, + 0x00000000, + 0x01F00000, + 0x03F80000, + 0x07BC0000, + 0x073C0000, + 0x0F1E0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x5F '_' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x1FFFFF00, + 0x1FFFFF00, + + /* 0x60 '`' */ + 0x00000000, + 0x00000000, + 0x0F800000, + 0x07C00000, + 0x03C00000, + 0x01E00000, + 0x00E00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x61 'a' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00FFC000, + 0x01FFE000, + 0x03F3F000, + 0x03C0F800, + 0x07C07800, + 0x07807800, + 0x00007800, + 0x0000F800, + 0x00FFF800, + 0x03FFF800, + 0x07FC7800, + 0x07C07800, + 0x0F807800, + 0x0F807800, + 0x0F80F800, + 0x0F81F800, + 0x07C7F800, + 0x03FFFE00, + 0x01FE3E00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x62 'b' */ + 0x00000000, + 0x00000000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07BFC000, + 0x07FFF000, + 0x07FFF800, + 0x07E0F800, + 0x07C07C00, + 0x07C03C00, + 0x07C03C00, + 0x07803C00, + 0x07803E00, + 0x07803E00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07C03C00, + 0x07C07800, + 0x07E07800, + 0x07F1F000, + 0x07FFE000, + 0x07BFC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x63 'c' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x01FFE000, + 0x03FFF000, + 0x03E0F000, + 0x07C0F800, + 0x07807800, + 0x07807800, + 0x0F800000, + 0x0F000000, + 0x0F000000, + 0x0F000000, + 0x0F000000, + 0x0F807800, + 0x07807800, + 0x0780F800, + 0x07C0F000, + 0x03E3F000, + 0x01FFE000, + 0x007F8000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x64 'd' */ + 0x00000000, + 0x00000000, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x007F3C00, + 0x01FFBC00, + 0x03FFFC00, + 0x03E1FC00, + 0x07C0FC00, + 0x07807C00, + 0x07807C00, + 0x0F807C00, + 0x0F803C00, + 0x0F803C00, + 0x0F803C00, + 0x0F803C00, + 0x07803C00, + 0x07807C00, + 0x07C07C00, + 0x03C0FC00, + 0x03F3FC00, + 0x01FFFC00, + 0x007FBC00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x65 'e' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x00FFE000, + 0x01FFF000, + 0x03E0F800, + 0x07C07800, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07FFFC00, + 0x0FFFFE00, + 0x0FFFFE00, + 0x07800000, + 0x07800000, + 0x07803C00, + 0x07C03C00, + 0x03C07800, + 0x03F1F800, + 0x01FFF000, + 0x007FE000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x66 'f' */ + 0x00000000, + 0x00000000, + 0x00F80000, + 0x01F80000, + 0x03F80000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x0FF80000, + 0x0FF80000, + 0x0FF80000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x67 'g' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FBC00, + 0x01FFFC00, + 0x03FFFC00, + 0x03E0FC00, + 0x07C07C00, + 0x07807C00, + 0x07807C00, + 0x07803C00, + 0x0F803C00, + 0x0F803C00, + 0x0F803C00, + 0x07803C00, + 0x07803C00, + 0x07807C00, + 0x07C07C00, + 0x03E0FC00, + 0x01F1FC00, + 0x00FFFC00, + 0x007FBC00, + 0x00003C00, + 0x00003C00, + 0x07807800, + 0x07C07800, + + /* 0x68 'h' */ + 0x00000000, + 0x00000000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x079FE000, + 0x07BFF000, + 0x07FFF800, + 0x07F07800, + 0x07E07800, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x69 'i' */ + 0x00000000, + 0x00000000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6A 'j' */ + 0x00000000, + 0x00000000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + + /* 0x6B 'k' */ + 0x00000000, + 0x00000000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x0780F800, + 0x0781F000, + 0x0783E000, + 0x0787C000, + 0x078F8000, + 0x079F0000, + 0x07BE0000, + 0x07FE0000, + 0x07FE0000, + 0x07FF0000, + 0x07EF8000, + 0x07CF8000, + 0x0787C000, + 0x0783C000, + 0x0783E000, + 0x0781F000, + 0x0781F000, + 0x0780F800, + 0x07807C00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6C 'l' */ + 0x00000000, + 0x00000000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x07C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6D 'm' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x079FC7F8, + 0x07FFEFFC, + 0x07FFFFFE, + 0x07F0FC3E, + 0x07E0F81F, + 0x07C0F81F, + 0x07C0F81F, + 0x07C0F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x0780F81F, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6E 'n' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x079FE000, + 0x07FFF000, + 0x07FFF800, + 0x07F0F800, + 0x07E07800, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x07807C00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x6F 'o' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007FC000, + 0x00FFE000, + 0x01FBF000, + 0x03E0F800, + 0x07C07C00, + 0x07803C00, + 0x07803C00, + 0x0F803C00, + 0x0F803E00, + 0x0F803E00, + 0x0F803E00, + 0x0F803C00, + 0x07803C00, + 0x07803C00, + 0x07C07C00, + 0x03E0F800, + 0x01F1F000, + 0x00FFE000, + 0x007FC000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x70 'p' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07BFC000, + 0x07FFF000, + 0x07FFF800, + 0x07E0F800, + 0x07C07C00, + 0x07C03C00, + 0x07C03C00, + 0x07803C00, + 0x07803E00, + 0x07803E00, + 0x07803C00, + 0x07803C00, + 0x07803C00, + 0x07C03C00, + 0x07C07800, + 0x07E07800, + 0x07F1F000, + 0x07FFE000, + 0x07BFC000, + 0x07800000, + 0x07800000, + 0x07800000, + 0x07800000, + + /* 0x71 'q' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x007F3C00, + 0x01FFBC00, + 0x03FFFC00, + 0x03E1FC00, + 0x07C0FC00, + 0x07807C00, + 0x07807C00, + 0x0F807C00, + 0x0F803C00, + 0x0F803C00, + 0x0F803C00, + 0x0F803C00, + 0x07803C00, + 0x07807C00, + 0x07C07C00, + 0x03C0FC00, + 0x03F3FC00, + 0x01FFFC00, + 0x007FBC00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + 0x00003C00, + + /* 0x72 'r' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03DF0000, + 0x03FF0000, + 0x03FF0000, + 0x03F80000, + 0x03E00000, + 0x03E00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x73 's' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00FF8000, + 0x03FFC000, + 0x03F7E000, + 0x0781F000, + 0x0780F000, + 0x0780F000, + 0x07800000, + 0x07F00000, + 0x03FF0000, + 0x01FFC000, + 0x003FF000, + 0x0003F000, + 0x0000F800, + 0x0F00F800, + 0x0F00F000, + 0x0780F000, + 0x07E3F000, + 0x03FFE000, + 0x00FF8000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x74 't' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x0FF80000, + 0x0FF80000, + 0x0FF80000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03E00000, + 0x03F80000, + 0x01F80000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x75 'u' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C07C00, + 0x07C0FC00, + 0x03C0FC00, + 0x03E3FC00, + 0x01FFBC00, + 0x00FF3C00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x76 'v' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x1F007800, + 0x0F007800, + 0x0F80F800, + 0x0780F000, + 0x0780F000, + 0x07C1F000, + 0x03C1E000, + 0x03C1E000, + 0x03E3C000, + 0x01E3C000, + 0x01E3C000, + 0x01E78000, + 0x00F78000, + 0x00F78000, + 0x007F0000, + 0x007F0000, + 0x007E0000, + 0x003E0000, + 0x003E0000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x77 'w' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0F03E078, + 0x0F03E078, + 0x0F03E078, + 0x0787F0F0, + 0x0787F0F0, + 0x0787F0F0, + 0x0787F0F0, + 0x03CF79E0, + 0x03CF79E0, + 0x03CF79E0, + 0x03CE39C0, + 0x01FE3FC0, + 0x01FE3FC0, + 0x01FE3FC0, + 0x00FC1F80, + 0x00FC1F80, + 0x00FC1F80, + 0x00FC1F00, + 0x00780F00, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x78 'x' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0F80F800, + 0x07C0F000, + 0x07C1F000, + 0x03E3E000, + 0x01F3C000, + 0x01F7C000, + 0x00FF8000, + 0x007F0000, + 0x007F0000, + 0x003E0000, + 0x007F0000, + 0x007F0000, + 0x00FF8000, + 0x01F7C000, + 0x03E3E000, + 0x03E3E000, + 0x07C1F000, + 0x0F80F800, + 0x0F80F800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x79 'y' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0F007800, + 0x0F007800, + 0x0F80F800, + 0x0780F000, + 0x0780F000, + 0x07C1F000, + 0x03C1E000, + 0x03C1E000, + 0x03E3E000, + 0x01E3C000, + 0x01E3C000, + 0x00F78000, + 0x00F78000, + 0x00F78000, + 0x007F0000, + 0x007F0000, + 0x007F0000, + 0x003E0000, + 0x003E0000, + 0x003C0000, + 0x003C0000, + 0x00780000, + 0x00780000, + + /* 0x7A 'z' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07FFF000, + 0x07FFF000, + 0x07FFF000, + 0x0001F000, + 0x0003E000, + 0x0007C000, + 0x000F8000, + 0x000F8000, + 0x001F0000, + 0x003E0000, + 0x007C0000, + 0x00F80000, + 0x01F80000, + 0x01F00000, + 0x03E00000, + 0x07C00000, + 0x0FFFF800, + 0x0FFFF800, + 0x0FFFF800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7B '{' */ + 0x00000000, + 0x00000000, + 0x003E0000, + 0x00FE0000, + 0x00F00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x03C00000, + 0x07C00000, + 0x07000000, + 0x07800000, + 0x03C00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x01E00000, + 0x00F00000, + + /* 0x7C '|' */ + 0x00000000, + 0x00000000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x03C00000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7D '}' */ + 0x00000000, + 0x00000000, + 0x07800000, + 0x07E00000, + 0x01E00000, + 0x01E00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00780000, + 0x007E0000, + 0x001E0000, + 0x007E0000, + 0x00780000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x00F00000, + 0x01E00000, + + /* 0x7E '~' */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00600C00, + 0x01FC0C00, + 0x03FF9E00, + 0x078FFC00, + 0x0303F800, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + /* 0x7F '' */ + 0x00000000, + 0x00000000, + 0x0FFC0000, + 0x0FFC0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0E1C0000, + 0x0FFC0000, + 0x0FFC0000, + 0x00000000, + 0x00000000, + 0x00000000, +#endif /* AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE */ +}; + +#endif /* _VIDEO_FONT_DATA_ */ + diff --git a/packages/artinchip/barcode/include/yydecoder.h b/packages/artinchip/barcode/include/yydecoder.h new file mode 100644 index 00000000..d0431661 --- /dev/null +++ b/packages/artinchip/barcode/include/yydecoder.h @@ -0,0 +1,8 @@ +#include +#include + +unsigned int Initial_Decoder(); +int Decoding_Image(unsigned char* img_buffer, int width, int height); +unsigned int GetResultLength(); +int GetDecoderResult(unsigned char * result); +void Set_Donfig_Decoder(int type, int tag); \ No newline at end of file diff --git a/packages/artinchip/barcode/lib/libdecoder.a b/packages/artinchip/barcode/lib/libdecoder.a new file mode 100644 index 00000000..6524ebc8 Binary files /dev/null and b/packages/artinchip/barcode/lib/libdecoder.a differ diff --git a/packages/artinchip/env/SConscript b/packages/artinchip/env/SConscript index ee106195..0cd2e229 100644 --- a/packages/artinchip/env/SConscript +++ b/packages/artinchip/env/SConscript @@ -8,7 +8,10 @@ CPPPATH = [cwd] src = [] if GetDepend('AIC_ENV_INTERFACE'): - src = Glob('*.c') + src += Glob('env.c') + +if GetDepend('AIC_AB_SYSTEM_INTERFACE') and not GetDepend('AIC_BOOTLOADER'): + src += Glob('absystem_os.c') group = DefineGroup('env', src, depend = [''], CPPPATH = CPPPATH) diff --git a/packages/artinchip/ota/absystem.c b/packages/artinchip/env/absystem_os.c similarity index 99% rename from packages/artinchip/ota/absystem.c rename to packages/artinchip/env/absystem_os.c index db0f0068..37ebdb2a 100644 --- a/packages/artinchip/ota/absystem.c +++ b/packages/artinchip/env/absystem_os.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/packages/artinchip/ota/absystem.h b/packages/artinchip/env/absystem_os.h similarity index 88% rename from packages/artinchip/ota/absystem.h rename to packages/artinchip/env/absystem_os.h index 380ffc54..98e67760 100644 --- a/packages/artinchip/ota/absystem.h +++ b/packages/artinchip/env/absystem_os.h @@ -6,8 +6,8 @@ * Authors: xuan.wen */ -#ifndef __ABSYSTEM_H__ -#define __ABSYSTEM_H__ +#ifndef __ABSYSTEM_OS_H__ +#define __ABSYSTEM_OS_H__ #ifdef __cplusplus extern "C" { diff --git a/packages/artinchip/lvgl-ui/aic_demo/demo_hub/app/navigation/navigation.c b/packages/artinchip/lvgl-ui/aic_demo/demo_hub/app/navigation/navigation.c index caf1cb2e..b4b1349c 100644 --- a/packages/artinchip/lvgl-ui/aic_demo/demo_hub/app/navigation/navigation.c +++ b/packages/artinchip/lvgl-ui/aic_demo/demo_hub/app/navigation/navigation.c @@ -86,9 +86,9 @@ static void camera_ui_cb(lv_event_t * e) #if defined(AIC_CHIP_D12X) if (LV_HOR_RES == 480) return; +#endif if (LV_HOR_RES == 1024) return; -#endif app_entrance(APP_CAMERA, 1); } diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/SConscript deleted file mode 100644 index 62ed0e99..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/SConscript +++ /dev/null @@ -1,21 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -cc_flages = "" -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - cc_flages += " -DAIC_LVGL_QC_TEST_DEMO " - - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH, CFLAGS = cc_flages) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/lvgl_src/lvgl_data/qc-test/assets/commond/du.wav b/packages/artinchip/lvgl-ui/aic_demo/qc_test/lvgl_src/lvgl_data/qc-test/assets/commond/du.wav deleted file mode 100644 index e9b90a9d..00000000 Binary files a/packages/artinchip/lvgl-ui/aic_demo/qc_test/lvgl_src/lvgl_data/qc-test/assets/commond/du.wav and /dev/null differ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_1603_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_1603_table.c deleted file mode 100644 index 037bd62a..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_1603_table.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" - -#if AIC_1603 -#if QC_BOARD_D133B -char *board_script = "Board: D133BXX"; -char *board_chip_intel_list[] = { - "D133BAS", - "D133BBS", - NULL -}; -#elif QC_BOARD_D133C == 1 -char *board_script = "Board: D133CXX"; -char *board_chip_intel_list[] = { - "D133CBS", - "D133CCS1", - "D133CCS2", - NULL -}; -#elif QC_BOARD_D133E == 1 -char *board_script = "Board: D133EXX"; -char *board_chip_intel_list[] = { - "D133EBS", - "D133ECS1", - "D133ECS2", - NULL -}; -#elif QC_BOARD_D132E == 1 -char *board_script = "Board: D132EXX"; -char *board_chip_intel_list[] = { - "D132ENS", - NULL -}; -#elif QC_BOARD_G730C == 1 -char *board_script = "Board: G730CXX"; -char *board_chip_intel_list[] = { - "G730CES", - NULL -}; -#elif QC_BOARD_G730E == 1 -char *board_script = "Board: G730CXX"; -char *board_chip_intel_list[] = { - "G730EES", - NULL -}; -#elif QC_BOARD_G730B == 1 -char *board_script = "Board: G730BXX"; -char *board_chip_intel_list[] = { - "G730BDU", - NULL -}; -#elif QC_BOARD_M6801 == 1 -char *board_script = "Board: M6801XX"; -char *board_chip_intel_list[] = { - "M6801SPCS", - NULL -}; -#elif QC_BOARD_M6806 == 1 -char *board_script = "Board: M6806XX"; -char *board_chip_intel_list[] = { - "M6806SPES", - NULL -}; -#elif QC_BOARD_DR128 == 1 -char *board_script = "Board: DR128XX"; -char *board_chip_intel_list[] = { - "DR128", - NULL -}; -#elif QC_BOARD_JYX68 == 1 -char *board_script = "Board: JYX68XX"; -char *board_chip_intel_list[] = { - "JYX68", - NULL -}; -#endif - -#endif /* AIC_1603 */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_table.c deleted file mode 100644 index 7dd32db1..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_table.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ -#include "../qc_board.h" -#include "../common/common_test.h" - -#if QC_BOARD_D133B -#define BOARD_NAME "D133B" - -extern qc_res_t d133b_gpai_0_test(void *param); -extern qc_res_t d133b_gpai_1_test(void *param); -extern qc_res_t d133b_gpai_4_test(void *param); -extern qc_res_t d133b_gpai_5_test(void *param); - -qc_mod_init_base_t board_init_base[] = { - {"SID", BOARD_NAME"XX R comparison", NULL, 0}, - {"GPIO", "GPIO R-W comparison", NULL, 0}, - {"GPAI", "GPAI Read comparison", NULL, 0}, - {"CARD", "CARD R-W comparison", NULL, 0}, - {"DSPK", "DISP Write comparison", NULL, 0}, - {"UART", "UART R-W comparison", NULL, 0}, - {"SAVE", "SAVE Results to Sd card", NULL, 0}, - {NULL, NULL} -}; - -qc_mod_init_list_pos_t board_init_list_pos[] = { - {"SID", BOARD_NAME"XX R comparison", 0, NULL, common_compare_chip_intel_module,QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"GPIO", "GROUP2", 0, "test_gpio -t 10 -i PB.8 -o PB.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 0, "test_gpio -t 10 -i PB.9 -o PB.8", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 1, "test_gpio -t 10 -i PB.10 -o PB.11", NULL,QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 1, "test_gpio -t 10 -i PB.11 -o PB.10", NULL,QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP6", 2, "test_gpio -t 10 -i PB.6 -o PB.7", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP6", 2, "test_gpio -t 10 -i PB.7 -o PB.6", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"GPAI", "GPAI0", 0, NULL, d133b_gpai_0_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI1", 1, NULL, d133b_gpai_1_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI4", 2, NULL, d133b_gpai_4_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI5", 3, NULL, d133b_gpai_5_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"CARD", "CARD", 0, NULL, common_sdcard_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"DSPK", "DSPK", 0, "aplay sound0 /data/lvgl_data/qc-test/assets/commond/du.wav", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"UART", "UART1", 0, NULL, common_uart_test, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"SAVE", "SAVE Udisk", 0, NULL, common_qc_save_chip, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {NULL, NULL, 0, NULL, NULL, 0, 0, 0} -}; - -qc_exec_ops_order_init_t board_exec_order[] = { - {"SID", 0}, - {"GPIO", 0}, {"GPIO", 1}, {"GPIO", 2}, - {"GPAI", 0}, {"GPAI", 1}, {"GPAI", 2}, {"GPAI", 3}, - {"CARD", 0}, - {"DSPK", 0}, - {"UART", 0}, - {"SAVE", 0}, - {NULL, 0} -}; - -qc_save_init_t board_save_list[] = { - {"/sdcard/qc_save/"BOARD_NAME"/", SDCARD_DEV, 0}, - {NULL, 0, 0} -}; - -qc_env_init_list_t board_list_env[] = { - {NULL, NULL, 0} -}; -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_test.c deleted file mode 100644 index 6a84b94b..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133b_test.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" -#include "../common/common_test.h" - -#if QC_BOARD_D133B -#if QC_OS_RT_THREAD -static qc_res_t d133b_gpai_0_cmp(int msh_result); -static qc_res_t d133b_gpai_1_cmp(int msh_result); -static qc_res_t d133b_gpai_4_cmp(int msh_result); -static qc_res_t d133b_gpai_5_cmp(int msh_result); - -qc_res_t d133b_gpai_0_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 0 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133b_gpai_0_cmp(msh_result); -} - -qc_res_t d133b_gpai_1_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 1 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133b_gpai_1_cmp(msh_result); -} - -qc_res_t d133b_gpai_4_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 4 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133b_gpai_4_cmp(msh_result); -} - -qc_res_t d133b_gpai_5_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 5 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133b_gpai_5_cmp(msh_result); -} - -static qc_res_t d133b_gpai_0_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 2.0, 0.065); -} - -static qc_res_t d133b_gpai_1_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.5, 0.015); -} - -static qc_res_t d133b_gpai_4_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.0, 0.015); -} - -static qc_res_t d133b_gpai_5_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.5, 0.065); -} -#endif - -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 -qc_res_t d133b_gpai_0_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133b_gpai_1_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133b_gpai_4_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133b_gpai_5_test(void *param) -{ - return QC_RES_OK; -} -#endif -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_table.c deleted file mode 100644 index f364af81..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_table.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ -#include "../qc_board.h" -#include "../common/common_test.h" -#if QC_BOARD_D133C -#define BOARD_NAME "D133C" - -extern qc_res_t d133c_gpai_0_test(void *param); -extern qc_res_t d133c_gpai_1_test(void *param); -extern qc_res_t d133c_gpai_2_test(void *param); -extern qc_res_t d133c_gpai_3_test(void *param); -extern qc_res_t d133c_gpai_4_test(void *param); -extern qc_res_t d133c_gpai_5_test(void *param); - -qc_mod_init_base_t board_init_base[] = { - {"SID", BOARD_NAME"XX R comparison", NULL, 0}, - {"GPIO", "GPIO R-W comparison", NULL, 0}, - {"GPAI", "GPAI Read comparison", NULL, 0}, - {"CARD", "CARD R-W comparison", NULL, 0}, - {"DSPK", "DSPK Write comparison", NULL, 0}, - {"UART", "UART R-W comparison", NULL, 0}, - {"MAC", "MAC R-W comparison", NULL, 0}, - {"RTC", "RTC R-W comparison", NULL, 0}, - {"USB", "USB R-W comparison", NULL, 0}, - {"SAVE", "SAVE Results to Udisk", NULL, 0}, - {NULL, NULL} -}; - -qc_mod_init_list_pos_t board_init_list_pos[] = { - {"SID", BOARD_NAME"XX R comparison", 0, NULL, common_compare_chip_intel_module, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.8 -o PB.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.9 -o PB.8", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PD.9 -o PD.10", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PD.10 -o PD.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PD.11 -o PD.12", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PD.12 -o PD.11", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP3", 3, "test_gpio -t 10 -i PD.13 -o PD.14", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP3", 3, "test_gpio -t 10 -i PD.14 -o PD.13", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP4", 4, "test_gpio -t 10 -i PD.15 -o PD.16", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP4", 4, "test_gpio -t 10 -i PD.16 -o PD.15", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 5, "test_gpio -t 10 -i PE.12 -o PE.13", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 5, "test_gpio -t 10 -i PE.13 -o PE.12", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"GPAI", "GPAI0", 0, NULL, d133c_gpai_0_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI1", 1, NULL, d133c_gpai_1_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI2", 2, NULL, d133c_gpai_2_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI3", 3, NULL, d133c_gpai_3_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI4", 4, NULL, d133c_gpai_4_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI5", 5, NULL, d133c_gpai_5_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"CARD", "CARD", 0, NULL, common_sdcard_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"DSPK", "DSPK", 0, "aplay sound0 /data/lvgl_data/qc-test/assets/commond/du.wav", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"RTC", "RTC", 0, NULL, common_rtc_module_test_start, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"RTC", "RTC", 1, NULL, common_rtc_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"UART", "UART0", 0, "test_uart -u uart0 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART2", 1, "test_uart -u uart2 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART5", 2, "test_uart -u uart5 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART7", 3, "test_uart -u uart7 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"MAC", "MAC", 0, NULL, common_mac_test_disp_testing, QC_MOD_NOT_RECORD, QC_MOD_NOT_RECORD, 0}, - {"MAC", "MAC", 0, NULL, common_mac_wait_start_up, QC_MOD_NOT_RECORD, QC_MOD_NOT_RECORD, 0}, - {"MAC", "MAC", 0, "test_eth -d 10 -n 10", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"USB", "USB", 0, NULL, common_usb_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"SAVE", "SAVE Udisk", 0, NULL, common_qc_save_chip, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {NULL, NULL, 0, NULL, NULL, 0, 0, 0} -}; - -qc_exec_ops_order_init_t board_exec_order[] = { - {"SID", 0}, - {"RTC", 0}, - {"GPIO", 0}, {"GPIO", 1}, {"GPIO", 2}, {"GPIO", 3}, {"GPIO", 4}, {"GPIO", 5}, - {"GPAI", 0}, {"GPAI", 1}, {"GPAI", 2}, {"GPAI", 3}, {"GPAI", 4}, {"GPAI", 5}, - {"CARD", 0}, - {"DSPK", 0}, - {"UART", 0}, {"UART", 1}, {"UART", 2}, {"UART", 3}, - {"MAC", 0}, - {"RTC", 1}, - {"USB", 0}, - {"SAVE", 0}, - {NULL, 0} -}; - -qc_save_init_t board_save_list[] = { - {"/udisk/qc_save/"BOARD_NAME"/", USB_DEV, 0}, - {NULL, 0, 0} -}; - -qc_env_init_list_t board_list_env[] = { - {NULL, common_rtc_module_test_init, 0}, - {NULL, NULL, 0} -}; -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_test.c deleted file mode 100644 index 702d6c4a..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133c_test.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" -#include "../common/common_test.h" - -#if QC_BOARD_D133C -#if QC_OS_RT_THREAD -static qc_res_t d133c_gpai_0_cmp(int msh_result); -static qc_res_t d133c_gpai_1_cmp(int msh_result); -static qc_res_t d133c_gpai_2_cmp(int msh_result); -static qc_res_t d133c_gpai_3_cmp(int msh_result); -static qc_res_t d133c_gpai_4_cmp(int msh_result); -static qc_res_t d133c_gpai_5_cmp(int msh_result); - -qc_res_t d133c_gpai_0_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 0 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_0_cmp(msh_result); -} - -qc_res_t d133c_gpai_1_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 1 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_1_cmp(msh_result); -} - -qc_res_t d133c_gpai_2_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 2 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_2_cmp(msh_result); -} - -qc_res_t d133c_gpai_3_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 3 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_3_cmp(msh_result); -} - -qc_res_t d133c_gpai_4_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 4 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_4_cmp(msh_result); -} - -qc_res_t d133c_gpai_5_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 5 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133c_gpai_5_cmp(msh_result); -} - -static qc_res_t d133c_gpai_0_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 2.14, 0.065); -} - -static qc_res_t d133c_gpai_1_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 1.79, 0.065); -} - -static qc_res_t d133c_gpai_2_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.43, 0.015); -} - -static qc_res_t d133c_gpai_3_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.07, 0.015); -} - -static qc_res_t d133c_gpai_4_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.71, 0.065); -} - -static qc_res_t d133c_gpai_5_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.36, 0.065); -} -#endif - -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 -qc_res_t d133c_gpai_0_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133c_gpai_1_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133c_gpai_2_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133c_gpai_3_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133c_gpai_4_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133c_gpai_5_test(void *param) -{ - return QC_RES_OK; -} -#endif - -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_table.c deleted file mode 100644 index 691a451e..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_table.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ -#include "../qc_board.h" -#include "../common/common_test.h" -#if QC_BOARD_D133E -#define BOARD_NAME "D133E" - -extern qc_res_t d133e_gpai_0_test(void *param); -extern qc_res_t d133e_gpai_1_test(void *param); -extern qc_res_t d133e_gpai_2_test(void *param); -extern qc_res_t d133e_gpai_3_test(void *param); -extern qc_res_t d133e_gpai_4_test(void *param); -extern qc_res_t d133e_gpai_5_test(void *param); -extern qc_res_t d133e_gpai_6_test(void *param); -extern qc_res_t d133e_gpai_7_test(void *param); - -qc_mod_init_base_t board_init_base[] = { - {"SID", BOARD_NAME"XX R comparison", NULL, 0}, - {"GPIO", "GPIO R-W comparison", NULL, 0}, - {"GPAI", "GPAI Read comparison", NULL, 0}, - {"CARD", "CARD R-W comparison", NULL, 0}, - {"CAN", "CAN R-W comparison", NULL, 0}, - {"DSPK", "DSPK Write comparison", NULL, 0}, - {"UART", "UART R-W comparison", NULL, 0}, - {"MAC", "MAC R-W comparison", NULL, 0}, - {"RTC", "RTC R-W comparison", NULL, 0}, - {"USB", "USB R-W comparison", NULL, 0}, - {"SAVE", "SAVE Results to Udisk", NULL, 0}, - {NULL, NULL} -}; - -qc_mod_init_list_pos_t board_init_list_pos[] = { - {"SID", BOARD_NAME"XX R comparison", 0, NULL, common_compare_chip_intel_module, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.8 -o PB.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.9 -o PB.8", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PD.9 -o PD.10", NULL,QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PD.10 -o PD.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PD.11 -o PD.12", NULL,QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PD.12 -o PD.11", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP3", 3, "test_gpio -t 10 -i PD.13 -o PD.14", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP3", 3, "test_gpio -t 10 -i PD.14 -o PD.13", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP4", 4, "test_gpio -t 10 -i PD.15 -o PD.16", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP4", 4, "test_gpio -t 10 -i PD.16 -o PD.15", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 5, "test_gpio -t 10 -i PE.12 -o PE.13", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP5", 5, "test_gpio -t 10 -i PE.13 -o PE.12", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP6", 6, "test_gpio -t 10 -i PE.16 -o PE.17", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP6", 6, "test_gpio -t 10 -i PE.17 -o PE.16", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP7", 7, "test_gpio -t 10 -i PC.7 -o PE.11", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP7", 7, "test_gpio -t 10 -i PE.11 -o PC.7", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"GPAI", "GPAI0", 0, NULL, d133e_gpai_0_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI1", 1, NULL, d133e_gpai_1_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI2", 2, NULL, d133e_gpai_2_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI3", 3, NULL, d133e_gpai_3_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI4", 4, NULL, d133e_gpai_4_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI5", 5, NULL, d133e_gpai_5_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI6", 6, NULL, d133e_gpai_6_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI7", 7, NULL, d133e_gpai_7_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"CARD", "CARD", 0, NULL, common_sdcard_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"CAN", "CARD0", 0, "test_can can0 1a3#11.22.9a.88.ef.00", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"CAN", "CARD1", 1, "test_can can1 1a3#11.22.33.44.55.66.77.88", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"DSPK", "DSPK", 0, "aplay sound0 /data/lvgl_data/qc-test/assets/commond/du.wav", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"RTC", "RTC", 0, NULL, common_rtc_module_test_start, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"RTC", "RTC", 1, NULL, common_rtc_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"UART", "UART0", 0, "test_uart -u uart0 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART2", 1, "test_uart -u uart2 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART5", 2, "test_uart -u uart5 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART6", 3, "test_uart -u uart6 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"UART", "UART7", 4, "test_uart -u uart7 -t 2000", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"MAC", "MAC", 0, NULL, common_mac_test_disp_testing, QC_MOD_NOT_RECORD, QC_MOD_NOT_RECORD, 0}, - {"MAC", "MAC", 0, NULL, common_mac_wait_start_up, QC_MOD_NOT_RECORD, QC_MOD_NOT_RECORD, 0}, - {"MAC", "MAC", 0, "test_eth -d 10 -n 10", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"USB", "USB", 0, NULL, common_usb_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"SAVE", "SAVE Udisk", 0, NULL, common_qc_save_chip, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {NULL, NULL, 0, NULL, NULL, 0, 0, 0} -}; - -qc_exec_ops_order_init_t board_exec_order[] = { - {"SID", 0}, - {"RTC", 0}, - {"GPIO", 0}, {"GPIO", 1}, {"GPIO", 2}, {"GPIO", 3}, {"GPIO", 4}, {"GPIO", 5}, {"GPIO", 6}, {"GPIO", 7}, - {"GPAI", 0}, {"GPAI", 1}, {"GPAI", 2}, {"GPAI", 3}, {"GPAI", 4}, {"GPAI", 5}, {"GPAI", 6}, {"GPAI", 7}, - {"CARD", 0}, - {"CAN", 0}, {"CAN", 1}, - {"DSPK", 0}, - {"UART", 0}, {"UART", 1}, {"UART", 2}, {"UART", 3}, {"UART", 4}, - {"MAC", 0}, - {"RTC", 1}, - {"USB", 0}, - {"SAVE", 0}, - {NULL, 0} -}; - -qc_save_init_t board_save_list[] = { - {"/udisk/qc_save/"BOARD_NAME"/", USB_DEV, 0}, - {NULL, 0, 0} -}; - -qc_env_init_list_t board_list_env[] = { - {NULL, common_rtc_module_test_init, 0}, - {NULL, NULL, 0} -}; -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_test.c deleted file mode 100644 index 379ba299..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1603/qc_d133e_test.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" -#include "../common/common_test.h" -#if QC_BOARD_D133E -#if QC_OS_RT_THREAD -static qc_res_t d133e_gpai_0_cmp(int msh_result); -static qc_res_t d133e_gpai_1_cmp(int msh_result); -static qc_res_t d133e_gpai_2_cmp(int msh_result); -static qc_res_t d133e_gpai_3_cmp(int msh_result); -static qc_res_t d133e_gpai_4_cmp(int msh_result); -static qc_res_t d133e_gpai_5_cmp(int msh_result); -static qc_res_t d133e_gpai_6_cmp(int msh_result); -static qc_res_t d133e_gpai_7_cmp(int msh_result); - -qc_res_t d133e_gpai_0_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 0 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_0_cmp(msh_result); -} - -qc_res_t d133e_gpai_1_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 1 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_1_cmp(msh_result); -} - -qc_res_t d133e_gpai_2_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 2 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_2_cmp(msh_result); -} - -qc_res_t d133e_gpai_3_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 3 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_3_cmp(msh_result); -} - -qc_res_t d133e_gpai_4_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 4 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_4_cmp(msh_result); -} -qc_res_t d133e_gpai_5_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 5 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_5_cmp(msh_result); -} - -qc_res_t d133e_gpai_6_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 6 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_6_cmp(msh_result); -} - -qc_res_t d133e_gpai_7_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 7 -t 2.5", NULL, 0, 0, NULL, NULL); - return d133e_gpai_7_cmp(msh_result); -} - -static qc_res_t d133e_gpai_0_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 2.1429, 0.065); -} - -static qc_res_t d133e_gpai_1_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 1.7857, 0.065); -} - -static qc_res_t d133e_gpai_2_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 1.4268, 0.065); -} - -static qc_res_t d133e_gpai_3_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.0714, 0.015); -} - -static qc_res_t d133e_gpai_4_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 0.7143, 0.015);; -} - -static qc_res_t d133e_gpai_5_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.3571, 0.065); -} - -static qc_res_t d133e_gpai_6_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 1.6667, 0.065); -} - -static qc_res_t d133e_gpai_7_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.8333, 0.065); -} -#endif - -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 - -qc_res_t d133e_gpai_0_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_1_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_2_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_3_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_4_test(void *param) -{ - return QC_RES_OK; -} -qc_res_t d133e_gpai_5_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_6_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d133e_gpai_7_test(void *param) -{ - return QC_RES_OK; -} -#endif -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_1605_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_1605_table.c deleted file mode 100644 index 23306125..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_1605_table.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" - -#if AIC_1605 -#if QC_BOARD_D12XX -char *board_script = "Board: D12XXX"; -char *board_chip_intel_list[] = { - "D121BAV", - "D121BBV", - "D122BAV", - "D122BBV", - "D122BCV1", - "D122BCV2", - "TR230", - "JYX58", - NULL -}; -#elif QC_BOARD_D121B == 1 -char *board_script = "Board: D121BXX"; -char *board_chip_intel_list[] = { - "D121BAV", - "D121BBV", - NULL -}; -#elif QC_BOARD_D122B == 1 -char *board_script = "Board: D122BXX"; -char *board_chip_intel_list[] = { - "D122BAV", - "D122BBV", - "D122BCV1", - "D122BCV2", - NULL -}; -#elif QC_BOARD_TR23X == 1 -char *board_script = "Board: TR23XX"; -char *board_chip_intel_list[] = { - "TR230", - NULL -}; -#elif QC_BOARD_JYX58 == 1 -char *board_script = "Board: JYXXX"; -char *board_chip_intel_list[] = { - "JYX58", - NULL -}; -#endif - -#endif /* AIC_1605 */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_table.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_table.c deleted file mode 100644 index b553662d..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_table.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ -#include "../qc_board.h" -#include "../common/common_test.h" -#if QC_BOARD_D12XX -#define BOARD_NAME "D12XX" - -extern qc_res_t d12xx_gpai_0_test(void *param); -extern qc_res_t d12xx_gpai_1_test(void *param); -extern qc_res_t d12xx_gpai_4_test(void *param); -extern qc_res_t d12xx_gpai_5_test(void *param); - -qc_mod_init_base_t board_init_base[] = { - {"SID", BOARD_NAME"XX R comparison", NULL, 0}, - {"GPIO", "GPIO R-W comparison", NULL, 0}, - {"GPAI", "GPAI Read comparison", NULL, 0}, - {"CARD", "CARD R-W comparison", NULL, 0}, - {"DSPK", "DISP Write comparison", NULL, 0}, - {"UART", "UART R-W comparison", NULL, 0}, - {"SAVE", "SAVE Results to Udisk", NULL, 0}, - {NULL, NULL} -}; - -qc_mod_init_list_pos_t board_init_list_pos[] = { - {"SID", BOARD_NAME"XX R comparison", 0, NULL, common_compare_chip_intel_module, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.6 -o PB.7", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP0", 0, "test_gpio -t 10 -i PB.7 -o PB.6", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PB.8 -o PB.9", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP1", 1, "test_gpio -t 10 -i PB.9 -o PB.8", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PB.10 -o PB.11", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - {"GPIO", "GROUP2", 2, "test_gpio -t 10 -i PB.11 -o PB.10", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"GPAI", "GPAI0", 0, NULL, d12xx_gpai_0_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI1", 1, NULL, d12xx_gpai_1_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI4", 2, NULL, d12xx_gpai_4_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - {"GPAI", "GPAI5", 3, NULL, d12xx_gpai_5_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"CARD", "CARD", 0, NULL, common_sdcard_module_test, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {"DSPK", "DSPK", 0, "aplay sound0 /data/lvgl_data/qc-test/assets/commond/du.wav", NULL, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"UART", "UART1", 0, NULL, common_uart_test, QC_MOD_RECORD, QC_MOD_NOT_RECORD, 0}, - - {"SAVE", "SAVE Udisk", 0, NULL, common_qc_save_chip, QC_MOD_NOT_RECORD, QC_MOD_RECORD, 0}, - - {NULL, NULL, 0, NULL, NULL, 0, 0, 0} -}; - -qc_exec_ops_order_init_t board_exec_order[] = { - {"SID", 0}, - {"GPIO", 0}, {"GPIO", 1}, {"GPIO", 2}, - {"GPAI", 0}, {"GPAI", 1}, {"GPAI", 2}, {"GPAI", 3}, - {"CARD", 0}, - {"DSPK", 0}, - {"UART", 0}, - {"SAVE", 0}, - {NULL, 0} -}; - -qc_save_init_t board_save_list[] = { - {"/sdcard/qc_save/"BOARD_NAME"/", SDCARD_DEV, 0}, - {NULL, 0, 0} -}; - -qc_env_init_list_t board_list_env[] = { - {NULL, NULL, 0} -}; -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_test.c deleted file mode 100644 index 1ef08ae7..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/1605/qc_d12xx_test.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" -#include "../common/common_test.h" -#if QC_BOARD_D12XX -#if QC_OS_RT_THREAD -static qc_res_t d12xx_gpai_0_cmp(int msh_result); -static qc_res_t d12xx_gpai_1_cmp(int msh_result); -static qc_res_t d12xx_gpai_4_cmp(int msh_result); -static qc_res_t d12xx_gpai_5_cmp(int msh_result); - -qc_res_t d12xx_gpai_0_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 0 -t 2.5", NULL, 0, 0, NULL, NULL); - return d12xx_gpai_0_cmp(msh_result); -} - -qc_res_t d12xx_gpai_1_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 1 -t 2.5", NULL, 0, 0, NULL, NULL); - return d12xx_gpai_1_cmp(msh_result); -} - -qc_res_t d12xx_gpai_4_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 4 -t 2.5", NULL, 0, 0, NULL, NULL); - return d12xx_gpai_4_cmp(msh_result); -} - -qc_res_t d12xx_gpai_5_test(void *param) -{ - int msh_result; - - msh_result = qc_cmd_exec_ex("test_gpai -n 1 -c 5 -t 2.5", NULL, 0, 0, NULL, NULL); - return d12xx_gpai_5_cmp(msh_result); -} - -static qc_res_t d12xx_gpai_0_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 2.0, 0.065); -} - -static qc_res_t d12xx_gpai_1_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.5, 0.015); -} - -static qc_res_t d12xx_gpai_4_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_percentage_error_voltage(input_mv, 1.0, 0.015); -} - -static qc_res_t d12xx_gpai_5_cmp(int msh_result) -{ - float input_mv = (float)msh_result; - return gpai_calculate_range_error_voltage(input_mv, 0.5, 0.065); -} -#endif - -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 -qc_res_t d12xx_gpai_0_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d12xx_gpai_1_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d12xx_gpai_4_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t d12xx_gpai_5_test(void *param) -{ - return QC_RES_OK; -} -#endif - -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.c deleted file mode 100644 index 5f3ffe40..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include -#include -#include "common_test.h" - -#define AIC_GPAI_VOLTAGE_ACCURACY 10000 -#define AIC_GPAI_VOLITAGE_REFERENCE 2.5 -#define RTC_TEST_TIME 5 - -static char write_buff[512]; -#if QC_OS_RT_THREAD -#include -#include -#include - -qc_res_t gpai_calculate_range_error_voltage(float input_voltage, float reference_voltage, float voltage) -{ - if (abs(input_voltage - (reference_voltage * AIC_GPAI_VOLTAGE_ACCURACY)) > (voltage * AIC_GPAI_VOLTAGE_ACCURACY)) { - return QC_RES_INV; - } - return QC_RES_OK; -} - -qc_res_t gpai_calculate_percentage_error_voltage(float input_voltage, float reference_voltage, float percentage) -{ - if (abs(input_voltage - (reference_voltage * AIC_GPAI_VOLTAGE_ACCURACY)) / AIC_GPAI_VOLITAGE_REFERENCE > (percentage * AIC_GPAI_VOLTAGE_ACCURACY)) { - return QC_RES_INV; - } - return QC_RES_OK; -} - -qc_res_t common_sdcard_module_test(void *param) -{ - const char *file_name = "/sdcard/sd_text.txt"; - return qc_block_dev_test(file_name, write_buff, sizeof(write_buff)); -} - -qc_res_t common_usb_module_test(void *param) -{ - const char *file_name = "/udisk/udisk_text.txt"; - return qc_block_dev_test(file_name, write_buff, sizeof(write_buff)); -} - -qc_res_t common_qc_save_chip(void *param) -{ - struct qc_board_config *board = (struct qc_board_config *)(param); - - return qc_save_write(board); -} - -qc_res_t common_compare_chip_intel_module(void *param) -{ - char chip_intel_module[DESC_LEN] = {0}; - qc_board_config_t *board_config = (qc_board_config_t *)param; - - qc_read_chip_intel_model(chip_intel_module, sizeof(chip_intel_module)); - if (strncmp(chip_intel_module, board_config->chip_intel_module, DESC_LEN - 1) == 0) - return QC_RES_OK; - return QC_RES_INV; -} - -#ifdef AIC_RTC_DRV -static int last_hour = 0; -static int last_min = 0; -static int last_sec = 0; - -qc_res_t common_rtc_module_test_init(void *param) -{ - if (set_date(2024, 3, 20) != RT_EOK) { - printf("set RTC date failed"); - return QC_RES_INV; - } - rt_thread_mdelay(1); - if (set_time(00, 00, 00) != RT_EOK) { - printf("set RTC time failed"); - return QC_RES_INV; - } - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test_start(void *param) -{ - time_t now; - struct tm *local_time; - - now = time(RT_NULL); - local_time = localtime(&now); - last_hour = local_time->tm_hour; - last_min = local_time->tm_min; - last_sec = local_time->tm_sec; - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test(void *param) -{ - time_t now; - struct tm *local_time; - - now = time(RT_NULL); - local_time = localtime(&now); - if (abs(local_time->tm_year + 1900 - 2024) > 0 || - abs(local_time->tm_mon + 1 - 3) > 0 || - abs(local_time->tm_mday - 20) > 0) { - return QC_RES_INV; - } else { - int now_seconds = local_time->tm_hour *3600 + local_time->tm_min * 60 + local_time->tm_sec; - int last_seconds = last_hour * 3600 + last_min * 60 + last_sec; - if (abs(last_seconds - now_seconds) > RTC_TEST_TIME) { - return QC_RES_INV; - } - } - - return QC_RES_OK; -} -#else -qc_res_t common_rtc_module_test_init(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test_start(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test(void *param) -{ - return QC_RES_OK; -} -#endif - -#ifdef AIC_USING_GMAC0 -#include "lwip/netif.h" -qc_res_t common_mac_test_disp_testing(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_mac_wait_start_up(void *param) -{ - int timeout = 1000; - while ((!netif_is_link_up(netif_default)) || (timeout > 0)) { - rt_thread_mdelay(50); - timeout -= 50; - if (timeout < 0) - return QC_RES_INV; - } - return QC_RES_OK; -} -#else -qc_res_t common_mac_test_disp_testing(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_mac_wait_start_up(void *param) -{ - return QC_RES_OK; -} -#endif - -qc_res_t common_uart_test(void *param) -{ - return QC_RES_OK; -} - -#else -qc_res_t gpai_calculate_range_error_voltage(float input_voltage, float reference_voltage, float voltage) -{ - if (abs(input_voltage - (reference_voltage * AIC_GPAI_VOLTAGE_ACCURACY)) > (voltage * AIC_GPAI_VOLTAGE_ACCURACY)) { - return QC_RES_INV; - } - return QC_RES_OK; -} - -qc_res_t gpai_calculate_percentage_error_voltage(float input_voltage, float reference_voltage, float percentage) -{ - if (abs(input_voltage - (reference_voltage * AIC_GPAI_VOLTAGE_ACCURACY)) / AIC_GPAI_VOLITAGE_REFERENCE > (percentage * AIC_GPAI_VOLTAGE_ACCURACY)) { - return QC_RES_INV; - } - return QC_RES_OK; -} - -qc_res_t common_sdcard_module_test(void *param) -{ - const char *file_name = "./sd_text.txt"; - return qc_block_dev_test(file_name, write_buff, sizeof(write_buff)); -} - -qc_res_t common_usb_module_test(void *param) -{ - const char *file_name = "./udisk_text.txt"; - return qc_block_dev_test(file_name, write_buff, sizeof(write_buff)); -} - -qc_res_t common_qc_save_chip(void *param) -{ - struct qc_board_config *board = (struct qc_board_config *)(param); - - return qc_save_write(board); -} - -qc_res_t common_compare_chip_intel_module(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test_init(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test_start(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_rtc_module_test(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_mac_test_disp_testing(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_mac_wait_start_up(void *param) -{ - return QC_RES_OK; -} - -qc_res_t common_uart_test(void *param) -{ - return QC_RES_OK; -} - -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.h deleted file mode 100644 index ab401e9b..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/common/common_test.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_board.h" - -qc_res_t gpai_calculate_range_error_voltage(float input_voltage, float reference_voltage, float voltage); -qc_res_t gpai_calculate_percentage_error_voltage(float input_voltage, float reference_voltage, float percentage); - -qc_res_t common_sdcard_module_test(void *param); -qc_res_t common_usb_module_test(void *param); -qc_res_t common_rtc_module_test_init(void *param); -qc_res_t common_rtc_module_test_start(void *param); -qc_res_t common_rtc_module_test(void *param); -qc_res_t common_mac_test_disp_testing(void *param); -qc_res_t common_mac_wait_start_up(void *param); -qc_res_t common_uart_test(void *param); -qc_res_t common_qc_save_chip(void *param); -qc_res_t common_compare_chip_intel_module(void *param); diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.c deleted file mode 100644 index 22a3be60..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include -#include -#include "qc_board.h" - -static qc_res_t qc_board_get_chip_id(char *buf, int buf_len); -static qc_module_t *name_to_module(qc_module_t *module_list[], int module_list_num, char *name); -static void _qc_board_env_init(qc_env_init_list_t *list_env); -static qc_board_config_t* _qc_board_tests_create(char *board_describe, - char *chip_intel_list[], - qc_mod_init_base_t *base, - qc_mod_init_list_pos_t *list_pos); -static qc_res_t _qc_board_ops_push(qc_board_config_t* board, qc_exec_ops_order_init_t *order); - -extern char *board_script; -extern char *board_chip_intel_list[]; -extern qc_env_init_list_t board_list_env[]; -extern qc_mod_init_base_t board_init_base[]; -extern qc_mod_init_list_pos_t board_init_list_pos[]; -extern qc_exec_ops_order_init_t board_exec_order[]; - -qc_board_config_t* qc_board_tests_create(void) -{ - _qc_board_env_init(board_list_env); - return _qc_board_tests_create(board_script, board_chip_intel_list, board_init_base, board_init_list_pos); -} - -qc_res_t qc_board_ops_push(qc_board_config_t* board) -{ - return _qc_board_ops_push(board, board_exec_order); -} - -qc_res_t qc_board_ops_clear(qc_board_config_t* board) -{ - return qc_manager_clear_status(board->manager); -} - -static qc_module_t *name_to_module(qc_module_t *module_list[], int module_list_num, char *name) -{ - for (int i = 0; i < module_list_num; i++) { - if (strncmp(name, module_list[i]->name, strlen(name)) == 0) { - return module_list[i]; - } - } - return NULL; -} - -static qc_board_config_t* _qc_board_tests_create(char *board_describe, - char *chip_intel_list[], - qc_mod_init_base_t *base, - qc_mod_init_list_pos_t *list_pos) -{ - int i = 0; - - qc_board_config_t* board = NULL; - board = (qc_board_config_t *)malloc(sizeof(qc_board_config_t)); - if (board == NULL) { - return NULL; - } - memset(board, 0, sizeof(qc_board_config_t)); - - int module_num = 0; - while (1) { - if (base[module_num].name != NULL) - module_num++; - else - break; - } - qc_module_t **module_list = (qc_module_t **)malloc(sizeof(qc_module_t) * module_num); - if (module_list == NULL) - return NULL; - memset(module_list, 0, sizeof(qc_module_t) * module_num); - - qc_manager_t *mgr = qc_manager_create(); - if (mgr == NULL) { - free(board); - free(module_list); - return NULL; - } - - /* init chip id */ - qc_board_get_chip_id(board->chip_id, 64); - - /* init chip intel module */ - int chip_list_num = 0; - while (1) { - if (chip_intel_list[chip_list_num] != NULL) - chip_list_num++; - else - break; - } - for (i = 0; i < chip_list_num; i++) { - strncpy(board->chip_intel_module_list[i], chip_intel_list[i], DESC_LEN - 1); - board->chip_intel_module_list_num++; - } - if (qc_read_chip_intel_model_file(board->chip_intel_module, DESC_LEN - 1) == QC_RES_INV) { - strncpy(board->chip_intel_module, chip_intel_list[0], DESC_LEN - 1); - qc_write_chip_intel_module_file(board->chip_intel_module); - } - - /* init base */ - for (i = 0; i < module_num; i++) { - module_list[i] = qc_module_create(); - qc_module_set_name(module_list[i], base[i].name); - qc_module_set_desc(module_list[i], base[i].desc); - qc_module_set_log(module_list[i], base[i].log_buf, base[i].log_buf_len); - if ((strncmp(list_pos[i].name, "SID", strlen("SID")) == 0)) { - char sid_list_ops_desc[64] = {0}; - snprintf(sid_list_ops_desc, sizeof(sid_list_ops_desc), "%s R comparison", board->chip_intel_module); - qc_module_set_desc(module_list[i], sid_list_ops_desc); - } - } - - /* init list pos */ - qc_module_t *mod = NULL; - int list_pos_num = 0; - while (1) { - if (list_pos[list_pos_num].name != NULL) - list_pos_num++; - else - break; - } - for (i = 0; i < list_pos_num; i++) { - mod = name_to_module(module_list, module_num, list_pos[i].name); - qc_module_list_ops_set_desc(mod, list_pos[i].list_pos, list_pos[i].list_ops_desc); - qc_module_list_ops_cmd_append(mod, list_pos[i].list_pos, list_pos[i].list_ops_cmd, list_pos[i].list_ops_cmd_record, - NULL, NULL); - qc_module_list_ops_set_runtime(mod, list_pos[i].list_pos, list_pos[i].list_ops_runtime); - /* qc_save special deal with */ - if (strncmp(list_pos[i].name, "SAVE", strlen("SAVE")) == 0 || strncmp(list_pos[i].name, "SID", strlen("SID")) == 0) - qc_module_list_ops_func_append(mod, list_pos[i].list_pos, list_pos[i].list_ops_func, board, - list_pos[i].list_ops_func_record, NULL, NULL); - else - qc_module_list_ops_func_append(mod, list_pos[i].list_pos, list_pos[i].list_ops_func, NULL, - list_pos[i].list_ops_func_record, NULL, NULL); - } - - for (i = 0; i < module_num; i++) { - qc_manager_module_append(mgr, module_list[i]); - qc_module_delete(module_list[i]); - } - - board->board_describe = board_describe; - board->manager = mgr; - - return board; -} - -static void _qc_board_env_init(qc_env_init_list_t *list_env) -{ - int env_list_num = 0, i = 0; - while (1) { - if (list_env[env_list_num].cmd == NULL && list_env[env_list_num].func == NULL) - break; - else - env_list_num++; - } - - qc_list_ops_func_t func = NULL; - for (i = 0; i < env_list_num; i++) { - if (list_env[i].cmd != NULL) - qc_cmd_exec(list_env[i].cmd, NULL, 0, list_env[i].cmd_runtime); - if (list_env[i].func != NULL) { - func = list_env[i].func; - func(NULL); - } - } -} - -static qc_res_t _qc_board_ops_push(qc_board_config_t* board, qc_exec_ops_order_init_t *order) -{ - int exec_order_num = 0; - while (1) { - if (order[exec_order_num].name != NULL) - exec_order_num++; - else - break; - } - - for (int i = 0; i < exec_order_num; i++) { - qc_exec_ops_set_append(board->manager, order[i].name, order[i].order); - } - - return QC_RES_OK; -} - -static qc_res_t qc_board_get_chip_id(char *buf, int buf_len) -{ -#if QC_OS_RT_THREAD - extern qc_res_t qc_read_chip_id_rtos(char *buf, int buf_len); - return qc_read_chip_id_rtos(buf, buf_len); -#endif - -#if QC_OS_RT_LINUX - extern qc_res_t qc_read_chip_id_linux(char *buf); - return qc_read_chip_id_linux(buf, buf_len); -#endif - -#if QC_OS_RT_THREAD == 0 && QC_OS_RT_LINUX == 0 - strncpy(buf, "XXX", buf_len); - return QC_RES_OK; -#endif - return QC_RES_OK; -} - -void qc_board_debug(qc_board_config_t *board, qc_debug_t flag) -{ - if (board == NULL) - return; - printf("board describe = %s\n", board->board_describe); - if (flag & QC_DEBUG_BASE) { - printf("chip id = %s, chip intel model = %s\n", board->chip_id, board->chip_intel_module); - } -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.h deleted file mode 100644 index 6afab8ed..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/board/qc_board.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef _QC_BOARD_H_ -#define _QC_BOARD_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "../qc_config.h" -#include "../core/qc_core.h" -#include "../misc/qc_misc.h" - -typedef struct _qc_board_config -{ - char chip_id[64 + 4]; /* chip id fmt:44-80-ce-b8-52-2f-c0-0c-06-0c-11-18-09-00-30-04 */ - char chip_intel_module[DESC_LEN]; - char chip_intel_module_list[LIST_OPS_NUM][DESC_LEN]; - int chip_intel_module_list_num; - - char *board_describe; - qc_manager_t *manager; -} qc_board_config_t; - -typedef struct _qc_mod_init_base { - char *name; - char *desc; - char *log_buf; - int log_buf_len; -} qc_mod_init_base_t; - -typedef struct _qc_mod_init_list_pos { - char *name; - char *list_ops_desc; - int list_pos; - char *list_ops_cmd; - qc_list_ops_func_t list_ops_func; - qc_mod_record_t list_ops_cmd_record; - qc_mod_record_t list_ops_func_record; - unsigned int list_ops_runtime; -} qc_mod_init_list_pos_t; - -typedef struct _qc_exec_ops_order_init { - char *name; - int order; -} qc_exec_ops_order_init_t; - -typedef struct _qc_env_init_list { - char *cmd; - qc_list_ops_func_t func; - unsigned int cmd_runtime; -} qc_env_init_list_t; - -enum { - USB_DEV = 0, - SDCARD_DEV, -}; -typedef int qc_save_dev_t; - -typedef struct _qc_save_init { - const char *path; - qc_save_dev_t dev; - int blk_num; -} qc_save_init_t; - -qc_board_config_t* qc_board_tests_create(void); -qc_res_t qc_board_ops_push(qc_board_config_t* board); -qc_res_t qc_board_ops_clear(qc_board_config_t* board); -void qc_board_tests_del(qc_board_config_t* board_cfg); -void qc_board_debug(qc_board_config_t *board, qc_debug_t flag); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _QC_BOARD_CFG_H_ */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/common/qc_core_common.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/common/qc_core_common.c deleted file mode 100644 index ecdead0b..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/common/qc_core_common.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_core.h" -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 -#include - -void qc_module_list_ops_exec_cmd_common(qc_module_t *module, int list_ops, int list_ops_num, int *cmd_res_list) -{ - char cmd[256] = {0}; - int cmd_return = 0; - int cmd_result = 0; - qc_cap_cmp_int_t cmp_int; - - for (int i = 0; i < list_ops_num; i++) { - strncpy(cmd, module->list_ops_cmd[list_ops][i], sizeof(cmd) - 1); - cmp_int = module->list_ops_cmp_int[list_ops][i]; - - cmd_return = qc_cmd_exec(cmd, NULL, 0, 0); - cmd_result = cmp_int(cmd_return); - - /* save command run results */ - if (module->list_ops_cmd_record[list_ops][i] == QC_MOD_RECORD) { - cmd_res_list[i] = cmd_result; - } - } -} -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/qc_core_linux.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/qc_core_linux.c deleted file mode 100644 index 4b611cd6..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/linux/qc_core_linux.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#if QC_OS_LINUX -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../qc_core.h" - -static int _popen_close_and_get_status(FILE *fp); -static void _kill_process(char *command); -static int _qc_cmd_exec_linux(char *command, char *buf, - int buf_len, unsigned int runtime, - qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res); - -int qc_cmd_exec_linux(char *command, char *buf, - int buf_len, unsigned int runtime) -{ - int _runtime = runtime; - qc_res_t cmd_res = QC_RES_INV; - - return _qc_cmd_exec_linux(command, buf, buf_len, &_runtime, NULL, &cmd_res); -} - -int qc_cmd_exec_linux_ex(char *command, char *buf, - int buf_len, unsigned int runtime, - qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res) -{ - int _runtime = runtime; - qc_res_t cmd_res = QC_RES_INV; - - return _qc_cmd_exec_linux(command, buf, buf_len, &_runtime, cmp_str, &cmd_res); -} - -qc_res_t qc_module_list_ops_exec_cmd_linux(qc_module_t *module, int list_ops, int list_pos_num, int *cmd_res_list) -{ - qc_res_t cmd_str_res = QC_RES_INV; - qc_cmp_int_t cmp_int = NULL; - qc_cmp_str_t cmp_str = NULL; - qc_list_ops_cmd_t cmd[128] = {0}; - int cmd_return = 0; - int cmd_result = 0; - int runtime = -1; - - runtime = module->list_ops_runtime[list_ops]; - for (int i = 0; i < list_pos_func_num; i++) { - strncpy(cmd, module->list_ops_cmd[list_ops][i], sizeof(cmd)); - cmp_int = module->list_ops_cmp_int[list_ops][i]; - cmp_str = module->list_ops_cmp_str[list_ops][i]; - - cmd_return = _qc_cmd_exec_linux(cmd, module->log_buf, module->log_buf_len, &runtime, cmp_str, &cmd_str_res); - if (cmd_str_res != QC_RES_OK) - cmd_result = cmp_int(cmd_return); - - /* save command run results */ - if (module->list_ops_cmd_record[list_ops][i] == QC_MOD_RECORD) { - /* due to abnormal process shutdown, the return value is uncertain and - * the command is not used to return the value. - */ - cmd_res_list[i] = cmd_str_res; - } - } -} - -static int _popen_close_and_get_status(FILE *fp) -{ - int status; - int exit_status; - if (fp) - status = pclose(fp); - - if (_WIFEXITED(status)) { - exit_status = _WEXITSTATUS(status); - } else { - exit_status = _WTERMSIG(status); - } - return exit_status; -} - -static void _kill_process(char *command) -{ - char kill_cmd[256] = {0}; - snprintf(kill_cmd, sizeof(kill_cmd), "pkill -f \"*%s\"", command); - system(kill_cmd); -} - -static int _qc_cmd_exec_linux(char *command, char *buf, - int buf_len, unsigned int *runtime, - qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res) -{ - if (strlen(command) == 0) - return QC_RES_INV; - - *cmd_res = QC_RES_INV; - int *remain_time_ms = runtime; - int loop = 0; - if (*remain_time_ms <= 0) - loop = 1; - - FILE *fp = popen(command, "r"); - if (fp == NULL) - return QC_RES_INV; - - int fd = fileno(fp); - int flags = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, flags | O_NONBLOCK); - if (fd < 0) { - pclose(fp); - return QC_RES_INV; - } - - char buffer[256] = {0}; - int remain_buf_len = buf_len; - while(1) { - struct timeval start, end; - gettimeofday(&start, NULL); - - fd_set read_fds; - FD_ZERO(&read_fds); - FD_SET(fd, &read_fds); - - struct timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 50000; - int result = select(fd + 1, &read_fds, NULL, NULL, &timeout); - if (result) { - if (fgets(buffer, sizeof(buffer), fp) != NULL) { - if (buf != NULL && remain_buf_len > 0) - strncat(buf, buffer, buf_len); - remain_buf_len -= strlen(buffer); - if (cmp_str != NULL && cmp_str(buffer) == QC_RES_OK) { - *cmd_res = QC_RES_OK; - return _popen_close_and_get_status(); - } - } - } else if (result == -1) { - break; - } /* result == 0, timeout */ - - if (loop == 1) - continue; - - gettimeofday(&end, NULL); - int timeout_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_usec - start.tv_usec) / 1000; - *remain_time_ms -= (int)timeout_ms; - if (*remain_time_ms <= 0) { - _kill_process(command); - break; - } - } - - return _popen_close_and_get_status(); -} - -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.c deleted file mode 100644 index 805f11fa..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.c +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include -#include -#include - -#include "qc_core.h" - -#define TIMEOUT_MS_NULL -65550 - -static int qc_module_find_free_list_ops_cmd(qc_module_t *module, int list_ops); -static int qc_module_find_free_list_ops_func(qc_module_t *module, int list_ops); -static int qc_module_get_list_ops_func_num(qc_module_t *module, int list_ops); -static int qc_module_get_list_ops_cmd_num(qc_module_t *module, int list_ops); -static void qc_module_init_func_res_list(qc_module_t *module, int list_ops, qc_res_t *list); -static void qc_module_init_cmd_res_list(qc_module_t *module, int list_ops, qc_res_t *list); -static qc_res_t qc_module_list_ops_exec_res(qc_res_t *list); -static qc_res_t qc_module_list_ops_exec_func(qc_module_t *module, int list_ops); -static qc_res_t qc_module_list_ops_exec_cmd(qc_module_t *module, int list_ops); -static void qc_module_list_ops_status_update(qc_module_t *module, int list_ops, qc_res_t func_res, qc_res_t cmd_res); -static void qc_module_get_list_ops_record(qc_module_t *module, qc_mod_record_t *list_ops_record); -static void qc_module_status_update(qc_module_t *module); - -static void qc_mod_list_del(qc_manager_t *manager); -static void qc_exec_list_del(qc_manager_t *manager); -static void qc_disp_list_del(qc_manager_t *manager); -static qc_res_t qc_manager_check_include_module(qc_manager_t *manager, qc_module_t *module); - -static qc_res_t qc_exec_add(qc_exec_t *exec, qc_manager_t *mgr, int append); -static qc_res_t qc_disp_data_add(qc_disp_data_t *disp_data, qc_manager_t *manager, int append); - -static unsigned int module_id = 0; -static qc_module_t tmp_module = {0}; - -int qc_cmd_exec(char *command, char *buf, int buf_len, unsigned int runtime) /* capture output and return result */ -{ -#if QC_OS_RT_THREAD - extern int qc_cmd_exec_rtos(char *command); - return qc_cmd_exec_rtos(command); -#endif - -#if QC_OS_LINUX - extern int qc_cmd_exec_linux(char *command, char *buf, int buf_len, unsigned int runtime); - return qc_cmd_exec_linux(module, buf, buf_len, runtime); -#endif - return QC_RES_OK; -} - -int qc_cmd_exec_ex(char *command, char *buf, - int buf_len, unsigned int runtime, - qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res) -{ -#if QC_OS_RT_THREAD - extern int qc_cmd_exec_rtos_ex(char *command); - return qc_cmd_exec_rtos_ex(command); -#endif - -#if QC_OS_LINUX - extern int qc_cmd_exec_linux_ex(char *command, char *buf, int buf_len, unsigned int runtime, qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res); - return qc_cmd_exec_linux_ex(module, buf, buf_len, runtime, cmp_str, cmd_res); -#endif - - return QC_RES_OK; -} - -static int get_module_id(void) -{ - return ++module_id; -} - -static int free_module_id(void) -{ - return --module_id; -} - -static qc_res_t list_ops_cmp_int_default(int result) -{ - if (result == 0) - return QC_RES_OK; - - return QC_RES_INV; -} - -static qc_res_t list_ops_cmp_str_default(char *str) -{ - int i = 0; - char lower_str[256] = {0}; - const char *keywords[] ={ - "success", - "test ok" - }; - - for (i = 0; i < strlen(str) && i < sizeof(lower_str); i++) { - lower_str[i] = tolower(str[i]); - } - - for (i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) { - if (strstr(lower_str, keywords[i]) != NULL) { - return QC_RES_OK; - } - } - - return QC_RES_INV; -} - -qc_module_t *qc_module_create(void) -{ - int i = 0, j = 0; - qc_module_t *module = NULL; - - module = (qc_module_t *)malloc(sizeof(qc_module_t)); - if (module == NULL) { - printf("malloc module failed\n"); - return NULL; - } - memset(module, 0, sizeof(qc_module_t)); - - module->id = get_module_id(); - module->status = QC_MOD_UNEXECUTED; - - for (i = 0; i < LIST_OPS_NUM; i++) { - module->list_ops_status[i] = QC_MOD_UNEXECUTED; - module->list_ops_runtime[i] = TIMEOUT_MS_NULL; - } - - for (i = 0; i < LIST_OPS_NUM; i++) { - for (j = 0; j < OPS_NUM; j++) { - module->list_ops_cmd_record[i][j] = QC_MOD_NOT_RECORD; - module->list_ops_func_record[i][j] = QC_MOD_NOT_RECORD; - module->list_ops_cmp_int[i][j] = list_ops_cmp_int_default; - module->list_ops_cmp_str[i][j] = list_ops_cmp_str_default; - } - } - - qc_list_init(&module->list); - - return module; -} - -qc_res_t qc_module_clear_status(qc_module_t *module) -{ - int i; - - memset(module->log_buf, 0, module->log_buf_len); - module->status = QC_MOD_UNEXECUTED; - - for (i = 0; i < LIST_OPS_NUM; i++) { - module->list_ops_status[i] = QC_MOD_UNEXECUTED; - } - - return QC_RES_OK; -} - -qc_res_t qc_module_delete(qc_module_t *module) -{ - if (module) - free(module); - - free_module_id(); - return QC_RES_OK; -} - - -qc_res_t qc_module_set_name(qc_module_t *module, char *name) -{ - if (module == NULL || name == NULL) - return QC_RES_INV; - - strncpy(module->name, name, NAME_LEN -1); - return QC_RES_OK; -} - -qc_res_t qc_module_set_desc(qc_module_t *module, char *desc) -{ - if (module == NULL || desc == NULL) - return QC_RES_INV; - - strncpy(module->desc, desc, DESC_LEN -1); - return QC_RES_OK; -} - -qc_res_t qc_module_set_log(qc_module_t *module, char *log_buf, int buf_len) -{ - if (module == NULL || log_buf == NULL || buf_len <= 0) - return QC_RES_INV; - - module->log_buf = log_buf; - module->log_buf_len = buf_len; - return QC_RES_OK; -} - -qc_res_t qc_module_list_ops_set_desc(qc_module_t *module, int list_ops, char *list_desc) -{ - if (module == NULL || list_ops < 0 || list_ops > LIST_OPS_NUM - 1 || list_desc == NULL) - return QC_RES_INV; - - strncpy(module->list_ops_desc[list_ops], list_desc, DESC_LEN -1); - return QC_RES_OK; -} - -qc_res_t qc_module_list_ops_set_runtime(qc_module_t *module, int list_ops, int runtime) -{ - if (module == NULL || list_ops < 0 || list_ops > LIST_OPS_NUM - 1 || runtime <= 0) - return QC_RES_INV; - - module->list_ops_runtime[list_ops] = runtime; - return QC_RES_OK; -} - -qc_res_t qc_module_list_ops_cmd_append(qc_module_t *module, int list_ops, char *cmd, - qc_mod_record_t ops_record, qc_cap_cmp_int_t int_cmp, qc_cap_cmp_str_t str_cmp) -{ - if (module == NULL || list_ops < 0 || list_ops > LIST_OPS_NUM - 1 || cmd == NULL - || (ops_record != QC_MOD_NOT_RECORD && ops_record != QC_MOD_RECORD)) - return QC_RES_INV; - - int pos = qc_module_find_free_list_ops_cmd(module, list_ops); - if (pos == -1) - return QC_RES_INV; - - strncpy(module->list_ops_cmd[list_ops][pos], cmd, OPS_LEN -1); - module->list_ops_cmd_record[list_ops][pos] = ops_record; - - if (int_cmp != NULL) - module->list_ops_cmp_int[list_ops][pos] = int_cmp; - - if (str_cmp != NULL) - module->list_ops_cmp_str[list_ops][pos] = str_cmp; - - return QC_RES_OK; -} - -qc_res_t qc_module_list_ops_func_append(qc_module_t *module, int list_ops, qc_list_ops_func_t ops, void *para, - qc_mod_record_t ops_record, qc_cap_cmp_int_t int_cmp, qc_cap_cmp_str_t str_cmp) -{ - if (module == NULL || list_ops < 0 || list_ops > LIST_OPS_NUM - 1 - || (ops_record != QC_MOD_NOT_RECORD && ops_record != QC_MOD_RECORD)) - return QC_RES_INV; - - int pos = qc_module_find_free_list_ops_func(module, list_ops); - if (pos == -1) - return QC_RES_INV; - - module->list_ops_func[list_ops][pos] = ops; - module->list_ops_func_para[list_ops][pos] = para; - module->list_ops_func_record[list_ops][pos] = ops_record; - - if (int_cmp != NULL) - module->list_ops_cmp_int[list_ops][pos] = int_cmp; - - if (str_cmp != NULL) - module->list_ops_cmp_str[list_ops][pos] = str_cmp; - - return QC_RES_OK; -} - -qc_res_t qc_module_list_ops_exec(qc_module_t *module, int list_ops) -{ - if (module == NULL || list_ops < 0 || list_ops > LIST_OPS_NUM - 1) - return QC_RES_INV; - - if (module->status == QC_MOD_SUCCESS || module->status == QC_MOD_FAILURE) - return QC_RES_OK; - - /* Marking is being executed */ - module->status = QC_MOD_EXECUTING; - module->list_ops_status[list_ops] = QC_MOD_EXECUTING; - - qc_res_t func_res = qc_module_list_ops_exec_func(module, list_ops); - - qc_res_t cmd_res = qc_module_list_ops_exec_cmd(module, list_ops); - - qc_module_list_ops_status_update(module, list_ops, func_res, cmd_res); - - qc_module_status_update(module); - - return QC_RES_OK; -} - -qc_manager_t *qc_manager_create(void) -{ - qc_manager_t *manager = NULL; - - manager = (qc_manager_t *)malloc(sizeof(qc_manager_t )); - if (manager == NULL) { - printf("malloc manager failed\n"); - return NULL; - } - memset(manager, 0, sizeof(qc_manager_t )); - - qc_list_init(&manager->mod_head); - qc_list_init(&manager->exec_head); - qc_list_init(&manager->disp_head); - - return manager; -} - -qc_res_t qc_manager_clear_status(qc_manager_t *manager) -{ - qc_module_t *mod = NULL, *next_mod = NULL; - - if (manager == NULL) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - if (manager->exec_num > 0) { - qc_exec_list_del(manager); - } - - if (manager->disp_num > 0) { - qc_disp_list_del(manager); - } - - if (manager->module_num > 0) { - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - qc_module_clear_status(mod); - } - } - } - - manager->progress = 0; - manager->success_num = 0; - manager->failure_num = 0; - manager->success_rate = 0; - manager->exec_num = 0; - manager->disp_num = 0; - - qc_manager_unlock(manager); - - return QC_RES_OK; -} - -qc_res_t qc_manager_delete(qc_manager_t *manager) -{ - if (manager == NULL) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - qc_mod_list_del(manager); - qc_exec_list_del(manager); - qc_disp_list_del(manager); - - qc_manager_unlock(manager); - free(manager); - - return QC_RES_OK; -} - -qc_res_t qc_manager_set_lock(qc_manager_t *manager, qc_lock_t lock, qc_lock_t un_lock) -{ - if (manager == NULL) { - return QC_RES_INV; - } - - manager->lock = lock; - manager->un_lock = un_lock; - - return QC_RES_OK; -} - -qc_res_t qc_manager_module_append(qc_manager_t *manager, qc_module_t *module) -{ - if (module == NULL || manager == NULL) { - return QC_RES_INV; - } - - qc_module_t *new_module = qc_module_create(); - if (new_module == NULL) { - return QC_RES_INV; - } - memcpy(new_module, module, sizeof(qc_module_t)); - - qc_manager_lock(manager); - - qc_list_add_tail(&new_module->list, &manager->mod_head); - - manager->module_num++; - - qc_manager_unlock(manager); - - return QC_RES_OK; -} - - -qc_res_t qc_manager_module_get(qc_manager_t *manager, qc_module_t *back, char *name) -{ - if (manager == NULL || strlen(name) == 0 || manager->module_num <= 0) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - qc_module_t *mod = NULL, *next_mod = NULL; - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - if (strncmp(mod->name, name, strlen(name)) == 0) { - memcpy(back, mod, sizeof(qc_module_t)); - qc_manager_unlock(manager); - return QC_RES_OK; - } - } - } - - qc_manager_unlock(manager); - return QC_RES_INV; -} - -qc_res_t qc_manager_module_get_index(qc_manager_t *manager, qc_module_t *back, int index) -{ - if (manager == NULL || index < 0 || index >= manager->module_num) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - int _index = index; - qc_module_t *mod = NULL, *next_mod = NULL; - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - if (_index-- == 0) { - memcpy(back, mod, sizeof(qc_module_t)); - qc_manager_unlock(manager); - return QC_RES_OK; - } - } - } - - qc_manager_unlock(manager); - return QC_RES_INV; -} - -qc_res_t qc_manager_module_del(qc_manager_t *manager, char *name) -{ - if (manager == NULL || strlen(name) == 0 || manager->module_num <= 0) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - qc_module_t *mod = NULL, *next_mod = NULL; - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - if (strncmp(mod->name, name, strlen(mod->name)) == 0) { - qc_list_del(&mod->list); - qc_module_delete(mod); - manager->module_num--; - } - } - } - - qc_manager_unlock(manager); - - return QC_RES_OK; -} - -qc_res_t qc_manager_update(qc_manager_t *manager, qc_module_t *module) -{ - if (manager == NULL || module == NULL) { - return QC_RES_INV; - } - - /* check if the module result has been written */ - if (qc_manager_check_include_module(manager, module) == QC_RES_INV) { - return QC_RES_INV; - } - - /* check if the module has been update */ - qc_manager_module_get(manager, &tmp_module, module->name); - if (tmp_module.status == QC_MOD_SUCCESS || tmp_module.status == QC_MOD_FAILURE) - return QC_RES_INV; - - qc_manager_lock(manager); - - if (module->status == QC_MOD_SUCCESS) { - manager->success_num++; - manager->success_rate = (manager->success_num * 100) / manager->module_num; - } else if (module->status == QC_MOD_FAILURE) { - manager->failure_num++; - } - - int module_run_num = manager->success_num + manager->failure_num; - manager->progress = (module_run_num * 100) / manager->module_num; - - qc_manager_module_sync(manager, module); - - qc_manager_unlock(manager); - - return QC_RES_OK; -} - - -qc_exec_t *qc_exec_create(void) -{ - qc_exec_t *exec = NULL; - - exec = (qc_exec_t *)malloc(sizeof(qc_exec_t)); - if (exec == NULL) { - return NULL; - } - memset(exec, 0, sizeof(qc_exec_t)); - - qc_list_init(&exec->list); - - return exec; -} - -qc_res_t qc_exec_delete(qc_exec_t *exec) -{ - if (exec) { - free(exec); - } - - return QC_RES_OK; -} - -qc_res_t qc_exec_set(qc_exec_t *exec, char *mod_name, int list_ops_pos) -{ - if (exec == NULL || mod_name == NULL) { - return QC_RES_INV; - } - - if (list_ops_pos < 0 || list_ops_pos > LIST_OPS_NUM -1) { - return QC_RES_INV; - } - - strncpy(exec->module_name, mod_name, NAME_LEN - 1); - - exec->list_ops_pos = list_ops_pos; - - qc_list_init(&exec->list); - - return QC_RES_OK; -} - -qc_res_t qc_exec_append(qc_exec_t *exec, qc_manager_t *mgr) -{ - return qc_exec_add(exec, mgr, 1); -} - -qc_res_t qc_exec_append_left(qc_exec_t *exec, qc_manager_t *mgr) -{ - return qc_exec_add(exec, mgr, 0); -} - -qc_res_t qc_exec_pop(qc_exec_t *exec, qc_manager_t *mgr) -{ - if (mgr == NULL || exec == NULL || mgr->exec_num <= 0) { - return QC_RES_INV; - } - - qc_manager_lock(mgr); - - qc_exec_t *list_exec = NULL, *next_list_exec = NULL; - qc_list_for_each_entry_safe(list_exec, next_list_exec, &mgr->exec_head, list) { - if (list_exec) { - memcpy(exec, list_exec, sizeof(qc_exec_t)); - break; - } - } - - mgr->exec_num--; - qc_list_del(&list_exec->list); - - qc_manager_unlock(mgr); - - qc_exec_delete(list_exec); - - return QC_RES_OK; -} - -qc_res_t qc_exec_ops_set_append(qc_manager_t *mgr, char *mod_name, int list) -{ - qc_exec_t tmp_exec; - qc_exec_set(&tmp_exec, mod_name, list); - return qc_exec_append(&tmp_exec, mgr); -} - - -qc_disp_data_t *qc_disp_data_create(void) -{ - qc_disp_data_t * disp_data = NULL; - - disp_data = (qc_disp_data_t *)malloc(sizeof(qc_disp_data_t)); - if (disp_data == NULL) { - return NULL; - } - memset(disp_data, 0, sizeof(qc_disp_data_t)); - - qc_list_init(&disp_data->list); - - return disp_data; -} - -qc_res_t qc_disp_data_delete(qc_disp_data_t *disp_data) -{ - if (disp_data) { - free(disp_data); - } - - return QC_RES_OK; -} - -qc_res_t qc_disp_data_set(qc_disp_data_t *disp_data, qc_manager_t *manager, qc_module_t *module) -{ - if (disp_data == NULL || manager == NULL || module == NULL) { - return QC_RES_INV; - } - - memset(disp_data, 0, sizeof(qc_disp_data_t)); - memcpy(disp_data->mod_name, module->name, strlen(module->name)); - memcpy(disp_data->mod_desc, module->desc, DESC_LEN); - memcpy(disp_data->list_ops_status, module->list_ops_status, sizeof(int) * LIST_OPS_NUM); - memcpy(disp_data->list_ops_desc, module->list_ops_desc, sizeof(char) * LIST_OPS_NUM * DESC_LEN); - disp_data->mod_status = module->status; - - memcpy(disp_data->mgr_name, manager->name, strlen(manager->name)); - disp_data->mgr_progress = manager->progress; - disp_data->mgr_success_num = manager->success_num; - disp_data->mgr_failure_num = manager->failure_num; - disp_data->mgr_success_rate = manager->success_rate; - - qc_list_init(&disp_data->list); - - return QC_RES_OK; -} - -qc_res_t qc_disp_data_append(qc_disp_data_t *disp_data, qc_manager_t *manager) -{ - return qc_disp_data_add(disp_data, manager, 1); -} - -qc_res_t qc_disp_data_append_left(qc_disp_data_t *disp_data, qc_manager_t *manager) -{ - return qc_disp_data_add(disp_data, manager, 0); -} - -qc_res_t qc_disp_data_pop(qc_disp_data_t *disp_data, qc_manager_t *manager) -{ - if (manager == NULL|| manager->disp_num <= 0) { - return QC_RES_INV; - } - - qc_manager_lock(manager); - - qc_disp_data_t *list_disp = NULL, *next_list_disp = NULL; - qc_list_for_each_entry_safe(list_disp, next_list_disp, &manager->disp_head, list) { - if (list_disp) { - memcpy(disp_data, list_disp, sizeof(qc_disp_data_t)); - break; - } - } - - manager->disp_num--; - - qc_list_del(&list_disp->list); - - qc_manager_unlock(manager); - - qc_disp_data_delete(list_disp); - - return QC_RES_OK; -} - -void qc_module_debug(qc_module_t *module, qc_debug_t debug_flag) -{ - if (module == NULL) - return; - - int i = 0, j = 0; - printf("module name = %s", module->name); - - if (debug_flag & QC_DEBUG_BASE) { - printf(" status = %d, desc = %s\n", module->status, module->desc); - } - - if (debug_flag & QC_DEBUG_CORE) { - for (i = 0; i < LIST_OPS_NUM; i++) { - if (strlen(module->list_ops_desc[i]) > 0) - printf("\tlist_ops_desc[%d] = %s\n", i, module->list_ops_desc[i]); - - if (module->list_ops_status[i] != QC_MOD_UNEXECUTED) - printf("\tlist_ops_status[%d] = %d\n", i, module->list_ops_status[i]); - - if (module->list_ops_runtime[i] != TIMEOUT_MS_NULL) - printf("\tlist_ops_runtime[%d] = %d\n", i, module->list_ops_runtime[i]); - - for (j = 0; j < OPS_NUM; j++) { - if (strlen(module->list_ops_cmd[i][j]) > 0) - printf("\tlist_ops_cmd[%d][%d] = %s\n", i, j, module->list_ops_cmd[i][j]); - - if (module->list_ops_func[i][j] != NULL) { - printf("\tlist_ops_func[%d][%d] = %p para = %p\n", i, j, module->list_ops_func[i][j], module->list_ops_func_para[i][j]); - } - - if (module->list_ops_cmp_int[i][j] != list_ops_cmp_int_default) { - printf("\tlist_ops_cmp_int[%d][%d] = %p\n", i, j, module->list_ops_cmp_int[i][j]); - } - - if (module->list_ops_cmp_str[i][j] != list_ops_cmp_str_default) { - printf("\tlist_ops_cmp_str[%d][%d] = %p\n", i, j, module->list_ops_cmp_str[i][j]); - } - - if (module->list_ops_cmd_record[i][j] != QC_MOD_NOT_RECORD) { - printf("\tlist_ops_cmd_record[%d][%d] = %d\n", i, j, module->list_ops_cmd_record[i][j]); - } - - if (module->list_ops_func_record[i][j] != QC_MOD_NOT_RECORD) { - printf("\tlist_ops_func_record[%d][%d] = %d\n", i, j, module->list_ops_func_record[i][j]); - } - } - } - } - - if (debug_flag & QC_DEBUG_DETAIL && module->log_buf) { - printf("\tlog_buf_len = %d, log_buf = %s\n", module->log_buf_len, module->log_buf); - } -} - -void qc_manager_debug(qc_manager_t *manager, qc_debug_t debug_flag) -{ - if (manager == NULL) - return; - - printf("manager name = %s\n", manager->name); - if (debug_flag & QC_DEBUG_BASE) { - printf("progress = %d, success_num = %d, failure_num = %d\n", - manager->progress, manager->success_num, manager->failure_num); - } - - if (debug_flag & QC_DEBUG_CORE) { - printf("success_rate = %d module_num = %d, exec_num = %d, disp_num = %d\n", - manager->success_rate, manager->module_num, manager->exec_num, manager->disp_num); - } - - qc_module_t *mod = NULL, *next_mod = NULL; - if (manager->module_num > 0 && debug_flag & QC_DEBUG_DETAIL) { - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - qc_module_debug(mod, QC_DEBUG_ALL); - } - } - - qc_exec_t *exec = NULL, *next_exec = NULL; - if (manager->exec_num > 0 && debug_flag & QC_DEBUG_DETAIL) { - qc_list_for_each_entry_safe(exec, next_exec, &manager->exec_head, list) { - qc_exec_debug(exec, QC_DEBUG_ALL); - } - } - - qc_disp_data_t *disp_data = NULL, *next_disp = NULL; - if (manager->exec_num > 0 && debug_flag & QC_DEBUG_DETAIL) { - qc_list_for_each_entry_safe(disp_data, next_disp, &manager->disp_head, list) { - qc_disp_data_debug(disp_data, QC_DEBUG_BASE); - } - } -} - -void qc_exec_debug(qc_exec_t *exec, qc_debug_t debug_flag) -{ - if (exec == NULL) - return; - - printf("exec name = %s, sets = %d\n", exec->module_name, exec->list_ops_pos); -} - -void qc_disp_data_debug(qc_disp_data_t *disp_data, qc_debug_t debug_flag) -{ - if (disp_data == NULL) - return; - - if (debug_flag & QC_DEBUG_BASE) { - printf("disp_data mod_name = %s, mod_status = %d, mgr_name = %s, mgr_progress = %d, mgr_success_rate = %d\n", - disp_data->mod_name, disp_data->mod_status, disp_data->mgr_name, - disp_data->mgr_progress, disp_data->mgr_success_rate); - } - - if (debug_flag & QC_DEBUG_CORE) { - printf("disp_data mgr_status = %d, mod_desc = %s, mgr_success_num = %d, mgr_failure_num = %d\n", - disp_data->mgr_status, disp_data->mod_desc, disp_data->mgr_success_num, disp_data->mgr_failure_num); - } - - if (debug_flag & QC_DEBUG_DETAIL) { - for (int i = 0; i < LIST_OPS_NUM; i++) { - if (disp_data->list_ops_status[i] == QC_MOD_UNEXECUTED) - continue; - printf("disp_data list_ops_status[%d] = %d, list_ops_desc[%d] = %s\n", - i, disp_data->list_ops_status[i], i, disp_data->list_ops_desc[i]); - } - } -} - -static int qc_module_find_free_list_ops_cmd(qc_module_t *module, int list_ops) -{ - for (int pos = 0; pos < OPS_NUM; pos++) { - if (strlen(module->list_ops_cmd[list_ops][pos]) == 0) { - return pos; - } - } - - return -1; -} - -static int qc_module_find_free_list_ops_func(qc_module_t *module, int list_ops) -{ - for (int pos = 0; pos < OPS_NUM; pos++) { - if (module->list_ops_func[list_ops][pos] == NULL) { - return pos; - } - } - - return -1; -} - -static int qc_module_get_list_ops_func_num(qc_module_t *module, int list_ops) -{ - int pos = 0; - for (pos = 0; pos < OPS_NUM; pos++) { - if (module->list_ops_func[list_ops][pos] == NULL) { - break; - } - } - return pos; -} - -static int qc_module_get_list_ops_cmd_num(qc_module_t *module, int list_ops) -{ - int pos = 0; - for (pos = 0; pos < OPS_NUM; pos++) { - if (strlen(module->list_ops_cmd[list_ops][pos]) == 0) { - break; - } - } - return pos; -} - -static void qc_module_init_cmd_res_list(qc_module_t *module, int list_ops, qc_res_t *list) -{ - for (int i = 0; i < OPS_NUM; i++) { - if (module->list_ops_cmd_record[list_ops][i] == QC_MOD_RECORD) { - list[i] = QC_RES_INV; - } else { - list[i] = QC_RES_OK; - } - } -} - -static void qc_module_init_func_res_list(qc_module_t *module, int list_ops, qc_res_t *list) -{ - for (int i = 0; i < OPS_NUM; i++) { - if (module->list_ops_func_record[list_ops][i] == QC_MOD_RECORD) { - list[i] = QC_RES_INV; - } else { - list[i] = QC_RES_OK; - } - } -} - -qc_res_t qc_module_list_ops_exec_res(qc_res_t *list) -{ - for (int i = 0; i < OPS_NUM; i++) { - if (list[i] == QC_RES_INV) - return QC_RES_INV; - } - - return QC_RES_OK; -} - -static qc_res_t qc_module_list_ops_exec_func(qc_module_t *module, int list_ops) -{ - int list_ops_func_num = 0; - qc_res_t func_res_list[OPS_NUM] = {0}; - - list_ops_func_num = qc_module_get_list_ops_func_num(module, list_ops); - - if (list_ops_func_num == 0) - return QC_RES_OK; - - qc_module_init_func_res_list(module, list_ops, func_res_list); - - for (int i = 0; i < list_ops_func_num; i++) { - qc_list_ops_func_t list_ops_func = module->list_ops_func[list_ops][i]; - void *list_ops_func_para = module->list_ops_func_para[list_ops][i]; - qc_res_t result = list_ops_func(list_ops_func_para); - - /* save command run results */ - if (module->list_ops_func_record[list_ops][i] == QC_MOD_RECORD) { - func_res_list[i] = result; - } - } - - return qc_module_list_ops_exec_res(func_res_list); -} - -static qc_res_t qc_module_list_ops_exec_cmd(qc_module_t *module, int list_ops) -{ - int list_ops_cmd_num = 0; - qc_res_t cmd_res_list[OPS_NUM] = {0}; - - list_ops_cmd_num = qc_module_get_list_ops_cmd_num(module, list_ops); - if (list_ops_cmd_num == 0) - return QC_RES_OK; - - qc_module_init_cmd_res_list(module, list_ops, cmd_res_list); - -#if QC_OS_RT_THREAD - extern void qc_module_list_ops_exec_cmd_rtos(qc_module_t *module, int list_ops, int list_pos_num, int *cmd_res_list); - qc_module_list_ops_exec_cmd_rtos(module, list_ops, list_ops_cmd_num, cmd_res_list); -#elif QC_OS_LINUX - extern void qc_module_list_ops_exec_cmd_linux(qc_module_t *module, int list_ops); - qc_module_list_ops_exec_cmd_linux(module, list_ops, list_ops_cmd_num, cmd_res_list); -#else - extern void qc_module_list_ops_exec_cmd_common(qc_module_t *module, int list_ops, int list_pos_num, int *cmd_res_list); - qc_module_list_ops_exec_cmd_common(module, list_ops, list_ops_cmd_num, cmd_res_list); -#endif - - return qc_module_list_ops_exec_res(cmd_res_list); -} - -static void qc_module_list_ops_status_update(qc_module_t *module, int list_ops, qc_res_t func_res, qc_res_t cmd_res) -{ - if (func_res == QC_RES_OK && cmd_res == QC_RES_OK) - module->list_ops_status[list_ops] = QC_MOD_SUCCESS; - else - module->list_ops_status[list_ops] = QC_MOD_FAILURE; -} - -static void qc_module_get_list_ops_record(qc_module_t *module, qc_mod_record_t *list_ops_record) -{ - for (int i = 0; i < LIST_OPS_NUM; i++) { - for (int j = 0; j < OPS_NUM; j++) { - if (module->list_ops_cmd_record[i][j] == QC_MOD_RECORD || - module->list_ops_func_record[i][j] == QC_MOD_RECORD) { - list_ops_record[i] = QC_MOD_RECORD; - break; - } - } - } -} - -static void qc_module_status_update(qc_module_t *module) -{ - int list_ops_failure_num = 0; - qc_mod_status_t list_ops_record[LIST_OPS_NUM]; - qc_module_get_list_ops_record(module, list_ops_record); - - for (int i = 0; i < LIST_OPS_NUM; i++) { - if (list_ops_record[i] == QC_MOD_RECORD && module->list_ops_status[i] == QC_MOD_FAILURE) - list_ops_failure_num++; - if (list_ops_record[i] == QC_MOD_RECORD && module->list_ops_status[i] == QC_MOD_UNEXECUTED) { - module->status = QC_MOD_EXECUTING; - return; - } - } - - if (list_ops_failure_num) - module->status = QC_MOD_FAILURE; - else - module->status = QC_MOD_SUCCESS; -} - - -qc_res_t qc_manager_lock(qc_manager_t *manager) -{ - if (manager->lock) { - manager->lock(); - } - return QC_RES_OK; -} - -qc_res_t qc_manager_unlock(qc_manager_t *manager) -{ - if (manager->un_lock) { - manager->un_lock(); - } - return QC_RES_OK; -} - -static void qc_mod_list_del(qc_manager_t *manager) -{ - qc_module_t *mod = NULL, *next_mod = NULL; - - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - qc_list_del(&mod->list); - qc_module_delete(mod); - } - } -} - -static void qc_exec_list_del(qc_manager_t *manager) -{ - qc_exec_t *exec = NULL, *next_exec = NULL; - - qc_list_for_each_entry_safe(exec, next_exec, &manager->mod_head, list) { - if (exec) { - qc_list_del(&exec->list); - qc_exec_delete(exec); - } - } -} - -static void qc_disp_list_del(qc_manager_t *manager) -{ - qc_disp_data_t *disp_data = NULL, *next_disp = NULL; - - qc_list_for_each_entry_safe(disp_data, next_disp, &manager->disp_head, list) { - if (disp_data) { - qc_list_del(&disp_data->list); - qc_disp_data_delete(disp_data); - } - } -} - -static qc_res_t qc_manager_check_include_module(qc_manager_t *manager, qc_module_t *module) -{ - qc_module_t *mod = NULL, *next_mod = NULL; - - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - if (strncmp(mod->name, module->name, strlen(module->name)) == 0) { - return QC_RES_OK; - } - } - } - - return QC_RES_INV; -} - -qc_res_t qc_manager_module_sync(qc_manager_t *manager, qc_module_t *module) -{ - qc_module_t *mod = NULL, *next_mod = NULL; - - qc_list_for_each_entry_safe(mod, next_mod, &manager->mod_head, list) { - if (mod) { - if (strncmp(mod->name, module->name, strlen(module->name)) == 0) { - memcpy(mod, module, sizeof(qc_module_t)); - return QC_RES_OK; - } - } - } - return QC_RES_INV; -} - -static qc_res_t qc_exec_add(qc_exec_t *exec, qc_manager_t *mgr, int append) -{ - if (mgr == NULL || exec == NULL) { - return QC_RES_INV; - } - - qc_exec_t *new_exec = qc_exec_create(); - if (new_exec == NULL) { - return QC_RES_INV; - } - memcpy(new_exec, exec, sizeof(qc_exec_t)); - - qc_manager_lock(mgr); - - if (append) - qc_list_add_tail(&new_exec->list, &mgr->exec_head); - else - qc_list_add_head(&new_exec->list, &mgr->exec_head); - mgr->exec_num++; - - qc_manager_unlock(mgr); - - return QC_RES_OK; -} - -static qc_res_t qc_disp_data_add(qc_disp_data_t *disp_data, qc_manager_t *manager, int append) -{ - if (manager == NULL || disp_data == NULL) { - return QC_RES_INV; - } - - qc_disp_data_t *new_disp = qc_disp_data_create(); - if (new_disp == NULL) { - return QC_RES_INV; - } - memcpy(new_disp, disp_data, sizeof(qc_disp_data_t)); - - qc_manager_lock(manager); - - if (append) - qc_list_add_tail(&new_disp->list, &manager->disp_head); - else - qc_list_add_head(&new_disp->list, &manager->disp_head); - manager->disp_num++; - - qc_manager_unlock(manager); - - return QC_RES_OK; -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.h deleted file mode 100644 index 18aec287..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_core.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef _QC_OPS_CORE_H_ -#define _QC_OPS_CORE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "qc_list.h" -#include "../qc_config.h" - -#define NAME_LEN 30 -#define DESC_LEN 30 - -#define LIST_OPS_NUM 8 -#define OPS_NUM 5 -#define OPS_LEN 100 - -enum { - QC_RES_INV = -1, - QC_RES_OK, -}; -typedef int qc_res_t; - -enum { - QC_MOD_NOT_RECORD = 0, - QC_MOD_RECORD, -}; -typedef int qc_mod_record_t; - -enum { - QC_MOD_UNEXECUTED, - QC_MOD_EXECUTING, - QC_MOD_SUCCESS, - QC_MOD_FAILURE, -}; -typedef int qc_mod_status_t; - -enum { - QC_DEBUG_BASE = 1, - QC_DEBUG_CORE = 2, - QC_DEBUG_DETAIL= 4, - QC_DEBUG_ALL = 7 -}; -typedef int qc_debug_t; - -typedef qc_res_t (*qc_cap_cmp_int_t)(int); -typedef qc_res_t (*qc_cap_cmp_str_t)(char *); -typedef qc_res_t (*qc_list_ops_func_t)(void *); -typedef void (*qc_lock_t)(void); - -typedef struct _qc_module -{ - /* base */ - unsigned int id; - char name[NAME_LEN]; - char desc[DESC_LEN]; - qc_mod_status_t status; - - /* core */ - char list_ops_desc[LIST_OPS_NUM][DESC_LEN]; - char list_ops_cmd[LIST_OPS_NUM][OPS_NUM][OPS_LEN]; - qc_list_ops_func_t list_ops_func[LIST_OPS_NUM][OPS_NUM]; - void *list_ops_func_para[LIST_OPS_NUM][OPS_NUM]; - qc_cap_cmp_int_t list_ops_cmp_int[LIST_OPS_NUM][OPS_NUM]; /* in the form of a function, there is no need to use a comparision function */ - qc_cap_cmp_str_t list_ops_cmp_str[LIST_OPS_NUM][OPS_NUM]; - qc_mod_record_t list_ops_cmd_record[LIST_OPS_NUM][OPS_NUM]; - qc_mod_record_t list_ops_func_record[LIST_OPS_NUM][OPS_NUM]; - int list_ops_runtime[LIST_OPS_NUM]; /* only used for executing commands on linux */ - qc_mod_status_t list_ops_status[LIST_OPS_NUM]; - - /* log relative */ - char *log_buf; - int log_buf_len; - void *reserve; - - struct qc_list list; -} qc_module_t; - -typedef struct _qc_manager -{ - /* base */ - char name[NAME_LEN]; - int progress; - int success_num; - int failure_num; - int success_rate; - int module_num; - int exec_num; - int disp_num; - void *reserve; - - /* list */ - struct qc_list mod_head; - struct qc_list exec_head; - struct qc_list disp_head; - - qc_lock_t lock; /* the way to access a mutex in a blocking manager */ - qc_lock_t un_lock; /* the way to access a mutex in a blocking manager */ -} qc_manager_t; - -typedef struct _qc_exec_t -{ - char module_name[NAME_LEN]; - int list_ops_pos; - - struct qc_list list; -} qc_exec_t; - -typedef struct _qc_disp_data_t -{ - /* module data */ - char mod_name[NAME_LEN]; - char mod_desc[DESC_LEN]; - qc_mod_status_t mod_status; - qc_mod_status_t list_ops_status[LIST_OPS_NUM]; - char list_ops_desc[LIST_OPS_NUM][DESC_LEN]; - - /* manager data */ - char mgr_name[NAME_LEN]; - int mgr_status; - int mgr_progress; - int mgr_success_num; - int mgr_failure_num; - int mgr_success_rate; - - struct qc_list list; -} qc_disp_data_t; - -int qc_cmd_exec(char *command, char *buf, int buf_len, unsigned int runtime); /* capture output and return result */ -int qc_cmd_exec_ex(char *command, char *buf, - int buf_len, unsigned int runtime, - qc_cap_cmp_str_t cmp_str, qc_res_t *cmd_res); -qc_module_t *qc_module_create(void); -qc_res_t qc_module_clear_status(qc_module_t *module); -qc_res_t qc_module_delete(qc_module_t *module); - -qc_res_t qc_module_set_name(qc_module_t *module, char *name); -qc_res_t qc_module_set_desc(qc_module_t *module, char *desc); -qc_res_t qc_module_set_log(qc_module_t *module, char *log_buf, int buf_len); -qc_res_t qc_module_list_ops_set_desc(qc_module_t *module, int list_pos, char *list_desc); -qc_res_t qc_module_list_ops_set_runtime(qc_module_t *module, int list_ops, int runtime); /* unit: ms, after will exec */ -qc_res_t qc_module_list_ops_cmd_append(qc_module_t *module, int list_pos, char *cmd, - qc_mod_record_t ops_record, qc_cap_cmp_int_t int_cmp, qc_cap_cmp_str_t str_cmp); -qc_res_t qc_module_list_ops_func_append(qc_module_t *module, int list_ops, qc_list_ops_func_t ops, void *para, - qc_mod_record_t ops_record, qc_cap_cmp_int_t int_cmp, qc_cap_cmp_str_t str_cmp); -qc_res_t qc_module_list_ops_exec(qc_module_t *module, int list_ops); /* execute in a blocking manner */ - -qc_manager_t *qc_manager_create(void); -qc_res_t qc_manager_clear_status(qc_manager_t *manager); -qc_res_t qc_manager_delete(qc_manager_t *manager); -qc_res_t qc_manager_set_lock(qc_manager_t *manager, qc_lock_t lock, qc_lock_t un_lock); -qc_res_t qc_manager_lock(qc_manager_t *manager); -qc_res_t qc_manager_unlock(qc_manager_t *manager); - -qc_res_t qc_manager_module_append(qc_manager_t *manager, qc_module_t *module); -qc_res_t qc_manager_module_get(qc_manager_t *manager, qc_module_t *back, char *name); -qc_res_t qc_manager_module_get_index(qc_manager_t *manager, qc_module_t *back, int index); /* search by index, 0 is the first to be added */ -qc_res_t qc_manager_module_del(qc_manager_t *manager, char *name); -qc_res_t qc_manager_module_sync(qc_manager_t *manager, qc_module_t *module); -qc_res_t qc_manager_update(qc_manager_t *manager, qc_module_t *module); - -qc_exec_t *qc_exec_create(void); -qc_res_t qc_exec_delete(qc_exec_t *exec); -qc_res_t qc_exec_set(qc_exec_t *exec, char *mod_name, int list_ops_pos); -qc_res_t qc_exec_append(qc_exec_t *exec, qc_manager_t *mgr); -qc_res_t qc_exec_append_left(qc_exec_t *exec, qc_manager_t *mgr); -qc_res_t qc_exec_pop(qc_exec_t *exec, qc_manager_t *mgr); -qc_res_t qc_exec_ops_set_append(qc_manager_t *mgr, char *mod_name, int list); - -qc_disp_data_t *qc_disp_data_create(void); -qc_res_t qc_disp_data_delete(qc_disp_data_t *disp_data); -qc_res_t qc_disp_data_set(qc_disp_data_t *disp_data, qc_manager_t *manager, qc_module_t *module); -qc_res_t qc_disp_data_append(qc_disp_data_t *disp_data, qc_manager_t *manager); -qc_res_t qc_disp_data_append_left(qc_disp_data_t *disp_data, qc_manager_t *manager); -qc_res_t qc_disp_data_pop(qc_disp_data_t *disp_data, qc_manager_t *manager); -qc_res_t qc_disp_data_set_append(qc_disp_data_t *disp_data, qc_manager_t *manager, qc_module_t *module); - -void qc_module_debug(qc_module_t *module, qc_debug_t flag); -void qc_manager_debug(qc_manager_t *manager, qc_debug_t flag); -void qc_exec_debug(qc_exec_t *exec, qc_debug_t debug_flag); -void qc_disp_data_debug(qc_disp_data_t *disp, qc_debug_t debug_flag); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _QC_OPS_CORE_H_ */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_list.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_list.h deleted file mode 100644 index e68f3ce5..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/qc_list.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef _QC_TEST_LIST_H_ -#define _QC_TEST_LIST_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -struct qc_list; - -struct qc_list { - struct qc_list *next; - struct qc_list *prev; -}; - -static inline void qc_list_init(struct qc_list *list) { - list->next = list; - list->prev = list; -} - -static inline void qc_list_add_head(struct qc_list *elem, - struct qc_list *head) { - assert(elem != NULL); - assert(head != NULL); - - struct qc_list *prev = head; - struct qc_list *next = head->next; - - next->prev = elem; - elem->next = next; - elem->prev = prev; - prev->next = elem; -} - -static inline void qc_list_add_tail(struct qc_list *elem, - struct qc_list *head) { - assert(elem != NULL); - assert(head != NULL); - - struct qc_list *prev = head->prev; - struct qc_list *next = head; - - next->prev = elem; - elem->next = next; - elem->prev = prev; - prev->next = elem; -} - -static inline void qc_list_del(struct qc_list *elem) { - assert(elem != NULL); - - struct qc_list *prev = elem->prev; - struct qc_list *next = elem->next; - - next->prev = prev; - prev->next = next; - elem->next = NULL; - elem->prev = NULL; -} - -static inline void qc_list_del_init(struct qc_list *entry) { - assert(entry != NULL); - - struct qc_list *prev = entry->prev; - struct qc_list *next = entry->next; - - next->prev = prev; - prev->next = next; - entry->next = entry; - entry->prev = entry; -} - -static inline int qc_list_empty(struct qc_list *head) { - assert(head != NULL); - - return head->next == head; -} - -#define qc_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#ifndef container_of -#define container_of(ptr, type, member) ( { \ -const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -(type *)( (char *)__mptr - qc_offsetof(type,member) ); } ) -#endif - -#define qc_list_entry(ptr, type, member) \ - container_of(ptr, type, member) - -#define qc_list_first_entry(ptr, type, member) \ - qc_list_entry((ptr)->next, type, member) - -#define qc_list_first_entry_or_null(ptr, type, member) ({ \ - struct qc_list *head__ = (ptr); \ - struct qc_list *pos__ = head__->next; \ - pos__ != head__ ? qc_list_entry(pos__, type, member) : NULL; \ -}) - -#define qc_list_next_entry(pos, member) \ - qc_list_entry((pos)->member.next, typeof(*(pos)), member) - -#define qc_list_entry_is_head(pos, head, member) \ - (&pos->member == (head)) - -#define qc_list_for_each_entry(pos, head, member) \ - for (pos = qc_list_first_entry(head, typeof(*pos), member); \ - !qc_list_entry_is_head(pos, head, member); \ - pos = qc_list_next_entry(pos, member)) - -#define qc_list_for_each_entry_safe(pos, n, head, member) \ - for (pos = qc_list_first_entry(head, typeof(*pos), member), \ - n = qc_list_next_entry(pos, member); \ - !qc_list_entry_is_head(pos, head, member); \ - pos = n, n = qc_list_next_entry(n, member)) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _QC_TEST_LIST_H_ */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/qc_core_rtos.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/qc_core_rtos.c deleted file mode 100644 index 3c743a97..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/core/rtos/qc_core_rtos.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_core.h" -#if QC_OS_RT_THREAD -#include -#include -#include - -extern int msh_exec(char *cmd, rt_size_t length); - -int qc_cmd_exec_rtos(char *command) -{ - static char cmd[256] = {0}; - - strncpy(cmd, command, sizeof(cmd) - 1); - cmd[sizeof(cmd) - 1] = '\0'; - return msh_exec(cmd, strlen(cmd)); -} - -qc_res_t qc_cmd_exec_rtos_ex(char *command) -{ - return qc_cmd_exec_rtos(command); -} - -void qc_module_list_ops_exec_cmd_rtos(qc_module_t *module, int list_ops, int list_ops_num, int *cmd_res_list) -{ - char cmd[256] = {0}; - int cmd_return = 0; - int cmd_result = 0; - qc_cap_cmp_int_t cmp_int; - - for (int i = 0; i < list_ops_num; i++) { - strncpy(cmd, module->list_ops_cmd[list_ops][i], sizeof(cmd) - 1); - cmp_int = module->list_ops_cmp_int[list_ops][i]; - - cmd_return = qc_cmd_exec_rtos(cmd); - cmd_result = cmp_int(cmd_return); - - /* save command run results */ - if (module->list_ops_cmd_record[list_ops][i] == QC_MOD_RECORD) { - cmd_res_list[i] = cmd_result; - } - } -} -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_block_dev_test.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_block_dev_test.c deleted file mode 100644 index 7a2f52fa..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_block_dev_test.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include "qc_misc_common.h" - -qc_res_t qc_block_dev_test_common(const char *filename, const char *content, int content_len) -{ - FILE *fp; - - fp = fopen(filename, "wb"); - if (fp == NULL) { - return QC_RES_INV; - } - - if (fwrite(content, 1, content_len, fp) != content_len) { - fclose(fp); - return QC_RES_INV; - } - - if (fclose(fp) != 0) { - return QC_RES_INV; - } - - if (remove(filename) != 0) { - return QC_RES_INV; - } - return QC_RES_OK; -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_misc_common.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_misc_common.h deleted file mode 100644 index 31154728..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_misc_common.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_misc.h" -#include "../../board/qc_board.h" - -qc_res_t qc_block_dev_test_common(const char *file, const char *content, int content_len); -qc_res_t qc_save_result_common(qc_board_config_t *board, const char *path); -qc_res_t qc_read_chip_intel_model_file_common(char *chip_model, int len, const char *file); -qc_res_t qc_write_chip_intel_module_file_common(char *chip_model, const char *file); diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_save_common.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_save_common.c deleted file mode 100644 index 7214b517..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/common/qc_save_common.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "qc_misc_common.h" - -#include -#include -#include -#include - -#define PATH_LEN 256 -#define CHIP_ID_PREFIX "ID_" - -static char* extract_directory(const char* path); -static void set_status(char *status, int failure_num) -{ - if (failure_num == 0) { - strcpy(status, "SUCCESS"); - } else { - strcpy(status, "FAILURE"); - } -} - -static qc_res_t create_dir(const char *path) -{ - struct stat st = {0}; - char temp_path[PATH_LEN + 1] = {0}; - char *ptr = NULL; - - if (path == NULL) { - return QC_RES_INV; - } - strncpy(temp_path, path, PATH_LEN); - ptr = temp_path; -#if defined(_WIN32) || defined(_WIN64) - while ((ptr = strchr(ptr, '\\')) != NULL) { - *ptr = '\0'; - if (stat(temp_path, &st) != 0) { - if (mkdir(temp_path) != 0) { - return QC_RES_INV; - } - } - *ptr++ = '\\'; - } -#else - while ((ptr = strchr(ptr, '/')) != NULL) { - *ptr = '\0'; - if (stat(temp_path, &st) != 0) { - if (mkdir(temp_path, 0755) != 0) { - return QC_RES_INV; - } - } - *ptr++ = '/'; - } -#endif - return QC_RES_OK; -} - -qc_res_t qc_save_result_common(qc_board_config_t *board, const char *path) -{ - FILE *fp = NULL; - char file_name[PATH_LEN] = {0}; - char file_path[PATH_LEN] = {0}; - char status[20] = {0}; - - if (board == NULL || path == NULL) { - return QC_RES_INV; - } - -#if defined(_WIN32) || defined(_WIN64) - snprintf(file_path, sizeof(file_path), "%s%s\\", path, board->chip_intel_module); -#else - snprintf(file_path, sizeof(file_path), "%s%s/", path, board->chip_intel_module); -#endif - /* get save file name */ - snprintf(file_name, sizeof(file_name), "%s%s%s.csv", file_path, CHIP_ID_PREFIX, board->chip_id); - - /* check if the file is exist */ - struct stat buffer; - int file_exist = 0; - if (stat(file_name, &buffer) == 0) { - file_exist = 1; - } - - char *extract_path = extract_directory(file_path); - create_dir(extract_path); - - if (file_exist == 0) { - fp = fopen(file_name, "w"); - } else { - fp = fopen(file_name, "a"); - } - if (fp == NULL) { - return QC_RES_INV; - } - - /* write version */ - if (file_exist == 0) - fprintf(fp, "Version: %s\n\n", QC_TEST_TOOL_VERSION); - else - fprintf(fp, "\n\n"); - /* write head */ - fprintf(fp, "The actual results are as follows:\n"); - - /* write head */ - qc_manager_t *mgr = board->manager; - set_status(status, mgr->failure_num); - fprintf(fp, "chip_id,status,success_rate,success_num,failure_num,module_num\n"); - fprintf(fp, "%s,%s,%d,%d,%d,%d\n\n", - board->chip_id, status, mgr->success_rate, mgr->success_num, mgr->failure_num, mgr->module_num); - - /* write module */ - fprintf(fp, "module_name,status\n"); - qc_module_t *mod = qc_module_create(); - for (int i = 0; i < mgr->module_num; i++) { - qc_manager_module_get_index(mgr, mod, i); - set_status(status, mod->status != QC_MOD_SUCCESS); - fprintf(fp, "%s,%s\n", mod->name, status); - } - - fflush(fp); - fclose(fp); - qc_module_delete(mod); - - return QC_RES_OK; -} - -qc_res_t qc_read_chip_intel_model_file_common(char *chip_model, int len, const char *file) -{ - FILE *fp = fopen(file, "r"); - if (fp == NULL) { - return QC_RES_INV; - } - - if (fgets(chip_model, len, fp) != NULL) { - size_t n = strlen(chip_model); - if (n > 0 && chip_model[n-1] == '\n') { - chip_model[n-1] = '\0'; - } - fclose(fp); - return 0; - } else { - fclose(fp); - return QC_RES_INV; - } - - return QC_RES_OK; -} - -qc_res_t qc_write_chip_intel_module_file_common(char *chip_model, const char *file) -{ - char *path = extract_directory(file); - create_dir(path); - - FILE *fp = fopen(file, "w"); - if (fp == NULL) { - return QC_RES_INV; - } - - if (fprintf(fp, "%s", chip_model) >= 0) { - fclose(fp); - return QC_RES_OK; - } else { - fclose(fp); - return QC_RES_INV; - } - return QC_RES_OK; -} - -static char* extract_directory(const char* path) -{ - const char* last_slash = strrchr(path, '/'); -#if defined(_WIN32) || defined(_WIN64) - const char* last_backslash = strrchr(path, '\\'); - if (last_backslash && (!last_slash || last_backslash > last_slash)) { - last_slash = last_backslash; - } -#endif - - if (last_slash) { - return (char*)path + (path - path) / sizeof(char) * (last_slash - path + 1); - } else { - return NULL; - } -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_misc_linux.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_misc_linux.h deleted file mode 100644 index a4f85646..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_misc_linux.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../qc_misc.h" diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_save_result_linux.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_save_result_linux.c deleted file mode 100644 index d9a33d0e..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/linux/qc_save_result_linux.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#if QC_OS_LINUX -#include -#include "qc_misc_linux.h" - -/* - * file.csv name:chipid.csv - * file.csv context: - * chip_id,status,success_rate,success_num,failure_num,module_num - * XXXXXX,XXXXX,XXXXX,XXXXX,XXXXX,XXXXX,XXXXX - * - * module_name,status - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * -*/ - -enum { - USB_DEV = 0, - SDCARD_DEV, -}; -typedef int qc_save_dev_t; - -typedef struct _qc_save { - qc_board_config_t *board; - const char *path; - qc_save_dev_t dev; - int blk_num; -} qc_save_t; - -qc_save_t save_list[] = { -#if QC_BOARD_D133C - {NULL, "udisk/qc_save/d13c/", USB_DEV, 0}, -#endif - -#if QC_BOARD_D213C - {NULL, "udisk/qc_save/d21c/", USB_DEV, 0}, - {NULL, "udisk/qc_save/d21c/", USB_DEV, 1}, -#endif - {NULL, NULL, 0, 0} -}; - - -qc_res_t _qc_save_write_linux(qc_board_config_t *board, const char *path, qc_save_dev_t dev, int blk_num) -{ - return QC_RES_OK; -} - -qc_res_t qc_save_write_linux(qc_board_config_t *board) -{ - int save_time = 0; - while(1) { - if (strlen(save_list[save_time]) != 0) { - save_time++; - } else { - break; - } - } - - int failure_time = 0; - for (int i = 0;i < save_time; i++) { - if (_qc_save_write_linux(board, save_list[i].path, save_list[i].dev, save_list[i].blk_num) == QC_RES_INV) - failure_time++; - } - - if (failure_time) - return QC_RES_INV; - return QC_RES_OK; -} -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.c deleted file mode 100644 index ffdb03ea..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "qc_misc.h" -#include "./common/qc_misc_common.h" -#include "../board/qc_board.h" -#if QC_OS_RT_THREAD -#include "./rtos/qc_misc_rtos.h" -#endif -#if QC_OS_LINUX -#include "./rtos/qc_misc_linux.h" -#endif - -qc_res_t qc_save_write(void *board) -{ -#if QC_OS_RT_THREAD - return qc_save_result_rtos(board); -#endif -#if QC_OS_LINUX - return qc_save_result_linux(board); -#endif - - return qc_save_result_common(board, "result"); -} - -qc_res_t qc_read_chip_id(char *chip_id, int len) -{ -#if QC_OS_RT_THREAD - return qc_read_chip_id_rtos(chip_id, len); -#endif -#if QC_OS_LINUX - return qc_read_chip_id_linux(chip_id, len); -#endif - return QC_RES_INV; -} - -qc_res_t qc_read_chip_intel_model(char *chip_model, int len) -{ -#if QC_OS_RT_THREAD - return qc_read_chip_intel_model_rtos(chip_model, len); -#endif -#if QC_OS_LINUX - return qc_read_chip_intel_model_linux(chip_model, len); -#endif - return QC_RES_INV; -} - -qc_res_t qc_read_chip_intel_model_file(char *chip_model, int len) -{ -#if QC_OS_RT_THREAD - return qc_read_chip_intel_model_file_common(chip_model, len, "/data/chip_model.txt"); -#endif -#if QC_OS_LINUX - return qc_read_chip_intel_model_file_linux(chip_model, len, "tmp/chip_model.txt"); -#endif -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 - return qc_read_chip_intel_model_file_common(chip_model, len, "chip_model.txt"); -#endif -} - -qc_res_t qc_write_chip_intel_module_file(char *chip_model) -{ -#if QC_OS_RT_THREAD - return qc_write_chip_intel_module_file_common(chip_model, "/data/chip_model.txt"); -#endif -#if QC_OS_LINUX - return qc_write_chip_intel_module_file_linux(chip_model, "data/chip_model.txt"); -#endif -#if QC_OS_RT_THREAD == 0 && QC_OS_LINUX == 0 - return qc_write_chip_intel_module_file_common(chip_model, "chip_model.txt"); -#endif -} - -qc_res_t qc_block_dev_test(const char *file, const char *content, int content_len) -{ - return qc_block_dev_test_common(file, content, content_len); -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.h deleted file mode 100644 index 0aa3cb6f..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/qc_misc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef _QC_TEST_OPS_H_ -#define _QC_TEST_OPS_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "../qc_config.h" -#include "../core/qc_core.h" - -qc_res_t qc_block_dev_test(const char *file, const char *content, int content_len); - -qc_res_t qc_read_chip_id(char *chip_id, int len); -qc_res_t qc_read_chip_intel_model(char *chip_model, int len); /* read the actual model */ -qc_res_t qc_read_chip_intel_model_file(char *chip_model, int len); /* read the from the save */ -qc_res_t qc_write_chip_intel_module_file(char *chip_model); - -qc_res_t qc_save_write(void *board); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _QC_BOARD_CFG_H_ */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.c deleted file mode 100644 index d8a6a76a..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include -#include -#include - -#include "qc_chip_info_rtos.h" -#if QC_OS_RT_THREAD - -#define DEBUG_CHIP_INFO 0 - -typedef unsigned long u32; - -static void bin_to_hex_str(unsigned char byte, char hex_str[2]); -static u32 get_efuse_sid_offset(u32 addr); -static u32 efuse_read_sid(u32 addr); - -#ifdef AIC_1603 -static void get_aic_1603_burn_info(aic_1603_burn_rule_t *rule); -static qc_res_t compare_aic_1603_burn_info(aic_1603_burn_rule_t *rule, int *rule_table_index); - -static aic_1603_burn_rule_t aic_1603_rule_table[] = { - {"D133BAS", 0x01, 0xB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x78}, - {"D133BBS", 0x02, 0xB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x78}, - {"D133CBS", 0x03, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D133CCS1", 0x06, 0xC, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D133CCS2", 0x06, 0xC, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D133EBS", 0x04, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D133ECS1", 0x07, 0xE, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D133ECS2", 0x07, 0xE, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"D132ENS", 0x05, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"G730CES", 0x21, 0xC, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0}, - {"G730EES", 0x22, 0xE, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0}, - {"G730BDU", 0x23, 0xB, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0}, - {"M6801SPCS", 0x31, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x78}, - {"M6806SPES", 0x32, 0x3, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0}, - {"DR128", 0XA1, 0xB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - {"JYX68", 0XA2, 0xB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} -}; -#endif - -#ifdef AIC_1605 -static void get_aic_1605_burn_info(aic_1605_burn_rule_t *rule); -static qc_res_t compare_aic_1605_burn_info(aic_1605_burn_rule_t *rule, int *rule_table_index); - -static aic_1605_burn_rule_t aic_1605_rule_table[] = { - {"D121BAV", 0x03, 0xB, 0x0, 0x00, 0x1, 0x1, 0x1}, - {"D121BBV", 0x04, 0xB, 0x0, 0x00, 0x1, 0x1, 0x1}, - {"D122BAV", 0x01, 0xB, 0x0, 0x00, 0x1, 0x0, 0x0}, - {"D122BBV", 0x02, 0xB, 0x0, 0x00, 0x1, 0x0, 0x0}, - {"D122BCV1", 0x05, 0xB, 0x1, 0x00, 0x1, 0x0, 0x0}, - {"D122BCV2", 0x05, 0xB, 0x2, 0x00, 0x1, 0x0, 0x0}, - {"TR230", 0xA1, 0xB, 0x0, 0x00, 0x0, 0x0, 0x0}, - {"JYX58", 0xB1, 0xB, 0x0, 0x00, 0x1, 0x0, 0x0} -}; - -#endif - -qc_res_t qc_read_chip_intel_model_rtos(char *chip_model, int len) -{ -#ifdef AIC_1603 - int rule_table_index = -1; - aic_1603_burn_rule_t burn_rule = {0}; - - get_aic_1603_burn_info(&burn_rule); - if (compare_aic_1603_burn_info(&burn_rule, &rule_table_index) == QC_RES_INV) { - strncpy(chip_model, "Unkown chip model", len); - return QC_RES_INV; - } - strncpy(chip_model, aic_1603_rule_table[rule_table_index].intel_model, len); - return QC_RES_OK; -#endif - -#ifdef AIC_1605 - int rule_table_index = -1; - aic_1605_burn_rule_t burn_rule = {0}; - - get_aic_1605_burn_info(&burn_rule); - if (compare_aic_1605_burn_info(&burn_rule, &rule_table_index) == QC_RES_INV) { - strncpy(chip_model, "Unkown chip model", len); - return QC_RES_INV; - } - - strncpy(chip_model, aic_1605_rule_table[rule_table_index].intel_model, len); - return QC_RES_OK; -#endif - - return QC_RES_INV; -} - -qc_res_t qc_read_chip_intel_model_file_rtos(char *chip_model, int len, const char *file) -{ - return QC_RES_INV; -} - -qc_res_t qc_write_chip_intel_module_file_rtos(char *chip_model, const char *file) -{ - return QC_RES_INV; -} - -qc_res_t qc_read_chip_id_rtos(char *chip_id, int len) -{ - static unsigned char chip_id_context[128 / 8] = {0}; - char cmd[128] = {0}; - int i = 0, pos = 0, chip_id_len = 128 / 8; - - if (len < chip_id_len) { - return QC_RES_INV; - } - - snprintf(cmd, sizeof(cmd), "efuse read %p 10 0x20", (void *)chip_id_context); - qc_cmd_exec(cmd, NULL, 0, 0); - - /* the chip_id buf context is - * 44-80-ce-b8-52-2f-c0-0c-06-0c-11-18-09-00-30-04 - */ - for (i = 0; i < chip_id_len; i++) { - bin_to_hex_str(chip_id_context[i], (chip_id + pos)); - pos = ((i + 1) * 2) + i; - chip_id[pos] = '-'; - pos++; - } - chip_id[pos - 1] = '\0'; - - printf("chip_id = %s\n", chip_id); - return QC_RES_OK; -} - -static void bin_to_hex_str(unsigned char byte, char hex_str[2]) -{ - static const char *hex_digits = "0123456789abcdef"; - - hex_str[0] = hex_digits[(byte >> 4) & 0xF]; - hex_str[1] = hex_digits[byte & 0xF]; -} - -static u32 get_efuse_sid_offset(u32 addr) -{ - u32 offset = 0; - -#ifdef AIC_1603 - switch (addr) { - case 0x19010210: /* CHIPID_MAIN_NVM1 or CHIID_MAIN_BASE */ - offset = 0x10; - break; - case 0x19010214: /* CHIPID_MAIN_NVM2 */ - offset = 0x14; - break; - case 0x19010218: /* CHIPID_MAIN_NVM3 */ - offset = 0x18; - break; - case 0x1901021C: /* CHIPID_MAIN_NVM4 */ - offset = 0x1C; - break; - case 0x19010220: /* CHIP_LOCK_NVM1 or CHIP_LOCK_BASE */ - offset = 0x20; - break; - case 0x19010224: /* CHIP_LOCK_NVM2 */ - offset = 0x24; - break; - default: - break; - } -#endif - -#ifdef AIC_1605 - switch (addr) { - case 0x19010210: /* CHIPID_MAIN_NVM1 or CHIID_MAIN_BASE */ - offset = 0x10; - break; - case 0x19010214: /* CHIPID_MAIN_NVM2 */ - offset = 0x14; - break; - case 0x19010218: /* CHIPID_MAIN_NVM3 */ - offset = 0x18; - break; - case 0x1901021C: /* CHIPID_MAIN_NVM4 */ - offset = 0x1C; - break; - default: - break; - } -#endif - - return offset; -} - -static u32 efuse_read_sid(u32 addr) -{ - static unsigned char efuse_context[32 / 8] = {0}; - char cmd[128] = {0}; - - u32 efuse_offset = get_efuse_sid_offset(addr); - if (efuse_offset == 0) - return 0; - - snprintf(cmd, sizeof(cmd), "efuse read %p %lx 0x4", (void *)efuse_context, efuse_offset); - qc_cmd_exec(cmd, NULL, 0, 0); - u32 result = efuse_context[3] << 24 | - efuse_context[2] << 16 | - efuse_context[1] << 8 | - efuse_context[0]; -#if DEBUG_CHIP_INFO - printf("cmd = %s, result = 0x%x 0x%x 0x%x 0x%x\n", cmd, efuse_context[3], efuse_context[2], efuse_context[1], efuse_context[0]); -#endif - return result; -} - -#ifdef AIC_1603 -static void get_aic_1603_burn_info(aic_1603_burn_rule_t *rule) -{ - u32 chipid_main_nvm3 = 0; - u32 chip_lock_nvm1 = 0; - u32 chip_lock_nvm2 = 0; - - chipid_main_nvm3 = efuse_read_sid(CHIPID_MAIN_NVM3); - chip_lock_nvm1 = efuse_read_sid(CHIP_LOCK_NVM1); - chip_lock_nvm2 = efuse_read_sid(CHIP_LOCK_NVM2); - - rule->mark_id = (((chipid_main_nvm3 & MARK_ID_MASK) >> 0) & 0xff); - rule->package_id = (((chipid_main_nvm3 & PACKAGE_ID_MASK) >> 8) & 0xff); - rule->psram_id = (((chip_lock_nvm2 & PSRAM_ID_MASK) >> 20) & 0xff); - rule->flash_iomap = (((chip_lock_nvm2 & FLASH_IOMAP_MASK) >> 24) & 0xff); - rule->pwmcs_dis = (((chip_lock_nvm1 & PWMCS_DIS_MASK) >> 17) & 0xff); - rule->spi_enc_dis = (((chip_lock_nvm1 & SPI_ENC_DIS_MASK) >> 16) & 0xff); - rule->ce_dis = (((chip_lock_nvm1 & CE_DIS_MASK) >> 15) & 0xff); - rule->can1_dis = (((chip_lock_nvm1 & CAN1_DIS_MASK) >> 14) & 0xff); - rule->can0_dis = (((chip_lock_nvm1 & CAN0_DIS_MASK) >> 13) & 0xff); - rule->emac_dis = (((chip_lock_nvm1 & EMAC_DIS_MASK) >> 12) & 0xff); - rule->dvp_dis = (((chip_lock_nvm1 & DVP_DIS_MASK) >> 11) & 0xff); - rule->mipi_dis = (((chip_lock_nvm1 & MIPI_DIS_MASK) >> 10) & 0xff); - rule->de_dis = (((chip_lock_nvm1 & DE_DIS_MASK) >> 8) & 0xff); - rule->sram_dis = (((chip_lock_nvm1 & SRAM_DIS_MASK) >> 0) & 0xff); - -#if DEBUG_CHIP_INFO - printf("mark_id = 0x%x\n", rule->mark_id); - printf("package_id = 0x%x\n", rule->package_id); - printf("psram_id = 0x%x\n", rule->psram_id); - printf("flash_iomap = 0x%x\n", rule->flash_iomap); - printf("pwmcs_dis = 0x%x\n", rule->pwmcs_dis); - printf("ce_dis = 0x%x\n", rule->ce_dis); - printf("can1_dis = 0x%x\n", rule->can1_dis); - printf("can0_dis = 0x%x\n", rule->can0_dis); - printf("emac_dis = 0x%x\n", rule->emac_dis); - printf("dvp_dis = 0x%x\n", rule->dvp_dis); - printf("mipi_dis = 0x%x\n", rule->mipi_dis); - printf("de_dis = 0x%x\n", rule->de_dis); - printf("sram_dis = 0x%x\n", rule->sram_dis); -#endif -} - -static int compare_aic_1603_burn_info(aic_1603_burn_rule_t *rule, int *rule_table_index) -{ - int rule_table_len = sizeof(aic_1603_rule_table) / sizeof(aic_1603_rule_table[0]); - int i = -1; - - for (i = 0; i < rule_table_len; i++) { - if (rule->mark_id != aic_1603_rule_table[i].mark_id || - rule->package_id != aic_1603_rule_table[i].package_id || - rule->psram_id != aic_1603_rule_table[i].psram_id || - rule->flash_iomap != aic_1603_rule_table[i].flash_iomap || - rule->pwmcs_dis != aic_1603_rule_table[i].pwmcs_dis || - rule->spi_enc_dis != aic_1603_rule_table[i].spi_enc_dis || - rule->ce_dis != aic_1603_rule_table[i].ce_dis || - rule->can1_dis != aic_1603_rule_table[i].can1_dis || - rule->can0_dis != aic_1603_rule_table[i].can0_dis || - rule->emac_dis != aic_1603_rule_table[i].emac_dis || - rule->dvp_dis != aic_1603_rule_table[i].dvp_dis || - rule->mipi_dis != aic_1603_rule_table[i].mipi_dis || - rule->lvds_dis != aic_1603_rule_table[i].lvds_dis || - rule->de_dis != aic_1603_rule_table[i].de_dis || - rule->sram_dis != aic_1603_rule_table[i].sram_dis) { - continue; - } - break; - } - - if (i == rule_table_len) - return QC_RES_INV; - - *rule_table_index = i; - return QC_RES_OK; -} - -#endif - -#ifdef AIC_1605 -static void get_aic_1605_burn_info(aic_1605_burn_rule_t *rule) -{ - u32 chipid_main_nvm3 = 0; - u32 chipid_main_nvm4 = 0; - - chipid_main_nvm3 = efuse_read_sid(CHIPID_MAIN_NVM3); - chipid_main_nvm4 = efuse_read_sid(CHIPID_MAIN_NVM4); - - rule->mark_id = (((chipid_main_nvm3 & MARK_ID_MASK) >> 0) & 0xff); - rule->package_id = (((chipid_main_nvm3 & PACKAGE_ID_MASK) >> 8) & 0xff); - rule->psram_id = (((chipid_main_nvm4 & PSRAM_ID_MASK) >> 4) & 0xff); - rule->flash_iomap = (((chipid_main_nvm4 & FLASH_IOMAP_MASK) >> 8) & 0xff); - rule->mdi_dis = (((chipid_main_nvm4 & MDI_DIS) >> 2) & 0xff); - rule->can1_dis = (((chipid_main_nvm4 & CAN1_DIS_MASK) >> 1) & 0xff); - rule->can0_dis = (((chipid_main_nvm4 & CAN0_DIS_MASK) >> 0) & 0xff); - -#if DEBUG_CHIP_INFO - printf("mark_id = 0x%x\n", rule->mark_id); - printf("package_id = 0x%x\n", rule->package_id); - printf("psram_id = 0x%x\n", rule->psram_id); - printf("flash_iomap = 0x%x\n", rule->flash_iomap); - printf("mdi_dis = 0x%x\n", rule->mdi_dis); - printf("can1_dis = 0x%x\n", rule->can1_dis); - printf("can0_dis = 0x%x\n", rule->can0_dis); -#endif -} - -static int compare_aic_1605_burn_info(aic_1605_burn_rule_t *rule, int *rule_table_index) -{ - int rule_table_len = sizeof(aic_1605_rule_table) / sizeof(aic_1605_rule_table[0]); - int i = -1; - - for (i = 0; i < rule_table_len; i++) { - if (rule->mark_id != aic_1605_rule_table[i].mark_id || - rule->package_id != aic_1605_rule_table[i].package_id || - rule->psram_id != aic_1605_rule_table[i].psram_id || - rule->flash_iomap != aic_1605_rule_table[i].flash_iomap || - rule->mdi_dis != aic_1605_rule_table[i].mdi_dis || - rule->can1_dis != aic_1605_rule_table[i].can1_dis || - rule->can0_dis != aic_1605_rule_table[i].can0_dis) { - continue; - } - break; - } - - if (i == rule_table_len) - return QC_RES_INV; - - *rule_table_index = i; - return QC_RES_OK; -} -#endif -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.h deleted file mode 100644 index c5e72f7b..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_chip_info_rtos.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef _QC_CHIP_BURN_OPS_H_ -#define _QC_CHIP_BURN_OPS_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "qc_misc_rtos.h" - -#define BITS_PER_LONG 32 -#define BIT(s) (1U << (s)) -#define GENMASK(h, l) (((~(0U)) - ((1U) << (l)) + 1) & \ - (~(0U) >> (BITS_PER_LONG - 1 - (h)))) - -#ifdef AIC_1603 -#define CHIID_MAIN_BASE 0x19010210 -#define CHIP_LOCK_BASE 0x19010220 - -#define CHIPID_MAIN_NVM1 (CHIID_MAIN_BASE + 0X0) -#define CHIPID_MAIN_NVM2 (CHIID_MAIN_BASE + 0X4) -#define CHIPID_MAIN_NVM3 (CHIID_MAIN_BASE + 0X8) -#define CHIPID_MAIN_NVM4 (CHIID_MAIN_BASE + 0XC) - -#define CHIP_LOCK_NVM1 (CHIP_LOCK_BASE + 0X0) -#define CHIP_LOCK_NVM2 (CHIP_LOCK_BASE + 0X4) - -#define PACKAGE_ID_MASK GENMASK(15, 8) -#define MARK_ID_MASK GENMASK(7, 0) -#define PSRAM_ID_MASK GENMASK(23, 20) -#define FLASH_IOMAP_MASK (GENMASK(30, 24) & (~BIT(27))) /* bit 27 is reserved */ -#define PWMCS_DIS_MASK BIT(17) -#define SPI_ENC_DIS_MASK BIT(16) -#define CE_DIS_MASK BIT(15) -#define CAN1_DIS_MASK BIT(14) -#define CAN0_DIS_MASK BIT(13) -#define EMAC_DIS_MASK BIT(12) -#define DVP_DIS_MASK BIT(11) -#define MIPI_DIS_MASK BIT(10) -#define LVDS_DIS_MASK BIT(9) -#define DE_DIS_MASK BIT(8) -#define SRAM_DIS_MASK GENMASK(6, 0) -#endif - -#ifdef AIC_1605 -#define CHIID_MAIN_BASE 0x19010210 - -#define CHIPID_MAIN_NVM1 (CHIID_MAIN_BASE + 0X0) -#define CHIPID_MAIN_NVM2 (CHIID_MAIN_BASE + 0X4) -#define CHIPID_MAIN_NVM3 (CHIID_MAIN_BASE + 0X8) -#define CHIPID_MAIN_NVM4 (CHIID_MAIN_BASE + 0XC) - -#define PACKAGE_ID_MASK GENMASK(11, 8) -#define MARK_ID_MASK GENMASK(7, 0) -#define PSRAM_ID_MASK GENMASK(7, 4) -#define FLASH_IOMAP_MASK (GENMASK(14, 8) & (~BIT(11))) -#define MDI_DIS BIT(2) -#define CAN1_DIS_MASK BIT(1) -#define CAN0_DIS_MASK BIT(0) -#endif - -typedef struct _aic_1603_chip_burn_rule { - char intel_model[64]; - unsigned char mark_id; - unsigned char package_id; - unsigned char psram_id; - unsigned char flash_iomap; - unsigned char pwmcs_dis; - unsigned char spi_enc_dis; - unsigned char ce_dis; - unsigned char can1_dis; - unsigned char can0_dis; - unsigned char emac_dis; - unsigned char dvp_dis; - unsigned char mipi_dis; - unsigned char lvds_dis; - unsigned char de_dis; - unsigned char sram_dis; -} aic_1603_burn_rule_t; - -typedef struct _aic_1605_chip_burn_rule { - char intel_model[64]; - unsigned char mark_id; - unsigned char package_id; - unsigned char psram_id; - unsigned char flash_iomap; - unsigned char mdi_dis; - unsigned char can1_dis; - unsigned char can0_dis; -} aic_1605_burn_rule_t; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _QC_BOARD_CFG_H_ */ diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_misc_rtos.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_misc_rtos.h deleted file mode 100644 index 2a1e3e13..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_misc_rtos.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "../../board/qc_board.h" -#include "../qc_misc.h" - -qc_res_t qc_save_result_rtos(qc_board_config_t *board); -qc_res_t qc_read_chip_id_rtos(char *chip_id, int len); -qc_res_t qc_read_chip_intel_model_rtos(char *chip_model, int len); -qc_res_t qc_read_chip_intel_model_file_rtos(char *chip_model, int len, const char *file); -qc_res_t qc_write_chip_intel_module_file_rtos(char *chip_model, const char *file); diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_save_result_rtos.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_save_result_rtos.c deleted file mode 100644 index 8ebfd25b..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/misc/rtos/qc_save_result_rtos.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include "qc_misc_rtos.h" - -/* - * file.csv name:chipid.csv - * file.csv context: - * chip_id,status,success_rate,success_num,QC_RES_INV_num,module_num - * XXXXXX,XXXXX,XXXXX,XXXXX,XXXXX,XXXXX,XXXXX - * - * module_name,status - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * XXXXXX,XXXXX - * -*/ -#if QC_OS_RT_THREAD -#include -#include -#include -#include - -#define PATH_LEN 256 -#define CHIP_ID_PREFIX "ID_" - -extern qc_save_init_t board_save_list[]; - -extern qc_res_t qc_save_result_common(qc_board_config_t *board, const char *path); - -qc_res_t qc_save_result_rtos(qc_board_config_t *board) -{ - int i = 0; - int failure_time = 0; - - while (board_save_list[i].path != NULL) { - if (qc_save_result_common(board, board_save_list[i].path) == QC_RES_INV) - failure_time++; - i++; - } - - if (failure_time) - return QC_RES_INV; - return QC_RES_OK; -} - -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_config.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_config.h deleted file mode 100644 index ab8f70c6..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_config.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#define QC_TEST_TOOL_VERSION "V2.1.3" - -/* Only one item can be selected from a large category */ - -/* operating system */ -#define QC_OS_RT_THREAD 1 -#define QC_OS_LINUX 0 - -/* AIC_1605 */ -#define QC_BOARD_D12XX 0 - -/* AIC_1603 */ -#define QC_BOARD_D133B 1 -#define QC_BOARD_D133C 0 -#define QC_BOARD_D133E 0 -#define QC_BOARD_D132E 0 -#define QC_BOARD_G730C 0 -#define QC_BOARD_G730E 0 -#define QC_BOARD_G730B 0 -#define QC_BOARD_M6801 0 -#define QC_BOARD_M6806 0 -#define QC_BOARD_DR128 0 -#define QC_BOARD_JYX68 0 - -/* auto config */ -#if QC_BOARD_D133B || QC_BOARD_D133C || QC_BOARD_D132E || QC_BOARD_G730B || \ - QC_BOARD_D133E || QC_BOARD_G730C || QC_BOARD_G730E || QC_BOARD_M6801 || \ - QC_BOARD_M6806 || QC_BOARD_DR128 || QC_BOARD_JYX68 -#define AIC_1603 1 -#endif - -#if QC_BOARD_D121B || QC_BOARD_TR230 || QC_BOARD_D122B || QC_BOARD_D12XX -#define AIC_1605 1 -#endif diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_test.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_test.h deleted file mode 100644 index dc818d81..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/module/qc_test.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ -#include "qc_config.h" -#include "board/qc_board.h" -#include "core/qc_core.h" -#include "misc/qc_misc.h" - diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.c deleted file mode 100644 index 5dbd1909..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include "qc_demo.h" -#include "lvgl.h" - -extern void lv_qc_test_init(void); - -void qc_test_init() -{ - lv_qc_test_init(); -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.h b/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.h deleted file mode 100644 index 9d9694ea..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/qc_demo.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#ifndef QC_DEMO_UI_H -#define QC_DEMO_UI_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "aic_ui.h" - -void qc_test_init(); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif //LAUNCHER_UI_H diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/lv_font_montserrat_24_cp.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/lv_font_montserrat_24_cp.c deleted file mode 100644 index 49510a97..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/font/lv_font_montserrat_24_cp.c +++ /dev/null @@ -1,4050 +0,0 @@ -/******************************************************************************* - * Size: 24 px - * Bpp: 4 - * Opts: --no-compress --no-prefilter --bpp 4 --size 24 --font Montserrat-Medium.ttf -r 0x20-0x7F,0xB0,0x2022 --font FontAwesome5-Solid+Brands+Regular.woff -r 61441,61448,61451,61452,61452,61453,61457,61459,61461,61465,61468,61473,61478,61479,61480,61502,61507,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61641,61664,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62087,62099,62212,62189,62810,63426,63650 --format lvgl -o lv_font_montserrat_24.c --force-fast-kern-format - ******************************************************************************/ -#include "lvgl.h" - -/*----------------- - * BITMAPS - *----------------*/ - -/*Store the image of the glyphs*/ -static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { - /* U+0020 " " */ - - /* U+0021 "!" */ - 0x1f, 0xf8, 0x1f, 0xf8, 0xf, 0xf7, 0xf, 0xf7, - 0xf, 0xf6, 0xe, 0xf5, 0xe, 0xf5, 0xd, 0xf4, - 0xd, 0xf3, 0xc, 0xf3, 0xb, 0xf2, 0x7, 0xa1, - 0x0, 0x0, 0x0, 0x0, 0x1d, 0xf6, 0x4f, 0xfb, - 0xc, 0xe5, - - /* U+0022 "\"" */ - 0x7f, 0x80, 0x2f, 0xd7, 0xf7, 0x1, 0xfd, 0x6f, - 0x70, 0x1f, 0xc6, 0xf7, 0x1, 0xfc, 0x6f, 0x60, - 0xf, 0xc5, 0xf6, 0x0, 0xfb, 0x38, 0x30, 0x8, - 0x60, - - /* U+0023 "#" */ - 0x0, 0x0, 0x8, 0xf2, 0x0, 0x5, 0xf5, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0x0, 0x0, 0x7f, 0x30, - 0x0, 0x0, 0x0, 0xd, 0xe0, 0x0, 0x9, 0xf1, - 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0xbf, - 0x0, 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x30, 0x7c, 0xcd, 0xfe, 0xcc, 0xcc, - 0xfe, 0xcc, 0xc2, 0x0, 0x0, 0x4f, 0x60, 0x0, - 0x1f, 0x90, 0x0, 0x0, 0x0, 0x6, 0xf4, 0x0, - 0x3, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x8f, 0x20, - 0x0, 0x4f, 0x60, 0x0, 0x0, 0x0, 0xa, 0xf0, - 0x0, 0x6, 0xf4, 0x0, 0x0, 0x0, 0x0, 0xce, - 0x0, 0x0, 0x8f, 0x20, 0x0, 0x5, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, 0x4c, 0xcc, - 0xfe, 0xcc, 0xcc, 0xff, 0xcc, 0xc5, 0x0, 0x0, - 0x2f, 0x90, 0x0, 0xe, 0xd0, 0x0, 0x0, 0x0, - 0x4, 0xf7, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, - 0x0, 0x6f, 0x50, 0x0, 0x2f, 0x90, 0x0, 0x0, - 0x0, 0x8, 0xf3, 0x0, 0x4, 0xf7, 0x0, 0x0, - 0x0, - - /* U+0024 "$" */ - 0x0, 0x0, 0x0, 0x3f, 0x50, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3f, 0x50, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3f, 0x50, 0x0, 0x0, 0x0, 0x1, 0x7c, - 0xff, 0xfe, 0xb6, 0x0, 0x0, 0x3e, 0xff, 0xff, - 0xff, 0xff, 0xe1, 0x1, 0xef, 0xe6, 0x5f, 0x73, - 0x7d, 0xc0, 0x6, 0xff, 0x20, 0x3f, 0x50, 0x0, - 0x20, 0x9, 0xfc, 0x0, 0x3f, 0x50, 0x0, 0x0, - 0x8, 0xfe, 0x0, 0x3f, 0x50, 0x0, 0x0, 0x3, - 0xff, 0xc3, 0x3f, 0x50, 0x0, 0x0, 0x0, 0x8f, - 0xff, 0xef, 0x91, 0x0, 0x0, 0x0, 0x4, 0xcf, - 0xff, 0xff, 0xc5, 0x0, 0x0, 0x0, 0x1, 0x7f, - 0xff, 0xff, 0xb0, 0x0, 0x0, 0x0, 0x3f, 0x53, - 0xbf, 0xf7, 0x0, 0x0, 0x0, 0x3f, 0x50, 0xb, - 0xfc, 0x0, 0x0, 0x0, 0x3f, 0x50, 0x7, 0xfe, - 0x5, 0x70, 0x0, 0x3f, 0x50, 0xc, 0xfb, 0xc, - 0xfd, 0x73, 0x4f, 0x64, 0xbf, 0xf4, 0x5, 0xef, - 0xff, 0xff, 0xff, 0xff, 0x70, 0x0, 0x6, 0xbe, - 0xff, 0xfe, 0x93, 0x0, 0x0, 0x0, 0x0, 0x3f, - 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x50, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x50, 0x0, - 0x0, - - /* U+0025 "%" */ - 0x0, 0x3c, 0xfe, 0x90, 0x0, 0x0, 0x0, 0x6f, - 0x70, 0x0, 0x3, 0xfd, 0x78, 0xfb, 0x0, 0x0, - 0x2, 0xfc, 0x0, 0x0, 0xb, 0xe1, 0x0, 0x6f, - 0x40, 0x0, 0xc, 0xf2, 0x0, 0x0, 0xf, 0x90, - 0x0, 0xf, 0x90, 0x0, 0x7f, 0x60, 0x0, 0x0, - 0x1f, 0x70, 0x0, 0xe, 0xa0, 0x2, 0xfb, 0x0, - 0x0, 0x0, 0xf, 0x80, 0x0, 0xf, 0x90, 0xc, - 0xf1, 0x0, 0x0, 0x0, 0xd, 0xd0, 0x0, 0x3f, - 0x60, 0x7f, 0x60, 0x0, 0x0, 0x0, 0x5, 0xf9, - 0x24, 0xde, 0x2, 0xfb, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x7f, 0xff, 0xd3, 0xc, 0xe1, 0x8, 0xff, - 0xe7, 0x0, 0x0, 0x1, 0x43, 0x0, 0x7f, 0x50, - 0x9f, 0x85, 0xaf, 0x70, 0x0, 0x0, 0x0, 0x2, - 0xfa, 0x2, 0xf8, 0x0, 0xb, 0xf0, 0x0, 0x0, - 0x0, 0xd, 0xe1, 0x5, 0xf3, 0x0, 0x5, 0xf4, - 0x0, 0x0, 0x0, 0x8f, 0x50, 0x6, 0xf1, 0x0, - 0x3, 0xf5, 0x0, 0x0, 0x3, 0xfa, 0x0, 0x5, - 0xf3, 0x0, 0x5, 0xf3, 0x0, 0x0, 0xd, 0xe1, - 0x0, 0x1, 0xf8, 0x0, 0xa, 0xe0, 0x0, 0x0, - 0x8f, 0x40, 0x0, 0x0, 0x8f, 0x84, 0x9f, 0x60, - 0x0, 0x3, 0xfa, 0x0, 0x0, 0x0, 0x7, 0xdf, - 0xd6, 0x0, - - /* U+0026 "&" */ - 0x0, 0x1, 0x9e, 0xfe, 0xa2, 0x0, 0x0, 0x0, - 0x0, 0x2e, 0xfe, 0xbd, 0xff, 0x30, 0x0, 0x0, - 0x0, 0xaf, 0xb0, 0x0, 0x7f, 0xb0, 0x0, 0x0, - 0x0, 0xdf, 0x50, 0x0, 0x2f, 0xd0, 0x0, 0x0, - 0x0, 0xcf, 0x70, 0x0, 0x6f, 0xa0, 0x0, 0x0, - 0x0, 0x6f, 0xe1, 0x6, 0xff, 0x20, 0x0, 0x0, - 0x0, 0xb, 0xfd, 0xbf, 0xf4, 0x0, 0x0, 0x0, - 0x0, 0x2, 0xff, 0xfb, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x6f, 0xff, 0xfd, 0x10, 0x0, 0x0, 0x0, - 0x8, 0xff, 0x51, 0xcf, 0xd1, 0x0, 0xac, 0x20, - 0x4f, 0xf2, 0x0, 0xc, 0xfd, 0x20, 0xff, 0x0, - 0xbf, 0x80, 0x0, 0x0, 0xcf, 0xe8, 0xfb, 0x0, - 0xef, 0x60, 0x0, 0x0, 0xc, 0xff, 0xf3, 0x0, - 0xcf, 0xa0, 0x0, 0x0, 0x1, 0xff, 0xf2, 0x0, - 0x6f, 0xfa, 0x20, 0x1, 0x6e, 0xff, 0xfe, 0x20, - 0x8, 0xff, 0xff, 0xff, 0xff, 0xa1, 0xbf, 0xd0, - 0x0, 0x39, 0xdf, 0xfd, 0x93, 0x0, 0xb, 0x40, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+0027 "'" */ - 0x7f, 0x87, 0xf7, 0x6f, 0x76, 0xf7, 0x6f, 0x65, - 0xf6, 0x38, 0x30, - - /* U+0028 "(" */ - 0x0, 0x2f, 0xf1, 0x0, 0x9f, 0x90, 0x1, 0xff, - 0x20, 0x6, 0xfc, 0x0, 0xc, 0xf7, 0x0, 0xf, - 0xf3, 0x0, 0x3f, 0xf0, 0x0, 0x6f, 0xd0, 0x0, - 0x8f, 0xb0, 0x0, 0x9f, 0xa0, 0x0, 0xaf, 0x90, - 0x0, 0xbf, 0x80, 0x0, 0xaf, 0x90, 0x0, 0x9f, - 0xa0, 0x0, 0x8f, 0xb0, 0x0, 0x6f, 0xd0, 0x0, - 0x3f, 0xf0, 0x0, 0xf, 0xf3, 0x0, 0xc, 0xf7, - 0x0, 0x6, 0xfc, 0x0, 0x1, 0xff, 0x20, 0x0, - 0x9f, 0x90, 0x0, 0x2f, 0xf1, - - /* U+0029 ")" */ - 0xf, 0xf3, 0x0, 0x8, 0xfb, 0x0, 0x1, 0xff, - 0x30, 0x0, 0xbf, 0x80, 0x0, 0x6f, 0xd0, 0x0, - 0x1f, 0xf2, 0x0, 0xe, 0xf5, 0x0, 0xb, 0xf8, - 0x0, 0x9, 0xfa, 0x0, 0x8, 0xfb, 0x0, 0x7, - 0xfc, 0x0, 0x6, 0xfd, 0x0, 0x7, 0xfc, 0x0, - 0x8, 0xfb, 0x0, 0x9, 0xfa, 0x0, 0xb, 0xf8, - 0x0, 0xe, 0xf5, 0x0, 0x1f, 0xf2, 0x0, 0x6f, - 0xd0, 0x0, 0xbf, 0x80, 0x1, 0xff, 0x30, 0x8, - 0xfb, 0x0, 0xf, 0xf3, 0x0, - - /* U+002A "*" */ - 0x0, 0x0, 0xe8, 0x0, 0x0, 0x3, 0x0, 0xe8, - 0x0, 0x20, 0x4f, 0xa1, 0xe8, 0x4d, 0xe0, 0x8, - 0xff, 0xfe, 0xfd, 0x40, 0x0, 0x2e, 0xff, 0xb0, - 0x0, 0x7, 0xef, 0xff, 0xfc, 0x30, 0x5f, 0xb2, - 0xe8, 0x5e, 0xe0, 0x4, 0x0, 0xe8, 0x0, 0x30, - 0x0, 0x0, 0xe8, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, - - /* U+002B "+" */ - 0x0, 0x0, 0xa, 0xa0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0, 0x6f, 0xff, - 0xff, 0xff, 0xff, 0xf5, 0x5e, 0xee, 0xef, 0xfe, - 0xee, 0xe5, 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf0, - 0x0, 0x0, - - /* U+002C "," */ - 0x3b, 0x80, 0xcf, 0xf3, 0xaf, 0xf3, 0xf, 0xe0, - 0x1f, 0x90, 0x5f, 0x40, 0x9e, 0x0, - - /* U+002D "-" */ - 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0xfd, 0xaf, - 0xff, 0xff, 0xd0, - - /* U+002E "." */ - 0x4, 0x10, 0x9f, 0xf1, 0xdf, 0xf4, 0x6f, 0xb0, - - /* U+002F "/" */ - 0x0, 0x0, 0x0, 0x0, 0xef, 0x20, 0x0, 0x0, - 0x0, 0x4f, 0xd0, 0x0, 0x0, 0x0, 0x9, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0xef, 0x20, 0x0, 0x0, - 0x0, 0x4f, 0xc0, 0x0, 0x0, 0x0, 0xa, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0xff, 0x10, 0x0, 0x0, - 0x0, 0x5f, 0xc0, 0x0, 0x0, 0x0, 0xa, 0xf6, - 0x0, 0x0, 0x0, 0x0, 0xff, 0x10, 0x0, 0x0, - 0x0, 0x5f, 0xb0, 0x0, 0x0, 0x0, 0xb, 0xf6, - 0x0, 0x0, 0x0, 0x1, 0xff, 0x10, 0x0, 0x0, - 0x0, 0x6f, 0xb0, 0x0, 0x0, 0x0, 0xb, 0xf5, - 0x0, 0x0, 0x0, 0x1, 0xff, 0x0, 0x0, 0x0, - 0x0, 0x6f, 0xa0, 0x0, 0x0, 0x0, 0xc, 0xf5, - 0x0, 0x0, 0x0, 0x2, 0xff, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xa0, 0x0, 0x0, 0x0, 0xd, 0xf4, - 0x0, 0x0, 0x0, 0x2, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0x90, 0x0, 0x0, 0x0, 0x0, - - /* U+0030 "0" */ - 0x0, 0x1, 0x8d, 0xff, 0xd8, 0x10, 0x0, 0x0, - 0x2e, 0xff, 0xff, 0xff, 0xe2, 0x0, 0x1, 0xff, - 0xe7, 0x33, 0x7e, 0xff, 0x10, 0xb, 0xfe, 0x20, - 0x0, 0x2, 0xef, 0xb0, 0x2f, 0xf5, 0x0, 0x0, - 0x0, 0x5f, 0xf2, 0x7f, 0xe0, 0x0, 0x0, 0x0, - 0xe, 0xf7, 0xaf, 0xb0, 0x0, 0x0, 0x0, 0xb, - 0xfa, 0xcf, 0x90, 0x0, 0x0, 0x0, 0x9, 0xfc, - 0xdf, 0x80, 0x0, 0x0, 0x0, 0x8, 0xfd, 0xcf, - 0x90, 0x0, 0x0, 0x0, 0x9, 0xfc, 0xaf, 0xb0, - 0x0, 0x0, 0x0, 0xb, 0xfa, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0xe, 0xf7, 0x2f, 0xf5, 0x0, 0x0, - 0x0, 0x5f, 0xf2, 0xb, 0xfe, 0x10, 0x0, 0x2, - 0xef, 0xb0, 0x1, 0xff, 0xe7, 0x33, 0x7e, 0xff, - 0x10, 0x0, 0x3e, 0xff, 0xff, 0xff, 0xe2, 0x0, - 0x0, 0x1, 0x7c, 0xee, 0xc7, 0x10, 0x0, - - /* U+0031 "1" */ - 0xdf, 0xff, 0xff, 0x5d, 0xff, 0xff, 0xf5, 0x11, - 0x11, 0xff, 0x50, 0x0, 0xf, 0xf5, 0x0, 0x0, - 0xff, 0x50, 0x0, 0xf, 0xf5, 0x0, 0x0, 0xff, - 0x50, 0x0, 0xf, 0xf5, 0x0, 0x0, 0xff, 0x50, - 0x0, 0xf, 0xf5, 0x0, 0x0, 0xff, 0x50, 0x0, - 0xf, 0xf5, 0x0, 0x0, 0xff, 0x50, 0x0, 0xf, - 0xf5, 0x0, 0x0, 0xff, 0x50, 0x0, 0xf, 0xf5, - 0x0, 0x0, 0xff, 0x50, - - /* U+0032 "2" */ - 0x0, 0x17, 0xce, 0xfe, 0xc6, 0x0, 0x0, 0x7f, - 0xff, 0xff, 0xff, 0xfc, 0x10, 0x6f, 0xfc, 0x63, - 0x35, 0xbf, 0xfa, 0x0, 0x97, 0x0, 0x0, 0x0, - 0xaf, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x3, 0xff, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xf2, 0x0, - 0x0, 0x0, 0x0, 0x8, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x2, 0xff, 0x70, 0x0, 0x0, 0x0, 0x2, - 0xef, 0xc0, 0x0, 0x0, 0x0, 0x2, 0xef, 0xd1, - 0x0, 0x0, 0x0, 0x2, 0xef, 0xd1, 0x0, 0x0, - 0x0, 0x3, 0xef, 0xc1, 0x0, 0x0, 0x0, 0x3, - 0xef, 0xc0, 0x0, 0x0, 0x0, 0x3, 0xff, 0xb0, - 0x0, 0x0, 0x0, 0x4, 0xff, 0xc2, 0x11, 0x11, - 0x11, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - - /* U+0033 "3" */ - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1, 0x11, 0x11, - 0x11, 0x7f, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x3f, - 0xf7, 0x0, 0x0, 0x0, 0x0, 0x1e, 0xfa, 0x0, - 0x0, 0x0, 0x0, 0xc, 0xfd, 0x0, 0x0, 0x0, - 0x0, 0x9, 0xfe, 0x20, 0x0, 0x0, 0x0, 0x3, - 0xff, 0xfc, 0x71, 0x0, 0x0, 0x0, 0x3f, 0xff, - 0xff, 0xe3, 0x0, 0x0, 0x0, 0x0, 0x15, 0xef, - 0xe1, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0x60, - 0x0, 0x0, 0x0, 0x0, 0xc, 0xf9, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xdf, 0x81, 0xa1, 0x0, 0x0, - 0x0, 0x4f, 0xf5, 0x9f, 0xfa, 0x53, 0x34, 0x9f, - 0xfd, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xfd, 0x20, - 0x0, 0x49, 0xdf, 0xfe, 0xb6, 0x0, 0x0, - - /* U+0034 "4" */ - 0x0, 0x0, 0x0, 0x0, 0xd, 0xfb, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xaf, 0xe1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3f, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xdf, 0xb0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xa, 0xfd, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xf3, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0xff, 0x60, 0x0, 0x9d, 0x70, 0x0, - 0x0, 0x1e, 0xfa, 0x0, 0x0, 0xbf, 0x90, 0x0, - 0x0, 0xbf, 0xd0, 0x0, 0x0, 0xbf, 0x90, 0x0, - 0x7, 0xff, 0x41, 0x11, 0x11, 0xbf, 0x91, 0x11, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x90, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x90, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x90, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x90, 0x0, - - /* U+0035 "5" */ - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0x0, 0xa, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0xbf, 0x81, - 0x11, 0x11, 0x11, 0x0, 0xd, 0xf6, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xef, 0x40, 0x0, 0x0, 0x0, - 0x0, 0xf, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x2, - 0xff, 0x31, 0x10, 0x0, 0x0, 0x0, 0x3f, 0xff, - 0xff, 0xfe, 0xa3, 0x0, 0x5, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x26, 0xdf, - 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0xb0, - 0x0, 0x0, 0x0, 0x0, 0x8, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x8f, 0xd0, 0x93, 0x0, 0x0, - 0x0, 0x1e, 0xfa, 0x5f, 0xfb, 0x63, 0x24, 0x7e, - 0xff, 0x31, 0xbf, 0xff, 0xff, 0xff, 0xff, 0x50, - 0x0, 0x28, 0xce, 0xfe, 0xc8, 0x10, 0x0, - - /* U+0036 "6" */ - 0x0, 0x0, 0x4a, 0xdf, 0xfe, 0xb5, 0x0, 0x0, - 0xa, 0xff, 0xff, 0xff, 0xff, 0x10, 0x0, 0xcf, - 0xf9, 0x42, 0x23, 0x76, 0x0, 0x8, 0xfe, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x1f, 0xf5, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xaf, 0xa0, 0x5b, 0xef, 0xd9, 0x30, - 0x0, 0xbf, 0x9a, 0xff, 0xff, 0xff, 0xf7, 0x0, - 0xdf, 0xff, 0xc4, 0x1, 0x4c, 0xff, 0x40, 0xcf, - 0xfc, 0x0, 0x0, 0x0, 0xcf, 0xc0, 0xbf, 0xf5, - 0x0, 0x0, 0x0, 0x5f, 0xf0, 0x8f, 0xf2, 0x0, - 0x0, 0x0, 0x3f, 0xf1, 0x4f, 0xf4, 0x0, 0x0, - 0x0, 0x4f, 0xf0, 0xd, 0xfc, 0x0, 0x0, 0x0, - 0xbf, 0xb0, 0x4, 0xff, 0xc3, 0x0, 0x3b, 0xff, - 0x30, 0x0, 0x5f, 0xff, 0xff, 0xff, 0xf5, 0x0, - 0x0, 0x1, 0x8d, 0xff, 0xd9, 0x20, 0x0, - - /* U+0037 "7" */ - 0x4f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x4f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0x4f, 0xf2, - 0x11, 0x11, 0x11, 0x8f, 0xf1, 0x4f, 0xf0, 0x0, - 0x0, 0x0, 0xef, 0x90, 0x4f, 0xf0, 0x0, 0x0, - 0x5, 0xff, 0x20, 0x2, 0x20, 0x0, 0x0, 0xc, - 0xfa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xf3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0xff, 0x50, 0x0, 0x0, - 0x0, 0x0, 0x9, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x1f, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xef, - 0x90, 0x0, 0x0, 0x0, 0x0, 0x6, 0xff, 0x20, - 0x0, 0x0, 0x0, 0x0, 0xd, 0xfb, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x4f, 0xf4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xbf, 0xd0, 0x0, 0x0, 0x0, - - /* U+0038 "8" */ - 0x0, 0x6, 0xbe, 0xff, 0xd9, 0x20, 0x0, 0x2, - 0xdf, 0xff, 0xff, 0xff, 0xf7, 0x0, 0xd, 0xff, - 0x71, 0x0, 0x4b, 0xff, 0x40, 0x3f, 0xf5, 0x0, - 0x0, 0x0, 0xcf, 0xa0, 0x4f, 0xf1, 0x0, 0x0, - 0x0, 0x9f, 0xc0, 0x2f, 0xf5, 0x0, 0x0, 0x0, - 0xdf, 0x90, 0xa, 0xff, 0x72, 0x1, 0x4c, 0xff, - 0x20, 0x0, 0x8f, 0xff, 0xff, 0xff, 0xd3, 0x0, - 0x4, 0xdf, 0xff, 0xef, 0xff, 0xf8, 0x0, 0x2f, - 0xfc, 0x40, 0x0, 0x18, 0xff, 0x90, 0xaf, 0xd0, - 0x0, 0x0, 0x0, 0x6f, 0xf2, 0xdf, 0x80, 0x0, - 0x0, 0x0, 0xf, 0xf5, 0xdf, 0x80, 0x0, 0x0, - 0x0, 0x1f, 0xf5, 0xaf, 0xe1, 0x0, 0x0, 0x0, - 0x8f, 0xf2, 0x3f, 0xfd, 0x51, 0x0, 0x3a, 0xff, - 0xa0, 0x5, 0xff, 0xff, 0xff, 0xff, 0xfa, 0x0, - 0x0, 0x17, 0xce, 0xff, 0xd9, 0x40, 0x0, - - /* U+0039 "9" */ - 0x0, 0x4, 0xae, 0xfe, 0xc7, 0x0, 0x0, 0x0, - 0xaf, 0xff, 0xff, 0xff, 0xe2, 0x0, 0x8, 0xff, - 0x82, 0x0, 0x4c, 0xfe, 0x10, 0x1f, 0xf6, 0x0, - 0x0, 0x0, 0xcf, 0xa0, 0x3f, 0xf0, 0x0, 0x0, - 0x0, 0x6f, 0xf1, 0x4f, 0xf0, 0x0, 0x0, 0x0, - 0x6f, 0xf5, 0x1f, 0xf6, 0x0, 0x0, 0x0, 0xcf, - 0xf8, 0xa, 0xff, 0x82, 0x0, 0x4c, 0xff, 0xf9, - 0x0, 0xcf, 0xff, 0xff, 0xff, 0x9c, 0xfa, 0x0, - 0x6, 0xbe, 0xfe, 0xa4, 0xd, 0xf8, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xf, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3f, 0xf2, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xbf, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0x50, 0x0, 0xa7, 0x31, 0x25, 0xcf, 0xf9, - 0x0, 0x3, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0, - 0x0, 0x7b, 0xdf, 0xec, 0x82, 0x0, 0x0, - - /* U+003A ":" */ - 0x5f, 0xb0, 0xdf, 0xf4, 0x9f, 0xf1, 0x4, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4, 0x10, 0x9f, 0xf1, 0xdf, 0xf4, - 0x6f, 0xb0, - - /* U+003B ";" */ - 0x5f, 0xb0, 0xdf, 0xf4, 0x9f, 0xf1, 0x4, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x5e, 0xb0, 0xcf, 0xf4, - 0x8f, 0xf2, 0xf, 0xd0, 0x2f, 0x80, 0x6f, 0x30, - 0x7b, 0x0, - - /* U+003C "<" */ - 0x0, 0x0, 0x0, 0x0, 0x1, 0x84, 0x0, 0x0, - 0x0, 0x4, 0xbf, 0xf5, 0x0, 0x0, 0x18, 0xef, - 0xfe, 0x81, 0x0, 0x4b, 0xff, 0xfa, 0x40, 0x0, - 0x3e, 0xff, 0xd7, 0x10, 0x0, 0x0, 0x6f, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0x3e, 0xff, 0xd7, 0x10, - 0x0, 0x0, 0x0, 0x4b, 0xff, 0xfa, 0x40, 0x0, - 0x0, 0x0, 0x18, 0xef, 0xfe, 0x81, 0x0, 0x0, - 0x0, 0x4, 0xbf, 0xf5, 0x0, 0x0, 0x0, 0x0, - 0x1, 0x84, - - /* U+003D "=" */ - 0x5e, 0xee, 0xee, 0xee, 0xee, 0xe5, 0x6f, 0xff, - 0xff, 0xff, 0xff, 0xf5, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x5e, 0xee, 0xee, 0xee, - 0xee, 0xe5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xf5, - - /* U+003E ">" */ - 0x47, 0x10, 0x0, 0x0, 0x0, 0x0, 0x6f, 0xfa, - 0x40, 0x0, 0x0, 0x0, 0x18, 0xef, 0xfe, 0x71, - 0x0, 0x0, 0x0, 0x4, 0xbf, 0xff, 0xb4, 0x0, - 0x0, 0x0, 0x1, 0x7d, 0xff, 0xe3, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xf5, 0x0, 0x0, 0x1, 0x7d, - 0xff, 0xe3, 0x0, 0x4, 0xaf, 0xff, 0xb4, 0x0, - 0x18, 0xef, 0xfe, 0x71, 0x0, 0x0, 0x6f, 0xfb, - 0x40, 0x0, 0x0, 0x0, 0x47, 0x10, 0x0, 0x0, - 0x0, 0x0, - - /* U+003F "?" */ - 0x0, 0x28, 0xce, 0xfe, 0xc7, 0x0, 0x0, 0x8f, - 0xff, 0xff, 0xff, 0xfd, 0x10, 0x7f, 0xfb, 0x52, - 0x13, 0xaf, 0xfb, 0x0, 0x96, 0x0, 0x0, 0x0, - 0xaf, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xff, - 0x10, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x3f, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x3f, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x4f, - 0xfa, 0x0, 0x0, 0x0, 0x0, 0xe, 0xfb, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0x10, 0x0, 0x0, - 0x0, 0x0, 0x48, 0x70, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xfd, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0xf2, 0x0, 0x0, - 0x0, 0x0, 0x6, 0xfb, 0x0, 0x0, 0x0, - - /* U+0040 "@" */ - 0x0, 0x0, 0x0, 0x16, 0xad, 0xff, 0xfd, 0xa6, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, - 0xca, 0x9a, 0xcf, 0xff, 0x80, 0x0, 0x0, 0x0, - 0x2, 0xdf, 0xc5, 0x0, 0x0, 0x0, 0x4, 0xcf, - 0xd2, 0x0, 0x0, 0x2, 0xef, 0x70, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xe2, 0x0, 0x0, 0xdf, - 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f, - 0xd0, 0x0, 0x8f, 0x80, 0x0, 0x7, 0xcf, 0xfc, - 0x60, 0xaf, 0x70, 0x7f, 0x70, 0xf, 0xe0, 0x0, - 0x2d, 0xff, 0xfe, 0xff, 0xcb, 0xf7, 0x0, 0xde, - 0x5, 0xf7, 0x0, 0xd, 0xfd, 0x30, 0x1, 0x7f, - 0xff, 0x70, 0x7, 0xf4, 0x9f, 0x30, 0x6, 0xfe, - 0x10, 0x0, 0x0, 0x6f, 0xf7, 0x0, 0x2f, 0x7c, - 0xf0, 0x0, 0xbf, 0x70, 0x0, 0x0, 0x0, 0xef, - 0x70, 0x0, 0xf9, 0xde, 0x0, 0xd, 0xf3, 0x0, - 0x0, 0x0, 0xa, 0xf7, 0x0, 0xf, 0xad, 0xe0, - 0x0, 0xdf, 0x30, 0x0, 0x0, 0x0, 0xaf, 0x70, - 0x0, 0xf9, 0xbf, 0x0, 0xb, 0xf7, 0x0, 0x0, - 0x0, 0xd, 0xf7, 0x0, 0x2f, 0x79, 0xf3, 0x0, - 0x6f, 0xe0, 0x0, 0x0, 0x6, 0xff, 0x70, 0x6, - 0xf4, 0x5f, 0x70, 0x0, 0xdf, 0xc3, 0x0, 0x7, - 0xff, 0xfb, 0x1, 0xde, 0x0, 0xee, 0x0, 0x2, - 0xdf, 0xfe, 0xdf, 0xfc, 0x3f, 0xfe, 0xff, 0x50, - 0x8, 0xf9, 0x0, 0x0, 0x7c, 0xff, 0xc7, 0x0, - 0x5d, 0xfd, 0x50, 0x0, 0xd, 0xf5, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2e, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x2d, 0xfc, 0x50, 0x0, - 0x0, 0x2, 0x81, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfc, 0xaa, 0xbd, 0xff, 0x60, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x1, 0x6a, 0xdf, 0xff, - 0xd9, 0x40, 0x0, 0x0, 0x0, - - /* U+0041 "A" */ - 0x0, 0x0, 0x0, 0x0, 0xaf, 0xf2, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0xa0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xfe, - 0xff, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xff, 0x5d, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xe0, 0x6f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xd, 0xf7, 0x0, 0xef, 0x60, 0x0, - 0x0, 0x0, 0x0, 0x5, 0xff, 0x10, 0x8, 0xfd, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0xa0, 0x0, - 0x1f, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xf3, - 0x0, 0x0, 0xaf, 0xc0, 0x0, 0x0, 0x0, 0xa, - 0xfc, 0x0, 0x0, 0x4, 0xff, 0x30, 0x0, 0x0, - 0x2, 0xff, 0x50, 0x0, 0x0, 0xd, 0xfa, 0x0, - 0x0, 0x0, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf2, 0x0, 0x0, 0x1f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x90, 0x0, 0x7, 0xff, 0x10, 0x0, - 0x0, 0x0, 0x8, 0xff, 0x10, 0x0, 0xef, 0x90, - 0x0, 0x0, 0x0, 0x0, 0x1f, 0xf7, 0x0, 0x5f, - 0xf2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xe0, - 0xc, 0xfa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, - 0xff, 0x50, - - /* U+0042 "B" */ - 0x7f, 0xff, 0xff, 0xff, 0xfe, 0xb6, 0x0, 0x7, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x10, 0x7f, - 0xe0, 0x0, 0x0, 0x2, 0x9f, 0xfa, 0x7, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x9f, 0xf0, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x5, 0xff, 0x7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x9f, 0xd0, 0x7f, 0xe0, 0x0, - 0x0, 0x2, 0x9f, 0xf5, 0x7, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf6, 0x0, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xd4, 0x7, 0xfe, 0x0, 0x0, 0x0, - 0x14, 0xcf, 0xf3, 0x7f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0xdf, 0xa7, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xfd, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x8f, 0xe7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xc, - 0xfc, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x3b, 0xff, - 0x67, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xd9, 0x30, 0x0, - - /* U+0043 "C" */ - 0x0, 0x0, 0x5, 0xad, 0xff, 0xda, 0x50, 0x0, - 0x0, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xfd, 0x30, - 0x0, 0x5f, 0xff, 0xb6, 0x43, 0x59, 0xff, 0xf2, - 0x3, 0xff, 0xd3, 0x0, 0x0, 0x0, 0x1c, 0x80, - 0xd, 0xfe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x5f, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xcf, 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xdf, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xcf, 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x5f, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xd, 0xfe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0xff, 0xd3, 0x0, 0x0, 0x0, 0x1c, 0x80, - 0x0, 0x5f, 0xff, 0xb5, 0x33, 0x49, 0xff, 0xf2, - 0x0, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xfd, 0x30, - 0x0, 0x0, 0x5, 0xae, 0xff, 0xda, 0x50, 0x0, - - /* U+0044 "D" */ - 0x7f, 0xff, 0xff, 0xff, 0xfd, 0x94, 0x0, 0x0, - 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x20, - 0x0, 0x7f, 0xe1, 0x11, 0x12, 0x36, 0xbf, 0xff, - 0x40, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x4e, - 0xfe, 0x20, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x2f, 0xfb, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xf2, 0x7f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x1, 0xff, 0x77, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xd, 0xf9, 0x7f, 0xe0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xcf, 0xa7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xd, 0xf9, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x1, 0xff, 0x77, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf2, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x0, 0x2f, 0xfb, 0x7, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x3e, 0xfe, 0x20, 0x7f, - 0xe1, 0x11, 0x11, 0x35, 0xbf, 0xff, 0x40, 0x7, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x20, 0x0, - 0x7f, 0xff, 0xff, 0xff, 0xfd, 0x94, 0x0, 0x0, - 0x0, - - /* U+0045 "E" */ - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf6, 0x7f, 0xe1, 0x11, - 0x11, 0x11, 0x11, 0x7, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, - 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x50, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xf5, 0x7, 0xfe, 0x11, 0x11, 0x11, 0x11, - 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xe1, 0x11, 0x11, 0x11, - 0x11, 0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb0, - - /* U+0046 "F" */ - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf6, 0x7f, 0xe1, 0x11, - 0x11, 0x11, 0x11, 0x7, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, - 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xf5, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x50, 0x7f, 0xe1, 0x11, 0x11, 0x11, 0x10, 0x7, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+0047 "G" */ - 0x0, 0x0, 0x5, 0xad, 0xff, 0xeb, 0x60, 0x0, - 0x0, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xfe, 0x50, - 0x0, 0x5f, 0xff, 0xb6, 0x43, 0x48, 0xef, 0xf5, - 0x3, 0xff, 0xd3, 0x0, 0x0, 0x0, 0x9, 0xb0, - 0xd, 0xfe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x5f, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xcf, 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xdf, 0x90, 0x0, 0x0, 0x0, 0x0, 0x7, 0x94, - 0xcf, 0xa0, 0x0, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x5f, 0xf5, 0x0, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0xd, 0xfe, 0x10, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x3, 0xff, 0xd3, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x0, 0x5f, 0xff, 0xb6, 0x32, 0x47, 0xdf, 0xf7, - 0x0, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x5, 0xad, 0xff, 0xeb, 0x71, 0x0, - - /* U+0048 "H" */ - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf7, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0x7f, - 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf7, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x7, 0xff, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xf7, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf7, 0xfe, 0x11, 0x11, 0x11, - 0x11, 0x17, 0xff, 0x7f, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xf7, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x7, 0xff, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xf7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x7, - 0xff, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7f, - 0xf7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf0, - - /* U+0049 "I" */ - 0x7f, 0xe7, 0xfe, 0x7f, 0xe7, 0xfe, 0x7f, 0xe7, - 0xfe, 0x7f, 0xe7, 0xfe, 0x7f, 0xe7, 0xfe, 0x7f, - 0xe7, 0xfe, 0x7f, 0xe7, 0xfe, 0x7f, 0xe7, 0xfe, - 0x7f, 0xe0, - - /* U+004A "J" */ - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xf0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x1, 0x11, 0x11, 0x7f, - 0xf0, 0x0, 0x0, 0x0, 0x7, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xf0, 0x0, 0x0, 0x0, 0x7, - 0xff, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf0, 0x0, - 0x0, 0x0, 0x7, 0xff, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xf0, 0x0, 0x0, 0x0, 0x7, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xf0, 0x0, 0x0, 0x0, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xd0, - 0x5a, 0x0, 0x0, 0xd, 0xfa, 0xf, 0xfc, 0x41, - 0x3b, 0xff, 0x50, 0x5f, 0xff, 0xff, 0xff, 0xa0, - 0x0, 0x29, 0xdf, 0xfc, 0x60, 0x0, - - /* U+004B "K" */ - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x6, 0xff, 0x50, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x6f, 0xf6, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x5, 0xff, 0x60, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x5f, 0xf7, 0x0, 0x0, - 0x7f, 0xe0, 0x0, 0x4, 0xff, 0x80, 0x0, 0x0, - 0x7f, 0xe0, 0x0, 0x4f, 0xf9, 0x0, 0x0, 0x0, - 0x7f, 0xe0, 0x3, 0xff, 0xa0, 0x0, 0x0, 0x0, - 0x7f, 0xe0, 0x3f, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xe3, 0xef, 0xff, 0x40, 0x0, 0x0, 0x0, - 0x7f, 0xfe, 0xfd, 0xdf, 0xf2, 0x0, 0x0, 0x0, - 0x7f, 0xff, 0xd1, 0x2f, 0xfd, 0x10, 0x0, 0x0, - 0x7f, 0xfe, 0x10, 0x4, 0xff, 0xb0, 0x0, 0x0, - 0x7f, 0xf2, 0x0, 0x0, 0x6f, 0xf8, 0x0, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x8, 0xff, 0x50, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0xbf, 0xf3, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0xc, 0xfe, 0x10, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x1, 0xef, 0xc0, - - /* U+004C "L" */ - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, - 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, - 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x7, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7f, 0xe1, 0x11, 0x11, 0x11, - 0x11, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, - - /* U+004D "M" */ - 0x7f, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xdf, 0x67, 0xff, 0x50, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xf6, 0x7f, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1f, 0xff, 0x67, 0xff, 0xf8, 0x0, - 0x0, 0x0, 0x0, 0x9, 0xff, 0xf6, 0x7f, 0xff, - 0xf2, 0x0, 0x0, 0x0, 0x3, 0xff, 0xff, 0x67, - 0xfd, 0xbf, 0xb0, 0x0, 0x0, 0x0, 0xcf, 0x8e, - 0xf6, 0x7f, 0xd2, 0xff, 0x40, 0x0, 0x0, 0x5f, - 0xe0, 0xef, 0x67, 0xfd, 0x8, 0xfd, 0x0, 0x0, - 0xe, 0xf6, 0xe, 0xf6, 0x7f, 0xd0, 0xe, 0xf7, - 0x0, 0x8, 0xfc, 0x0, 0xef, 0x67, 0xfd, 0x0, - 0x5f, 0xf1, 0x1, 0xff, 0x30, 0xe, 0xf6, 0x7f, - 0xd0, 0x0, 0xbf, 0xa0, 0xaf, 0x90, 0x0, 0xef, - 0x67, 0xfd, 0x0, 0x2, 0xff, 0x7f, 0xe1, 0x0, - 0xe, 0xf6, 0x7f, 0xd0, 0x0, 0x8, 0xff, 0xf6, - 0x0, 0x0, 0xef, 0x67, 0xfd, 0x0, 0x0, 0xe, - 0xfd, 0x0, 0x0, 0xe, 0xf6, 0x7f, 0xd0, 0x0, - 0x0, 0x5f, 0x40, 0x0, 0x0, 0xef, 0x67, 0xfd, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xf6, - 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xef, 0x60, - - /* U+004E "N" */ - 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf7, - 0xff, 0xa0, 0x0, 0x0, 0x0, 0x7, 0xff, 0x7f, - 0xff, 0x70, 0x0, 0x0, 0x0, 0x7f, 0xf7, 0xff, - 0xff, 0x40, 0x0, 0x0, 0x7, 0xff, 0x7f, 0xfd, - 0xfe, 0x20, 0x0, 0x0, 0x7f, 0xf7, 0xfe, 0x3f, - 0xfd, 0x0, 0x0, 0x7, 0xff, 0x7f, 0xe0, 0x5f, - 0xfa, 0x0, 0x0, 0x7f, 0xf7, 0xfe, 0x0, 0x8f, - 0xf7, 0x0, 0x7, 0xff, 0x7f, 0xe0, 0x0, 0xbf, - 0xf4, 0x0, 0x7f, 0xf7, 0xfe, 0x0, 0x1, 0xef, - 0xe1, 0x7, 0xff, 0x7f, 0xe0, 0x0, 0x3, 0xff, - 0xc0, 0x7f, 0xf7, 0xfe, 0x0, 0x0, 0x6, 0xff, - 0xa7, 0xff, 0x7f, 0xe0, 0x0, 0x0, 0x9, 0xff, - 0xdf, 0xf7, 0xfe, 0x0, 0x0, 0x0, 0xc, 0xff, - 0xff, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x1e, 0xff, - 0xf7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xff, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x6f, 0xf0, - - /* U+004F "O" */ - 0x0, 0x0, 0x5, 0xad, 0xff, 0xeb, 0x60, 0x0, - 0x0, 0x0, 0x0, 0x2d, 0xff, 0xff, 0xff, 0xff, - 0xe4, 0x0, 0x0, 0x0, 0x5f, 0xff, 0xb6, 0x33, - 0x5a, 0xff, 0xf7, 0x0, 0x0, 0x3f, 0xfd, 0x30, - 0x0, 0x0, 0x1, 0xcf, 0xf5, 0x0, 0xd, 0xfe, - 0x10, 0x0, 0x0, 0x0, 0x0, 0xcf, 0xf1, 0x4, - 0xff, 0x40, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, - 0x70, 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xb, 0xfc, 0xc, 0xfa, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8f, 0xf0, 0xdf, 0x90, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0xc, 0xfa, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xf0, 0x9f, - 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0xfc, - 0x5, 0xff, 0x40, 0x0, 0x0, 0x0, 0x0, 0x2, - 0xff, 0x70, 0xd, 0xfe, 0x10, 0x0, 0x0, 0x0, - 0x0, 0xcf, 0xf1, 0x0, 0x3f, 0xfd, 0x30, 0x0, - 0x0, 0x1, 0xcf, 0xf5, 0x0, 0x0, 0x5f, 0xff, - 0xb5, 0x33, 0x59, 0xff, 0xf8, 0x0, 0x0, 0x0, - 0x3d, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x0, 0x0, - 0x0, 0x0, 0x5, 0xad, 0xff, 0xeb, 0x60, 0x0, - 0x0, 0x0, - - /* U+0050 "P" */ - 0x7f, 0xff, 0xff, 0xff, 0xeb, 0x60, 0x0, 0x7, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd2, 0x0, 0x7f, - 0xe1, 0x11, 0x12, 0x49, 0xff, 0xe1, 0x7, 0xfe, - 0x0, 0x0, 0x0, 0x3, 0xff, 0x90, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x9, 0xfe, 0x7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x5f, 0xf0, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x5, 0xff, 0x7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x9f, 0xe0, 0x7f, 0xe0, 0x0, 0x0, - 0x0, 0x3f, 0xf9, 0x7, 0xfe, 0x11, 0x11, 0x24, - 0x8f, 0xfe, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xfd, 0x20, 0x7, 0xff, 0xff, 0xff, 0xfe, 0xb6, - 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+0051 "Q" */ - 0x0, 0x0, 0x5, 0xad, 0xff, 0xeb, 0x60, 0x0, - 0x0, 0x0, 0x0, 0x2d, 0xff, 0xff, 0xff, 0xff, - 0xe4, 0x0, 0x0, 0x0, 0x5f, 0xff, 0xb6, 0x33, - 0x5a, 0xff, 0xf7, 0x0, 0x0, 0x2f, 0xfd, 0x30, - 0x0, 0x0, 0x2, 0xcf, 0xf5, 0x0, 0xd, 0xfe, - 0x10, 0x0, 0x0, 0x0, 0x0, 0xdf, 0xf1, 0x4, - 0xff, 0x50, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, - 0x70, 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xb, 0xfc, 0xc, 0xfa, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8f, 0xf0, 0xdf, 0x90, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0xc, 0xfa, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xe0, 0xaf, - 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0xfc, - 0x5, 0xff, 0x40, 0x0, 0x0, 0x0, 0x0, 0x2, - 0xff, 0x70, 0xe, 0xfd, 0x10, 0x0, 0x0, 0x0, - 0x0, 0xcf, 0xf1, 0x0, 0x4f, 0xfc, 0x20, 0x0, - 0x0, 0x1, 0xbf, 0xf6, 0x0, 0x0, 0x7f, 0xff, - 0xa4, 0x22, 0x48, 0xef, 0xf9, 0x0, 0x0, 0x0, - 0x5f, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x0, 0x0, - 0x0, 0x0, 0x17, 0xce, 0xff, 0xfd, 0x71, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xcf, 0xf7, - 0x10, 0x4, 0xc3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xff, 0xff, 0xff, 0x70, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3a, 0xef, 0xea, 0x40, - - /* U+0052 "R" */ - 0x7f, 0xff, 0xff, 0xff, 0xeb, 0x60, 0x0, 0x7, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd2, 0x0, 0x7f, - 0xe1, 0x11, 0x12, 0x49, 0xff, 0xe1, 0x7, 0xfe, - 0x0, 0x0, 0x0, 0x3, 0xff, 0x90, 0x7f, 0xe0, - 0x0, 0x0, 0x0, 0x9, 0xfe, 0x7, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x5f, 0xf0, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x5, 0xff, 0x7, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x9f, 0xe0, 0x7f, 0xe0, 0x0, 0x0, - 0x0, 0x3f, 0xf8, 0x7, 0xfe, 0x11, 0x11, 0x13, - 0x8f, 0xfe, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xfd, 0x20, 0x7, 0xff, 0xff, 0xff, 0xff, 0xfa, - 0x0, 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x7f, 0xf2, - 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0xcf, 0xd0, - 0x0, 0x7f, 0xe0, 0x0, 0x0, 0x1, 0xef, 0x90, - 0x7, 0xfe, 0x0, 0x0, 0x0, 0x5, 0xff, 0x40, - 0x7f, 0xe0, 0x0, 0x0, 0x0, 0x9, 0xfe, 0x10, - - /* U+0053 "S" */ - 0x0, 0x0, 0x6b, 0xef, 0xfd, 0xa5, 0x0, 0x0, - 0x2e, 0xff, 0xff, 0xff, 0xff, 0xd1, 0x0, 0xef, - 0xe7, 0x21, 0x14, 0x8e, 0xc0, 0x6, 0xff, 0x20, - 0x0, 0x0, 0x0, 0x20, 0x9, 0xfc, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x8, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3, 0xff, 0xc3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xff, 0xd9, 0x51, 0x0, 0x0, - 0x0, 0x4, 0xbf, 0xff, 0xff, 0xc5, 0x0, 0x0, - 0x0, 0x1, 0x59, 0xdf, 0xff, 0xb0, 0x0, 0x0, - 0x0, 0x0, 0x2, 0xaf, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xb, 0xfc, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x7, 0xfe, 0x5, 0x80, 0x0, 0x0, 0x0, - 0xc, 0xfb, 0xd, 0xfe, 0x84, 0x21, 0x25, 0xcf, - 0xf4, 0x3, 0xdf, 0xff, 0xff, 0xff, 0xff, 0x60, - 0x0, 0x4, 0x9d, 0xef, 0xec, 0x82, 0x0, - - /* U+0054 "T" */ - 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, 0x11, - 0x13, 0xff, 0x51, 0x11, 0x11, 0x0, 0x0, 0x2, - 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x2, 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, 0x2, - 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, - - /* U+0055 "U" */ - 0xaf, 0xc0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x9a, - 0xfc, 0x0, 0x0, 0x0, 0x0, 0xc, 0xf9, 0xaf, - 0xc0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0x9a, 0xfc, - 0x0, 0x0, 0x0, 0x0, 0xc, 0xf9, 0xaf, 0xc0, - 0x0, 0x0, 0x0, 0x0, 0xcf, 0x9a, 0xfc, 0x0, - 0x0, 0x0, 0x0, 0xc, 0xf9, 0xaf, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0xcf, 0x9a, 0xfc, 0x0, 0x0, - 0x0, 0x0, 0xc, 0xf9, 0xaf, 0xc0, 0x0, 0x0, - 0x0, 0x0, 0xcf, 0x99, 0xfc, 0x0, 0x0, 0x0, - 0x0, 0xc, 0xf9, 0x9f, 0xd0, 0x0, 0x0, 0x0, - 0x0, 0xdf, 0x87, 0xff, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf6, 0x3f, 0xf5, 0x0, 0x0, 0x0, 0x5, - 0xff, 0x20, 0xdf, 0xe1, 0x0, 0x0, 0x1, 0xef, - 0xc0, 0x3, 0xff, 0xe7, 0x32, 0x38, 0xef, 0xf3, - 0x0, 0x4, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x0, - 0x0, 0x1, 0x7c, 0xef, 0xec, 0x71, 0x0, 0x0, - - /* U+0056 "V" */ - 0xd, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xfe, 0x0, 0x6f, 0xf3, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xef, 0x70, 0x0, 0xef, 0xa0, 0x0, 0x0, - 0x0, 0x0, 0x6f, 0xf1, 0x0, 0x8, 0xff, 0x10, - 0x0, 0x0, 0x0, 0xc, 0xf9, 0x0, 0x0, 0x1f, - 0xf8, 0x0, 0x0, 0x0, 0x4, 0xff, 0x20, 0x0, - 0x0, 0xaf, 0xe0, 0x0, 0x0, 0x0, 0xbf, 0xb0, - 0x0, 0x0, 0x3, 0xff, 0x50, 0x0, 0x0, 0x2f, - 0xf4, 0x0, 0x0, 0x0, 0xc, 0xfc, 0x0, 0x0, - 0x9, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x5f, 0xf3, - 0x0, 0x0, 0xff, 0x60, 0x0, 0x0, 0x0, 0x0, - 0xef, 0xa0, 0x0, 0x7f, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0x7, 0xff, 0x10, 0xd, 0xf8, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1f, 0xf8, 0x5, 0xff, 0x20, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xe0, 0xcf, - 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, - 0x9f, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xb, 0xff, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4f, 0xff, 0x60, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0xe0, 0x0, 0x0, - 0x0, 0x0, - - /* U+0057 "W" */ - 0x1f, 0xf6, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xe0, - 0x0, 0x0, 0x0, 0x3, 0xff, 0x10, 0xbf, 0xb0, - 0x0, 0x0, 0x0, 0xf, 0xff, 0x30, 0x0, 0x0, - 0x0, 0x8f, 0xc0, 0x6, 0xff, 0x10, 0x0, 0x0, - 0x5, 0xff, 0xf8, 0x0, 0x0, 0x0, 0xd, 0xf6, - 0x0, 0x1f, 0xf6, 0x0, 0x0, 0x0, 0xbf, 0xef, - 0xe0, 0x0, 0x0, 0x3, 0xff, 0x10, 0x0, 0xbf, - 0xb0, 0x0, 0x0, 0x1f, 0xf4, 0xff, 0x30, 0x0, - 0x0, 0x8f, 0xc0, 0x0, 0x6, 0xff, 0x10, 0x0, - 0x6, 0xfd, 0xc, 0xf8, 0x0, 0x0, 0xd, 0xf6, - 0x0, 0x0, 0x1f, 0xf5, 0x0, 0x0, 0xbf, 0x70, - 0x6f, 0xe0, 0x0, 0x3, 0xff, 0x10, 0x0, 0x0, - 0xcf, 0xb0, 0x0, 0x1f, 0xf2, 0x1, 0xff, 0x30, - 0x0, 0x8f, 0xc0, 0x0, 0x0, 0x6, 0xff, 0x0, - 0x6, 0xfd, 0x0, 0xc, 0xf8, 0x0, 0xd, 0xf7, - 0x0, 0x0, 0x0, 0x1f, 0xf5, 0x0, 0xbf, 0x70, - 0x0, 0x6f, 0xe0, 0x3, 0xff, 0x10, 0x0, 0x0, - 0x0, 0xcf, 0xb0, 0x1f, 0xf2, 0x0, 0x1, 0xff, - 0x30, 0x8f, 0xc0, 0x0, 0x0, 0x0, 0x6, 0xff, - 0x6, 0xfc, 0x0, 0x0, 0xb, 0xf8, 0xd, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0x1f, 0xf5, 0xcf, 0x70, - 0x0, 0x0, 0x6f, 0xe3, 0xff, 0x20, 0x0, 0x0, - 0x0, 0x0, 0xcf, 0xcf, 0xf2, 0x0, 0x0, 0x1, - 0xff, 0xbf, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x7, - 0xff, 0xfc, 0x0, 0x0, 0x0, 0xb, 0xff, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0x70, - 0x0, 0x0, 0x0, 0x6f, 0xff, 0x20, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xcf, 0xf1, 0x0, 0x0, 0x0, - 0x1, 0xff, 0xc0, 0x0, 0x0, 0x0, - - /* U+0058 "X" */ - 0xe, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xe1, - 0x3, 0xff, 0x80, 0x0, 0x0, 0x4, 0xff, 0x50, - 0x0, 0x8f, 0xf3, 0x0, 0x0, 0x1e, 0xf9, 0x0, - 0x0, 0xc, 0xfe, 0x10, 0x0, 0xbf, 0xd0, 0x0, - 0x0, 0x2, 0xff, 0xa0, 0x6, 0xff, 0x20, 0x0, - 0x0, 0x0, 0x5f, 0xf6, 0x2f, 0xf6, 0x0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xdf, 0xb0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xef, 0xfe, 0x10, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x9f, 0xfb, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4, 0xff, 0xff, 0x60, 0x0, 0x0, - 0x0, 0x0, 0x1e, 0xfa, 0x9f, 0xf2, 0x0, 0x0, - 0x0, 0x0, 0xbf, 0xe1, 0xd, 0xfd, 0x0, 0x0, - 0x0, 0x6, 0xff, 0x40, 0x2, 0xff, 0x90, 0x0, - 0x0, 0x2f, 0xf8, 0x0, 0x0, 0x6f, 0xf4, 0x0, - 0x0, 0xdf, 0xd0, 0x0, 0x0, 0xb, 0xfe, 0x10, - 0x9, 0xff, 0x20, 0x0, 0x0, 0x1, 0xef, 0xb0, - 0x5f, 0xf6, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xf7, - - /* U+0059 "Y" */ - 0xc, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x1, 0xff, - 0x50, 0x3f, 0xf5, 0x0, 0x0, 0x0, 0x0, 0xaf, - 0xb0, 0x0, 0x9f, 0xe0, 0x0, 0x0, 0x0, 0x4f, - 0xf2, 0x0, 0x1, 0xef, 0x90, 0x0, 0x0, 0xd, - 0xf8, 0x0, 0x0, 0x6, 0xff, 0x20, 0x0, 0x7, - 0xfe, 0x0, 0x0, 0x0, 0xc, 0xfc, 0x0, 0x1, - 0xff, 0x50, 0x0, 0x0, 0x0, 0x3f, 0xf5, 0x0, - 0xaf, 0xb0, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xe0, - 0x4f, 0xf2, 0x0, 0x0, 0x0, 0x0, 0x1, 0xef, - 0x9d, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, - 0xff, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xc, 0xff, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x6f, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x6, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x6f, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x6, 0xff, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6f, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0x0, 0x0, 0x0, - 0x0, - - /* U+005A "Z" */ - 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xc, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb0, 0x11, - 0x11, 0x11, 0x11, 0x11, 0xcf, 0xf2, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x8f, 0xf4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x5f, 0xf8, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2f, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xd, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, - 0xff, 0x20, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, - 0x50, 0x0, 0x0, 0x0, 0x0, 0x4, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xb0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0xd1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xbf, 0xf2, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8f, 0xf5, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x4f, 0xfa, 0x11, 0x11, 0x11, 0x11, 0x11, - 0xe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, - - /* U+005B "[" */ - 0x7f, 0xff, 0xf8, 0x7f, 0xfe, 0xe7, 0x7f, 0xd0, - 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, - 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, - 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, - 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, - 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, - 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, - 0x0, 0x7f, 0xd0, 0x0, 0x7f, 0xd0, 0x0, 0x7f, - 0xfe, 0xe7, 0x7f, 0xff, 0xf8, - - /* U+005C "\\" */ - 0xbf, 0x50, 0x0, 0x0, 0x0, 0x6, 0xfb, 0x0, - 0x0, 0x0, 0x0, 0x1f, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0xbf, 0x60, 0x0, 0x0, 0x0, 0x5, 0xfb, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xf1, 0x0, 0x0, - 0x0, 0x0, 0xaf, 0x60, 0x0, 0x0, 0x0, 0x5, - 0xfc, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf1, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0x70, 0x0, 0x0, 0x0, - 0x4, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xe, 0xf2, - 0x0, 0x0, 0x0, 0x0, 0x9f, 0x70, 0x0, 0x0, - 0x0, 0x4, 0xfd, 0x0, 0x0, 0x0, 0x0, 0xe, - 0xf2, 0x0, 0x0, 0x0, 0x0, 0x9f, 0x80, 0x0, - 0x0, 0x0, 0x3, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0xe, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x8f, 0x80, - 0x0, 0x0, 0x0, 0x3, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xd, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x8f, - 0x90, 0x0, 0x0, 0x0, 0x2, 0xfe, 0x0, - - /* U+005D "]" */ - 0x8f, 0xff, 0xf7, 0x8e, 0xef, 0xf7, 0x0, 0xd, - 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, - 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, - 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, - 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, - 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, - 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, - 0xf7, 0x0, 0xd, 0xf7, 0x0, 0xd, 0xf7, 0x8e, - 0xef, 0xf7, 0x8f, 0xff, 0xf7, - - /* U+005E "^" */ - 0x0, 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xf9, 0x0, 0x0, 0x0, 0x0, 0xfc, 0xbf, - 0x10, 0x0, 0x0, 0x7, 0xf5, 0x5f, 0x70, 0x0, - 0x0, 0xd, 0xe0, 0xe, 0xd0, 0x0, 0x0, 0x4f, - 0x80, 0x8, 0xf4, 0x0, 0x0, 0xbf, 0x10, 0x1, - 0xfb, 0x0, 0x2, 0xfa, 0x0, 0x0, 0xaf, 0x20, - 0x9, 0xf4, 0x0, 0x0, 0x4f, 0x80, 0xf, 0xd0, - 0x0, 0x0, 0xd, 0xe0, - - /* U+005F "_" */ - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, - - /* U+0060 "`" */ - 0x8, 0xff, 0x40, 0x0, 0x4, 0xef, 0x60, 0x0, - 0x1, 0xbf, 0x70, - - /* U+0061 "a" */ - 0x0, 0x6b, 0xef, 0xfd, 0x81, 0x0, 0x2e, 0xff, - 0xff, 0xff, 0xfe, 0x10, 0xe, 0xb5, 0x10, 0x27, - 0xff, 0xb0, 0x1, 0x0, 0x0, 0x0, 0x6f, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0x0, 0x37, - 0xaa, 0xaa, 0xaf, 0xf4, 0xa, 0xff, 0xff, 0xff, - 0xff, 0xf4, 0x6f, 0xf6, 0x10, 0x0, 0xf, 0xf4, - 0xbf, 0x90, 0x0, 0x0, 0xf, 0xf4, 0xcf, 0x80, - 0x0, 0x0, 0x5f, 0xf4, 0x8f, 0xe2, 0x0, 0x4, - 0xff, 0xf4, 0x1d, 0xff, 0xcb, 0xdf, 0xdf, 0xf4, - 0x1, 0x8d, 0xff, 0xd8, 0xe, 0xf4, - - /* U+0062 "b" */ - 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, - 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xdf, 0x70, 0x7c, 0xfe, 0xc7, - 0x10, 0x0, 0xdf, 0x9d, 0xff, 0xff, 0xff, 0xe3, - 0x0, 0xdf, 0xff, 0xa3, 0x12, 0x6e, 0xfe, 0x20, - 0xdf, 0xf8, 0x0, 0x0, 0x1, 0xef, 0xa0, 0xdf, - 0xe0, 0x0, 0x0, 0x0, 0x6f, 0xf1, 0xdf, 0x90, - 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xdf, 0x70, 0x0, - 0x0, 0x0, 0xf, 0xf5, 0xdf, 0x90, 0x0, 0x0, - 0x0, 0x1f, 0xf3, 0xdf, 0xe0, 0x0, 0x0, 0x0, - 0x6f, 0xf1, 0xdf, 0xf8, 0x0, 0x0, 0x2, 0xef, - 0xa0, 0xdf, 0xff, 0xa3, 0x12, 0x6e, 0xff, 0x20, - 0xdf, 0x8d, 0xff, 0xff, 0xff, 0xe3, 0x0, 0xdf, - 0x60, 0x7d, 0xfe, 0xc7, 0x10, 0x0, - - /* U+0063 "c" */ - 0x0, 0x3, 0xad, 0xfe, 0xc6, 0x0, 0x0, 0x9f, - 0xff, 0xff, 0xff, 0xc1, 0x9, 0xff, 0x93, 0x12, - 0x7f, 0xfa, 0x4f, 0xf6, 0x0, 0x0, 0x3, 0x91, - 0xaf, 0xc0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, - 0x0, 0x0, 0x0, 0x0, 0xff, 0x50, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, - 0xaf, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xf6, - 0x0, 0x0, 0x2, 0x91, 0x9, 0xff, 0x93, 0x12, - 0x7f, 0xfa, 0x0, 0x9f, 0xff, 0xff, 0xff, 0xc1, - 0x0, 0x3, 0xad, 0xfe, 0xc6, 0x0, - - /* U+0064 "d" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2f, 0xf3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x2f, 0xf3, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2f, 0xf3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x2f, 0xf3, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2f, 0xf3, 0x0, 0x5, 0xbe, 0xfe, 0x92, - 0x2f, 0xf3, 0x1, 0xbf, 0xff, 0xff, 0xff, 0x7f, - 0xf3, 0xb, 0xff, 0x93, 0x12, 0x7f, 0xff, 0xf3, - 0x5f, 0xf6, 0x0, 0x0, 0x3, 0xff, 0xf3, 0xbf, - 0xc0, 0x0, 0x0, 0x0, 0x8f, 0xf3, 0xdf, 0x70, - 0x0, 0x0, 0x0, 0x3f, 0xf3, 0xff, 0x50, 0x0, - 0x0, 0x0, 0x1f, 0xf3, 0xdf, 0x70, 0x0, 0x0, - 0x0, 0x3f, 0xf3, 0xbf, 0xb0, 0x0, 0x0, 0x0, - 0x7f, 0xf3, 0x5f, 0xf5, 0x0, 0x0, 0x2, 0xff, - 0xf3, 0xb, 0xff, 0x71, 0x0, 0x5e, 0xff, 0xf3, - 0x1, 0xbf, 0xff, 0xef, 0xff, 0x7f, 0xf3, 0x0, - 0x5, 0xbe, 0xfe, 0xa3, 0xf, 0xf3, - - /* U+0065 "e" */ - 0x0, 0x5, 0xbe, 0xfd, 0xa3, 0x0, 0x0, 0xa, - 0xff, 0xff, 0xff, 0xf8, 0x0, 0xa, 0xfe, 0x61, - 0x2, 0x8f, 0xf7, 0x4, 0xff, 0x20, 0x0, 0x0, - 0x5f, 0xf1, 0xaf, 0x90, 0x0, 0x0, 0x0, 0xcf, - 0x6d, 0xfc, 0xbb, 0xbb, 0xbb, 0xbd, 0xf9, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf6, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xaf, 0xc0, 0x0, 0x0, - 0x0, 0x0, 0x4, 0xff, 0x60, 0x0, 0x0, 0x6, - 0x0, 0xa, 0xff, 0xa3, 0x11, 0x4b, 0xf8, 0x0, - 0x9, 0xff, 0xff, 0xff, 0xff, 0x40, 0x0, 0x3, - 0xad, 0xff, 0xd8, 0x10, 0x0, - - /* U+0066 "f" */ - 0x0, 0x0, 0x8d, 0xfe, 0xa1, 0x0, 0xb, 0xff, - 0xff, 0xf0, 0x0, 0x4f, 0xf5, 0x0, 0x30, 0x0, - 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xc0, 0x0, - 0x0, 0xaf, 0xff, 0xff, 0xff, 0x70, 0x9e, 0xff, - 0xfe, 0xee, 0x60, 0x0, 0x7f, 0xd0, 0x0, 0x0, - 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, - 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, - 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, - 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, - 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, - 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, - 0x0, 0x0, - - /* U+0067 "g" */ - 0x0, 0x5, 0xbe, 0xfe, 0xa3, 0xd, 0xf5, 0x0, - 0xbf, 0xff, 0xff, 0xff, 0x8d, 0xf5, 0xb, 0xff, - 0x93, 0x12, 0x6e, 0xff, 0xf5, 0x4f, 0xf6, 0x0, - 0x0, 0x1, 0xef, 0xf5, 0xbf, 0xc0, 0x0, 0x0, - 0x0, 0x5f, 0xf5, 0xdf, 0x70, 0x0, 0x0, 0x0, - 0xf, 0xf5, 0xff, 0x50, 0x0, 0x0, 0x0, 0xe, - 0xf5, 0xdf, 0x70, 0x0, 0x0, 0x0, 0xf, 0xf5, - 0xaf, 0xc0, 0x0, 0x0, 0x0, 0x5f, 0xf5, 0x4f, - 0xf6, 0x0, 0x0, 0x1, 0xef, 0xf5, 0xa, 0xff, - 0xa3, 0x12, 0x6e, 0xff, 0xf5, 0x0, 0xbf, 0xff, - 0xff, 0xff, 0x8f, 0xf5, 0x0, 0x5, 0xbe, 0xfe, - 0xa3, 0xf, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2f, 0xf1, 0x3, 0x10, 0x0, 0x0, 0x0, 0xaf, - 0xd0, 0xd, 0xf9, 0x52, 0x11, 0x4b, 0xff, 0x50, - 0xa, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x0, 0x0, - 0x28, 0xce, 0xff, 0xd9, 0x30, 0x0, - - /* U+0068 "h" */ - 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, 0x0, - 0x0, 0x0, 0x0, 0xd, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, - 0xd, 0xf7, 0x18, 0xdf, 0xfc, 0x70, 0x0, 0xdf, - 0xae, 0xff, 0xff, 0xff, 0xc0, 0xd, 0xff, 0xf8, - 0x31, 0x4a, 0xff, 0x90, 0xdf, 0xf5, 0x0, 0x0, - 0xa, 0xff, 0xd, 0xfc, 0x0, 0x0, 0x0, 0x3f, - 0xf2, 0xdf, 0x80, 0x0, 0x0, 0x1, 0xff, 0x3d, - 0xf7, 0x0, 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, - 0x0, 0x0, 0x0, 0xff, 0x4d, 0xf7, 0x0, 0x0, - 0x0, 0xf, 0xf4, 0xdf, 0x70, 0x0, 0x0, 0x0, - 0xff, 0x4d, 0xf7, 0x0, 0x0, 0x0, 0xf, 0xf4, - 0xdf, 0x70, 0x0, 0x0, 0x0, 0xff, 0x4d, 0xf7, - 0x0, 0x0, 0x0, 0xf, 0xf4, - - /* U+0069 "i" */ - 0xb, 0xf6, 0x2f, 0xfd, 0xb, 0xf7, 0x0, 0x0, - 0x0, 0x0, 0xd, 0xf7, 0xd, 0xf7, 0xd, 0xf7, - 0xd, 0xf7, 0xd, 0xf7, 0xd, 0xf7, 0xd, 0xf7, - 0xd, 0xf7, 0xd, 0xf7, 0xd, 0xf7, 0xd, 0xf7, - 0xd, 0xf7, 0xd, 0xf7, - - /* U+006A "j" */ - 0x0, 0x0, 0x9, 0xf8, 0x0, 0x0, 0x1, 0xff, - 0xf0, 0x0, 0x0, 0xa, 0xf8, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xbf, 0x90, 0x0, 0x0, 0xb, 0xf9, 0x0, - 0x0, 0x0, 0xbf, 0x90, 0x0, 0x0, 0xb, 0xf9, - 0x0, 0x0, 0x0, 0xbf, 0x90, 0x0, 0x0, 0xb, - 0xf9, 0x0, 0x0, 0x0, 0xbf, 0x90, 0x0, 0x0, - 0xb, 0xf9, 0x0, 0x0, 0x0, 0xbf, 0x90, 0x0, - 0x0, 0xb, 0xf9, 0x0, 0x0, 0x0, 0xbf, 0x90, - 0x0, 0x0, 0xb, 0xf9, 0x0, 0x0, 0x0, 0xbf, - 0x90, 0x0, 0x0, 0xb, 0xf9, 0x0, 0x0, 0x0, - 0xdf, 0x80, 0x4, 0x20, 0x5f, 0xf4, 0x0, 0xef, - 0xff, 0xfc, 0x0, 0x9, 0xef, 0xe9, 0x0, 0x0, - - /* U+006B "k" */ - 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0x70, 0x0, - 0x0, 0x0, 0x0, 0xd, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, - 0xd, 0xf7, 0x0, 0x0, 0x3, 0xef, 0xa0, 0xdf, - 0x70, 0x0, 0x3, 0xff, 0xb0, 0xd, 0xf7, 0x0, - 0x4, 0xff, 0xb0, 0x0, 0xdf, 0x70, 0x5, 0xff, - 0xb0, 0x0, 0xd, 0xf7, 0x6, 0xff, 0xb0, 0x0, - 0x0, 0xdf, 0x77, 0xff, 0xf1, 0x0, 0x0, 0xd, - 0xfe, 0xff, 0xff, 0xb0, 0x0, 0x0, 0xdf, 0xff, - 0x87, 0xff, 0x70, 0x0, 0xd, 0xff, 0x70, 0xa, - 0xff, 0x40, 0x0, 0xdf, 0x90, 0x0, 0xd, 0xfe, - 0x10, 0xd, 0xf7, 0x0, 0x0, 0x2e, 0xfc, 0x0, - 0xdf, 0x70, 0x0, 0x0, 0x4f, 0xf9, 0xd, 0xf7, - 0x0, 0x0, 0x0, 0x7f, 0xf5, - - /* U+006C "l" */ - 0xdf, 0x7d, 0xf7, 0xdf, 0x7d, 0xf7, 0xdf, 0x7d, - 0xf7, 0xdf, 0x7d, 0xf7, 0xdf, 0x7d, 0xf7, 0xdf, - 0x7d, 0xf7, 0xdf, 0x7d, 0xf7, 0xdf, 0x7d, 0xf7, - 0xdf, 0x7d, 0xf7, - - /* U+006D "m" */ - 0xdf, 0x61, 0x9d, 0xfe, 0xb5, 0x0, 0x7, 0xcf, - 0xfd, 0x80, 0x0, 0xdf, 0xaf, 0xff, 0xff, 0xff, - 0x92, 0xef, 0xff, 0xff, 0xfd, 0x10, 0xdf, 0xfe, - 0x60, 0x3, 0xcf, 0xff, 0xfa, 0x20, 0x17, 0xff, - 0xa0, 0xdf, 0xf3, 0x0, 0x0, 0xe, 0xff, 0xa0, - 0x0, 0x0, 0x8f, 0xf0, 0xdf, 0xc0, 0x0, 0x0, - 0x9, 0xff, 0x20, 0x0, 0x0, 0x2f, 0xf3, 0xdf, - 0x80, 0x0, 0x0, 0x7, 0xff, 0x0, 0x0, 0x0, - 0xf, 0xf4, 0xdf, 0x70, 0x0, 0x0, 0x6, 0xfe, - 0x0, 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, 0x0, - 0x0, 0x6, 0xfe, 0x0, 0x0, 0x0, 0xf, 0xf4, - 0xdf, 0x70, 0x0, 0x0, 0x6, 0xfe, 0x0, 0x0, - 0x0, 0xf, 0xf4, 0xdf, 0x70, 0x0, 0x0, 0x6, - 0xfe, 0x0, 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, - 0x0, 0x0, 0x6, 0xfe, 0x0, 0x0, 0x0, 0xf, - 0xf4, 0xdf, 0x70, 0x0, 0x0, 0x6, 0xfe, 0x0, - 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, 0x0, 0x0, - 0x6, 0xfe, 0x0, 0x0, 0x0, 0xf, 0xf4, - - /* U+006E "n" */ - 0xdf, 0x61, 0x8d, 0xff, 0xc7, 0x0, 0xd, 0xf9, - 0xff, 0xff, 0xff, 0xfc, 0x0, 0xdf, 0xff, 0x61, - 0x2, 0x8f, 0xf9, 0xd, 0xff, 0x40, 0x0, 0x0, - 0x9f, 0xf0, 0xdf, 0xc0, 0x0, 0x0, 0x3, 0xff, - 0x2d, 0xf8, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xdf, - 0x70, 0x0, 0x0, 0x0, 0xff, 0x4d, 0xf7, 0x0, - 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, 0x0, 0x0, - 0x0, 0xff, 0x4d, 0xf7, 0x0, 0x0, 0x0, 0xf, - 0xf4, 0xdf, 0x70, 0x0, 0x0, 0x0, 0xff, 0x4d, - 0xf7, 0x0, 0x0, 0x0, 0xf, 0xf4, 0xdf, 0x70, - 0x0, 0x0, 0x0, 0xff, 0x40, - - /* U+006F "o" */ - 0x0, 0x4, 0xad, 0xfe, 0xb5, 0x0, 0x0, 0x0, - 0xaf, 0xff, 0xff, 0xff, 0xc1, 0x0, 0xa, 0xff, - 0x93, 0x12, 0x7f, 0xfd, 0x0, 0x4f, 0xf6, 0x0, - 0x0, 0x3, 0xff, 0x80, 0xaf, 0xc0, 0x0, 0x0, - 0x0, 0x8f, 0xe0, 0xdf, 0x70, 0x0, 0x0, 0x0, - 0x3f, 0xf1, 0xff, 0x50, 0x0, 0x0, 0x0, 0x1f, - 0xf3, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x3f, 0xf1, - 0xaf, 0xc0, 0x0, 0x0, 0x0, 0x8f, 0xe0, 0x4f, - 0xf6, 0x0, 0x0, 0x3, 0xff, 0x80, 0xa, 0xff, - 0x93, 0x12, 0x7f, 0xfd, 0x0, 0x0, 0x9f, 0xff, - 0xff, 0xff, 0xc1, 0x0, 0x0, 0x4, 0xad, 0xfe, - 0xb5, 0x0, 0x0, - - /* U+0070 "p" */ - 0xdf, 0x61, 0x8d, 0xfe, 0xc7, 0x10, 0x0, 0xdf, - 0x8e, 0xff, 0xff, 0xff, 0xe3, 0x0, 0xdf, 0xff, - 0x92, 0x0, 0x5d, 0xfe, 0x20, 0xdf, 0xf7, 0x0, - 0x0, 0x1, 0xef, 0xa0, 0xdf, 0xd0, 0x0, 0x0, - 0x0, 0x5f, 0xf1, 0xdf, 0x90, 0x0, 0x0, 0x0, - 0x1f, 0xf3, 0xdf, 0x70, 0x0, 0x0, 0x0, 0xf, - 0xf5, 0xdf, 0x90, 0x0, 0x0, 0x0, 0x1f, 0xf3, - 0xdf, 0xe0, 0x0, 0x0, 0x0, 0x6f, 0xf1, 0xdf, - 0xf8, 0x0, 0x0, 0x2, 0xef, 0xa0, 0xdf, 0xff, - 0xa3, 0x12, 0x6e, 0xff, 0x20, 0xdf, 0x9d, 0xff, - 0xff, 0xff, 0xe3, 0x0, 0xdf, 0x70, 0x7c, 0xfe, - 0xc7, 0x10, 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xdf, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, - 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+0071 "q" */ - 0x0, 0x5, 0xbe, 0xfe, 0xa2, 0xf, 0xf3, 0x1, - 0xbf, 0xff, 0xff, 0xff, 0x6f, 0xf3, 0xb, 0xff, - 0x93, 0x12, 0x7f, 0xff, 0xf3, 0x5f, 0xf6, 0x0, - 0x0, 0x3, 0xff, 0xf3, 0xbf, 0xc0, 0x0, 0x0, - 0x0, 0x8f, 0xf3, 0xdf, 0x70, 0x0, 0x0, 0x0, - 0x3f, 0xf3, 0xff, 0x50, 0x0, 0x0, 0x0, 0x1f, - 0xf3, 0xdf, 0x70, 0x0, 0x0, 0x0, 0x3f, 0xf3, - 0xbf, 0xc0, 0x0, 0x0, 0x0, 0x8f, 0xf3, 0x5f, - 0xf6, 0x0, 0x0, 0x3, 0xff, 0xf3, 0xb, 0xff, - 0x93, 0x12, 0x7f, 0xff, 0xf3, 0x1, 0xbf, 0xff, - 0xff, 0xff, 0x7f, 0xf3, 0x0, 0x5, 0xbe, 0xfe, - 0x92, 0x2f, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2f, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2f, - 0xf3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2f, 0xf3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2f, 0xf3, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x2f, 0xf3, - - /* U+0072 "r" */ - 0xdf, 0x61, 0x8d, 0xf0, 0xdf, 0x7e, 0xff, 0xf0, - 0xdf, 0xff, 0xb5, 0x40, 0xdf, 0xf7, 0x0, 0x0, - 0xdf, 0xd0, 0x0, 0x0, 0xdf, 0x90, 0x0, 0x0, - 0xdf, 0x70, 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, - 0xdf, 0x70, 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, - 0xdf, 0x70, 0x0, 0x0, 0xdf, 0x70, 0x0, 0x0, - 0xdf, 0x70, 0x0, 0x0, - - /* U+0073 "s" */ - 0x0, 0x18, 0xcf, 0xfe, 0xb7, 0x10, 0x2, 0xef, - 0xff, 0xff, 0xff, 0xb0, 0xb, 0xfe, 0x41, 0x2, - 0x6c, 0x30, 0xf, 0xf5, 0x0, 0x0, 0x0, 0x0, - 0xe, 0xf9, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, - 0xd9, 0x52, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xe9, 0x10, 0x0, 0x0, 0x47, 0xad, 0xff, 0xc0, - 0x0, 0x0, 0x0, 0x0, 0x5f, 0xf3, 0x1, 0x0, - 0x0, 0x0, 0xf, 0xf4, 0xe, 0xc6, 0x20, 0x3, - 0xaf, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x60, - 0x1, 0x7b, 0xef, 0xfd, 0x92, 0x0, - - /* U+0074 "t" */ - 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, - 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, 0xaf, - 0xff, 0xff, 0xff, 0x70, 0x9e, 0xff, 0xfe, 0xee, - 0x60, 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, - 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, - 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xd0, - 0x0, 0x0, 0x0, 0x7f, 0xd0, 0x0, 0x0, 0x0, - 0x7f, 0xd0, 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, - 0x0, 0x0, 0x4f, 0xf7, 0x1, 0x50, 0x0, 0xc, - 0xff, 0xff, 0xf1, 0x0, 0x0, 0x9e, 0xfd, 0x81, - - /* U+0075 "u" */ - 0xff, 0x60, 0x0, 0x0, 0x4, 0xff, 0xf, 0xf6, - 0x0, 0x0, 0x0, 0x4f, 0xf0, 0xff, 0x60, 0x0, - 0x0, 0x4, 0xff, 0xf, 0xf6, 0x0, 0x0, 0x0, - 0x4f, 0xf0, 0xff, 0x60, 0x0, 0x0, 0x4, 0xff, - 0xf, 0xf6, 0x0, 0x0, 0x0, 0x4f, 0xf0, 0xff, - 0x60, 0x0, 0x0, 0x4, 0xff, 0xe, 0xf6, 0x0, - 0x0, 0x0, 0x5f, 0xf0, 0xdf, 0x80, 0x0, 0x0, - 0x8, 0xff, 0xa, 0xfe, 0x0, 0x0, 0x1, 0xef, - 0xf0, 0x3f, 0xfb, 0x20, 0x4, 0xdf, 0xff, 0x0, - 0x8f, 0xff, 0xff, 0xff, 0x9f, 0xf0, 0x0, 0x4b, - 0xef, 0xea, 0x32, 0xff, 0x0, - - /* U+0076 "v" */ - 0xd, 0xf9, 0x0, 0x0, 0x0, 0x1, 0xff, 0x30, - 0x6f, 0xf0, 0x0, 0x0, 0x0, 0x7f, 0xc0, 0x0, - 0xef, 0x60, 0x0, 0x0, 0xd, 0xf5, 0x0, 0x8, - 0xfd, 0x0, 0x0, 0x5, 0xfe, 0x0, 0x0, 0x2f, - 0xf3, 0x0, 0x0, 0xbf, 0x80, 0x0, 0x0, 0xbf, - 0xa0, 0x0, 0x2f, 0xf1, 0x0, 0x0, 0x4, 0xff, - 0x10, 0x9, 0xfa, 0x0, 0x0, 0x0, 0xd, 0xf7, - 0x1, 0xff, 0x30, 0x0, 0x0, 0x0, 0x6f, 0xe0, - 0x7f, 0xc0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x5d, - 0xf5, 0x0, 0x0, 0x0, 0x0, 0x8, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2f, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, 0xf1, 0x0, - 0x0, 0x0, - - /* U+0077 "w" */ - 0xaf, 0x80, 0x0, 0x0, 0x5, 0xff, 0x0, 0x0, - 0x0, 0xc, 0xf4, 0x5f, 0xd0, 0x0, 0x0, 0xb, - 0xff, 0x50, 0x0, 0x0, 0x2f, 0xe0, 0xe, 0xf3, - 0x0, 0x0, 0x1f, 0xff, 0xb0, 0x0, 0x0, 0x8f, - 0x80, 0x9, 0xf9, 0x0, 0x0, 0x7f, 0xbf, 0xf1, - 0x0, 0x0, 0xef, 0x20, 0x3, 0xfe, 0x0, 0x0, - 0xcf, 0x4b, 0xf7, 0x0, 0x4, 0xfc, 0x0, 0x0, - 0xdf, 0x40, 0x2, 0xfe, 0x5, 0xfc, 0x0, 0xa, - 0xf6, 0x0, 0x0, 0x7f, 0xa0, 0x8, 0xf8, 0x0, - 0xef, 0x20, 0xf, 0xf1, 0x0, 0x0, 0x2f, 0xf0, - 0xe, 0xf2, 0x0, 0x9f, 0x80, 0x5f, 0xb0, 0x0, - 0x0, 0xc, 0xf5, 0x4f, 0xc0, 0x0, 0x3f, 0xe0, - 0xbf, 0x50, 0x0, 0x0, 0x6, 0xfb, 0xaf, 0x60, - 0x0, 0xd, 0xf5, 0xfe, 0x0, 0x0, 0x0, 0x1, - 0xff, 0xff, 0x0, 0x0, 0x7, 0xff, 0xf9, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0xfa, 0x0, 0x0, 0x1, - 0xff, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xf4, - 0x0, 0x0, 0x0, 0xbf, 0xd0, 0x0, 0x0, - - /* U+0078 "x" */ - 0x1e, 0xf8, 0x0, 0x0, 0x4, 0xff, 0x40, 0x4f, - 0xf4, 0x0, 0x1, 0xef, 0x80, 0x0, 0x8f, 0xe1, - 0x0, 0xbf, 0xb0, 0x0, 0x0, 0xcf, 0xb0, 0x7f, - 0xe1, 0x0, 0x0, 0x1, 0xef, 0xaf, 0xf4, 0x0, - 0x0, 0x0, 0x4, 0xff, 0xf7, 0x0, 0x0, 0x0, - 0x0, 0xd, 0xff, 0x10, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x4, 0xff, 0x5e, - 0xf7, 0x0, 0x0, 0x1, 0xef, 0x80, 0x4f, 0xf3, - 0x0, 0x0, 0xcf, 0xc0, 0x0, 0x8f, 0xe1, 0x0, - 0x8f, 0xe1, 0x0, 0x0, 0xcf, 0xb0, 0x4f, 0xf4, - 0x0, 0x0, 0x2, 0xff, 0x80, - - /* U+0079 "y" */ - 0xd, 0xf9, 0x0, 0x0, 0x0, 0x1, 0xff, 0x30, - 0x6f, 0xf0, 0x0, 0x0, 0x0, 0x7f, 0xc0, 0x0, - 0xef, 0x60, 0x0, 0x0, 0xd, 0xf5, 0x0, 0x8, - 0xfd, 0x0, 0x0, 0x4, 0xfe, 0x0, 0x0, 0x2f, - 0xf4, 0x0, 0x0, 0xbf, 0x80, 0x0, 0x0, 0xbf, - 0xb0, 0x0, 0x2f, 0xf1, 0x0, 0x0, 0x4, 0xff, - 0x10, 0x8, 0xfa, 0x0, 0x0, 0x0, 0xd, 0xf8, - 0x0, 0xef, 0x30, 0x0, 0x0, 0x0, 0x6f, 0xe0, - 0x6f, 0xc0, 0x0, 0x0, 0x0, 0x0, 0xef, 0x6c, - 0xf5, 0x0, 0x0, 0x0, 0x0, 0x8, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0x70, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xf1, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xa, 0xfa, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0xff, 0x30, 0x0, 0x0, - 0x0, 0xa4, 0x2, 0xcf, 0xb0, 0x0, 0x0, 0x0, - 0x5f, 0xff, 0xff, 0xe1, 0x0, 0x0, 0x0, 0x0, - 0x8d, 0xfe, 0x91, 0x0, 0x0, 0x0, 0x0, - - /* U+007A "z" */ - 0xe, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xd, 0xee, - 0xee, 0xee, 0xff, 0xf5, 0x0, 0x0, 0x0, 0x1, - 0xef, 0xa0, 0x0, 0x0, 0x0, 0xc, 0xfd, 0x0, - 0x0, 0x0, 0x0, 0x8f, 0xf2, 0x0, 0x0, 0x0, - 0x5, 0xff, 0x40, 0x0, 0x0, 0x0, 0x2f, 0xf8, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0xb0, 0x0, 0x0, - 0x0, 0xb, 0xfd, 0x10, 0x0, 0x0, 0x0, 0x7f, - 0xf2, 0x0, 0x0, 0x0, 0x4, 0xff, 0x50, 0x0, - 0x0, 0x0, 0xe, 0xff, 0xee, 0xee, 0xee, 0xe8, - 0xf, 0xff, 0xff, 0xff, 0xff, 0xf9, - - /* U+007B "{" */ - 0x0, 0x3, 0xce, 0xf0, 0x2, 0xff, 0xfe, 0x0, - 0x8f, 0xe2, 0x0, 0xa, 0xfa, 0x0, 0x0, 0xbf, - 0x90, 0x0, 0xb, 0xf9, 0x0, 0x0, 0xbf, 0x90, - 0x0, 0xb, 0xf9, 0x0, 0x0, 0xbf, 0x90, 0x0, - 0xb, 0xf9, 0x0, 0x1, 0xef, 0x70, 0xa, 0xff, - 0xd1, 0x0, 0x9f, 0xfe, 0x20, 0x0, 0xd, 0xf8, - 0x0, 0x0, 0xbf, 0x90, 0x0, 0xb, 0xf9, 0x0, - 0x0, 0xbf, 0x90, 0x0, 0xb, 0xf9, 0x0, 0x0, - 0xbf, 0x90, 0x0, 0xb, 0xfa, 0x0, 0x0, 0x9f, - 0xe2, 0x0, 0x3, 0xff, 0xfe, 0x0, 0x4, 0xcf, - 0xf0, - - /* U+007C "|" */ - 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, - 0xfa, 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, 0xfa, 0x7f, - 0xa7, 0xfa, 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, 0xfa, - 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, 0xfa, 0x7f, 0xa7, - 0xfa, 0x7f, 0xa0, - - /* U+007D "}" */ - 0x8f, 0xd7, 0x0, 0x0, 0x8f, 0xff, 0x80, 0x0, - 0x0, 0xaf, 0xf0, 0x0, 0x0, 0x3f, 0xf1, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0xf, 0xf6, 0x0, 0x0, 0x8, 0xff, 0xf0, - 0x0, 0x9, 0xff, 0xf0, 0x0, 0x1f, 0xf5, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0x2f, 0xf2, 0x0, 0x0, 0x2f, 0xf2, 0x0, - 0x0, 0x9f, 0xf0, 0x0, 0x8f, 0xff, 0xa0, 0x0, - 0x8f, 0xd8, 0x0, 0x0, - - /* U+007E "~" */ - 0x3, 0xcf, 0xd5, 0x0, 0x0, 0xf8, 0xe, 0xfd, - 0xff, 0x90, 0x5, 0xf5, 0x6f, 0x60, 0x1b, 0xfe, - 0xbf, 0xe0, 0x8f, 0x0, 0x0, 0x6d, 0xfc, 0x20, - - /* U+00B0 "°" */ - 0x0, 0x0, 0x0, 0x0, 0x2, 0xbf, 0xfb, 0x20, - 0x1e, 0xc5, 0x5c, 0xe2, 0x9d, 0x0, 0x0, 0xda, - 0xd8, 0x0, 0x0, 0x7e, 0xd7, 0x0, 0x0, 0x7e, - 0xac, 0x0, 0x0, 0xcb, 0x3f, 0xa2, 0x2a, 0xf3, - 0x4, 0xef, 0xfe, 0x40, 0x0, 0x2, 0x20, 0x0, - - /* U+2022 "•" */ - 0x1, 0x64, 0x1, 0xef, 0xf7, 0x5f, 0xff, 0xd4, - 0xff, 0xfc, 0x8, 0xfd, 0x20, - - /* U+F001 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x7b, 0xe8, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x49, 0xdf, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x16, 0xbf, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0x0, 0x3, 0x8c, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3a, - 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xaf, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xd8, 0x30, 0xf, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xfb, 0x62, 0x0, 0x0, 0xf, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xfe, 0x94, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x0, - 0x3a, 0xdf, 0xef, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xf0, 0x0, 0x0, 0x6, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0xe, - 0xff, 0xff, 0xff, 0xff, 0x3, 0xad, 0xfe, 0xff, - 0xf0, 0x0, 0x0, 0xe, 0xff, 0xff, 0xff, 0xfe, - 0x6f, 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x6, - 0xff, 0xff, 0xff, 0xf6, 0xef, 0xff, 0xff, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x3a, 0xef, 0xea, 0x30, - 0xef, 0xff, 0xff, 0xff, 0xe0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x6f, 0xff, 0xff, 0xff, - 0x60, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0xae, 0xfe, 0xa3, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - /* U+F008 "" */ - 0xb7, 0x0, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf4, 0x0, 0x7b, 0xfd, 0x88, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x88, 0xdf, - 0xff, 0xff, 0xff, 0xb4, 0x44, 0x44, 0x44, 0x44, - 0x5f, 0xff, 0xff, 0xff, 0xf9, 0x0, 0xcf, 0x80, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xf5, 0x0, 0x9f, - 0xf8, 0x0, 0xbf, 0x80, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf4, 0x0, 0x8f, 0xf9, 0x0, 0xcf, 0x80, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xf5, 0x0, 0x9f, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xff, 0xfd, 0x88, 0xef, 0xa2, - 0x22, 0x22, 0x22, 0x22, 0x3f, 0xfb, 0x88, 0xdf, - 0xf8, 0x0, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf4, 0x0, 0x8f, 0xf8, 0x0, 0xbf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, 0x8f, - 0xfd, 0x88, 0xef, 0xa2, 0x22, 0x22, 0x22, 0x22, - 0x3f, 0xfb, 0x88, 0xdf, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xf9, 0x0, 0xcf, 0x80, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf5, 0x0, 0x9f, 0xf8, 0x0, 0xbf, 0x80, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xf4, 0x0, 0x8f, - 0xf9, 0x0, 0xcf, 0x80, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xf5, 0x0, 0x9f, 0xff, 0xff, 0xff, 0xb4, - 0x44, 0x44, 0x44, 0x44, 0x5f, 0xff, 0xff, 0xff, - 0xfd, 0x88, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x88, 0xdf, 0xb7, 0x0, 0xbf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, 0x7b, - - /* U+F00B "" */ - 0x14, 0x44, 0x44, 0x10, 0x3, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x41, 0xef, 0xff, 0xff, 0xe0, - 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7b, 0xbb, 0xbb, 0x60, 0x2a, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xb7, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xbf, 0xff, 0xff, 0xb0, 0x4f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xb0, - 0x4f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x14, 0x44, 0x44, 0x10, - 0x3, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x41, - 0xef, 0xff, 0xff, 0xe0, 0x6f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7b, 0xbb, 0xbb, 0x60, - 0x2a, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xb7, - - /* U+F00C "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xbd, 0x20, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, 0xe2, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xcf, 0xff, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, 0xff, 0xfd, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xcf, 0xff, 0xff, 0xd1, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xc, 0xff, 0xff, 0xfd, 0x10, - 0x2, 0xdb, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, - 0xff, 0xff, 0xd1, 0x0, 0x2e, 0xff, 0xc0, 0x0, - 0x0, 0x0, 0xc, 0xff, 0xff, 0xfd, 0x10, 0x0, - 0xdf, 0xff, 0xfc, 0x0, 0x0, 0x0, 0xcf, 0xff, - 0xff, 0xd1, 0x0, 0x0, 0xdf, 0xff, 0xff, 0xc0, - 0x0, 0xc, 0xff, 0xff, 0xfd, 0x10, 0x0, 0x0, - 0x1d, 0xff, 0xff, 0xfc, 0x0, 0xcf, 0xff, 0xff, - 0xd1, 0x0, 0x0, 0x0, 0x1, 0xdf, 0xff, 0xff, - 0xcc, 0xff, 0xff, 0xfd, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x1d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd1, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xdf, 0xff, - 0xff, 0xff, 0xfd, 0x10, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1d, 0xff, 0xff, 0xff, 0xd1, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xdf, - 0xff, 0xfd, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1d, 0xff, 0xd1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, - 0xcc, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+F00D "" */ - 0x1, 0x41, 0x0, 0x0, 0x0, 0x0, 0x3, 0x30, - 0x1, 0xdf, 0xd2, 0x0, 0x0, 0x0, 0x7, 0xff, - 0x70, 0xcf, 0xff, 0xe2, 0x0, 0x0, 0x8, 0xff, - 0xff, 0x4e, 0xff, 0xff, 0xe2, 0x0, 0x8, 0xff, - 0xff, 0xf6, 0x4f, 0xff, 0xff, 0xe2, 0x8, 0xff, - 0xff, 0xfb, 0x0, 0x4f, 0xff, 0xff, 0xe9, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x4f, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xff, - 0xff, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xe2, 0x0, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xe2, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe2, 0x0, 0x8, 0xff, - 0xff, 0xfb, 0x5f, 0xff, 0xff, 0xe2, 0x7, 0xff, - 0xff, 0xfb, 0x0, 0x4f, 0xff, 0xff, 0xe1, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x4f, 0xff, 0xff, 0x7a, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xf3, - 0xb, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xf4, - 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, - - /* U+F011 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xf8, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xef, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0x60, 0x0, 0xef, 0xfd, 0x0, - 0x7, 0x70, 0x0, 0x0, 0x0, 0x1, 0xcf, 0xf3, - 0x0, 0xef, 0xfd, 0x0, 0x5f, 0xfb, 0x0, 0x0, - 0x0, 0xc, 0xff, 0xfb, 0x0, 0xef, 0xfd, 0x0, - 0xcf, 0xff, 0xb0, 0x0, 0x0, 0x9f, 0xff, 0xf6, - 0x0, 0xef, 0xfd, 0x0, 0x7f, 0xff, 0xf7, 0x0, - 0x3, 0xff, 0xff, 0x60, 0x0, 0xef, 0xfd, 0x0, - 0x8, 0xff, 0xff, 0x20, 0xa, 0xff, 0xf9, 0x0, - 0x0, 0xef, 0xfd, 0x0, 0x0, 0xbf, 0xff, 0x90, - 0x1f, 0xff, 0xe0, 0x0, 0x0, 0xef, 0xfd, 0x0, - 0x0, 0x1f, 0xff, 0xf0, 0x5f, 0xff, 0x90, 0x0, - 0x0, 0xef, 0xfd, 0x0, 0x0, 0xa, 0xff, 0xf3, - 0x8f, 0xff, 0x40, 0x0, 0x0, 0xef, 0xfd, 0x0, - 0x0, 0x6, 0xff, 0xf6, 0x9f, 0xff, 0x20, 0x0, - 0x0, 0xef, 0xfd, 0x0, 0x0, 0x4, 0xff, 0xf8, - 0x9f, 0xff, 0x20, 0x0, 0x0, 0xef, 0xfc, 0x0, - 0x0, 0x4, 0xff, 0xf7, 0x8f, 0xff, 0x40, 0x0, - 0x0, 0x37, 0x72, 0x0, 0x0, 0x6, 0xff, 0xf6, - 0x5f, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xa, 0xff, 0xf4, 0x1f, 0xff, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0xf0, - 0xb, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xa0, 0x3, 0xff, 0xff, 0x60, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xff, 0x20, - 0x0, 0xaf, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x1, - 0x9f, 0xff, 0xf8, 0x0, 0x0, 0xd, 0xff, 0xff, - 0xe8, 0x42, 0x24, 0x9e, 0xff, 0xff, 0xb0, 0x0, - 0x0, 0x1, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x10, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3b, 0xff, 0xff, 0xff, 0xff, - 0xb3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x15, 0x89, 0x97, 0x51, 0x0, 0x0, 0x0, 0x0, - - /* U+F013 "" */ - 0x0, 0x0, 0x0, 0x0, 0x4, 0x89, 0x98, 0x40, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x4f, 0xff, 0xff, 0xf4, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xc, 0xc3, 0x2c, 0xff, 0xff, 0xff, 0xff, - 0xc2, 0x3c, 0xc0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, - 0x3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x30, 0xa, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, - 0xf, 0xff, 0xff, 0xff, 0xff, 0x94, 0x49, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x6, 0xef, 0xff, 0xff, - 0xf4, 0x0, 0x0, 0x4f, 0xff, 0xff, 0xfe, 0x60, - 0x0, 0x1e, 0xff, 0xff, 0x90, 0x0, 0x0, 0x9, - 0xff, 0xff, 0xe1, 0x0, 0x0, 0xf, 0xff, 0xff, - 0x40, 0x0, 0x0, 0x4, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0xf, 0xff, 0xff, 0x40, 0x0, 0x0, 0x4, - 0xff, 0xff, 0xf0, 0x0, 0x0, 0x1e, 0xff, 0xff, - 0x90, 0x0, 0x0, 0x9, 0xff, 0xff, 0xe1, 0x0, - 0x6, 0xef, 0xff, 0xff, 0xf4, 0x0, 0x0, 0x4f, - 0xff, 0xff, 0xfe, 0x60, 0xf, 0xff, 0xff, 0xff, - 0xff, 0x94, 0x49, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0xa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xa0, 0x3, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf8, 0x0, 0x0, 0xc, 0xc3, 0x2c, - 0xff, 0xff, 0xff, 0xff, 0xc2, 0x3c, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, 0xf4, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x4, 0x89, 0x98, 0x40, 0x0, 0x0, 0x0, 0x0, - - /* U+F015 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x13, 0x10, - 0x0, 0x2, 0x44, 0x20, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x5f, 0xfe, 0x40, 0x0, 0xdf, - 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xff, 0xff, 0x70, 0xe, 0xff, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, - 0xff, 0xa0, 0xef, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x1, 0xcf, 0xff, 0xb3, 0xbf, 0xff, 0xce, - 0xff, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xef, - 0xff, 0x90, 0x0, 0x9f, 0xff, 0xff, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x6, 0xff, 0xff, 0x60, 0x5d, - 0x50, 0x6f, 0xff, 0xff, 0xe0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0x30, 0x8f, 0xff, 0x70, 0x4e, - 0xff, 0xfe, 0x0, 0x0, 0x0, 0x1b, 0xff, 0xfd, - 0x20, 0xaf, 0xff, 0xff, 0xa0, 0x2d, 0xff, 0xfb, - 0x0, 0x0, 0x2d, 0xff, 0xfb, 0x1, 0xcf, 0xff, - 0xff, 0xff, 0xc1, 0xb, 0xff, 0xfd, 0x20, 0x4f, - 0xff, 0xf8, 0x3, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xe3, 0x8, 0xff, 0xfe, 0x4e, 0xff, 0xf5, 0x5, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0x5, - 0xff, 0xfe, 0x4f, 0xe3, 0x8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3, 0xef, 0x40, - 0x41, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf7, 0x1, 0x40, 0x0, 0x0, 0x8f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x80, 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, - 0xeb, 0xbb, 0xef, 0xff, 0xff, 0xf8, 0x0, 0x0, - 0x0, 0x0, 0x8f, 0xff, 0xff, 0xf4, 0x0, 0x4, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0x40, 0x0, 0x4f, 0xff, 0xff, - 0xf8, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xf4, 0x0, 0x4, 0xff, 0xff, 0xff, 0x80, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0x40, 0x0, - 0x4f, 0xff, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, - 0x7f, 0xff, 0xff, 0xf3, 0x0, 0x3, 0xff, 0xff, - 0xff, 0x70, 0x0, 0x0, 0x0, 0x3, 0xbb, 0xbb, - 0xba, 0x10, 0x0, 0x1a, 0xbb, 0xbb, 0xb3, 0x0, - 0x0, - - /* U+F019 "" */ - 0x0, 0x0, 0x0, 0x0, 0x9, 0xdd, 0xdd, 0x90, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xad, 0xdd, - 0xdf, 0xff, 0xff, 0xfd, 0xdd, 0xda, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x2d, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd1, 0x0, 0x0, - 0x0, 0x0, 0x1, 0xdf, 0xff, 0xff, 0xff, 0xff, - 0xfd, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d, - 0xff, 0xff, 0xff, 0xff, 0xd1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1, 0xdf, 0xff, 0xff, 0xfd, - 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1d, 0xff, 0xff, 0xd1, 0x0, 0x0, 0x0, 0x0, - 0x25, 0x55, 0x55, 0x55, 0x11, 0xdf, 0xfd, 0x11, - 0x55, 0x55, 0x55, 0x52, 0xef, 0xff, 0xff, 0xff, - 0xd1, 0x1d, 0xd1, 0x1d, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x10, 0x1, 0xdf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf9, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x71, 0xe7, 0x1e, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xb6, 0xfb, 0x6f, 0xff, 0xbf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - - /* U+F01C "" */ - 0x0, 0x0, 0x3, 0xcf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xd3, 0x0, 0x0, 0x0, 0x0, 0x1, - 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe1, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0x5f, 0xff, 0x40, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4f, 0xff, 0x50, 0x0, 0x0, 0x1e, - 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xfe, 0x10, 0x0, 0xa, 0xff, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xef, 0xfa, - 0x0, 0x5, 0xff, 0xf4, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x4, 0xff, 0xf5, 0x1, 0xef, - 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x9, 0xff, 0xe1, 0xaf, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, - 0xff, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x20, 0x0, 0x0, 0x2f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfa, 0x0, 0x0, 0xa, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xd3, - - /* U+F021 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3, 0x32, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x67, 0x75, 0x20, 0x0, 0x0, 0x4f, 0xff, - 0x0, 0x0, 0x0, 0x29, 0xff, 0xff, 0xff, 0xfd, - 0x70, 0x0, 0x4f, 0xff, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x60, 0x3f, 0xff, - 0x0, 0x1, 0xcf, 0xff, 0xff, 0xfe, 0xef, 0xff, - 0xff, 0xfb, 0x3f, 0xff, 0x0, 0xd, 0xff, 0xff, - 0xb4, 0x0, 0x0, 0x5b, 0xff, 0xff, 0xdf, 0xff, - 0x0, 0xaf, 0xff, 0xe4, 0x0, 0x0, 0x0, 0x0, - 0x4d, 0xff, 0xff, 0xff, 0x4, 0xff, 0xfd, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0xff, 0xff, - 0xc, 0xff, 0xf2, 0x0, 0x0, 0x0, 0x6, 0xff, - 0xee, 0xef, 0xff, 0xff, 0x1f, 0xff, 0x80, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x5f, 0xff, 0x10, 0x0, 0x0, 0x0, 0x7, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x4, 0x43, 0x0, 0x0, - 0x0, 0x0, 0x1, 0x44, 0x44, 0x44, 0x44, 0x43, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x34, 0x44, 0x44, 0x44, 0x44, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x34, 0x40, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0x0, 0x0, 0x0, 0x1, 0xff, 0xf5, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xf1, 0xff, 0xff, 0xfd, 0xee, - 0xff, 0x60, 0x0, 0x0, 0x0, 0x2f, 0xff, 0xb0, - 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0xdf, 0xff, 0x40, 0xff, 0xff, 0xff, 0xd3, - 0x0, 0x0, 0x0, 0x0, 0x4e, 0xff, 0xfa, 0x0, - 0xff, 0xfe, 0xff, 0xff, 0xb5, 0x0, 0x0, 0x4b, - 0xff, 0xff, 0xd0, 0x0, 0xff, 0xf3, 0xbf, 0xff, - 0xff, 0xfe, 0xef, 0xff, 0xff, 0xfc, 0x10, 0x0, - 0xff, 0xf3, 0x6, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x80, 0x0, 0x0, 0xff, 0xf4, 0x0, 0x17, - 0xdf, 0xff, 0xff, 0xff, 0xa2, 0x0, 0x0, 0x0, - 0xff, 0xf4, 0x0, 0x0, 0x2, 0x67, 0x76, 0x30, - 0x0, 0x0, 0x0, 0x0, 0x23, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+F026 "" */ - 0x0, 0x0, 0x0, 0x0, 0x1, 0xa7, 0x0, 0x0, - 0x0, 0x0, 0x1c, 0xff, 0x0, 0x0, 0x0, 0x1, - 0xcf, 0xff, 0x0, 0x0, 0x0, 0x1c, 0xff, 0xff, - 0x14, 0x44, 0x44, 0xcf, 0xff, 0xff, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7b, 0xbb, - 0xbb, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x5f, - 0xff, 0xff, 0x0, 0x0, 0x0, 0x5, 0xff, 0xff, - 0x0, 0x0, 0x0, 0x0, 0x5f, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x5, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x10, - - /* U+F027 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x96, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0xff, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, - 0xff, 0x0, 0x0, 0x0, 0x13, 0x33, 0x33, 0xcf, - 0xff, 0xff, 0x0, 0x0, 0x0, 0xdf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x4a, 0x20, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0xcf, 0xe1, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x3e, 0xfa, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x6, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x5, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x2e, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0, 0xcf, 0xf2, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x5b, 0x30, 0x7c, 0xcc, 0xcc, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x5f, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x5, 0xff, 0xff, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x5f, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xfd, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, - 0x0, 0x0, 0x0, - - /* U+F028 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, - 0xb1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xd1, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1a, 0x70, 0x0, - 0x0, 0x0, 0x6, 0xff, 0xd0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1c, 0xff, 0x0, 0x0, 0x6, 0x30, - 0x5, 0xff, 0xa0, 0x0, 0x0, 0x0, 0x0, 0x1c, - 0xff, 0xf0, 0x0, 0x3, 0xff, 0x70, 0x8, 0xff, - 0x40, 0x0, 0x0, 0x0, 0x1c, 0xff, 0xff, 0x0, - 0x0, 0xc, 0xff, 0x70, 0xc, 0xfc, 0x1, 0x44, - 0x44, 0x4c, 0xff, 0xff, 0xf0, 0x0, 0x0, 0xa, - 0xff, 0x30, 0x4f, 0xf3, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x5a, 0x20, 0xc, 0xfb, 0x0, - 0xdf, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0xc, 0xfe, 0x20, 0x4f, 0xf1, 0x8, 0xfb, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x2e, 0xfa, - 0x0, 0xff, 0x50, 0x5f, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0x0, 0x6f, 0xe0, 0xc, 0xf7, - 0x4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x6, 0xfe, 0x0, 0xcf, 0x70, 0x4f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x2, 0xef, - 0xa0, 0xf, 0xf5, 0x6, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0, 0xcf, 0xe2, 0x4, 0xff, - 0x10, 0x9f, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x4, 0xa2, 0x0, 0xcf, 0xb0, 0xd, 0xf8, - 0x7b, 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0xaf, 0xf3, 0x4, 0xff, 0x30, 0x0, 0x0, - 0x5, 0xff, 0xff, 0xf0, 0x0, 0x0, 0xcf, 0xf7, - 0x0, 0xcf, 0xc0, 0x0, 0x0, 0x0, 0x5, 0xff, - 0xff, 0x0, 0x0, 0x3f, 0xf7, 0x0, 0x6f, 0xf4, - 0x0, 0x0, 0x0, 0x0, 0x5, 0xff, 0xf0, 0x0, - 0x0, 0x53, 0x0, 0x4f, 0xfa, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x5, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0x6f, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xfd, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x9, 0xfb, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x0, - - /* U+F03E "" */ - 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xd3, 0xdf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, - 0xff, 0xff, 0xca, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x0, 0x1d, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xc0, 0x0, 0x4, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x0, 0x2, - 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, - 0xff, 0xe1, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, - 0x4, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x42, 0x8f, - 0xff, 0xff, 0xff, 0x40, 0x0, 0x4f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, - 0x0, 0x4, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6b, - 0xff, 0xff, 0x40, 0x0, 0x0, 0x0, 0x4f, 0xff, - 0xff, 0xff, 0xf4, 0x0, 0xbf, 0xf4, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0x40, 0x0, - 0xb, 0x40, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfd, 0x3d, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, - - /* U+F043 "" */ - 0x0, 0x0, 0x0, 0xc, 0xe3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x5, 0xff, 0xa0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xbf, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x2f, 0xff, 0xf6, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x9, 0xff, 0xff, 0xd0, - 0x0, 0x0, 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, - 0x50, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x0, 0x0, 0x1e, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0x0, 0x0, 0xa, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x0, 0x5, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x90, 0x0, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x5f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xef, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x2f, - 0xff, 0x2d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, - 0xef, 0xf1, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3c, 0xff, 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf1, 0x8f, 0xfc, 0x7, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0x1, 0xff, 0xf9, 0x2, 0x7c, 0xff, 0xff, - 0xff, 0x50, 0x7, 0xff, 0xfb, 0x40, 0x6f, 0xff, - 0xff, 0xb0, 0x0, 0xa, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xd1, 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, - 0xff, 0xb0, 0x0, 0x0, 0x0, 0x2, 0x8d, 0xff, - 0xda, 0x40, 0x0, 0x0, - - /* U+F048 "" */ - 0x34, 0x40, 0x0, 0x0, 0x0, 0x0, 0x4, 0xf, - 0xff, 0x50, 0x0, 0x0, 0x0, 0x1d, 0xfb, 0xff, - 0xf6, 0x0, 0x0, 0x0, 0x2d, 0xff, 0xff, 0xff, - 0x60, 0x0, 0x0, 0x2e, 0xff, 0xff, 0xff, 0xf6, - 0x0, 0x0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x60, - 0x0, 0x4f, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x0, - 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x60, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x8f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x8e, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf6, 0x1d, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x60, 0x1c, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf6, 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x60, 0x0, 0xa, 0xff, 0xff, 0xff, 0xff, - 0xf6, 0x0, 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, - 0x60, 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf6, - 0x0, 0x0, 0x0, 0x6, 0xff, 0xea, 0xbb, 0x30, - 0x0, 0x0, 0x0, 0x5, 0xb4, - - /* U+F04B "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3, 0xdf, 0x91, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0xff, 0xe6, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, - 0xff, 0xff, 0xfc, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xa1, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x40, 0x0, 0x0, - 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xa2, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf8, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x50, - 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xb2, 0xf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x20, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe5, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x80, 0x0, 0x0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfb, 0x20, 0x0, 0x0, 0xf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd4, 0x0, 0x0, - 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xfa, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xd3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xd, 0xff, 0xfe, 0x60, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x3d, 0xf9, 0x10, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, - - /* U+F04C "" */ - 0x19, 0xcc, 0xcc, 0xc9, 0x10, 0x0, 0x19, 0xcc, - 0xcc, 0xc9, 0x1b, 0xff, 0xff, 0xff, 0xfb, 0x0, - 0xb, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0xf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0xf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0xf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, - 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xfe, 0x0, 0xe, 0xff, 0xff, - 0xff, 0xfe, 0x5f, 0xff, 0xff, 0xff, 0x50, 0x0, - 0x5f, 0xff, 0xff, 0xff, 0x50, 0x13, 0x33, 0x33, - 0x10, 0x0, 0x0, 0x13, 0x33, 0x33, 0x10, - - /* U+F04D "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x41, 0x6, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf6, 0xef, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xb1, 0x8b, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0x81, - - /* U+F051 "" */ - 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x3b, - 0xfd, 0x10, 0x0, 0x0, 0x0, 0x5f, 0xff, 0xff, - 0xfd, 0x20, 0x0, 0x0, 0x6, 0xff, 0xff, 0xff, - 0xfe, 0x30, 0x0, 0x0, 0x6f, 0xff, 0xff, 0xff, - 0xff, 0x40, 0x0, 0x6, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x50, 0x0, 0x6f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x60, 0x6, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x86, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x8f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x16, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0, 0x6f, 0xff, - 0xff, 0xff, 0xff, 0xfb, 0x0, 0x6, 0xff, 0xff, - 0xff, 0xff, 0xfa, 0x0, 0x0, 0x6f, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x0, 0x6, 0xff, 0xff, 0xff, - 0xf7, 0x0, 0x0, 0x0, 0x6f, 0xff, 0xef, 0xf6, - 0x0, 0x0, 0x0, 0x6, 0xff, 0xf4, 0xb5, 0x0, - 0x0, 0x0, 0x0, 0x3b, 0xba, - - /* U+F052 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x37, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x5f, 0xff, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, 0x40, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xff, - 0xff, 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2f, 0xff, 0xff, 0xff, 0xfe, 0x20, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x2e, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0x20, 0x0, 0x0, 0x0, 0x0, 0x1d, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x10, 0x0, - 0x0, 0x0, 0xc, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0x0, 0x0, 0x0, 0xc, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0, 0x0, - 0xb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfa, 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0xd, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0x3d, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x0, - 0xb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfb, 0x0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xe, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0x0, 0x4b, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0x40, - - /* U+F053 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0xb0, 0x0, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0x80, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xf8, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xfa, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xfa, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, - 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0xa0, - 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0xa0, 0x0, 0x0, - 0x0, 0xa, 0xff, 0xff, 0xa0, 0x0, 0x0, 0x0, - 0xa, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0xa, - 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, 0xa, 0xfb, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, - - /* U+F054 "" */ - 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, - 0xa0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xa0, - 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0xa0, 0x0, 0x0, - 0x0, 0xa, 0xff, 0xff, 0xa0, 0x0, 0x0, 0x0, - 0xa, 0xff, 0xff, 0xa0, 0x0, 0x0, 0x0, 0xa, - 0xff, 0xff, 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, - 0xa0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xf8, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xfa, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xfa, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xfa, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xfa, - 0x0, 0x0, 0x0, 0x8, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0x0, 0xb, 0xfa, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+F067 "" */ - 0x0, 0x0, 0x0, 0x0, 0x3, 0x43, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, - 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xbf, 0xff, 0xb0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xc, 0xff, 0xfc, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcf, 0xff, - 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xc, 0xff, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xcf, 0xff, 0xc0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, 0xfc, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xcf, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xd1, 0x77, 0x77, 0x77, 0x7d, 0xff, 0xfd, 0x77, - 0x77, 0x77, 0x71, 0x0, 0x0, 0x0, 0x0, 0xcf, - 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xc, 0xff, 0xfc, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xcf, 0xff, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, - 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xcf, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xc, 0xff, 0xfc, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, - 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2, 0xab, 0xa2, 0x0, 0x0, 0x0, 0x0, - - /* U+F068 "" */ - 0x16, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x76, 0x1d, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - /* U+F06E "" */ - 0x0, 0x0, 0x0, 0x0, 0x16, 0xad, 0xef, 0xed, - 0xa6, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb2, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xff, 0xff, - 0xe9, 0x54, 0x59, 0xef, 0xff, 0xf9, 0x0, 0x0, - 0x0, 0x0, 0x2d, 0xff, 0xff, 0x90, 0x0, 0x0, - 0x0, 0x9f, 0xff, 0xfd, 0x20, 0x0, 0x0, 0x2e, - 0xff, 0xff, 0x70, 0x0, 0x14, 0x20, 0x0, 0x7f, - 0xff, 0xfe, 0x20, 0x0, 0x1e, 0xff, 0xff, 0xb0, - 0x0, 0x6, 0xff, 0xc2, 0x0, 0xbf, 0xff, 0xfe, - 0x10, 0xb, 0xff, 0xff, 0xf3, 0x0, 0x0, 0x5f, - 0xff, 0xe2, 0x3, 0xff, 0xff, 0xfb, 0x6, 0xff, - 0xff, 0xfe, 0x0, 0x0, 0x1c, 0xff, 0xff, 0xa0, - 0xe, 0xff, 0xff, 0xf5, 0xef, 0xff, 0xff, 0xc0, - 0xd, 0xcf, 0xff, 0xff, 0xfe, 0x0, 0xcf, 0xff, - 0xff, 0xee, 0xff, 0xff, 0xfc, 0x0, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0xc, 0xff, 0xff, 0xfe, 0x5f, - 0xff, 0xff, 0xe0, 0xc, 0xff, 0xff, 0xff, 0xfc, - 0x0, 0xef, 0xff, 0xff, 0x50, 0xbf, 0xff, 0xff, - 0x30, 0x4f, 0xff, 0xff, 0xff, 0x50, 0x3f, 0xff, - 0xff, 0xb0, 0x1, 0xdf, 0xff, 0xfb, 0x0, 0x7f, - 0xff, 0xff, 0x80, 0xb, 0xff, 0xff, 0xe1, 0x0, - 0x2, 0xef, 0xff, 0xf7, 0x0, 0x39, 0xb9, 0x30, - 0x7, 0xff, 0xff, 0xe2, 0x0, 0x0, 0x2, 0xcf, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0x9, 0xff, 0xff, - 0xd2, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xff, 0xfe, - 0x95, 0x45, 0x9e, 0xff, 0xff, 0x90, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2a, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x1, 0x6a, 0xdf, 0xfe, 0xda, 0x71, 0x0, - 0x0, 0x0, 0x0, - - /* U+F070 "" */ - 0x5, 0xe6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd, - 0xff, 0xfc, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, - 0xff, 0xfe, 0x40, 0x0, 0x48, 0xce, 0xff, 0xeb, - 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, - 0xff, 0xff, 0x88, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0xef, 0xff, 0xff, 0xff, 0xb6, 0x45, 0x7d, 0xff, - 0xff, 0xb1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, - 0xbf, 0xff, 0xfd, 0x20, 0x0, 0x0, 0x6, 0xff, - 0xff, 0xe4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8f, 0xff, 0xf6, 0x1, 0x76, 0x20, 0x4, 0xff, - 0xff, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, - 0x4e, 0xff, 0xfa, 0x1f, 0xff, 0x90, 0x8, 0xff, - 0xff, 0xf3, 0x0, 0x0, 0x0, 0x6e, 0x40, 0x0, - 0x2c, 0xff, 0xfd, 0xff, 0xff, 0x80, 0xf, 0xff, - 0xff, 0xe1, 0x0, 0x0, 0x2f, 0xff, 0x70, 0x0, - 0x9, 0xff, 0xff, 0xff, 0xff, 0x0, 0xbf, 0xff, - 0xff, 0x90, 0x0, 0x9, 0xff, 0xff, 0xb1, 0x0, - 0x6, 0xff, 0xff, 0xff, 0xf3, 0x9, 0xff, 0xff, - 0xff, 0x10, 0x0, 0x9f, 0xff, 0xff, 0xd1, 0x0, - 0x3, 0xdf, 0xff, 0xff, 0x30, 0x9f, 0xff, 0xff, - 0xf1, 0x0, 0x2, 0xff, 0xff, 0xff, 0x40, 0x0, - 0x1, 0xbf, 0xff, 0xf4, 0xb, 0xff, 0xff, 0xf9, - 0x0, 0x0, 0x7, 0xff, 0xff, 0xf9, 0x0, 0x0, - 0x0, 0x7f, 0xff, 0xf7, 0xff, 0xff, 0xfd, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0xf1, 0x0, 0x0, - 0x0, 0x4e, 0xff, 0xff, 0xff, 0xff, 0x20, 0x0, - 0x0, 0x0, 0xb, 0xff, 0xff, 0xc0, 0x0, 0x0, - 0x0, 0x1c, 0xff, 0xff, 0xff, 0x40, 0x0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0xc2, 0x0, 0x0, - 0x0, 0x9, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x6, 0xff, 0xff, 0xfb, 0x64, 0x51, - 0x0, 0x5, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1, 0x9f, 0xff, 0xff, 0xff, 0xe3, - 0x0, 0x2, 0xdf, 0xff, 0xc1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x5, 0x9d, 0xef, 0xfe, 0xa1, - 0x0, 0x0, 0xaf, 0xff, 0xe4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7f, 0xff, 0xf6, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x3e, 0xff, 0x80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1b, 0xc0, - - /* U+F071 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0xfc, - 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xfa, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4, 0xff, 0xff, 0xf4, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xdf, 0xff, 0xff, 0xd0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0x60, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1e, 0xff, 0xff, - 0xff, 0xfe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, - 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf2, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xbf, 0xff, 0xa4, 0x44, 0xaf, 0xff, 0xb0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f, 0xff, - 0xf7, 0x0, 0x7, 0xff, 0xff, 0x40, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xd, 0xff, 0xff, 0x80, - 0x0, 0x8f, 0xff, 0xfd, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7, 0xff, 0xff, 0xf9, 0x0, 0x9, - 0xff, 0xff, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0xff, 0xff, 0xff, 0xa0, 0x0, 0xaf, 0xff, - 0xff, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9f, - 0xff, 0xff, 0xfb, 0x0, 0xb, 0xff, 0xff, 0xff, - 0x90, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xff, 0xff, - 0xff, 0xc0, 0x0, 0xcf, 0xff, 0xff, 0xff, 0x30, - 0x0, 0x0, 0x0, 0xc, 0xff, 0xff, 0xff, 0xfd, - 0x0, 0xd, 0xff, 0xff, 0xff, 0xfc, 0x0, 0x0, - 0x0, 0x5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, - 0xff, 0xff, 0xff, 0xff, 0xf5, 0x0, 0x0, 0x0, - 0xef, 0xff, 0xff, 0xff, 0xfd, 0x10, 0x2d, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x0, 0x0, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0x60, 0x0, 0x6f, 0xff, 0xff, - 0xff, 0xff, 0x70, 0x0, 0x1f, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x10, 0xa, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf5, 0x26, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfa, - 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xd, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0x3d, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfd, 0x30, - - /* U+F074 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x69, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xfc, 0x0, 0x9b, 0xbb, 0xbb, 0x30, - 0x0, 0x0, 0x0, 0x3b, 0xbb, 0xff, 0xff, 0xc0, - 0xff, 0xff, 0xff, 0xf3, 0x0, 0x0, 0x2, 0xef, - 0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xfe, - 0x20, 0x0, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xff, 0xe1, 0x1, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xe3, 0x0, 0x0, 0x3e, 0xff, - 0xe2, 0xc, 0xff, 0xfe, 0x20, 0xff, 0xfe, 0x30, - 0x0, 0x0, 0x3, 0xff, 0x30, 0xaf, 0xff, 0xf3, - 0x0, 0xff, 0xe3, 0x0, 0x0, 0x0, 0x0, 0x54, - 0x9, 0xff, 0xff, 0x40, 0x0, 0xbe, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xff, 0xf6, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, - 0xff, 0xff, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x4f, 0xff, 0xf9, 0x4, 0x50, - 0x0, 0xbe, 0x30, 0x0, 0x0, 0x0, 0x3, 0xff, - 0xff, 0xa0, 0x3f, 0xf3, 0x0, 0xff, 0xe3, 0x0, - 0x0, 0x0, 0x2e, 0xff, 0xfc, 0x2, 0xef, 0xfe, - 0x30, 0xff, 0xfe, 0x30, 0xff, 0xff, 0xff, 0xff, - 0xd1, 0x1, 0xef, 0xff, 0xff, 0xff, 0xff, 0xe3, - 0xff, 0xff, 0xff, 0xfe, 0x10, 0x0, 0x2e, 0xff, - 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xe2, - 0x0, 0x0, 0x3, 0xff, 0xff, 0xff, 0xff, 0xfb, - 0x9b, 0xbb, 0xbb, 0x30, 0x0, 0x0, 0x0, 0x3b, - 0xbb, 0xff, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xfc, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x69, 0x0, 0x0, - - /* U+F077 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, - 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, 0x90, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, - 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xfd, 0xff, 0xff, 0x90, 0x0, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xf9, 0xa, 0xff, 0xff, 0x90, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xf9, 0x0, 0xa, - 0xff, 0xff, 0x90, 0x0, 0x0, 0xaf, 0xff, 0xf9, - 0x0, 0x0, 0xa, 0xff, 0xff, 0x90, 0x0, 0xaf, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, - 0x90, 0x9f, 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, - 0xa, 0xff, 0xff, 0x79, 0xff, 0xf9, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xa, 0xff, 0xf8, 0xb, 0xf9, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0xfa, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0x0, - - /* U+F078 "" */ - 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x20, 0x0, 0xbf, 0x90, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xaf, 0xa0, 0x9f, 0xff, 0x90, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0x89, - 0xff, 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, 0xaf, - 0xff, 0xf7, 0xa, 0xff, 0xff, 0x90, 0x0, 0x0, - 0x0, 0xaf, 0xff, 0xf9, 0x0, 0xa, 0xff, 0xff, - 0x90, 0x0, 0x0, 0xaf, 0xff, 0xf9, 0x0, 0x0, - 0xa, 0xff, 0xff, 0x90, 0x0, 0xaf, 0xff, 0xf9, - 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0x90, 0xaf, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xdf, 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xa, 0xff, 0xff, 0xff, 0xf9, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xa, 0xff, 0xff, 0xf9, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xa, 0xf9, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x0, 0x0, 0x0, - - /* U+F079 "" */ - 0x0, 0x0, 0x3, 0xd9, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x3, 0xef, 0xfa, 0x0, 0x0, 0x34, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x10, 0x0, 0x0, 0x0, - 0x3, 0xef, 0xff, 0xfa, 0x0, 0x7f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, - 0xef, 0xff, 0xff, 0xfa, 0x5, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf1, 0x0, 0x0, 0x3, 0xff, - 0xff, 0xff, 0xff, 0xfa, 0x5, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbf, 0xff, 0x10, 0x0, 0x0, 0xef, 0xfe, - 0xdf, 0xfb, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xef, 0xf1, 0x0, 0x0, 0xd, 0xfe, 0x2b, - 0xff, 0x48, 0xff, 0x60, 0x0, 0x0, 0x0, 0x0, - 0xe, 0xff, 0x10, 0x0, 0x0, 0x17, 0x20, 0xbf, - 0xf4, 0x5, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xef, 0xf1, 0x0, 0x0, 0x0, 0x0, 0xb, 0xff, - 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, - 0xff, 0x10, 0x0, 0x0, 0x0, 0x0, 0xbf, 0xf4, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xef, - 0xf1, 0x0, 0x0, 0x0, 0x0, 0xb, 0xff, 0x40, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xff, - 0x10, 0x0, 0x0, 0x0, 0x0, 0xbf, 0xf4, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xaf, 0x70, 0xef, 0xf1, - 0x4f, 0xc0, 0x0, 0x0, 0xb, 0xff, 0x40, 0x0, - 0x0, 0x0, 0x0, 0x3f, 0xff, 0x6e, 0xff, 0x5f, - 0xff, 0x60, 0x0, 0x0, 0xbf, 0xf7, 0x44, 0x44, - 0x44, 0x44, 0x20, 0xcf, 0xff, 0xff, 0xff, 0xff, - 0xd1, 0x0, 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x50, 0xbf, 0xff, 0xff, 0xff, 0xd1, - 0x0, 0x0, 0x0, 0xbf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0x0, 0xbf, 0xff, 0xff, 0xd1, 0x0, - 0x0, 0x0, 0x4, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0x60, 0x0, 0xbf, 0xff, 0xd1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xbf, 0xd1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, - - /* U+F07B "" */ - 0x3d, 0xff, 0xff, 0xff, 0xff, 0x40, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xdf, 0xff, 0xff, 0xff, - 0xff, 0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfd, 0x3d, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, - - /* U+F093 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0xa0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xbf, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xb, 0xff, 0xff, 0xb0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xbf, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, - 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, - 0xff, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xb0, 0x0, 0x0, 0x0, 0x0, 0xbf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0x0, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x2, 0x22, - 0x2f, 0xff, 0xff, 0xf2, 0x22, 0x20, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x25, 0x55, 0x55, 0x52, 0xf, 0xff, 0xff, 0xf0, - 0x25, 0x55, 0x55, 0x52, 0xef, 0xff, 0xff, 0xf9, - 0xc, 0xff, 0xff, 0xc0, 0x9f, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xff, 0x20, 0x1, 0x10, 0x2, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf9, 0x88, 0x88, 0x9f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x71, 0xe7, 0x1e, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xb6, 0xfb, 0x6f, 0xff, 0xbf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - - /* U+F095 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xd, 0xea, 0x63, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x6, 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4f, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xff, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, 0xff, 0xc0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f, - 0xff, 0xff, 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x9f, 0xff, 0xff, 0xff, - 0x60, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x6f, 0xff, 0xff, 0xf2, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6f, 0xff, - 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0x60, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xff, - 0xff, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1, 0xdf, 0xff, 0xf7, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, - 0xff, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x1, 0x40, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, 0x30, 0x0, - 0x0, 0x0, 0x3a, 0xff, 0xa0, 0x0, 0x1, 0xbf, - 0xff, 0xff, 0x70, 0x0, 0x0, 0x5, 0xcf, 0xff, - 0xff, 0x70, 0x3, 0xdf, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0xd, 0xff, 0xff, 0xff, 0xff, 0x6a, 0xff, - 0xff, 0xff, 0xb0, 0x0, 0x0, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0xa, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x70, 0x0, 0x0, 0x0, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x30, 0x0, - 0x0, 0x0, 0x0, 0x3, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xe7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xff, 0xfc, 0x60, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xfe, 0xc9, - 0x62, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, - - /* U+F0C4 "" */ - 0x0, 0x2, 0x42, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0xcf, 0xff, 0xc2, 0x0, - 0x0, 0x0, 0x0, 0x37, 0x73, 0x0, 0x2e, 0xff, - 0xff, 0xfe, 0x20, 0x0, 0x0, 0x8, 0xff, 0xff, - 0x90, 0xaf, 0xff, 0xcf, 0xff, 0xa0, 0x0, 0x0, - 0x9f, 0xff, 0xff, 0xb0, 0xef, 0xf4, 0x4, 0xff, - 0xe0, 0x0, 0x9, 0xff, 0xff, 0xfb, 0x0, 0xff, - 0xf1, 0x1, 0xff, 0xf0, 0x0, 0x9f, 0xff, 0xff, - 0xb0, 0x0, 0xcf, 0xfb, 0x5b, 0xff, 0xc0, 0x9, - 0xff, 0xff, 0xfb, 0x0, 0x0, 0x5f, 0xff, 0xff, - 0xff, 0xf5, 0x9f, 0xff, 0xff, 0xb0, 0x0, 0x0, - 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - 0x0, 0x0, 0x0, 0x0, 0x39, 0xbe, 0xff, 0xff, - 0xff, 0xff, 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2, 0xef, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, 0xf5, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x49, 0xff, - 0xff, 0xff, 0xff, 0x50, 0x0, 0x0, 0x0, 0x2, - 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0x0, - 0x0, 0x0, 0x2e, 0xff, 0xff, 0xff, 0xfb, 0xef, - 0xff, 0xff, 0x50, 0x0, 0x0, 0xaf, 0xff, 0xcf, - 0xff, 0xd0, 0x2e, 0xff, 0xff, 0xf5, 0x0, 0x0, - 0xef, 0xf4, 0x4, 0xff, 0xe0, 0x2, 0xef, 0xff, - 0xff, 0x50, 0x0, 0xff, 0xf1, 0x1, 0xff, 0xf0, - 0x0, 0x2e, 0xff, 0xff, 0xf5, 0x0, 0xcf, 0xfb, - 0x5b, 0xff, 0xc0, 0x0, 0x2, 0xef, 0xff, 0xff, - 0x50, 0x5f, 0xff, 0xff, 0xff, 0x50, 0x0, 0x0, - 0x2e, 0xff, 0xff, 0xd0, 0x8, 0xff, 0xff, 0xf8, - 0x0, 0x0, 0x0, 0x1, 0xae, 0xea, 0x20, 0x0, - 0x39, 0xb9, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, - - /* U+F0C5 "" */ - 0x0, 0x0, 0x0, 0xbf, 0xff, 0xff, 0xff, 0xf0, - 0x7a, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, - 0xff, 0xff, 0x8, 0xfb, 0x0, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xfb, 0x0, - 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0x8, - 0xff, 0xfa, 0x47, 0x88, 0x40, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x48, 0x88, 0x7f, 0xff, 0xf8, 0xf, - 0xff, 0xff, 0xff, 0xff, 0x40, 0x0, 0x0, 0xff, - 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf8, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf8, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf8, 0xf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0x4, 0x78, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x74, 0xff, 0xff, 0xfa, 0x10, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfb, 0x0, 0x0, 0x0, - - /* U+F0C7 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x42, - 0x0, 0x0, 0x6, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf8, 0x0, 0x0, 0xef, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0xf, - 0xff, 0xcb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbd, 0xff, - 0xf8, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xf, 0xff, 0xf8, 0xf, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xf7, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xef, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, - 0x54, 0x44, 0x44, 0x44, 0x44, 0x45, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0xce, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0, - 0x0, 0xc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x80, 0x0, 0x0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfa, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf2, 0x0, - 0x2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf7, 0x57, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xb1, 0x8b, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0x81, - - /* U+F0C9 "" */ - 0x13, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, - 0x33, 0x33, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0x13, 0x33, 0x33, 0x33, 0x33, 0x33, - 0x33, 0x33, 0x33, 0x33, 0x10, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x57, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x5f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfc, 0xee, 0xee, 0xee, 0xee, - 0xee, 0xee, 0xee, 0xee, 0xee, 0xeb, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x33, 0x33, - 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x31, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe1, - 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, - 0x33, 0x31, - - /* U+F0E0 "" */ - 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xd3, 0xdf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x2d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xd2, 0x0, 0x9f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x0, - 0xe4, 0x5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x50, 0x4e, 0xff, 0x80, 0x2c, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xc2, 0x8, 0xff, - 0xff, 0xfc, 0x20, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xf9, 0x1, 0xcf, 0xff, 0xff, 0xff, 0xf5, 0x4, - 0xef, 0xff, 0xff, 0xfe, 0x40, 0x5e, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x90, 0x1c, 0xff, 0xff, 0xb1, - 0x9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, - 0x20, 0x6d, 0xd6, 0x2, 0xdf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf6, 0x0, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xd9, 0x9d, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfd, 0x3d, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, - - /* U+F0E7 "" */ - 0x0, 0x4f, 0xff, 0xff, 0xff, 0xf3, 0x0, 0x0, - 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, 0x60, 0x0, - 0x0, 0x0, 0xbf, 0xff, 0xff, 0xff, 0xf1, 0x0, - 0x0, 0x0, 0xd, 0xff, 0xff, 0xff, 0xfc, 0x0, - 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x70, - 0x0, 0x0, 0x0, 0x1f, 0xff, 0xff, 0xff, 0xf2, - 0x0, 0x0, 0x0, 0x3, 0xff, 0xff, 0xff, 0xfc, - 0x0, 0x0, 0x0, 0x0, 0x5f, 0xff, 0xff, 0xff, - 0xc8, 0x88, 0x87, 0x30, 0x8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0xaf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xa0, 0xc, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf2, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0xf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0, 0x0, 0x37, - 0x88, 0x88, 0xaf, 0xff, 0xff, 0x50, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xc0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xcf, 0xff, 0xf3, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xf, 0xff, 0xfa, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3, 0xff, 0xff, 0x10, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xff, 0x70, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xb, 0xff, 0xd0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xf4, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xfb, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xff, 0x20, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f, 0x70, - 0x0, 0x0, 0x0, 0x0, - - /* U+F0EA "" */ - 0x0, 0x0, 0x3, 0xdf, 0xd3, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x4, 0x78, 0x88, 0xff, 0xef, 0xf8, - 0x88, 0x74, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, - 0x90, 0x9f, 0xff, 0xff, 0xf0, 0x0, 0x0, 0xf, - 0xff, 0xff, 0xf9, 0x9, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, - 0xff, 0xf0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xe5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xf, 0xff, 0xff, 0xf4, 0x7, 0x88, 0x88, - 0x88, 0x3, 0x30, 0x0, 0xff, 0xff, 0xff, 0x7, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0x40, 0xf, 0xff, - 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, 0x8, 0xff, - 0x40, 0xff, 0xff, 0xff, 0x8, 0xff, 0xff, 0xff, - 0xf0, 0x8f, 0xff, 0x4f, 0xff, 0xff, 0xf0, 0x8f, - 0xff, 0xff, 0xff, 0x8, 0xff, 0xfe, 0xff, 0xff, - 0xff, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, - 0xf, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xb8, 0x88, 0x88, 0xff, 0xff, 0xff, 0x8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x8, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, - 0x78, 0x88, 0x80, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfb, - - /* U+F0F3 "" */ - 0x0, 0x0, 0x0, 0x0, 0x8, 0xf8, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0x6f, 0xff, 0x51, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf8, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xc, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x0, 0xa, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf9, 0x0, 0x0, 0x0, - 0x4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x90, 0x0, 0x0, 0xe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf1, 0x0, 0x0, 0x4f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x0, 0xdf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xd0, 0x0, 0x5f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x50, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0xdf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd2, - 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x6f, 0xff, 0xff, 0x60, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x1, 0xff, 0xff, 0xe1, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xcf, 0xc3, - 0x0, 0x0, 0x0, 0x0, - - /* U+F11C "" */ - 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x3d, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x10, 0x1f, 0x90, 0x9, 0xf1, 0x1, - 0xf9, 0x0, 0x9f, 0x10, 0x1f, 0xff, 0xff, 0xf0, - 0x0, 0xf8, 0x0, 0x8f, 0x0, 0xf, 0x80, 0x8, - 0xf0, 0x0, 0xff, 0xff, 0xff, 0x10, 0x1f, 0x90, - 0x9, 0xf1, 0x1, 0xf9, 0x0, 0x9f, 0x10, 0x1f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xb8, 0x8f, 0xe8, 0x8b, 0xfb, 0x88, 0xfe, - 0x88, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, - 0xcc, 0x0, 0x4f, 0x40, 0xc, 0xc0, 0x4, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x40, 0xc, 0xc0, 0x4, - 0xf4, 0x0, 0xcc, 0x0, 0x4f, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x88, 0xfe, 0x88, 0xbf, 0xb8, 0x8f, - 0xe8, 0x8b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf1, 0x1, 0xf9, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x9, 0xf1, 0x1, 0xff, 0xff, - 0xff, 0x0, 0xf, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0x0, 0xf, 0xff, 0xff, 0xf1, 0x1, - 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xf1, - 0x1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xd3, - - /* U+F124 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3a, - 0xfc, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x4b, 0xff, 0xff, 0xc0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, - 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x6e, 0xff, 0xff, 0xff, 0xff, - 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x8e, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x0, 0x0, - 0x0, 0x0, 0x2, 0x9f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0x0, 0x0, 0x0, 0x0, 0x3, 0xaf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, - 0x0, 0x0, 0x4, 0xcf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xc0, 0x0, 0x0, 0x6, 0xdf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x50, 0x0, 0x3, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0, 0x0, 0xd, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf6, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x0, - 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x57, - 0x88, 0x88, 0x88, 0x8c, 0xff, 0xff, 0xff, 0xff, - 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xff, 0xff, 0xf9, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, - 0xff, 0xf2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xa0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0x30, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, 0xfc, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xf4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, - 0xff, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7, 0xff, 0xff, 0x60, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x5, 0xff, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xd3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, - - /* U+F15B "" */ - 0xbf, 0xff, 0xff, 0xff, 0xff, 0x80, 0xe4, 0x0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, - 0x40, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0xff, 0xf4, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x80, 0xff, 0xff, 0x40, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x80, 0xff, 0xff, 0xf4, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x80, 0xff, 0xff, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0x88, 0x88, 0x88, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, - - /* U+F1EB "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x3, 0x56, 0x77, 0x65, - 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0x7c, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xc7, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, - 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0x50, 0x0, 0x0, 0x0, 0x3, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfd, 0x30, 0x0, 0x0, 0x8f, 0xff, 0xff, 0xff, - 0xc9, 0x65, 0x44, 0x56, 0x9c, 0xff, 0xff, 0xff, - 0xf8, 0x0, 0x1c, 0xff, 0xff, 0xfd, 0x61, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x16, 0xdf, 0xff, 0xff, - 0xc1, 0xdf, 0xff, 0xfe, 0x50, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x5, 0xef, 0xff, 0xfd, - 0x9f, 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x9, 0xff, 0xf9, 0x9, - 0xf6, 0x0, 0x0, 0x0, 0x48, 0xcd, 0xff, 0xdc, - 0x84, 0x0, 0x0, 0x0, 0x6f, 0x90, 0x0, 0x10, - 0x0, 0x0, 0x6e, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe6, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, - 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xd3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xff, - 0xff, 0xff, 0xfe, 0xcc, 0xef, 0xff, 0xff, 0xff, - 0x50, 0x0, 0x0, 0x0, 0x0, 0x8, 0xff, 0xff, - 0xc5, 0x10, 0x0, 0x1, 0x5c, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xe4, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x4e, 0xfa, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x6, 0x10, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1, 0x60, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x32, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d, 0xff, 0xc1, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xbf, 0xff, 0xfb, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xdf, 0xff, 0xfd, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x5f, 0xff, 0xf5, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x4, 0xaa, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, - - /* U+F240 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x30, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xfb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbd, 0xff, 0xa1, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0xff, 0xf0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5, 0xbf, - 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0, 0xf, 0xff, 0xff, - 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x2, 0x4f, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x4a, 0xff, 0xd7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0x18, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xa4, 0x0, - - /* U+F241 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x30, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xfb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbd, 0xff, 0xa1, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0xff, 0xf0, 0xbf, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf4, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0xf0, 0xbf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf4, 0x0, 0x0, 0x5, 0xbf, - 0xff, 0xff, 0xf0, 0xbf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf4, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf4, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, - 0xf0, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf4, 0x0, 0x0, 0x2, 0x4f, 0xff, 0xff, 0xf0, - 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x4a, 0xff, 0xd7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0x18, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xa4, 0x0, - - /* U+F242 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x30, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xfb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbd, 0xff, 0xa1, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0xff, 0xf0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xbf, - 0xff, 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, - 0xf0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x4f, 0xff, 0xff, 0xf0, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x4a, 0xff, 0xd7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0x18, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xa4, 0x0, - - /* U+F243 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x30, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xfb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbd, 0xff, 0xa1, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0xff, 0xf0, 0xbf, 0xff, 0xff, - 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0xf0, 0xbf, 0xff, 0xff, 0x40, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xbf, - 0xff, 0xff, 0xf0, 0xbf, 0xff, 0xff, 0x40, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0xbf, 0xff, 0xff, 0x40, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, - 0xf0, 0xbf, 0xff, 0xff, 0x40, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x4f, 0xff, 0xff, 0xf0, - 0xbf, 0xff, 0xff, 0x40, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x4a, 0xff, 0xd7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0x18, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xa4, 0x0, - - /* U+F244 "" */ - 0x1, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x30, 0x0, 0x6f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfd, 0x0, 0xef, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xfb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbd, 0xff, 0xa1, 0xff, 0xf0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x8, 0xff, 0xfe, 0xff, 0xf0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xbf, - 0xff, 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, - 0xff, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x4f, 0xff, 0xff, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xf0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xf4, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x4a, 0xff, 0xd7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x70, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0x18, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xa4, 0x0, - - /* U+F287 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2d, - 0xfe, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x27, 0x7d, 0xff, - 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x4f, 0xff, 0xff, 0xff, - 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xe, 0xf5, 0x3a, 0xff, 0xfb, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x7, 0xf6, 0x0, 0x9, 0xda, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x0, 0xed, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x9f, 0xfe, 0x50, - 0x0, 0x6f, 0x60, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xa4, 0x0, 0x0, 0x8f, 0xff, 0xff, 0x30, - 0x1e, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xf, 0xfa, 0x10, 0xe, 0xff, 0xff, 0xfd, 0xbe, - 0xfe, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xff, 0xff, 0x60, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfb, 0xa, 0xff, 0xff, 0xf5, 0x0, 0x0, - 0x1c, 0xf2, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xd4, 0x0, 0x1c, 0xff, 0xf9, 0x0, 0x0, 0x0, - 0x2f, 0xa0, 0x0, 0x0, 0x0, 0x0, 0xe, 0x70, - 0x0, 0x0, 0x4, 0x63, 0x0, 0x0, 0x0, 0x0, - 0xbf, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0xfb, 0x0, 0x8f, 0xff, 0xf5, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, - 0xf8, 0x4b, 0xff, 0xff, 0x60, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, - 0xff, 0xff, 0xff, 0xf6, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x5c, 0xff, 0xff, 0x60, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x9f, 0xff, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x11, 0x10, 0x0, 0x0, 0x0, 0x0, - - /* U+F293 "" */ - 0x0, 0x0, 0x2, 0x8c, 0xef, 0xfe, 0xa6, 0x0, - 0x0, 0x0, 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0x30, 0x0, 0x0, 0xc, 0xff, 0xff, 0xf4, - 0xff, 0xff, 0xff, 0x40, 0x0, 0xa, 0xff, 0xff, - 0xff, 0x5, 0xff, 0xff, 0xfe, 0x10, 0x2, 0xff, - 0xff, 0xff, 0xf0, 0x5, 0xff, 0xff, 0xf8, 0x0, - 0x9f, 0xff, 0xff, 0xff, 0x0, 0x6, 0xff, 0xff, - 0xe0, 0xe, 0xff, 0xfc, 0xff, 0xf0, 0x16, 0x7, - 0xff, 0xff, 0x21, 0xff, 0xf8, 0x9, 0xff, 0x1, - 0xf6, 0x7, 0xff, 0xf5, 0x4f, 0xff, 0xd1, 0x9, - 0xf0, 0x1f, 0x70, 0x6f, 0xff, 0x86, 0xff, 0xff, - 0xd1, 0x7, 0x1, 0x70, 0x5f, 0xff, 0xf9, 0x7f, - 0xff, 0xff, 0xd1, 0x0, 0x0, 0x3f, 0xff, 0xff, - 0xa7, 0xff, 0xff, 0xff, 0xc1, 0x0, 0x2e, 0xff, - 0xff, 0xfb, 0x7f, 0xff, 0xff, 0xff, 0x30, 0x5, - 0xff, 0xff, 0xff, 0xb7, 0xff, 0xff, 0xff, 0x40, - 0x0, 0x6, 0xff, 0xff, 0xfa, 0x6f, 0xff, 0xff, - 0x40, 0x30, 0x3, 0x7, 0xff, 0xff, 0xa4, 0xff, - 0xff, 0x40, 0x4e, 0x1, 0xe2, 0x8, 0xff, 0xf8, - 0x2f, 0xff, 0x70, 0x4f, 0xf0, 0x1f, 0x90, 0x2f, - 0xff, 0x60, 0xef, 0xff, 0x7f, 0xff, 0x1, 0xb0, - 0x2e, 0xff, 0xf3, 0xa, 0xff, 0xff, 0xff, 0xf0, - 0x0, 0x2e, 0xff, 0xff, 0x0, 0x4f, 0xff, 0xff, - 0xff, 0x0, 0x2e, 0xff, 0xff, 0x90, 0x0, 0xbf, - 0xff, 0xff, 0xf0, 0x2e, 0xff, 0xff, 0xf2, 0x0, - 0x1, 0xdf, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xf7, - 0x0, 0x0, 0x0, 0xaf, 0xff, 0xff, 0xff, 0xff, - 0xf7, 0x0, 0x0, 0x0, 0x0, 0x28, 0xce, 0xff, - 0xec, 0x82, 0x0, 0x0, - - /* U+F2ED "" */ - 0x0, 0x0, 0x0, 0x1a, 0xcc, 0xcc, 0xca, 0x10, - 0x0, 0x0, 0x2, 0x44, 0x44, 0x49, 0xff, 0xff, - 0xff, 0xf9, 0x44, 0x44, 0x42, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x9b, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0x80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf8, 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0x8f, - 0xff, 0x66, 0xff, 0xd1, 0xdf, 0xf6, 0x6f, 0xff, - 0x80, 0x8, 0xff, 0xf4, 0x4f, 0xfc, 0xc, 0xff, - 0x44, 0xff, 0xf8, 0x0, 0x8f, 0xff, 0x44, 0xff, - 0xc0, 0xcf, 0xf4, 0x4f, 0xff, 0x80, 0x8, 0xff, - 0xf4, 0x4f, 0xfc, 0xc, 0xff, 0x44, 0xff, 0xf8, - 0x0, 0x8f, 0xff, 0x44, 0xff, 0xc0, 0xcf, 0xf4, - 0x4f, 0xff, 0x80, 0x8, 0xff, 0xf4, 0x4f, 0xfc, - 0xc, 0xff, 0x44, 0xff, 0xf8, 0x0, 0x8f, 0xff, - 0x44, 0xff, 0xc0, 0xcf, 0xf4, 0x4f, 0xff, 0x80, - 0x8, 0xff, 0xf4, 0x4f, 0xfc, 0xc, 0xff, 0x44, - 0xff, 0xf8, 0x0, 0x8f, 0xff, 0x44, 0xff, 0xc0, - 0xcf, 0xf4, 0x4f, 0xff, 0x80, 0x8, 0xff, 0xf4, - 0x4f, 0xfc, 0xc, 0xff, 0x44, 0xff, 0xf8, 0x0, - 0x8f, 0xff, 0x44, 0xff, 0xc0, 0xcf, 0xf4, 0x4f, - 0xff, 0x80, 0x8, 0xff, 0xf6, 0x6f, 0xfd, 0x1d, - 0xff, 0x66, 0xff, 0xf8, 0x0, 0x7f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, 0x5, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf5, 0x0, 0x9, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf9, 0x0, - - /* U+F304 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x6e, 0xe5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xf6, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xf6, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0xff, - 0xff, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x50, 0x3f, 0xff, 0xff, 0xff, 0xe0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xb0, 0x3f, - 0xff, 0xff, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xb0, 0x3f, 0xff, 0xff, 0x60, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xb0, 0x3f, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xb0, 0x3f, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xb0, 0x10, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x50, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x5f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xb, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdf, - 0xff, 0xff, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xbf, 0xdb, 0xa8, 0x50, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, - - /* U+F55A "" */ - 0x0, 0x0, 0x0, 0x2, 0xbf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x0, - 0x0, 0x0, 0x3e, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, 0x0, - 0x3, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0, 0x0, 0x3e, - 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xfc, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x3, 0xef, 0xff, - 0xff, 0xff, 0xf8, 0x6, 0xff, 0xff, 0x60, 0x8f, - 0xff, 0xff, 0xff, 0x0, 0x3e, 0xff, 0xff, 0xff, - 0xff, 0xc0, 0x0, 0x6f, 0xf6, 0x0, 0xc, 0xff, - 0xff, 0xff, 0x3, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xf6, 0x0, 0x6, 0x60, 0x0, 0x6f, 0xff, 0xff, - 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x60, 0x0, 0x0, 0x6, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, - 0x0, 0x0, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xdf, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, 0x0, - 0x0, 0x6f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x60, 0x0, 0x0, - 0x6, 0xff, 0xff, 0xff, 0xff, 0x3, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf6, 0x0, 0x6, 0x60, 0x0, - 0x6f, 0xff, 0xff, 0xff, 0x0, 0x3e, 0xff, 0xff, - 0xff, 0xff, 0xc0, 0x0, 0x6f, 0xf6, 0x0, 0xc, - 0xff, 0xff, 0xff, 0x0, 0x3, 0xef, 0xff, 0xff, - 0xff, 0xf8, 0x6, 0xff, 0xff, 0x60, 0x8f, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x3e, 0xff, 0xff, 0xff, - 0xff, 0xcf, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0x0, 0x0, 0x3, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x0, 0x0, 0x0, 0x3e, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0, - 0x0, 0x0, 0x2, 0xbf, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, - - /* U+F7C2 "" */ - 0x0, 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x80, 0x0, 0x0, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x0, 0x8, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x0, 0x8f, 0xf4, 0x8, 0xf0, - 0xe, 0x90, 0xf, 0xff, 0x8, 0xff, 0xf4, 0x8, - 0xf0, 0xe, 0x90, 0xf, 0xff, 0x8f, 0xff, 0xf4, - 0x8, 0xf0, 0xe, 0x90, 0xf, 0xff, 0xff, 0xff, - 0xf4, 0x8, 0xf0, 0xe, 0x90, 0xf, 0xff, 0xff, - 0xff, 0xfa, 0x8c, 0xf8, 0x8f, 0xc8, 0x8f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x8f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x8, - 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, - - /* U+F8A2 "" */ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, - 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x7, 0xff, 0x10, 0x0, 0x0, - 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, - 0xff, 0xf1, 0x0, 0x0, 0x1c, 0xf7, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0x10, 0x0, - 0x1d, 0xff, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xa, 0xff, 0xf1, 0x0, 0x2d, 0xff, 0xf9, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf, 0xff, 0x10, - 0x2e, 0xff, 0xff, 0xa2, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x2b, 0xff, 0xf1, 0x3e, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x1d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf1, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0, 0x8f, 0xff, 0xff, 0xd9, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x60, 0x0, 0x7f, - 0xff, 0xf9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x6f, 0xff, 0x90, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x5f, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4a, 0x20, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 -}; - - -/*--------------------- - * GLYPH DESCRIPTION - *--------------------*/ - -static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { - {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, - {.bitmap_index = 0, .adv_w = 103, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 0, .adv_w = 103, .box_w = 4, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 34, .adv_w = 150, .box_w = 7, .box_h = 7, .ofs_x = 1, .ofs_y = 10}, - {.bitmap_index = 59, .adv_w = 270, .box_w = 17, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 204, .adv_w = 238, .box_w = 14, .box_h = 23, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 365, .adv_w = 324, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 535, .adv_w = 263, .box_w = 16, .box_h = 18, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 679, .adv_w = 81, .box_w = 3, .box_h = 7, .ofs_x = 1, .ofs_y = 10}, - {.bitmap_index = 690, .adv_w = 129, .box_w = 6, .box_h = 23, .ofs_x = 2, .ofs_y = -5}, - {.bitmap_index = 759, .adv_w = 130, .box_w = 6, .box_h = 23, .ofs_x = 0, .ofs_y = -5}, - {.bitmap_index = 828, .adv_w = 154, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = 8}, - {.bitmap_index = 878, .adv_w = 223, .box_w = 12, .box_h = 11, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 944, .adv_w = 87, .box_w = 4, .box_h = 7, .ofs_x = 1, .ofs_y = -4}, - {.bitmap_index = 958, .adv_w = 147, .box_w = 7, .box_h = 3, .ofs_x = 1, .ofs_y = 6}, - {.bitmap_index = 969, .adv_w = 87, .box_w = 4, .box_h = 4, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 977, .adv_w = 135, .box_w = 11, .box_h = 23, .ofs_x = -1, .ofs_y = -2}, - {.bitmap_index = 1104, .adv_w = 256, .box_w = 14, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 1223, .adv_w = 142, .box_w = 7, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1283, .adv_w = 220, .box_w = 13, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1394, .adv_w = 220, .box_w = 13, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1505, .adv_w = 257, .box_w = 16, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1641, .adv_w = 220, .box_w = 13, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1752, .adv_w = 237, .box_w = 14, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 1871, .adv_w = 230, .box_w = 14, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1990, .adv_w = 247, .box_w = 14, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 2109, .adv_w = 237, .box_w = 14, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 2228, .adv_w = 87, .box_w = 4, .box_h = 13, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 2254, .adv_w = 87, .box_w = 4, .box_h = 17, .ofs_x = 1, .ofs_y = -4}, - {.bitmap_index = 2288, .adv_w = 223, .box_w = 12, .box_h = 11, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 2354, .adv_w = 223, .box_w = 12, .box_h = 8, .ofs_x = 1, .ofs_y = 5}, - {.bitmap_index = 2402, .adv_w = 223, .box_w = 12, .box_h = 11, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 2468, .adv_w = 220, .box_w = 13, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 2579, .adv_w = 397, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -5}, - {.bitmap_index = 2832, .adv_w = 281, .box_w = 19, .box_h = 17, .ofs_x = -1, .ofs_y = 0}, - {.bitmap_index = 2994, .adv_w = 291, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3122, .adv_w = 278, .box_w = 16, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 3258, .adv_w = 317, .box_w = 17, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3403, .adv_w = 257, .box_w = 13, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3514, .adv_w = 244, .box_w = 13, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3625, .adv_w = 296, .box_w = 16, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 3761, .adv_w = 312, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3889, .adv_w = 119, .box_w = 3, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 3915, .adv_w = 197, .box_w = 11, .box_h = 17, .ofs_x = -1, .ofs_y = 0}, - {.bitmap_index = 4009, .adv_w = 276, .box_w = 16, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 4145, .adv_w = 228, .box_w = 13, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 4256, .adv_w = 367, .box_w = 19, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 4418, .adv_w = 312, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 4546, .adv_w = 323, .box_w = 19, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 4708, .adv_w = 277, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 4836, .adv_w = 323, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 5026, .adv_w = 279, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 5154, .adv_w = 238, .box_w = 14, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 5273, .adv_w = 225, .box_w = 14, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 5392, .adv_w = 304, .box_w = 15, .box_h = 17, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 5520, .adv_w = 273, .box_w = 19, .box_h = 17, .ofs_x = -1, .ofs_y = 0}, - {.bitmap_index = 5682, .adv_w = 432, .box_w = 27, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 5912, .adv_w = 258, .box_w = 16, .box_h = 17, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 6048, .adv_w = 248, .box_w = 17, .box_h = 17, .ofs_x = -1, .ofs_y = 0}, - {.bitmap_index = 6193, .adv_w = 252, .box_w = 15, .box_h = 17, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 6321, .adv_w = 128, .box_w = 6, .box_h = 23, .ofs_x = 2, .ofs_y = -5}, - {.bitmap_index = 6390, .adv_w = 135, .box_w = 11, .box_h = 23, .ofs_x = -1, .ofs_y = -2}, - {.bitmap_index = 6517, .adv_w = 128, .box_w = 6, .box_h = 23, .ofs_x = 0, .ofs_y = -5}, - {.bitmap_index = 6586, .adv_w = 224, .box_w = 12, .box_h = 10, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 6646, .adv_w = 192, .box_w = 12, .box_h = 2, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 6658, .adv_w = 230, .box_w = 7, .box_h = 3, .ofs_x = 2, .ofs_y = 15}, - {.bitmap_index = 6669, .adv_w = 230, .box_w = 12, .box_h = 13, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 6747, .adv_w = 262, .box_w = 14, .box_h = 18, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 6873, .adv_w = 219, .box_w = 12, .box_h = 13, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 6951, .adv_w = 262, .box_w = 14, .box_h = 18, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 7077, .adv_w = 235, .box_w = 13, .box_h = 13, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 7162, .adv_w = 136, .box_w = 10, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 7252, .adv_w = 265, .box_w = 14, .box_h = 18, .ofs_x = 1, .ofs_y = -5}, - {.bitmap_index = 7378, .adv_w = 262, .box_w = 13, .box_h = 18, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 7495, .adv_w = 107, .box_w = 4, .box_h = 18, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 7531, .adv_w = 109, .box_w = 9, .box_h = 23, .ofs_x = -3, .ofs_y = -5}, - {.bitmap_index = 7635, .adv_w = 237, .box_w = 13, .box_h = 18, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 7752, .adv_w = 107, .box_w = 3, .box_h = 18, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 7779, .adv_w = 406, .box_w = 22, .box_h = 13, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 7922, .adv_w = 262, .box_w = 13, .box_h = 13, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 8007, .adv_w = 244, .box_w = 14, .box_h = 13, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 8098, .adv_w = 262, .box_w = 14, .box_h = 18, .ofs_x = 2, .ofs_y = -5}, - {.bitmap_index = 8224, .adv_w = 262, .box_w = 14, .box_h = 18, .ofs_x = 1, .ofs_y = -5}, - {.bitmap_index = 8350, .adv_w = 157, .box_w = 8, .box_h = 13, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 8402, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 8480, .adv_w = 159, .box_w = 10, .box_h = 16, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 8560, .adv_w = 260, .box_w = 13, .box_h = 13, .ofs_x = 2, .ofs_y = 0}, - {.bitmap_index = 8645, .adv_w = 215, .box_w = 15, .box_h = 13, .ofs_x = -1, .ofs_y = 0}, - {.bitmap_index = 8743, .adv_w = 345, .box_w = 22, .box_h = 13, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 8886, .adv_w = 212, .box_w = 13, .box_h = 13, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 8971, .adv_w = 215, .box_w = 15, .box_h = 18, .ofs_x = -1, .ofs_y = -5}, - {.bitmap_index = 9106, .adv_w = 200, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 9184, .adv_w = 135, .box_w = 7, .box_h = 23, .ofs_x = 1, .ofs_y = -5}, - {.bitmap_index = 9265, .adv_w = 115, .box_w = 3, .box_h = 23, .ofs_x = 2, .ofs_y = -5}, - {.bitmap_index = 9300, .adv_w = 135, .box_w = 8, .box_h = 23, .ofs_x = 0, .ofs_y = -5}, - {.bitmap_index = 9392, .adv_w = 223, .box_w = 12, .box_h = 4, .ofs_x = 1, .ofs_y = 7}, - {.bitmap_index = 9416, .adv_w = 161, .box_w = 8, .box_h = 10, .ofs_x = 1, .ofs_y = 9}, - {.bitmap_index = 9456, .adv_w = 121, .box_w = 5, .box_h = 5, .ofs_x = 1, .ofs_y = 4}, - {.bitmap_index = 9469, .adv_w = 384, .box_w = 24, .box_h = 25, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 9769, .adv_w = 384, .box_w = 24, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 9985, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 10249, .adv_w = 384, .box_w = 24, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 10465, .adv_w = 264, .box_w = 17, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 10618, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 10906, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 11194, .adv_w = 432, .box_w = 27, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 11491, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 11779, .adv_w = 432, .box_w = 27, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 12022, .adv_w = 384, .box_w = 24, .box_h = 26, .ofs_x = 0, .ofs_y = -4}, - {.bitmap_index = 12334, .adv_w = 192, .box_w = 12, .box_h = 19, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 12448, .adv_w = 288, .box_w = 18, .box_h = 19, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 12619, .adv_w = 432, .box_w = 27, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 12943, .adv_w = 384, .box_w = 24, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 13159, .adv_w = 264, .box_w = 17, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 13363, .adv_w = 336, .box_w = 15, .box_h = 22, .ofs_x = 3, .ofs_y = -2}, - {.bitmap_index = 13528, .adv_w = 336, .box_w = 21, .box_h = 26, .ofs_x = 0, .ofs_y = -4}, - {.bitmap_index = 13801, .adv_w = 336, .box_w = 21, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 14032, .adv_w = 336, .box_w = 21, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 14263, .adv_w = 336, .box_w = 15, .box_h = 22, .ofs_x = 3, .ofs_y = -2}, - {.bitmap_index = 14428, .adv_w = 336, .box_w = 23, .box_h = 22, .ofs_x = -1, .ofs_y = -2}, - {.bitmap_index = 14681, .adv_w = 240, .box_w = 13, .box_h = 22, .ofs_x = 1, .ofs_y = -2}, - {.bitmap_index = 14824, .adv_w = 240, .box_w = 13, .box_h = 22, .ofs_x = 1, .ofs_y = -2}, - {.bitmap_index = 14967, .adv_w = 336, .box_w = 21, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 15198, .adv_w = 336, .box_w = 21, .box_h = 6, .ofs_x = 0, .ofs_y = 6}, - {.bitmap_index = 15261, .adv_w = 432, .box_w = 27, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 15504, .adv_w = 480, .box_w = 31, .box_h = 24, .ofs_x = -1, .ofs_y = -3}, - {.bitmap_index = 15876, .adv_w = 432, .box_w = 29, .box_h = 24, .ofs_x = -1, .ofs_y = -3}, - {.bitmap_index = 16224, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 16488, .adv_w = 336, .box_w = 21, .box_h = 14, .ofs_x = 0, .ofs_y = 2}, - {.bitmap_index = 16635, .adv_w = 336, .box_w = 21, .box_h = 14, .ofs_x = 0, .ofs_y = 2}, - {.bitmap_index = 16782, .adv_w = 480, .box_w = 31, .box_h = 19, .ofs_x = -1, .ofs_y = -1}, - {.bitmap_index = 17077, .adv_w = 384, .box_w = 24, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 17293, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 17581, .adv_w = 384, .box_w = 25, .box_h = 25, .ofs_x = -1, .ofs_y = -3}, - {.bitmap_index = 17894, .adv_w = 336, .box_w = 22, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 18136, .adv_w = 336, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 18388, .adv_w = 336, .box_w = 21, .box_h = 22, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 18619, .adv_w = 336, .box_w = 21, .box_h = 20, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 18829, .adv_w = 384, .box_w = 24, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 19045, .adv_w = 240, .box_w = 17, .box_h = 24, .ofs_x = -1, .ofs_y = -3}, - {.bitmap_index = 19249, .adv_w = 336, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 19501, .adv_w = 336, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 19753, .adv_w = 432, .box_w = 27, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 19996, .adv_w = 384, .box_w = 26, .box_h = 26, .ofs_x = -1, .ofs_y = -4}, - {.bitmap_index = 20334, .adv_w = 288, .box_w = 18, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 20550, .adv_w = 480, .box_w = 30, .box_h = 23, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 20895, .adv_w = 480, .box_w = 30, .box_h = 16, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 21135, .adv_w = 480, .box_w = 30, .box_h = 16, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 21375, .adv_w = 480, .box_w = 30, .box_h = 16, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 21615, .adv_w = 480, .box_w = 30, .box_h = 16, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 21855, .adv_w = 480, .box_w = 30, .box_h = 16, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 22095, .adv_w = 480, .box_w = 31, .box_h = 20, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 22405, .adv_w = 336, .box_w = 19, .box_h = 24, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 22633, .adv_w = 336, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 22885, .adv_w = 384, .box_w = 25, .box_h = 25, .ofs_x = -1, .ofs_y = -4}, - {.bitmap_index = 23198, .adv_w = 480, .box_w = 30, .box_h = 18, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 23468, .adv_w = 288, .box_w = 18, .box_h = 24, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 23684, .adv_w = 386, .box_w = 25, .box_h = 16, .ofs_x = 0, .ofs_y = 1} -}; - -/*--------------------- - * CHARACTER MAPPING - *--------------------*/ - -static const uint16_t unicode_list_1[] = { - 0x0, 0x1f72, 0xef51, 0xef58, 0xef5b, 0xef5c, 0xef5d, 0xef61, - 0xef63, 0xef65, 0xef69, 0xef6c, 0xef71, 0xef76, 0xef77, 0xef78, - 0xef8e, 0xef93, 0xef98, 0xef9b, 0xef9c, 0xef9d, 0xefa1, 0xefa2, - 0xefa3, 0xefa4, 0xefb7, 0xefb8, 0xefbe, 0xefc0, 0xefc1, 0xefc4, - 0xefc7, 0xefc8, 0xefc9, 0xefcb, 0xefe3, 0xefe5, 0xf014, 0xf015, - 0xf017, 0xf019, 0xf030, 0xf037, 0xf03a, 0xf043, 0xf06c, 0xf074, - 0xf0ab, 0xf13b, 0xf190, 0xf191, 0xf192, 0xf193, 0xf194, 0xf1d7, - 0xf1e3, 0xf23d, 0xf254, 0xf4aa, 0xf712, 0xf7f2 -}; - -/*Collect the unicode lists and glyph_id offsets*/ -static const lv_font_fmt_txt_cmap_t cmaps[] = { - { - .range_start = 32, .range_length = 95, .glyph_id_start = 1, - .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY - }, - { - .range_start = 176, .range_length = 63475, .glyph_id_start = 96, - .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 62, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY - } -}; - -/*----------------- - * KERNING - *----------------*/ - - -/*Map glyph_ids to kern left classes*/ -static const uint8_t kern_left_class_mapping[] = { - 0, 0, 1, 2, 0, 3, 4, 5, - 2, 6, 7, 8, 9, 10, 9, 10, - 11, 12, 0, 13, 14, 15, 16, 17, - 18, 19, 12, 20, 20, 0, 0, 0, - 21, 22, 23, 24, 25, 22, 26, 27, - 28, 29, 29, 30, 31, 32, 29, 29, - 22, 33, 34, 35, 3, 36, 30, 37, - 37, 38, 39, 40, 41, 42, 43, 0, - 44, 0, 45, 46, 47, 48, 49, 50, - 51, 45, 52, 52, 53, 48, 45, 45, - 46, 46, 54, 55, 56, 57, 51, 58, - 58, 59, 58, 60, 41, 0, 0, 9, - 61, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; - -/*Map glyph_ids to kern right classes*/ -static const uint8_t kern_right_class_mapping[] = { - 0, 0, 1, 2, 0, 3, 4, 5, - 2, 6, 7, 8, 9, 10, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 12, - 18, 19, 20, 21, 21, 0, 0, 0, - 22, 23, 24, 25, 23, 25, 25, 25, - 23, 25, 25, 26, 25, 25, 25, 25, - 23, 25, 23, 25, 3, 27, 28, 29, - 29, 30, 31, 32, 33, 34, 35, 0, - 36, 0, 37, 38, 39, 39, 39, 0, - 39, 38, 40, 41, 38, 38, 42, 42, - 39, 42, 39, 42, 43, 44, 45, 46, - 46, 47, 46, 48, 0, 0, 35, 9, - 49, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; - -/*Kern values between classes*/ -static const int8_t kern_class_values[] = { - 0, 1, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 4, 0, 0, 0, - 0, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 17, 0, 10, -8, 0, 0, - 0, 0, -21, -23, 3, 18, 8, 7, - -15, 3, 19, 1, 16, 4, 12, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 23, 3, -3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8, 0, -12, 0, 0, 0, 0, - 0, -8, 7, 8, 0, 0, -4, 0, - -3, 4, 0, -4, 0, -4, -2, -8, - 0, 0, 0, 0, -4, 0, 0, -5, - -6, 0, 0, -4, 0, -8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -4, - -4, 0, -6, 0, -10, 0, -46, 0, - 0, -8, 0, 8, 12, 0, 0, -8, - 4, 4, 13, 8, -7, 8, 0, 0, - -22, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -10, -5, -19, 0, -15, - -3, 0, 0, 0, 0, 1, 15, 0, - -12, -3, -1, 1, 0, -7, 0, 0, - -3, -28, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -31, -3, 15, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -16, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 13, - 0, 4, 0, 0, -8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 15, 3, - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - -14, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3, - 8, 4, 12, -4, 0, 0, 8, -4, - -13, -53, 3, 10, 8, 1, -5, 0, - 14, 0, 12, 0, 12, 0, -36, 0, - -5, 12, 0, 13, -4, 8, 4, 0, - 0, 1, -4, 0, 0, -7, 31, 0, - 31, 0, 12, 0, 16, 5, 7, 12, - 0, 0, 0, -14, 0, 0, 0, 0, - 1, -3, 0, 3, -7, -5, -8, 3, - 0, -4, 0, 0, 0, -15, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -25, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, -21, 0, -24, 0, 0, 0, - 0, -3, 0, 38, -5, -5, 4, 4, - -3, 0, -5, 4, 0, 0, -20, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -37, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -24, 0, 23, 0, 0, -14, 0, - 13, 0, -26, -37, -26, -8, 12, 0, - 0, -26, 0, 5, -9, 0, -6, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 12, -47, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 3, 0, 0, 0, - 0, 0, 3, 3, -5, -8, 0, -1, - -1, -4, 0, 0, -3, 0, 0, 0, - -8, 0, -3, 0, -9, -8, 0, -10, - -13, -13, -7, 0, -8, 0, -8, 0, - 0, 0, 0, -3, 0, 0, 4, 0, - 3, -4, 0, 1, 0, 0, 0, 4, - -3, 0, 0, 0, -3, 4, 4, -1, - 0, 0, 0, -7, 0, -1, 0, 0, - 0, 0, 0, 1, 0, 5, -3, 0, - -5, 0, -7, 0, 0, -3, 0, 12, - 0, 0, -4, 0, 0, 0, 0, 0, - -1, 1, -3, -3, 0, 0, -4, 0, - -4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -2, -2, 0, -4, -5, 0, - 0, 0, 0, 0, 1, 0, 0, -3, - 0, -4, -4, -4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -2, 0, 0, - 0, 0, -3, -5, 0, -6, 0, -12, - -3, -12, 8, 0, 0, -8, 4, 8, - 10, 0, -10, -1, -5, 0, -1, -18, - 4, -3, 3, -20, 4, 0, 0, 1, - -20, 0, -20, -3, -33, -3, 0, -19, - 0, 8, 11, 0, 5, 0, 0, 0, - 0, 1, 0, -7, -5, 0, -12, 0, - 0, 0, -4, 0, 0, 0, -4, 0, - 0, 0, 0, 0, -2, -2, 0, -2, - -5, 0, 0, 0, 0, 0, 0, 0, - -4, -4, 0, -3, -5, -3, 0, 0, - -4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -3, -3, 0, -5, - 0, -3, 0, -8, 4, 0, 0, -5, - 2, 4, 4, 0, 0, 0, 0, 0, - 0, -3, 0, 0, 0, 0, 0, 3, - 0, 0, -4, 0, -4, -3, -5, 0, - 0, 0, 0, 0, 0, 0, 3, 0, - -3, 0, 0, 0, 0, -4, -6, 0, - -7, 0, 12, -3, 1, -12, 0, 0, - 10, -19, -20, -16, -8, 4, 0, -3, - -25, -7, 0, -7, 0, -8, 6, -7, - -25, 0, -10, 0, 0, 2, -1, 3, - -3, 0, 4, 0, -12, -15, 0, -19, - -9, -8, -9, -12, -5, -10, -1, -7, - -10, 2, 0, 1, 0, -4, 0, 0, - 0, 3, 0, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -4, - 0, -2, 0, -1, -4, 0, -7, -8, - -8, -1, 0, -12, 0, 0, 0, 0, - 0, 0, -3, 0, 0, 0, 0, 2, - -2, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 18, 0, 0, - 0, 0, 0, 0, 3, 0, 0, 0, - -4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -7, 0, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -3, 0, 0, 0, - -7, 0, 0, 0, 0, -19, -12, 0, - 0, 0, -6, -19, 0, 0, -4, 4, - 0, -10, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -6, 0, 0, -7, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, -7, 0, - 0, 0, 0, 5, 0, 3, -8, -8, - 0, -4, -4, -5, 0, 0, 0, 0, - 0, 0, -12, 0, -4, 0, -6, -4, - 0, -8, -10, -12, -3, 0, -8, 0, - -12, 0, 0, 0, 0, 31, 0, 0, - 2, 0, 0, -5, 0, 4, 0, -17, - 0, 0, 0, 0, 0, -36, -7, 13, - 12, -3, -16, 0, 4, -6, 0, -19, - -2, -5, 4, -27, -4, 5, 0, 6, - -13, -6, -14, -13, -16, 0, 0, -23, - 0, 22, 0, 0, -2, 0, 0, 0, - -2, -2, -4, -10, -13, -1, -36, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -4, 0, -2, -4, -6, 0, 0, - -8, 0, -4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -1, 0, -8, 0, 0, 8, - -1, 5, 0, -8, 4, -3, -1, -10, - -4, 0, -5, -4, -3, 0, -6, -7, - 0, 0, -3, -1, -3, -7, -5, 0, - 0, -4, 0, 4, -3, 0, -8, 0, - 0, 0, -8, 0, -7, 0, -7, -7, - 4, 0, 0, 0, 0, 0, 0, 0, - 0, -8, 4, 0, -5, 0, -3, -5, - -12, -3, -3, -3, -1, -3, -5, -1, - 0, 0, 0, 0, 0, -4, -3, -3, - 0, 0, 0, 0, 5, -3, 0, -3, - 0, 0, 0, -3, -5, -3, -3, -5, - -3, 0, 3, 15, -1, 0, -10, 0, - -3, 8, 0, -4, -16, -5, 6, 0, - 0, -18, -7, 4, -7, 3, 0, -3, - -3, -12, 0, -6, 2, 0, 0, -7, - 0, 0, 0, 4, 4, -8, -7, 0, - -7, -4, -6, -4, -4, 0, -7, 2, - -7, -7, 12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - -3, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -3, -4, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -6, 0, 0, -5, - 0, 0, -4, -4, 0, 0, 0, 0, - -4, 0, 0, 0, 0, -2, 0, 0, - 0, 0, 0, -3, 0, 0, 0, 0, - -6, 0, -8, 0, 0, 0, -13, 0, - 3, -8, 8, 1, -3, -18, 0, 0, - -8, -4, 0, -15, -10, -11, 0, 0, - -17, -4, -15, -15, -18, 0, -10, 0, - 3, 26, -5, 0, -9, -4, -1, -4, - -7, -10, -7, -14, -16, -9, -4, 0, - 0, -3, 0, 1, 0, 0, -27, -3, - 12, 8, -8, -14, 0, 1, -12, 0, - -19, -3, -4, 8, -35, -5, 1, 0, - 0, -25, -5, -20, -4, -28, 0, 0, - -27, 0, 23, 1, 0, -3, 0, 0, - 0, 0, -2, -3, -15, -3, 0, -25, - 0, 0, 0, 0, -12, 0, -3, 0, - -1, -11, -18, 0, 0, -2, -6, -12, - -4, 0, -3, 0, 0, 0, 0, -17, - -4, -13, -12, -3, -7, -10, -4, -7, - 0, -8, -3, -13, -6, 0, -5, -7, - -4, -7, 0, 2, 0, -3, -13, 0, - 8, 0, -7, 0, 0, 0, 0, 5, - 0, 3, -8, 16, 0, -4, -4, -5, - 0, 0, 0, 0, 0, 0, -12, 0, - -4, 0, -6, -4, 0, -8, -10, -12, - -3, 0, -8, 3, 15, 0, 0, 0, - 0, 31, 0, 0, 2, 0, 0, -5, - 0, 4, 0, 0, 0, 0, 0, 0, - 0, 0, -1, 0, 0, 0, 0, 0, - -3, -8, 0, 0, 0, 0, 0, -2, - 0, 0, 0, -4, -4, 0, 0, -8, - -4, 0, 0, -8, 0, 7, -2, 0, - 0, 0, 0, 0, 0, 2, 0, 0, - 0, 0, 6, 8, 3, -3, 0, -12, - -6, 0, 12, -13, -12, -8, -8, 15, - 7, 4, -33, -3, 8, -4, 0, -4, - 4, -4, -13, 0, -4, 4, -5, -3, - -12, -3, 0, 0, 12, 8, 0, -11, - 0, -21, -5, 11, -5, -15, 1, -5, - -13, -13, -4, 15, 4, 0, -6, 0, - -10, 0, 3, 13, -9, -14, -15, -10, - 12, 0, 1, -28, -3, 4, -7, -3, - -9, 0, -8, -14, -6, -6, -3, 0, - 0, -9, -8, -4, 0, 12, 9, -4, - -21, 0, -21, -5, 0, -13, -22, -1, - -12, -7, -13, -11, 10, 0, 0, -5, - 0, -8, -3, 0, -4, -7, 0, 7, - -13, 4, 0, 0, -20, 0, -4, -8, - -7, -3, -12, -10, -13, -9, 0, -12, - -4, -9, -7, -12, -4, 0, 0, 1, - 18, -7, 0, -12, -4, 0, -4, -8, - -9, -10, -11, -15, -5, -8, 8, 0, - -6, 0, -19, -5, 2, 8, -12, -14, - -8, -13, 13, -4, 2, -36, -7, 8, - -8, -7, -14, 0, -12, -16, -5, -4, - -3, -4, -8, -12, -1, 0, 0, 12, - 11, -3, -25, 0, -23, -9, 9, -15, - -26, -8, -13, -16, -19, -13, 8, 0, - 0, 0, 0, -5, 0, 0, 4, -5, - 8, 3, -7, 8, 0, 0, -12, -1, - 0, -1, 0, 1, 1, -3, 0, 0, - 0, 0, 0, 0, -4, 0, 0, 0, - 0, 3, 12, 1, 0, -5, 0, 0, - 0, 0, -3, -3, -5, 0, 0, 0, - 1, 3, 0, 0, 0, 0, 3, 0, - -3, 0, 15, 0, 7, 1, 1, -5, - 0, 8, 0, 0, 0, 3, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 12, 0, 11, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -23, 0, -4, 7, 0, 12, - 0, 0, 38, 5, -8, -8, 4, 4, - -3, 1, -19, 0, 0, 18, -23, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -26, 15, 54, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -23, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -6, 0, 0, -7, - -3, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -3, 0, -10, 0, - 0, 1, 0, 0, 4, 50, -8, -3, - 12, 10, -10, 4, 0, 0, 4, 4, - -5, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -50, 11, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -11, - 0, 0, 0, -10, 0, 0, 0, 0, - -8, -2, 0, 0, 0, -8, 0, -5, - 0, -18, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -26, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, - 0, -4, 0, 0, -7, 0, -6, 0, - -10, 0, 0, 0, -7, 4, -5, 0, - 0, -10, -4, -9, 0, 0, -10, 0, - -4, 0, -18, 0, -4, 0, 0, -31, - -7, -15, -4, -14, 0, 0, -26, 0, - -10, -2, 0, 0, 0, 0, 0, 0, - 0, 0, -6, -7, -3, -7, 0, 0, - 0, 0, -8, 0, -8, 5, -4, 8, - 0, -3, -9, -3, -7, -7, 0, -5, - -2, -3, 3, -10, -1, 0, 0, 0, - -34, -3, -5, 0, -8, 0, -3, -18, - -3, 0, 0, -3, -3, 0, 0, 0, - 0, 3, 0, -3, -7, -3, 7, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 0, 0, 0, 0, 0, - 0, -8, 0, -3, 0, 0, 0, -8, - 4, 0, 0, 0, -10, -4, -8, 0, - 0, -11, 0, -4, 0, -18, 0, 0, - 0, 0, -37, 0, -8, -14, -19, 0, - 0, -26, 0, -3, -6, 0, 0, 0, - 0, 0, 0, 0, 0, -4, -6, -2, - -6, 1, 0, 0, 7, -5, 0, 12, - 19, -4, -4, -12, 5, 19, 7, 8, - -10, 5, 16, 5, 11, 8, 10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 24, 18, -7, -4, 0, -3, - 31, 17, 31, 0, 0, 0, 4, 0, - 0, 14, 0, 0, -6, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -3, 0, - 0, 0, 0, 0, 0, 0, 0, 5, - 0, 0, 0, 0, -32, -5, -3, -16, - -19, 0, 0, -26, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -3, - 0, 0, 0, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 0, -32, -5, -3, - -16, -19, 0, 0, -15, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - -3, 0, 0, 0, -9, 4, 0, -4, - 3, 7, 4, -12, 0, -1, -3, 4, - 0, 3, 0, 0, 0, 0, -10, 0, - -3, -3, -8, 0, -3, -15, 0, 24, - -4, 0, -8, -3, 0, -3, -7, 0, - -4, -11, -8, -5, 0, 0, 0, -6, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -3, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 0, 0, 0, 0, -32, - -5, -3, -16, -19, 0, 0, -26, 0, - 0, 0, 0, 0, 0, 19, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - -6, 0, -12, -5, -3, 12, -3, -4, - -15, 1, -2, 1, -3, -10, 1, 8, - 1, 3, 1, 3, -9, -15, -5, 0, - -15, -7, -10, -16, -15, 0, -6, -8, - -5, -5, -3, -3, -5, -3, 0, -3, - -1, 6, 0, 6, -3, 0, 12, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -3, -4, -4, 0, 0, - -10, 0, -2, 0, -7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - -23, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -4, -4, 0, -5, - 0, 0, 0, 0, -3, 0, 0, -7, - -4, 4, 0, -7, -7, -3, 0, -11, - -3, -8, -3, -5, 0, -7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, -26, 0, 12, 0, 0, -7, 0, - 0, 0, 0, -5, 0, -4, 0, 0, - -2, 0, 0, -3, 0, -9, 0, 0, - 16, -5, -13, -12, 3, 4, 4, -1, - -11, 3, 6, 3, 12, 3, 13, -3, - -10, 0, 0, -15, 0, 0, -12, -10, - 0, 0, -8, 0, -5, -7, 0, -6, - 0, -6, 0, -3, 6, 0, -3, -12, - -4, 14, 0, 0, -3, 0, -8, 0, - 0, 5, -9, 0, 4, -4, 3, 0, - 0, -13, 0, -3, -1, 0, -4, 4, - -3, 0, 0, 0, -16, -5, -8, 0, - -12, 0, 0, -18, 0, 14, -4, 0, - -7, 0, 2, 0, -4, 0, -4, -12, - 0, -4, 4, 0, 0, 0, 0, -3, - 0, 0, 4, -5, 1, 0, 0, -5, - -3, 0, -5, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -24, 0, 8, 0, - 0, -3, 0, 0, 0, 0, 1, 0, - -4, -4, 0, 0, 0, 8, 0, 9, - 0, 0, 0, 0, 0, -24, -22, 1, - 17, 12, 7, -15, 3, 16, 0, 14, - 0, 8, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 20, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0 -}; - - -/*Collect the kern class' data in one place*/ -static const lv_font_fmt_txt_kern_classes_t kern_classes = { - .class_pair_values = kern_class_values, - .left_class_mapping = kern_left_class_mapping, - .right_class_mapping = kern_right_class_mapping, - .left_class_cnt = 61, - .right_class_cnt = 49, -}; - -/*-------------------- - * ALL CUSTOM DATA - *--------------------*/ - -#if LV_VERSION_CHECK(8, 0, 0) -/*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; -static const lv_font_fmt_txt_dsc_t font_dsc = { -#else -static lv_font_fmt_txt_dsc_t font_dsc = { -#endif - .glyph_bitmap = glyph_bitmap, - .glyph_dsc = glyph_dsc, - .cmaps = cmaps, - .kern_dsc = &kern_classes, - .kern_scale = 16, - .cmap_num = 2, - .bpp = 4, - .kern_classes = 1, - .bitmap_format = 0, -#if LV_VERSION_CHECK(8, 0, 0) - .cache = &cache -#endif -}; - - -/*----------------- - * PUBLIC FONT - *----------------*/ - -/*Initialize a public general font descriptor*/ -#if LV_VERSION_CHECK(8, 0, 0) -const lv_font_t lv_font_montserrat_24_cp = { -#else -lv_font_t lv_font_montserrat_24 = { -#endif - .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ - .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ - .line_height = 27, /*The maximum line height required by the font*/ - .base_line = 5, /*Baseline measured from the bottom of the line*/ -#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) - .subpx = LV_FONT_SUBPX_NONE, -#endif -#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 - .underline_position = -2, - .underline_thickness = 1, -#endif - .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ -}; diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/SConscript b/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/SConscript deleted file mode 100644 index 245e36e0..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] -src = Glob('*.c') -CPPPATH = [cwd] - -if (GetDepend('AIC_FS_IMAGE_DIR_1')) and "qc_test" in GetConfigValue('AIC_FS_IMAGE_DIR_1').lower(): - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - - group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DEMO'], CPPPATH = CPPPATH) - -Return('group') diff --git a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/main_page.c b/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/main_page.c deleted file mode 100644 index 4c88c72e..00000000 --- a/packages/artinchip/lvgl-ui/aic_demo/qc_test/view/screen/main_page.c +++ /dev/null @@ -1,902 +0,0 @@ -/* - * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd - * - * SPDX-License-Identifier: Apache-2.0 - * - * Authors: Zequan Liang - */ - -#include -#include -#include -#include - -#if QC_OS_LINUX -#include -#endif -#if QC_OS_RT_THREAD -#include -#include -#include -#endif - -#include "lvgl/lvgl.h" -#include "aic_ui.h" - -#include "../../module/qc_test.h" - -LV_FONT_DECLARE(lv_font_montserrat_24_cp); - -static void mgr_lock(void); -static void mgr_un_lock(void); -static void qc_mdelay(int delay_ms); - -static int qc_ops_create(void); - -static int module_name_to_table_row(char *name); -static void table_cell_update(qc_disp_data_t *disp); -static void mgr_result_label_update(qc_disp_data_t *disp); -static void arc_update(qc_disp_data_t *disp); -static void start_btn_update(int progress); - -static void table_init(void); -static void title_init(void); -static void start_btn_init(void); -static void cut_line_init(void); -static void progress_arc_init(void); -static void mgr_result_label_init(); -static void top_windows_create(lv_obj_t *parent); - -static void table_status_clear(void); -static void arc_status_clear(void); -static void mgr_result_label_clear(void); - -static void draw_table_event_cb(lv_event_t * e); -static void reverse_btn_status_cb(lv_timer_t *lv_timer); -static void start_btn_handler(lv_event_t * e); -static void del_top_window_cb(lv_event_t * e); -static void get_chip_intel_model_cb(lv_event_t * e); -static void create_top_window_cb(lv_event_t * e); - -static void disable_unused_obj(void); - -static void sys_time_update(lv_timer_t *lv_timer); - -#if QC_OS_RT_THREAD || QC_OS_LINUX -static void qc_exec_task(void *arg); -#else -static void qc_exec_task(lv_timer_t *lv_timer); -#endif -static void qc_draw_task(lv_timer_t *lv_timer); - -#if QC_OS_LINUX -static pthread_mutex_t *mgr_mutex; -#elif QC_OS_RT_THREAD -#define QC_TASK_THREAD_STACK_SIZE 4096 -static rt_mutex_t mgr_mutex = NULL; -static struct rt_thread qc_task_thread; -static rt_uint8_t qc_task_thread_stack[QC_TASK_THREAD_STACK_SIZE]; -#else -static lv_timer_t *exec_timer; -#endif - -static qc_board_config_t *board; -static qc_manager_t *mgr; - -static lv_obj_t *start_label; -static lv_obj_t *start_btn; -static lv_obj_t *choose_btn; - -static lv_style_t arc_style_main; -static lv_style_t arc_style_indicate; -static lv_style_t arc_style_pass_indicate; -static lv_style_t arc_style_err_indicate; -static lv_obj_t *arc_label; -static lv_obj_t *arc; -static lv_anim_t arc_anim; - -static lv_obj_t * table; -static lv_obj_t *mgr_result_label; - -static lv_obj_t * rtc_time; -static lv_timer_t *sys_timer; - -void lv_qc_test_init(void) -{ - if (qc_ops_create() == QC_RES_INV) - return; - - /* set the active layer background to white */ - lv_obj_set_style_bg_color(lv_scr_act(), lv_color_white(), 0); - - lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE); - /* set header title */ - title_init(); - - table_init(); - - start_btn_init(); - - mgr_result_label_init(); - - cut_line_init(); - - progress_arc_init(); - - sys_timer = lv_timer_create(sys_time_update, 1000, NULL); - lv_timer_ready(sys_timer); - - lv_timer_t *draw_timer = lv_timer_create(qc_draw_task, 50, NULL); - lv_timer_ready(draw_timer); - - lv_timer_create(reverse_btn_status_cb, 100, NULL); - -#if QC_OS_RT_THREAD - mgr_mutex = rt_mutex_create("qc_mutex", RT_IPC_FLAG_PRIO); - if (mgr_mutex == NULL) { - printf("rt mutex create failed\n"); - } - - rt_err_t err; - err = rt_thread_init(&qc_task_thread, "qc_task", - qc_exec_task, (void *)NULL, - &qc_task_thread_stack[0], sizeof(qc_task_thread_stack), - LPKG_LVGL_THREAD_PRIO, 0); - if (err != RT_EOK) { - printf("failed to create qc task thread"); - return; - } - (void)err; - rt_thread_startup(&qc_task_thread); -#elif QC_OS_LINUX - pthread_t task_thread; - pthread_create(&task_thread, NULL, qc_exec_task, NULL); - mgr_mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (mgr_mutex == NULL) { - printf("pthread mutex create failed\n"); - } - pthread_mutex_init(mgr_mutex, NULL); -#else - exec_timer = lv_timer_create(qc_exec_task, 300, NULL); -#endif - - disable_unused_obj(); -} - -#if QC_OS_LINUX -static void mgr_lock(void) -{ - if (mgr_mutex) { - pthread_mutex_lock(mgr_mutex); - } -} - -static void mgr_un_lock(void) -{ - if (mgr_mutex) { - pthread_mutex_unlock(mgr_mutex); - } -} - -static void qc_mdelay(int delay_ms) -{ - usleep(delay_ms * 1000); -} -#elif QC_OS_RT_THREAD -static void mgr_lock(void) -{ - if (mgr_mutex) - rt_mutex_take(mgr_mutex, RT_WAITING_FOREVER); -} - -static void mgr_un_lock(void) -{ - if (mgr_mutex) - rt_mutex_release(mgr_mutex); -} -static void qc_mdelay(int delay_ms) -{ - rt_thread_mdelay(delay_ms); -} -#else -static void mgr_lock(void) {;} -static void mgr_un_lock(void) {;} -static void qc_mdelay(int delay_ms) {;} -#endif - -static int qc_ops_create(void) -{ - board = qc_board_tests_create(); - if (board == NULL) { - printf("qc_board_tests_create failed\n"); - return QC_RES_INV; - } - - mgr = board->manager; - - qc_manager_set_lock(mgr, mgr_lock, mgr_un_lock); - - return QC_RES_OK; -} - -static int module_name_to_table_row(char *name) -{ - int num_modules = mgr->module_num; - static qc_module_t *temp_module = NULL; - if (temp_module == NULL) - temp_module = qc_module_create(); - - for (int i = 0; i < num_modules; i++) { - if (qc_manager_module_get_index(mgr, temp_module, i) == QC_RES_INV) - return -1; - - if (strncmp(name, temp_module->name, strlen(name)) == 0) { - return i + 1; - } - } - - return -1; -} - -static void table_cell_update(qc_disp_data_t *disp) -{ - int table_row_pos = -1; - char failure_item[128] = {0}; - - table_row_pos = module_name_to_table_row(disp->mod_name); - if (table_row_pos > 0) { - if (disp->mod_status == QC_MOD_EXECUTING) { - lv_table_set_cell_value(table, table_row_pos, 3, "Testing"); - } else if (disp->mod_status == QC_MOD_SUCCESS) { - lv_table_set_cell_value(table, table_row_pos, 3, "Success"); - } else if (disp->mod_status == QC_MOD_FAILURE) { - lv_table_set_cell_value(table, table_row_pos, 3, "Failure"); - } - - lv_table_set_cell_value(table, table_row_pos, 1, disp->mod_desc); - - for (int i = 0; i < LIST_OPS_NUM; i++) { - if (disp->list_ops_status[i] == QC_MOD_FAILURE) { - strcat(failure_item, disp->list_ops_desc[i]); - strcat(failure_item, " failure\n"); - } - } - - /* clear the line break on the last line */ - int len = strlen(failure_item); - if (len > 0) { - *(failure_item + len - 1) = '\0'; - lv_table_set_cell_value(table, table_row_pos, 2, failure_item); - } - } -} - -static void mgr_result_label_update(qc_disp_data_t *disp) -{ - char mgr_result_context[100] = {0}; - - if (disp->mgr_success_num != 0 || disp->mgr_failure_num != 0) { - snprintf(mgr_result_context, sizeof(mgr_result_context), - "Passed items: %d Failed items: %d", - disp->mgr_success_num, disp->mgr_failure_num); - lv_label_set_text(mgr_result_label, mgr_result_context); - } -} - -static void arc_update(qc_disp_data_t *disp) -{ - static int last_progress = 0; - - lv_anim_set_values(&arc_anim, last_progress, disp->mgr_progress); - lv_anim_start(&arc_anim); - - last_progress = disp->mgr_progress; - - if (lv_obj_has_flag(arc_label, LV_OBJ_FLAG_HIDDEN)) - lv_obj_clear_flag(arc_label, LV_OBJ_FLAG_HIDDEN); - - if (disp->mgr_progress == 100) { - if (disp->mgr_failure_num != 0) { - lv_obj_add_style(arc, &arc_style_err_indicate, - LV_PART_INDICATOR); - lv_anim_set_values(&arc_anim, disp->mgr_progress, disp->mgr_progress); - lv_anim_start(&arc_anim); - - lv_label_set_text(arc_label, "#f44336 Failure #"); /* main red */ - } else { - lv_obj_add_style(arc, &arc_style_pass_indicate, - LV_PART_INDICATOR); - lv_anim_set_values(&arc_anim, disp->mgr_progress, disp->mgr_progress); - lv_anim_start(&arc_anim); - - lv_label_set_text(arc_label, "#4caf50 Success #"); /* main gree */ - } - } else if (disp->mgr_progress > 0 && disp->mgr_progress < 100) { - lv_label_set_text(arc_label, "#2196f3 Testing#"); /* main blue */ - } -} - -static void start_btn_update(int progress) -{ - if (progress == 100) { - lv_label_set_text(start_label, "Restart"); - } else if (progress > 0 && progress < 100) { - lv_label_set_text(start_label, "Testing"); - } -} - -static void title_init(void) -{ - lv_obj_t * top_bg = lv_obj_create(lv_scr_act()); - lv_obj_set_style_bg_color(top_bg, lv_palette_darken(LV_PALETTE_BLUE, 2), 0); - lv_obj_set_pos(top_bg, 0, 0); - lv_obj_set_size(top_bg, 1024, 54); - lv_obj_clear_flag(top_bg, LV_OBJ_FLAG_SCROLLABLE); - - lv_obj_t * title = lv_label_create(top_bg); - lv_obj_set_style_text_color(title, lv_palette_lighten(LV_PALETTE_BLUE, 5), 0); - lv_label_set_text_fmt(title, "ArtInChip QC Test Tool %s", QC_TEST_TOOL_VERSION); - lv_obj_set_align(title, LV_ALIGN_CENTER); - - lv_obj_t * chip_version = lv_label_create(top_bg); - lv_obj_set_style_text_color(chip_version, lv_palette_lighten(LV_PALETTE_BLUE, 5), 0); - - lv_label_set_text(chip_version, board->board_describe); - lv_obj_set_align(chip_version, LV_ALIGN_TOP_LEFT); - - rtc_time = lv_label_create(top_bg); - lv_obj_set_style_text_color(rtc_time, lv_palette_lighten(LV_PALETTE_BLUE, 5), 0); - lv_obj_set_align(rtc_time, LV_ALIGN_RIGHT_MID); - lv_label_set_text(rtc_time, " "); -} - -static void table_init(void) -{ - qc_module_t *temp_module = {0}; - int table_row_pos = {0}; - int table_row_cnt = mgr->module_num; - - table = lv_table_create(lv_scr_act()); - lv_obj_set_scroll_dir(table, LV_DIR_TOP | LV_DIR_BOTTOM | LV_DIR_VER); - lv_obj_set_scrollbar_mode(table, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_pos(table, 0, 54); - lv_obj_set_size(table, 680, 544); - lv_table_set_row_cnt(table, table_row_cnt); - lv_table_set_col_cnt(table, 4); - lv_table_set_col_width(table, 0, 113); - lv_table_set_col_width(table, 1, 227); - lv_table_set_col_width(table, 2, 227); - lv_table_set_col_width(table, 3, 113); - - lv_table_set_cell_value(table, 0, 0, "Module"); - lv_table_set_cell_value(table, 0, 1, "Testing item"); - lv_table_set_cell_value(table, 0, 2, "Failure item"); - lv_table_set_cell_value(table, 0, 3, "Status"); - - temp_module = qc_module_create(); - if (temp_module == NULL) { - printf("qc module create failed, can't create temp module\n"); - return; - } - - for (int i = 0; i < table_row_cnt; i++) { - qc_res_t ret = qc_manager_module_get_index(mgr, temp_module, i); - if (ret == QC_RES_OK) { - table_row_pos = i + 1; - lv_table_set_cell_value(table, table_row_pos, 0, temp_module->name); - lv_table_set_cell_value(table, table_row_pos, 1, temp_module->desc); - } - } - - qc_module_delete(temp_module); - /*Add an event callback to to apply some custom drawing*/ - lv_obj_add_event_cb(table, draw_table_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL); -} - -static void table_status_clear() -{ - /* due to the unique nature of the table object, delete and recreate the table - * object to force a refresh of the table. - */ - if (table) { - lv_obj_del(table); - } - table_init(); -} - -static void arc_status_clear() -{ - lv_obj_add_style(arc, &arc_style_indicate, LV_PART_INDICATOR); - - lv_anim_set_time(&arc_anim, 0); - lv_anim_set_values(&arc_anim, 0, 0); - lv_anim_start(&arc_anim); - lv_anim_set_time(&arc_anim, 1000); - - lv_obj_add_flag(arc_label, LV_OBJ_FLAG_HIDDEN); -} - -static void mgr_result_label_clear() -{ - char mgr_result_context[100]; - - snprintf(mgr_result_context, sizeof(mgr_result_context), - "Passed items: %s Failed items: %s", - "--", "--"); - lv_label_set_text(mgr_result_label, mgr_result_context); -} - -static void start_btn_init(void) -{ - static lv_style_t start_btn_style; - - start_btn = lv_btn_create(lv_scr_act()); - lv_obj_clear_flag(start_btn, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_pos(start_btn, 690, 60); - lv_obj_set_size(start_btn, 323, 83); - - lv_obj_add_event_cb(start_btn, start_btn_handler, LV_EVENT_ALL, NULL); - lv_style_init(&start_btn_style); - lv_style_set_bg_color(&start_btn_style, lv_palette_main(LV_PALETTE_BLUE)); - lv_obj_add_style(start_btn, &start_btn_style, 0); - - start_label = lv_label_create(start_btn); - lv_obj_clear_flag(start_label, LV_OBJ_FLAG_SCROLLABLE); - lv_label_set_text(start_label, "Start"); - lv_obj_set_style_text_font(start_label, &lv_font_montserrat_24_cp, 0); - lv_obj_center(start_label); - - choose_btn = lv_btn_create(lv_scr_act()); - lv_obj_clear_flag(choose_btn, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_pos(choose_btn, 690, 150); - lv_obj_set_size(choose_btn, 323, 83); - - lv_obj_t *choose_label = lv_label_create(choose_btn); - lv_obj_clear_flag(choose_label, LV_OBJ_FLAG_SCROLLABLE); - lv_label_set_text(choose_label, "Choose Model"); - lv_obj_set_style_text_font(choose_label, &lv_font_montserrat_24_cp, 0); - lv_obj_center(choose_label); - - lv_obj_add_event_cb(start_btn, start_btn_handler, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(choose_btn, create_top_window_cb, LV_EVENT_ALL, NULL); -} - -static void cut_line_init(void) -{ - static lv_point_t cut_line_point[] = {{680, 245}, {1020, 245}}; - static lv_style_t cut_line_style; - - lv_style_init(&cut_line_style); - lv_style_set_line_width(&cut_line_style, 2); - lv_style_set_line_color(&cut_line_style, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_line_opa(&cut_line_style, LV_OPA_20); - lv_style_set_line_rounded(&cut_line_style, false); - - static lv_obj_t *cut_line; - cut_line = lv_line_create(lv_scr_act()); - lv_line_set_points(cut_line, cut_line_point, 2); - lv_obj_add_style(cut_line, &cut_line_style, 0); - lv_obj_set_align(cut_line, LV_ALIGN_TOP_LEFT); -} - -static void set_arc_value(void *obj, int32_t v) -{ - lv_arc_set_value(obj, v); -} - -static void progress_arc_init(void) -{ - lv_style_init(&arc_style_main); - lv_style_set_arc_width(&arc_style_main, 20); - lv_style_set_arc_color(&arc_style_main, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_arc_opa(&arc_style_main, LV_OPA_20); - - lv_style_init(&arc_style_indicate); - lv_style_set_arc_width(&arc_style_indicate, 20); - lv_style_set_arc_color(&arc_style_indicate, lv_palette_main(LV_PALETTE_BLUE)); - lv_style_set_arc_opa(&arc_style_indicate, LV_OPA_COVER); - - lv_style_init(&arc_style_pass_indicate); - lv_style_set_arc_width(&arc_style_pass_indicate, 20); - lv_style_set_arc_color(&arc_style_pass_indicate, lv_palette_main(LV_PALETTE_GREEN)); - lv_style_set_arc_opa(&arc_style_pass_indicate, LV_OPA_COVER); - - lv_style_init(&arc_style_err_indicate); - lv_style_set_arc_width(&arc_style_err_indicate, 20); - lv_style_set_arc_color(&arc_style_err_indicate, lv_palette_main(LV_PALETTE_RED)); - lv_style_set_arc_opa(&arc_style_err_indicate, LV_OPA_COVER); - - arc = lv_arc_create(lv_scr_act()); - lv_obj_add_style(arc, &arc_style_main, LV_PART_MAIN); - lv_obj_add_style(arc, &arc_style_indicate, LV_PART_INDICATOR); - - lv_arc_set_rotation(arc, 270); - lv_arc_set_bg_angles(arc, 0, 360); - - lv_obj_remove_style(arc, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/ - lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/ - lv_obj_set_pos(arc, 705, 290); - lv_obj_set_size(arc, 295, 350); - lv_obj_set_align(arc, LV_ALIGN_TOP_LEFT); - - lv_obj_set_style_anim_time(arc, 1000, 0); - lv_arc_set_mode(arc, LV_ARC_MODE_NORMAL); - - lv_arc_set_range(arc, 0, 100); - - lv_anim_init(&arc_anim); - lv_anim_set_var(&arc_anim, arc); - lv_anim_set_exec_cb(&arc_anim, set_arc_value); - lv_anim_set_time(&arc_anim, 1000); - - arc_label = lv_label_create(arc); - lv_label_set_recolor(arc_label, true); - lv_label_set_text(arc_label, " "); /* main blue */ - lv_obj_set_style_text_font(arc_label, &lv_font_montserrat_24_cp, 0); - lv_obj_set_size(arc_label, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_pos(arc_label, 0, -25); - lv_obj_set_align(arc_label, LV_ALIGN_CENTER); - lv_obj_add_flag(arc_label, LV_OBJ_FLAG_HIDDEN); -} - -static void mgr_result_label_init() -{ - char mgr_result_context[100]; - mgr_result_label = lv_label_create(lv_scr_act()); - snprintf(mgr_result_context, sizeof(mgr_result_context), - "Passed items: %s Failed items: %s", - "--", "--"); - - lv_label_set_text(mgr_result_label, mgr_result_context); - lv_obj_set_pos(mgr_result_label, 690, 250); -} - -static void top_windows_create(lv_obj_t *parent) -{ - lv_obj_t *mask = lv_obj_create(lv_layer_top()); - lv_obj_remove_style_all(mask); - lv_obj_set_size(mask, 1024, 600); - lv_obj_set_style_bg_color(mask, lv_palette_main(LV_PALETTE_GREY), 0); - lv_obj_set_style_bg_opa(mask, LV_OPA_50, 0); - - lv_obj_t *windows = lv_obj_create(mask); - lv_obj_clear_flag(windows, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_size(windows, 480, 300); - lv_obj_set_style_clip_corner(windows, 40, 0); - lv_obj_set_style_bg_color(windows, lv_color_hex(0xffffff), 0); - lv_obj_set_style_bg_opa(windows, LV_OPA_100, 0); - lv_obj_set_style_border_color(windows, lv_palette_main(LV_PALETTE_GREY), 0); - lv_obj_set_style_border_width(windows, 2, 0); - lv_obj_center(windows); - - lv_obj_t *title = lv_label_create(windows); - lv_label_set_text(title, "Choose Chip Model"); - lv_obj_set_size(title, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_align(title, LV_ALIGN_TOP_MID); - lv_obj_set_pos(title, 0, 10); - lv_obj_set_style_text_font(title, &lv_font_montserrat_24_cp, 0); - lv_label_set_recolor(title, true); - lv_obj_set_style_text_color(title, lv_color_hex(0x393939), 0); - - lv_obj_t *prompt_desc = lv_label_create(windows); - lv_obj_set_size(prompt_desc, 200, 53); - lv_label_set_long_mode(prompt_desc, LV_LABEL_LONG_WRAP); - lv_label_set_text(prompt_desc, "Please select the internal model of the current test chip."); - lv_obj_set_align(prompt_desc, LV_ALIGN_TOP_LEFT); - lv_obj_set_pos(prompt_desc, 13, 53); - lv_label_set_recolor(prompt_desc, true); - - lv_obj_t *chip_model_desc = lv_label_create(windows); - lv_obj_set_size(chip_model_desc, 200, 53); - lv_label_set_long_mode(chip_model_desc, LV_LABEL_LONG_WRAP); - lv_label_set_text_fmt(chip_model_desc, "Please select the internal model of the current #76CB1D %s. #", board->chip_intel_module); - lv_obj_set_align(chip_model_desc, LV_ALIGN_TOP_LEFT); - lv_obj_set_pos(chip_model_desc, 13, 120); - lv_label_set_recolor(chip_model_desc, true); - - lv_obj_t *btn = lv_btn_create(windows); - lv_obj_set_size(btn, 150, 67); - lv_obj_set_pos(btn, 13, 191); - - lv_obj_t *btn_label = lv_label_create(btn); - lv_label_set_text(btn_label, "Apply"); - lv_obj_set_align(btn_label, LV_ALIGN_CENTER); - lv_obj_set_style_text_font(btn_label, &lv_font_montserrat_24_cp, 0); - - char roller_text[256] = {0}; - for (int i = 0; i < board->chip_intel_module_list_num; i++) { - strncat(roller_text, board->chip_intel_module_list[i], sizeof(roller_text) - 1); - if (i != board->chip_intel_module_list_num - 1) - strncat(roller_text, "\n", sizeof(roller_text) - 1); - } - lv_obj_t *roller = lv_roller_create(windows); - lv_roller_set_options(roller, roller_text, LV_ROLLER_MODE_NORMAL); - lv_obj_set_size(roller, 190, 205); - lv_obj_set_pos(roller, 250, 53); - int set_select = 0; - for (int i = 0; i < board->chip_intel_module_list_num; i++) { - if (strncmp(board->chip_intel_module, board->chip_intel_module_list[i], DESC_LEN) == 0) - set_select = i; - } - lv_roller_set_selected(roller, set_select, LV_ANIM_OFF); - - lv_obj_add_event_cb(roller, get_chip_intel_model_cb, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(btn, del_top_window_cb, LV_EVENT_ALL, mask); - - lv_event_send(roller, LV_EVENT_VALUE_CHANGED, NULL); -} - -static void sys_time_disabled(void) -{ - lv_obj_add_flag(rtc_time, LV_OBJ_FLAG_HIDDEN); - lv_timer_pause(sys_timer); -} - -static void chip_select_disable(void) -{ - lv_obj_clear_flag(choose_btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_style_bg_color(choose_btn, lv_palette_lighten(LV_PALETTE_GREY, 2), 0); -} - -static void disable_unused_obj(void) -{ - qc_module_t *module = qc_module_create(); - if (qc_manager_module_get(mgr, module, "RTC") == QC_RES_INV) { - sys_time_disabled(); - } - - if (qc_manager_module_get(mgr, module, "SID") == QC_RES_INV) { - chip_select_disable(); - } - qc_module_delete(module); -} - -static void sys_time_update(lv_timer_t *lv_timer) -{ - time_t now; - struct tm *local_time; - - now = time(NULL); - local_time = localtime(&now); - - lv_label_set_text_fmt(rtc_time, "%04d-%02d-%02d %02d:%02d:%02d", local_time->tm_year+1900, local_time->tm_mon+1, local_time->tm_mday, local_time->tm_hour, local_time->tm_min, local_time->tm_sec); -} - -static void reverse_btn_status_cb(lv_timer_t *lv_timer) -{ - if (mgr->progress == 0 || mgr->progress == 100) { - if (lv_obj_has_flag(choose_btn, LV_OBJ_FLAG_CLICKABLE) == false) { - lv_obj_add_flag(choose_btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_style_bg_color(choose_btn, lv_palette_lighten(LV_PALETTE_BLUE, 1), 0); - } - - if (lv_obj_has_flag(start_btn, LV_OBJ_FLAG_CLICKABLE) == false) { - lv_obj_add_flag(start_btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_style_bg_color(start_btn, lv_palette_lighten(LV_PALETTE_BLUE, 1), 0); - } - } else { - if (lv_obj_has_flag(choose_btn, LV_OBJ_FLAG_CLICKABLE) == true) { - lv_obj_clear_flag(choose_btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_style_bg_color(choose_btn, lv_palette_lighten(LV_PALETTE_GREY, 2), 0); - } - - if (lv_obj_has_flag(start_btn, LV_OBJ_FLAG_CLICKABLE) == true) { - lv_obj_clear_flag(start_btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_style_bg_color(start_btn, lv_palette_lighten(LV_PALETTE_GREY, 2), 0); - } - } -} - -static void draw_table_event_cb(lv_event_t * e) -{ - lv_obj_t * obj = lv_event_get_target(e); - lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e); - /* If the cells are drawn... */ - if(dsc->part == LV_PART_ITEMS) { - uint32_t row = dsc->id / lv_table_get_col_cnt(obj); - - /* Make the texts in the first cell center aligned */ - dsc->label_dsc->align = LV_TEXT_ALIGN_CENTER; - if(row == 0) { - dsc->rect_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), dsc->rect_dsc->bg_color, LV_OPA_20); - dsc->rect_dsc->bg_opa = LV_OPA_COVER; - } - - /* MAke every 2nd row grayish */ - if((row != 0 && row % 2) == 0) { - dsc->rect_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), dsc->rect_dsc->bg_color, LV_OPA_10); - dsc->rect_dsc->bg_opa = LV_OPA_COVER; - } - - } -} - -static void start_btn_handler(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - - if (code == LV_EVENT_PRESSED) { - if (mgr->exec_num == 0 && mgr->progress == 100) { - table_status_clear(); - arc_status_clear(); - mgr_result_label_clear(); - qc_board_ops_clear(board); - qc_board_ops_push(board); - } else if (mgr->exec_num == 0 && mgr->progress == 0) { - qc_board_ops_push(board); - } - } -} - - -static void del_top_window_cb(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - lv_obj_t *mask = lv_event_get_user_data(e); - char sid_desc[256]= {0}; - - if(code == LV_EVENT_CLICKED) { - qc_module_t *tmp = qc_module_create(); - qc_disp_data_t *disp = qc_disp_data_create(); - - lv_obj_del(mask); - - qc_write_chip_intel_module_file(board->chip_intel_module); - - qc_manager_module_get(mgr, tmp, "SID"); - snprintf(sid_desc, sizeof(sid_desc) - 1, "%s R comparison", board->chip_intel_module); - qc_module_set_desc(tmp, sid_desc); - qc_manager_module_sync(mgr, tmp); - - qc_disp_data_set(disp, mgr, tmp); - disp->mod_status = QC_MOD_UNEXECUTED; - qc_disp_data_append(disp, mgr); - - qc_disp_data_delete(disp); - qc_module_delete(tmp); - } -} - -static void get_chip_intel_model_cb(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - lv_obj_t *roller = lv_event_get_target(e); - char intel_model[DESC_LEN - 1] = {0}; - - if(code == LV_EVENT_VALUE_CHANGED) { - lv_roller_get_selected_str(roller, intel_model, sizeof(intel_model) - 1); - strncpy(board->chip_intel_module, intel_model, DESC_LEN - 1); - } -} - -static void create_top_window_cb(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - - if(code == LV_EVENT_CLICKED) { - top_windows_create(lv_layer_top()); - } -} - -static qc_res_t is_the_final_module(qc_exec_t *exec, qc_module_t *module) -{ - if (strncmp(exec->module_name, "SAVE", strlen("SAVE")) == 0) { - return QC_RES_OK; - } - return QC_RES_INV; -} - -static void assuming_the_final_test_is_successful(qc_exec_t *exec, qc_module_t *module) -{ - module->list_ops_status[exec->list_ops_pos] = QC_RES_OK; - module->status = QC_MOD_SUCCESS; - qc_manager_update(mgr, module); - module->status = QC_MOD_UNEXECUTED; -} - -static void the_final_test_special_handing(qc_module_t *module) -{ - /* execution result do not match expectations */ - if (module->status == QC_MOD_FAILURE) { - qc_manager_lock(mgr); - mgr->success_num -= 1; - qc_manager_unlock(mgr); - - module->status = QC_MOD_EXECUTING; - qc_manager_module_sync(mgr, module); /* forcefully overwrite the original test results */ - module->status = QC_MOD_FAILURE; - } -} - -#if QC_OS_RT_THREAD || QC_OS_LINUX -static void qc_exec_task(void *arg) -{ - qc_disp_data_t *disp = qc_disp_data_create(); - qc_exec_t *exec = qc_exec_create(); - qc_module_t *module = qc_module_create(); - - while(1) { - if (qc_exec_pop(exec, mgr) == QC_RES_OK) { - int ret = qc_manager_module_get(mgr, module, exec->module_name); - if (ret != QC_RES_OK) { - continue; - } - - /* pre final test successful */ - if (is_the_final_module(exec, module) == QC_RES_OK) { - assuming_the_final_test_is_successful(exec, module); - } - - qc_module_list_ops_exec(module, exec->list_ops_pos); - if (module->list_ops_status[exec->list_ops_pos] == QC_MOD_EXECUTING) { - continue; - } - - if (is_the_final_module(exec, module) == QC_RES_OK) { - the_final_test_special_handing(module); - } - - qc_manager_update(mgr, module); - qc_disp_data_set(disp, mgr, module); - qc_disp_data_append(disp, mgr); - } - qc_mdelay(10); - } - - qc_disp_data_delete(disp); - qc_exec_delete(exec); - qc_module_delete(module); -} -#else -static void qc_exec_task(lv_timer_t *lv_timer) -{ - static qc_disp_data_t *disp = NULL; - static qc_exec_t *exec = NULL; - static qc_module_t *module = NULL; - static int init = 0; - if (!init) { - disp = qc_disp_data_create(); - exec = qc_exec_create(); - module = qc_module_create(); - init = 1; - } - - if (qc_exec_pop(exec, mgr) == QC_RES_OK) { - int ret = qc_manager_module_get(mgr, module, exec->module_name); - if (ret != QC_RES_OK) { - return; - } - - /* pre final test successful */ - if (is_the_final_module(exec, module) == QC_RES_OK) { - assuming_the_final_test_is_successful(exec, module); - } - - qc_module_list_ops_exec(module, exec->list_ops_pos); - if (module->list_ops_status[exec->list_ops_pos] == QC_MOD_EXECUTING) { - return; - } - - if (is_the_final_module(exec, module) == QC_RES_OK) { - the_final_test_special_handing(module); - } - - qc_manager_update(mgr, module); - qc_disp_data_set(disp, mgr, module); - qc_disp_data_append(disp, mgr); - } - qc_mdelay(10); -} -#endif - -static void qc_draw_task(lv_timer_t *lv_timer) -{ - qc_disp_data_t draw_disp = {0}; - - if (qc_disp_data_pop(&draw_disp, mgr) == QC_RES_OK) { - table_cell_update(&draw_disp); - mgr_result_label_update(&draw_disp); - arc_update(&draw_disp); - start_btn_update(draw_disp.mgr_progress); - } -} diff --git a/packages/artinchip/lvgl-ui/aic_demo/usb_osd_demo/usb_osd_settings.c b/packages/artinchip/lvgl-ui/aic_demo/usb_osd_demo/usb_osd_settings.c index 2be0bdb9..889f8fed 100644 --- a/packages/artinchip/lvgl-ui/aic_demo/usb_osd_demo/usb_osd_settings.c +++ b/packages/artinchip/lvgl-ui/aic_demo/usb_osd_demo/usb_osd_settings.c @@ -576,13 +576,16 @@ static lv_obj_t * creat_screen_blank_delay_dropdown(lv_obj_t * parent) return dd; } +static void lv_mpp_fb_open(void) +{ + g_fb = mpp_fb_open(); +} + static void lv_bg_dark_set(lv_obj_t * parent) { struct aicfb_screeninfo info; char bg_dark[256]; - g_fb = mpp_fb_open(); - mpp_fb_ioctl(g_fb, AICFB_GET_SCREENINFO, &info); snprintf(bg_dark, 255, "L:/%dx%d_%d_%08x.fake",\ info.width, info.height, 0, 0x00000000); @@ -624,12 +627,37 @@ static unsigned int lv_calculate_pictures_count(void) return image_count; } +static void lv_menu_set_style(lv_obj_t * menu) +{ + struct aicfb_screeninfo info; + u32 height = USB_OSD_MENU_HEIGHT; + u32 width = USB_OSD_MENU_WIDTH; + + mpp_fb_ioctl(g_fb, AICFB_GET_SCREENINFO, &info); + + static lv_style_t menu_style; + lv_style_init(&menu_style); + lv_style_set_bg_opa(&menu_style, LV_OPA_90); + + if (info.width < width) + width = info.width * 0.8; + if (height > info.height) + height = info.height * 0.8; + + lv_style_set_width(&menu_style, width); + lv_style_set_height(&menu_style, height); + lv_style_set_align(&menu_style, LV_ALIGN_BOTTOM_MID); + + lv_obj_add_style(menu, &menu_style, 0); +} + lv_obj_t * lv_settings_screen_creat(void) { lv_obj_t * settings_screen = lv_obj_create(NULL); lv_obj_clear_flag(settings_screen, LV_OBJ_FLAG_SCROLLABLE); lv_obj_add_event_cb(settings_screen, menu_event_cb, LV_EVENT_ALL, NULL); + lv_mpp_fb_open(); lv_bg_dark_set(settings_screen); lv_logo_image_create(settings_screen); @@ -644,11 +672,7 @@ lv_obj_t * lv_settings_screen_creat(void) menu = lv_menu_create(settings_screen); lv_obj_add_event_cb(menu, menu_event_handler, LV_EVENT_ALL, menu); lv_timer_create(menu_hide_callback, USB_OSD_MENU_HIDE_TIME_MS, 0); - - static lv_style_t menu_style; - lv_style_init(&menu_style); - lv_style_set_bg_opa(&menu_style, LV_OPA_90); - lv_obj_add_style(menu, &menu_style, 0); + lv_menu_set_style(menu); lv_color_t bg_color = lv_obj_get_style_bg_color(menu, 0); if(lv_color_brightness(bg_color) > 127) @@ -656,9 +680,6 @@ lv_obj_t * lv_settings_screen_creat(void) else lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, 0), 50), 0); - lv_obj_set_size(menu, USB_OSD_MENU_WIDTH, USB_OSD_MENU_HEIGHT); - lv_obj_align(menu, LV_ALIGN_BOTTOM_MID, 0, 0); - /* Create sub pages */ lv_obj_t * cont; lv_obj_t * section; diff --git a/packages/artinchip/lvgl-ui/aic_ui.c b/packages/artinchip/lvgl-ui/aic_ui.c index 7cb30b0a..a70c5636 100644 --- a/packages/artinchip/lvgl-ui/aic_ui.c +++ b/packages/artinchip/lvgl-ui/aic_ui.c @@ -66,11 +66,6 @@ void aic_ui_init() dashboard_ui_init(); #endif -#ifdef AIC_LVGL_DASHBOARD_SMALL_DEMO - extern lv_obj_t* dashboard_ui_init(void); - dashboard_ui_init(); -#endif - #ifdef AIC_LVGL_DEMO_HUB_DEMO extern void demo_hub_init(void); demo_hub_init(); @@ -118,11 +113,6 @@ void aic_ui_init() image_ui_init(); #endif -#ifdef AIC_LVGL_86BOX_DEMO - extern void a_86_box_ui_init(void); - a_86_box_ui_init(); -#endif - #ifdef AIC_USE_TOUCH_MONKEY_TEST use_touch_monkey_test(); #endif diff --git a/packages/artinchip/lvgl-ui/aic_widgets/aic_lv_ffmpeg/aic_lv_ffmpeg.c b/packages/artinchip/lvgl-ui/aic_widgets/aic_lv_ffmpeg/aic_lv_ffmpeg.c index b26814b3..7e92b412 100644 --- a/packages/artinchip/lvgl-ui/aic_widgets/aic_lv_ffmpeg/aic_lv_ffmpeg.c +++ b/packages/artinchip/lvgl-ui/aic_widgets/aic_lv_ffmpeg/aic_lv_ffmpeg.c @@ -1,3 +1,12 @@ +/* + * Copyright (C) 2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: Zequan Liang + * Ning Fang + */ + #include "aic_lv_ffmpeg.h" #if LV_USE_FFMPEG == 0 && defined(AIC_MPP_PLAYER_INTERFACE) @@ -450,7 +459,7 @@ static void lv_ffmpeg_player_protect_disp_area(lv_obj_t *obj, lv_point_t *pos, } if (pos->y + *height > LV_VER_RES) { - *height = (LV_HOR_RES - pos->y); + *height = (LV_VER_RES - pos->y); LV_LOG_ERROR("lv obj height too large!"); } diff --git a/packages/artinchip/lvgl-ui/lv_demo.c b/packages/artinchip/lvgl-ui/lv_demo.c index 05b2ae41..ae6b0f0c 100644 --- a/packages/artinchip/lvgl-ui/lv_demo.c +++ b/packages/artinchip/lvgl-ui/lv_demo.c @@ -17,13 +17,15 @@ #include #include "aic_time.h" -void lv_user_gui_init(void) +void lv_wait_sdcard_mounted(void) { - // wait sdcard mounted if (!strcmp(LVGL_STORAGE_PATH, "/sdcard")) { aicos_msleep(1000); } +} +void lv_user_gui_init(void) +{ aic_ui_init(); } diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.c b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.c index 3490b81a..232d6ee8 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.c +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.c @@ -272,7 +272,7 @@ static lv_res_t jpeg_decoder_info(lv_img_decoder_t *decoder, const void *src, lv return LV_RES_INV; } -#if MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE == 1 +#if defined(MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE) int shift = jpeg_size_limit(width, height); header->w = width >> shift; header->h = height >> shift; @@ -694,7 +694,7 @@ static lv_res_t aic_decoder_open(lv_img_decoder_t *decoder, lv_img_decoder_dsc_t alloc_frame->buf.buf_type = MPP_PHY_ADDR; int size_shift = 0; -#if MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE == 1 +#if defined(MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE) if (type == MPP_CODEC_VIDEO_DECODER_MJPEG) size_shift = jpeg_size_limit(width, height); #endif diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.h b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.h index 2db58994..06865de9 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.h +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/aic_dec.h @@ -13,15 +13,22 @@ extern "C" { #endif +#include #include #include #include "lvgl.h" #ifndef MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE -#define MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE 0 +#define MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE #endif + +#ifndef MPP_JPEG_DEC_MAX_OUT_WIDTH #define MPP_JPEG_DEC_MAX_OUT_WIDTH 2048 +#endif + +#ifndef MPP_JPEG_DEC_MAX_OUT_HEIGHT #define MPP_JPEG_DEC_MAX_OUT_HEIGHT 2048 +#endif static inline int jpeg_width_limit(int width) { diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.c b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.c index d36e192c..e56d7483 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.c +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.c @@ -91,6 +91,16 @@ int fbdev_get_size(int *width, int *height) return 0; } +unsigned int fbdev_get_screen_width() +{ + return g_info.width; +} + +unsigned int fbdev_get_screen_height() +{ + return g_info.height; +} + enum mpp_pixel_format fbdev_get_fmt(void) { if (g_info.bits_per_pixel == 32) diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.h b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.h index 86acdcb5..8cd9d688 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.h +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_fbdev.h @@ -12,6 +12,7 @@ extern "C" { #endif +#include #include "mpp_types.h" /* @@ -25,9 +26,20 @@ extern "C" { */ -// #define USE_DRAW_BUF -#define DRAW_BUF_WIDTH 1024 -#define DRAW_BUF_HEIGHT 600 +#if defined(LV_DISPLAY_ROTATE_EN) +#ifndef USE_DRAW_BUF +#define USE_DRAW_BUF +#endif // USE_DRAW_BUF + +#ifndef DRAW_BUF_WIDTH +#define DRAW_BUF_WIDTH fbdev_get_screen_width() +#endif // DRAW_BUF_WIDTH + +#ifndef DRAW_BUF_HEIGHT +#define DRAW_BUF_HEIGHT fbdev_get_screen_height() +#endif // DRAW_BUF_HEIGHT + +#endif // LV_DISPLAY_ROTATE_EN #define MAX_FRAME_NUM 2 @@ -48,6 +60,10 @@ int fbdev_get_pitch(void); int draw_buf_size(int *width, int *height); +unsigned int fbdev_get_screen_width(); + +unsigned int fbdev_get_screen_height(); + enum mpp_pixel_format draw_buf_fmt(void); int draw_buf_bpp(void); diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_port_disp.c b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_port_disp.c index 55e791b8..4f2e38c5 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_port_disp.c +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lv_drivers/lv_port_disp.c @@ -379,11 +379,6 @@ void lv_port_disp_init(void) disp_drv.draw_ctx_deinit = lv_draw_aic_ctx_deinit; disp_drv.draw_ctx_size = sizeof(lv_draw_aic_ctx_t); - /* when define USE_DRAW_BUF, disp_drv.rotated can be - LV_DISP_ROT_90/LV_DISP_ROT_180/LV_DISP_ROT_270 - */ - //disp_drv.rotated = LV_DISP_ROT_90; - /*Finally register the driver*/ #ifdef AIC_LVGL_METER_DEMO lv_disp_t *disp = lv_disp_drv_register(&disp_drv); @@ -393,6 +388,10 @@ void lv_port_disp_init(void) lv_disp_drv_register(&disp_drv); #endif +#if defined(LV_DISPLAY_ROTATE_EN) && defined(LV_ROTATE_DEGREE) + lv_disp_set_rotation(lv_disp_get_default(), LV_ROTATE_DEGREE / 90); +#endif + #ifndef AIC_MONKEY_TEST #if defined(KERNEL_RTTHREAD) && defined(AIC_USING_TOUCH) result = tpc_run(AIC_TOUCH_PANEL_NAME, info.width, info.height); diff --git a/packages/artinchip/lvgl-ui/lvgl_v8/lvgl/env_support/rt-thread/lv_rt_thread_port.c b/packages/artinchip/lvgl-ui/lvgl_v8/lvgl/env_support/rt-thread/lv_rt_thread_port.c index c3342562..e6c0d8b1 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v8/lvgl/env_support/rt-thread/lv_rt_thread_port.c +++ b/packages/artinchip/lvgl-ui/lvgl_v8/lvgl/env_support/rt-thread/lv_rt_thread_port.c @@ -31,6 +31,7 @@ extern void lv_port_disp_init(void); extern void lv_port_indev_init(void); extern void lv_user_gui_init(void); +extern void lv_wait_sdcard_mounted(void); static struct rt_thread lvgl_thread; static ALIGN(8) rt_uint8_t lvgl_thread_stack[LPKG_LVGL_THREAD_STACK_SIZE]; @@ -59,6 +60,7 @@ void app_notify(rt_uint8_t event, rt_uint8_t mode, void *data) static void lvgl_thread_entry(void *parameter) { + lv_wait_sdcard_mounted(); #if LV_USE_LOG lv_log_register_print_cb(lv_rt_log); #endif /* LV_USE_LOG */ diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lv_conf.h b/packages/artinchip/lvgl-ui/lvgl_v9/lv_conf.h index 5e98350e..2a7ef0c9 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lv_conf.h +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lv_conf.h @@ -44,7 +44,7 @@ #endif #define LV_USE_MEM_MONITOR 0 -#define LV_USE_PERF_MONITOR 1 +#define LV_USE_PERF_MONITOR 0 #define LV_USE_SYSMON 1 #define LV_INDEV_DEF_READ_PERIOD 10 @@ -103,9 +103,13 @@ #define LV_USE_GIF 1 -#define LV_CACHE_DEF_SIZE 10 * 1024 * 1024 +#ifndef LV_CACHE_DEF_SIZE +#define LV_CACHE_DEF_SIZE 8 * 1024 * 1024 +#endif +#ifndef LV_IMAGE_HEADER_CACHE_DEF_CNT #define LV_IMAGE_HEADER_CACHE_DEF_CNT 20 +#endif #define LV_DEF_REFR_PERIOD 10 diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.c b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.c index d397056d..58a6955c 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.c +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.c @@ -382,6 +382,13 @@ static lv_result_t jpeg_decoder_info(lv_image_decoder_t *decoder, const void *sr return LV_RESULT_INVALID; } +#if defined(MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE) + int size_shift = jpeg_size_limit(width, height); + width = width >> size_shift; + height = height >> size_shift; + header->reserved_2 = size_shift; +#endif + header->w = width; header->h = height; header->cf = mpp_fmt_to_lv_fmt(format); @@ -754,7 +761,18 @@ static lv_result_t lv_mpp_dec_open(lv_image_decoder_t *decoder, lv_image_decoder dec_frame.buf.format = config.pix_fmt; dec_frame.buf.buf_type = MPP_PHY_ADDR; + int size_shift = 0; +#if defined(MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE) + if (type == MPP_CODEC_VIDEO_DECODER_MJPEG) + size_shift = dsc->header.reserved_2; +#endif set_frame_buf_size(&dec_frame, buf_size, 0); + if (size_shift > 0) { + struct mpp_scale_ratio scale; + scale.hor_scale = size_shift; + scale.ver_scale = size_shift; + mpp_decoder_control(dec, MPP_DEC_INIT_CMD_SET_SCALE, &scale); + } CHECK_RET(frame_buf_alloc(mpp_data, &dec_frame.buf, buf_size, dsc->header.cf), LV_RESULT_OK); @@ -894,7 +912,7 @@ void lv_mpp_dec_deinit(void) } } -#if defined(LPKG_USING_LVGL) && defined(LVGL_V_9) +#if defined(LPKG_USING_LVGL) && defined(LVGL_V_9) && LV_CACHE_DEF_SIZE > 0 bool lv_drop_one_cached_image() { #define img_cache_p (LV_GLOBAL_DEFAULT()->img_cache) diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.h b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.h index b3ccb928..53715690 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.h +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_mpp_dec/lv_mpp_dec.h @@ -13,6 +13,9 @@ extern "C" { #endif +#include +#include "lvgl.h" + #ifndef LV_USE_MPP_DEC #define LV_USE_MPP_DEC 1 #endif @@ -25,6 +28,53 @@ extern "C" { #define LV_CACHE_IMG_NUM 8 #endif +#ifndef MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE +#define MPP_JPEG_DEC_OUT_SIZE_LIMIT_ENABLE +#endif + +#ifndef MPP_JPEG_DEC_MAX_OUT_WIDTH +#define MPP_JPEG_DEC_MAX_OUT_WIDTH 2048 +#endif + +#ifndef MPP_JPEG_DEC_MAX_OUT_HEIGHT +#define MPP_JPEG_DEC_MAX_OUT_HEIGHT 2048 +#endif + +static inline int jpeg_width_limit(int width) +{ + int r = 0; + + while(width > MPP_JPEG_DEC_MAX_OUT_WIDTH) { + width = width >> 1; + r++; + + if (r == 3) { + break; + } + } + return r; +} + +static inline int jpeg_height_limit(int height) +{ + int r = 0; + + while(height > MPP_JPEG_DEC_MAX_OUT_HEIGHT) { + height = height >> 1; + r++; + + if (r == 3) { + break; + } + } + return r; +} + +static inline int jpeg_size_limit(int w, int h) +{ + return LV_MAX(jpeg_width_limit(w), jpeg_height_limit(h)); +} + void lv_mpp_dec_init(void); void lv_mpp_dec_deinit(void); diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.c b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.c index 50db2368..2cf7c9b8 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.c +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.c @@ -8,12 +8,83 @@ #include #include +#include +#include #include "lvgl.h" #include "lv_port_disp.h" #include "lv_tpc_run.h" #include "lv_draw_ge2d.h" #include "lv_mpp_dec.h" +#if LV_DISP_FB_DUMP +static char g_save_path[128] = { 0 }; +static bool g_dump_flag = false; + +static inline void lv_disp_buf_dump(lv_display_t *disp) +{ + if (g_dump_flag) { + g_dump_flag = false; + lv_fs_res_t res = LV_FS_RES_OK; + lv_color_format_t cf = lv_display_get_color_format(disp); + uint32_t h = lv_display_get_vertical_resolution(disp); + uint32_t w = lv_display_get_horizontal_resolution(disp); + uint32_t stride = lv_draw_buf_width_to_stride(w, cf); + lv_draw_buf_t *disp_buf = lv_display_get_buf_active(disp); + lv_fs_file_t file_save; + uint32_t data_write = 0; + char src[128]; + + snprintf(src, 127, "L:%s", g_save_path); + res = lv_fs_open(&file_save, src, LV_FS_MODE_WR); + if(res != LV_FS_RES_OK) { + LV_LOG_ERROR("open %s failed", src); + return; + } + lv_fs_write(&file_save, disp_buf->data, h * stride, &data_write); + lv_fs_close(&file_save); + printf("save %s ok\n", g_save_path); + } +} + +static void lv_fb_dump(int argc, char **argv) +{ + int ret; + const char sopts[] = "u:o:"; + const struct option lopts[] = { + {"usage", no_argument, NULL, 'u'}, + {"output", required_argument, NULL, 'o'}, + {0, 0, 0, 0} + }; + + optind = 0; + while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) { + switch (ret) { + case 'o': + strcpy(g_save_path, optarg); + break; + case 'u': + printf("Usage: %s [Options]: \n", argv[0]); + printf("\t-o, --output image path\n"); + printf("\tfor example:\n"); + printf("\tlv_fb_dump -o /sdcard/out.bin\n"); + return; + default: + LV_LOG_ERROR("Invalid parameter: %#x\n", ret); + return; + } + } + + if (strlen(g_save_path)) { + g_dump_flag = true; + } else { + printf("please check output path:%s\n", g_save_path); + } + return; +} + +MSH_CMD_EXPORT_ALIAS(lv_fb_dump, lv_dump, lvgl dump display buffer); +#endif + static void display_cal_frame_rate(aic_disp_t *aic_disp) { #if DISP_SHOW_FPS == 1 @@ -129,6 +200,10 @@ static void disp_flush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_ma (void)px_map; if (lv_disp_flush_is_last(disp)) { +#if LV_DISP_FB_DUMP + // dump frame buffer + lv_disp_buf_dump(disp); +#endif if (disp_buf->data == aic_disp->buf_aligned) { #ifdef AIC_PAN_DISPLAY aic_disp->buf_id = aic_disp->buf_id > 0 ? 0 : 1; @@ -186,7 +261,7 @@ static lv_color_format_t lv_display_fmt(enum mpp_pixel_format cf) return fmt; } -#if LV_USE_OS && defined(AIC_PAN_DISPLAY) +#if LV_USE_OS && defined(AIC_PAN_DISPLAY) && defined(LV_DISPLAY_ROTATE_EN) static void aic_display_thread(void *ptr) { aic_disp_t *aic_disp = (aic_disp_t *)ptr; @@ -219,7 +294,7 @@ static void aic_display_thread(void *ptr) #if defined(LV_DISPLAY_ROTATE_EN) static uint8_t *create_draw_buf(aic_disp_t *aic_disp, int w, int h, lv_color_format_t cf) { - int bpp = lv_color_format_get_bpp(cf); + int bpp = lv_color_format_get_bpp(cf) / 8; int buf_size = ALIGN_UP(w, 8) * ALIGN_UP(h, 8) * bpp; aic_disp->buf = (uint8_t *)aicos_malloc_try_cma(buf_size + CACHE_LINE_SIZE - 1); @@ -307,7 +382,7 @@ void lv_port_disp_init(void) lv_display_set_rotation(disp, LV_ROTATE_DEGREE / 90); #endif -#if LV_USE_OS && defined(AIC_PAN_DISPLAY) +#if LV_USE_OS && defined(AIC_PAN_DISPLAY) && defined(LV_DISPLAY_ROTATE_EN) aic_disp->sync_ready = true; lv_thread_sync_init(&aic_disp->sync); lv_thread_sync_init(&aic_disp->sync_notify); diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.h b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.h index 8855a505..0bffb949 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.h +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lv_drivers/lv_port_disp.h @@ -19,6 +19,10 @@ extern "C" { #define DISP_SHOW_FPS 1 #endif +#ifndef LV_DISP_FB_DUMP +#define LV_DISP_FB_DUMP 0 +#endif + typedef struct { struct mpp_fb *fb; struct aicfb_screeninfo info; diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/env_support/rt-thread/lv_rt_thread_port.c b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/env_support/rt-thread/lv_rt_thread_port.c index 1ae29b61..b6591640 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/env_support/rt-thread/lv_rt_thread_port.c +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/env_support/rt-thread/lv_rt_thread_port.c @@ -35,6 +35,7 @@ extern void lv_port_disp_init(void); extern void lv_port_indev_init(void); extern void lv_user_gui_init(void); +extern void lv_wait_sdcard_mounted(void); static struct rt_thread lvgl_thread; @@ -45,7 +46,7 @@ static struct rt_thread lvgl_thread; #endif #ifndef LV_MAIN_THREAD_STACK_SIZE - #define LV_MAIN_THREAD_STACK_SIZE (4096 * 2) + #define LV_MAIN_THREAD_STACK_SIZE LPKG_LVGL_THREAD_STACK_SIZE #endif /* LV_MAIN_THREAD_STACK_SIZE */ static rt_uint8_t lvgl_thread_stack[LV_MAIN_THREAD_STACK_SIZE]; @@ -60,6 +61,7 @@ static void lv_rt_log(lv_log_level_t level, const char *buf) static void lvgl_thread_entry(void *parameter) { + lv_wait_sdcard_mounted(); #if LV_USE_LOG lv_log_register_print_cb(lv_rt_log); #endif /* LV_USE_LOG */ diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/osal/lv_os.h b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/osal/lv_os.h index 9b3254fc..db9cf4e9 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/osal/lv_os.h +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/osal/lv_os.h @@ -49,7 +49,11 @@ typedef enum { LV_THREAD_PRIO_LOWEST, LV_THREAD_PRIO_LOW, LV_THREAD_PRIO_MID, +#ifdef LPKG_LVGL_THREAD_PRIO + LV_THREAD_PRIO_HIGH = LPKG_LVGL_THREAD_PRIO, +#else LV_THREAD_PRIO_HIGH, +#endif LV_THREAD_PRIO_HIGHEST, } lv_thread_prio_t; diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/others/sysmon/lv_sysmon.c b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/others/sysmon/lv_sysmon.c index a9f311fb..f2188eef 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/others/sysmon/lv_sysmon.c +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/others/sysmon/lv_sysmon.c @@ -188,6 +188,12 @@ static void perf_update_timer_cb(lv_timer_t * t) 1000 / disp_refr_period); /*Limit due to possible off-by-one error*/ info->calculated.cpu = 100 - LV_SYSMON_GET_IDLE(); + +#ifdef LPKG_USING_CPU_USAGE +#include "cpu_usage.h" + info->calculated.cpu = (uint32_t)cpu_load_average(); +#endif + info->calculated.refr_avg_time = info->measured.refr_cnt ? (info->measured.refr_elaps_sum / info->measured.refr_cnt) : 0; diff --git a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/widgets/image/lv_image.c b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/widgets/image/lv_image.c index 1f166b59..16a09e39 100644 --- a/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/widgets/image/lv_image.c +++ b/packages/artinchip/lvgl-ui/lvgl_v9/lvgl/src/widgets/image/lv_image.c @@ -226,10 +226,12 @@ void lv_image_set_src(lv_obj_t * obj, const void * src) update_align(obj); +#if !defined(AIC_LVGL_METER_DEMO) || defined(LV_METER_SIMPLE_POINT) /*Provide enough room for the rotated corners*/ if(img->rotation || img->scale_x != LV_SCALE_NONE || img->scale_y != LV_SCALE_NONE) { lv_obj_refresh_ext_draw_size(obj); } +#endif lv_obj_invalidate(obj); } @@ -284,12 +286,14 @@ void lv_image_set_rotation(lv_obj_t * obj, int32_t angle) img->rotation = angle; +#if !defined(AIC_LVGL_METER_DEMO) || defined(LV_METER_SIMPLE_POINT) /* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate * the whole ext draw area */ lv_display_t * disp = lv_obj_get_display(obj); lv_display_enable_invalidation(disp, false); lv_obj_refresh_ext_draw_size(obj); lv_display_enable_invalidation(disp, true); +#endif _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px); a.x1 += obj->coords.x1; @@ -325,14 +329,14 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y) lv_obj_invalidate_area(obj, &a); lv_point_set(&img->pivot, x, y); - +#if !defined(AIC_LVGL_METER_DEMO) || defined(LV_METER_SIMPLE_POINT) /* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate * the whole ext draw area */ lv_display_t * disp = lv_obj_get_display(obj); lv_display_enable_invalidation(disp, false); lv_obj_refresh_ext_draw_size(obj); lv_display_enable_invalidation(disp, true); - +#endif lv_image_get_pivot(obj, &pivot_px); _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px); a.x1 += obj->coords.x1; diff --git a/packages/artinchip/mpp/Kconfig b/packages/artinchip/mpp/Kconfig index 0e790a6f..8640f58a 100644 --- a/packages/artinchip/mpp/Kconfig +++ b/packages/artinchip/mpp/Kconfig @@ -20,6 +20,11 @@ config AIC_MPP_AVI_DEMUX default n depends on LPKG_MPP && AIC_MPP_PLAYER_INTERFACE +config AIC_MPP_FLAC_DEMUX + bool "Enable flac demux" + default n + depends on LPKG_MPP && AIC_MPP_PLAYER_INTERFACE && LPKG_USING_LIBFLAC + config AIC_MPP_RECORDER_INTERFACE bool "Enable recorder interface and demo" default n diff --git a/packages/artinchip/mpp/SConscript b/packages/artinchip/mpp/SConscript index ff53fb72..eff5abfd 100644 --- a/packages/artinchip/mpp/SConscript +++ b/packages/artinchip/mpp/SConscript @@ -25,6 +25,7 @@ if GetDepend(['AIC_MPP_PLAYER_INTERFACE']): path += [cwd + '/middle_media/base/parser/mp3'] path += [cwd + '/middle_media/base/parser/wav'] path += [cwd + '/middle_media/base/parser/avi'] + path += [cwd + '/middle_media/base/parser/flac'] #mm path += [cwd + '/middle_media/component/src'] @@ -59,6 +60,8 @@ CPPDEFINES = [] # mpp if GetDepend(['LPKG_MPP']): src += Glob('./base/memory/*.c') + src += Glob('./base/thread/*.c') + src += Glob('./base/ringbuf/*.c') src += Glob('./ge/*.c') src += Glob('./fb/*.c') src += Glob('ve/decoder/*.c') @@ -77,7 +80,9 @@ if GetDepend(['KERNEL_RTTHREAD']) and GetDepend(['LPKG_MPP']) and GetDepend(['AI src += Glob('./mpp_test/bit_stream_parser.c') src += Glob('./mpp_test/pic_crop_test.c') src += Glob('./mpp_test/jpeg_encode_test.c') - src += Glob('./mpp_test/test_mpp_dec.c') + + if GetDepend(['AIC_VE_DRV_V10']): + src += Glob('./mpp_test/test_mpp_dec.c') if GetDepend(['KERNEL_RTTHREAD']) and GetDepend(['LPKG_MPP']) and GetDepend(['AIC_GE_TEST']): src += Glob('./mpp_test/ge_test/public/*.c') @@ -126,6 +131,13 @@ if GetDepend(['AIC_MPP_PLAYER_INTERFACE']): if GetDepend(['AIC_MPP_PLAYER_VE_USE_FILL_FB']): src += Glob('middle_media/player/player_dec_share_test.c') +if GetDepend(['LPKG_USING_LIBFLAC']): + src += Glob('middle_media/audio_decoder/decoder/flac/flac_decoder.c') + +if GetDepend(['AIC_MPP_FLAC_DEMUX']): + src += Glob('middle_media/base/parser/flac/aic_flac_parser.c') + src += Glob('middle_media/base/parser/flac/flac.c') + if GetDepend(['AIC_MPP_AVI_DEMUX']): src += Glob('middle_media/base/parser/avi/aic_avi_parser.c') src += Glob('middle_media/base/parser/avi/avi.c') diff --git a/packages/artinchip/mpp/base/include/mpp_ringbuf.h b/packages/artinchip/mpp/base/include/mpp_ringbuf.h new file mode 100644 index 00000000..e6601a44 --- /dev/null +++ b/packages/artinchip/mpp/base/include/mpp_ringbuf.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: mpp ringbuf interface + */ + +#ifndef MPP_RINGBUF_H +#define MPP_RINGBUF_H + +#include +#ifdef __cplusplus +extern "C" { +#endif + + +typedef void *mpp_ringbuf_t; + +mpp_ringbuf_t mpp_ringbuffer_create(int length); +void mpp_ringbuffer_destroy(mpp_ringbuf_t rb); +void mpp_ringbuffer_reset(mpp_ringbuf_t rb); +int mpp_ringbuffer_put(mpp_ringbuf_t rb, const unsigned char *ptr, int length); +int mpp_ringbuffer_get(mpp_ringbuf_t rb, unsigned char *ptr, int length); +int mpp_ringbuffer_data_len(mpp_ringbuf_t rb); +int mpp_ringbuffer_space_len(mpp_ringbuf_t rb); + +#ifdef __cplusplus +} +#endif + +#endif /* MPP_RINGBUF_H */ diff --git a/packages/artinchip/mpp/base/include/mpp_thread.h b/packages/artinchip/mpp/base/include/mpp_thread.h new file mode 100644 index 00000000..f1203cfb --- /dev/null +++ b/packages/artinchip/mpp/base/include/mpp_thread.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: mpp thread interface + */ + +#ifndef MPP_THREAD_H +#define MPP_THREAD_H + +#include +#include +#include "mpp_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MPP_WAIT_FOREVER (-1) + +typedef void *mpp_sem_t; + + +mpp_sem_t mpp_sem_create(); +void mpp_sem_delete(mpp_sem_t sem); +int mpp_sem_signal(mpp_sem_t sem); +int mpp_sem_wait(mpp_sem_t sem, int64_t us); + + +#ifdef __cplusplus +} +#endif + +#endif /* MPP_THREAD_H */ diff --git a/packages/artinchip/mpp/base/ringbuf/mpp_ringbuf.c b/packages/artinchip/mpp/base/ringbuf/mpp_ringbuf.c new file mode 100644 index 00000000..cf77e5b2 --- /dev/null +++ b/packages/artinchip/mpp/base/ringbuf/mpp_ringbuf.c @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: mpp thread interface + */ + +#include "mpp_ringbuf.h" +#include "mpp_log.h" +#include "mpp_mem.h" +#include +#include +#include +#include "rtconfig.h" + +#if defined(KERNEL_RTTHREAD) +#include "aic_osal.h" +#include +#include +struct mpp_ringbuf_handle { + struct rt_ringbuffer ringbuf; + unsigned char *buf_pool; + int buf_len; +}; +#endif + +mpp_ringbuf_t mpp_ringbuffer_create(int length) +{ + struct mpp_ringbuf_handle *h_ringbuf = NULL; + +#if defined(KERNEL_RTTHREAD) + h_ringbuf = (struct mpp_ringbuf_handle *)mpp_alloc(sizeof(struct mpp_ringbuf_handle)); + if (!h_ringbuf) + return NULL; + memset(h_ringbuf, 0, sizeof(struct mpp_ringbuf_handle)); + h_ringbuf->buf_pool = aicos_malloc_align(MEM_DEFAULT, length, 64); + if (!h_ringbuf->buf_pool) { + loge("ERROR: allocating buffer pool(%d) failed\n", length); + mpp_free(h_ringbuf); + return NULL; + } + rt_ringbuffer_init(&h_ringbuf->ringbuf, h_ringbuf->buf_pool, length); +#else + /*Not support now*/ +#endif + return (mpp_ringbuf_t)h_ringbuf; +} + +void mpp_ringbuffer_destroy(mpp_ringbuf_t rb) +{ + if (rb) { +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + aicos_free_align(MEM_DEFAULT, h_ringbuf->buf_pool); + mpp_free(rb); +#else + /*Not support now*/ +#endif + } +} + +void mpp_ringbuffer_reset(mpp_ringbuf_t rb) +{ + if (rb) { +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + rt_ringbuffer_reset(&h_ringbuf->ringbuf); +#else + /*Not support now*/ +#endif + } +} + +int mpp_ringbuffer_put(mpp_ringbuf_t rb, const unsigned char *ptr, int length) +{ + if (!rb) { + return -1; + } +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + return rt_ringbuffer_put(&h_ringbuf->ringbuf, ptr, length); +#else + /*Not support now*/ + return -1; +#endif +} + +int mpp_ringbuffer_get(mpp_ringbuf_t rb, unsigned char *ptr, int length) +{ + if (!rb) { + return -1; + } +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + return rt_ringbuffer_get(&h_ringbuf->ringbuf, ptr, length); +#else + /*Not support now*/ + return -1; +#endif +} + +int mpp_ringbuffer_data_len(mpp_ringbuf_t rb) +{ + if (!rb) { + return -1; + } +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + return rt_ringbuffer_data_len(&h_ringbuf->ringbuf); +#else + /*Not support now*/ + return -1; +#endif +} + +int mpp_ringbuffer_space_len(mpp_ringbuf_t rb) +{ + if (!rb) { + return -1; + } +#if defined(KERNEL_RTTHREAD) + struct mpp_ringbuf_handle *h_ringbuf = (struct mpp_ringbuf_handle *)rb; + return rt_ringbuffer_space_len(&h_ringbuf->ringbuf); +#else + /*Not support now*/ + return -1; +#endif +} diff --git a/packages/artinchip/mpp/base/thread/mpp_thread.c b/packages/artinchip/mpp/base/thread/mpp_thread.c new file mode 100644 index 00000000..4a505353 --- /dev/null +++ b/packages/artinchip/mpp/base/thread/mpp_thread.c @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: mpp thread interface + */ + +#include "mpp_thread.h" +#include "mpp_log.h" +#include "mpp_mem.h" +#include +#include +#include +#include "rtconfig.h" + +#if defined(KERNEL_RTTHREAD) || \ + defined(KERNEL_FREERTOS) || \ + defined(KERNEL_BAREMETAL) || \ + defined(KERNEL_RHINO) || \ + defined(KERNEL_UCOS_II) +#define MPP_USING_AIC_OSAL +#endif + + +#if defined(MPP_USING_AIC_OSAL) +#include "aic_osal.h" +struct mpp_sem_handle { + aicos_sem_t sem; +}; +#else +#include +struct mpp_sem_handle { + pthread_mutex_t mutex; + pthread_cond_t cond; + pthread_condattr_t condattr; + int need_signal; +}; +#endif + +mpp_sem_t mpp_sem_create() +{ + struct mpp_sem_handle *h_sem = + (struct mpp_sem_handle *)mpp_alloc(sizeof(struct mpp_sem_handle)); + if (h_sem == NULL) + return NULL; + memset(h_sem, 0, sizeof(struct mpp_sem_handle)); + +#if defined(MPP_USING_AIC_OSAL) + h_sem->sem = aicos_sem_create(0); + if (!h_sem->sem) { + loge("aicos_sem_create err!!!\n"); + return NULL; + } +#else + h_sem->need_signal = 0; + if (pthread_mutex_init(&h_sem->mutex, NULL) != 0) { + loge("pthread_mutex_init err!!!\n"); + return NULL; + } + + pthread_condattr_init(&h_sem->condattr); + pthread_condattr_setclock(&h_sem->condattr, CLOCK_REALTIME); + pthread_cond_init(&h_sem->cond, &h_sem->condattr); +#endif + return (mpp_sem_t)h_sem; +} + +void mpp_sem_delete(mpp_sem_t sem) +{ + if (sem) { + struct mpp_sem_handle *h_sem = (struct mpp_sem_handle *)sem; +#if defined(MPP_USING_AIC_OSAL) + aicos_sem_delete(h_sem->sem); + h_sem->sem = NULL; +#else + pthread_condattr_destroy(&h_sem->condattr); + pthread_cond_destroy(&h_sem->cond); + pthread_mutex_destroy(&h_sem->mutex); +#endif + mpp_free(sem); + } +} + +int mpp_sem_signal(mpp_sem_t sem) +{ + if (!sem) + return -1; + struct mpp_sem_handle *h_sem = (struct mpp_sem_handle *)sem; +#if defined(MPP_USING_AIC_OSAL) + aicos_sem_give(h_sem->sem); +#else + pthread_mutex_lock(&h_sem->mutex); + if (h_sem->need_signal) { + pthread_cond_signal(&h_sem->cond); + } + pthread_mutex_unlock(&h_sem->mutex); +#endif + return 0; +} + +int mpp_sem_wait(mpp_sem_t sem, int64_t us) +{ + if (!sem) + return -1; + + struct mpp_sem_handle *h_sem = (struct mpp_sem_handle *)sem; + +#if defined(MPP_USING_AIC_OSAL) + if (us == MPP_WAIT_FOREVER) + aicos_sem_take(h_sem->sem, AICOS_WAIT_FOREVER); + else + aicos_sem_take(h_sem->sem, (unsigned int)(us * 1000)); + return 0; +#else + int ret; + pthread_mutex_lock(&h_sem->mutex); + if (us == MPP_WAIT_FOREVER) { + h_sem->need_signal = 1; + ret = pthread_cond_wait(&h_sem->cond, &h_sem->mutex); + h_sem->need_signal = 0; + } else { + struct timespec out_time; + uint64_t tmp; + ret = clock_gettime(CLOCK_REALTIME, &out_time); + out_time.tv_sec += us / (1 * 1000 * 1000); + tmp = out_time.tv_nsec / 1000 + us % (1 * 1000 * 1000); + out_time.tv_sec += tmp / (1 * 1000 * 1000); + tmp = tmp % (1 * 1000 * 1000); + out_time.tv_nsec = tmp * 1000; + h_sem->need_signal = 1; + ret = pthread_cond_timedwait(&h_sem->cond, &h_sem->mutex, &out_time); + h_sem->need_signal = 0; + } + + pthread_mutex_unlock(&h_sem->mutex); + return ret; +#endif +} diff --git a/packages/artinchip/mpp/include/mpp_dec_type.h b/packages/artinchip/mpp/include/mpp_dec_type.h index 8bca2907..89672691 100644 --- a/packages/artinchip/mpp/include/mpp_dec_type.h +++ b/packages/artinchip/mpp/include/mpp_dec_type.h @@ -159,6 +159,8 @@ enum mpp_dec_errno { // if frame manager not create, mpp_dec_get_frame return DEC_ERR_FM_NOT_CREATE. // app should wait a minute to get frame DEC_ERR_FM_NOT_CREATE = -3, + + DEC_ERR_NOT_CREATE = -4, }; #endif diff --git a/packages/artinchip/mpp/middle_media/audio_decoder/decoder/aic_audio_decoder.c b/packages/artinchip/mpp/middle_media/audio_decoder/decoder/aic_audio_decoder.c old mode 100755 new mode 100644 index cb96d935..e88c22dc --- a/packages/artinchip/mpp/middle_media/audio_decoder/decoder/aic_audio_decoder.c +++ b/packages/artinchip/mpp/middle_media/audio_decoder/decoder/aic_audio_decoder.c @@ -1,20 +1,29 @@ /* -* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd -* -* author: -* Desc: aic_audio_decoder interface -*/ + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: aic_audio_decoder interface + */ #include "mpp_log.h" #include "audio_decoder.h" extern struct aic_audio_decoder* create_mp3_decoder(); +#ifdef LPKG_USING_LIBFLAC +extern struct aic_audio_decoder* create_flac_decoder(); +#endif struct aic_audio_decoder* aic_audio_decoder_create(enum aic_audio_codec_type type) { if(type == MPP_CODEC_AUDIO_DECODER_MP3) return create_mp3_decoder(); +#ifdef LPKG_USING_LIBFLAC + else if (type == MPP_CODEC_AUDIO_DECODER_FLAC) + return create_flac_decoder(); +#endif return NULL; } diff --git a/packages/artinchip/mpp/middle_media/audio_decoder/decoder/flac/flac_decoder.c b/packages/artinchip/mpp/middle_media/audio_decoder/decoder/flac/flac_decoder.c new file mode 100644 index 00000000..47b2feb1 --- /dev/null +++ b/packages/artinchip/mpp/middle_media/audio_decoder/decoder/flac/flac_decoder.c @@ -0,0 +1,565 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: flac decoder interface + */ + +#include +#include +#include +#include +#include + +#include "FLAC/stream_decoder.h" +#include "audio_decoder.h" +#include "mpp_dec_type.h" +#include "mpp_list.h" +#include "mpp_log.h" +#include "mpp_mem.h" +#include "mpp_thread.h" +#include "mpp_ringbuf.h" +#include "share/compat.h" + +#define FLAC_BUFFER_LEN (16 * 1024) +#define FLAC_MIN_FRAME_SIZE 11 +#define FLAC_THD_START 0 +#define FLAC_THD_STOP 1 +#define FLAC_THD_EXIT 2 + +//#define FLAC_WRITE_FILE + +struct flac_stream_decoder_client { + struct aic_audio_decoder *decoder; + uint32_t current_metadata_number; + FLAC__bool ignore_errors; + FLAC__bool error_occurred; +}; + +struct flac_audio_decoder { + struct aic_audio_decoder decoder; + struct mpp_packet *curr_packet; + FLAC__StreamDecoder *stream_decoder; + unsigned char *flac_buffer; + uint32_t flac_buffer_len; + uint32_t channels; + uint32_t sample_rate; + uint32_t bits_per_sample; + FLAC__uint64 total_samples; + FLAC__uint64 have_samples; + uint32_t frame_id; + uint32_t frame_count; + struct flac_stream_decoder_client decoder_client_data; + mpp_ringbuf_t ringbuf; + pthread_t thread_id; + mpp_sem_t ringbuf_sem; + int packet_end_flag; + int read_end_flag; + int write_end_flag; + int thread_state; +}; + + +static void *flac_decoder_thread(void *p_decoder_data); + +#ifdef FLAC_WRITE_FILE +#define FLAC_WRITE_FILE_NAME "/sdcard/test.wav" +static FILE *fout_wav_file = NULL; +extern FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 x); +extern FLAC__bool write_little_endian_int16(FILE *f, FLAC__int16 x); +extern FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x); + +static void flac_decoder_write_file(struct aic_audio_decoder *decoder, + const FLAC__Frame *flac_frame, + const FLAC__int32 *const buffer[]) +{ + + /* write WAVE header before we write the first frame */ + int i = 0; + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)decoder; + FLAC__uint64 total_samples = flac_decoder->total_samples; + unsigned sample_rate = flac_decoder->sample_rate; + unsigned channels = flac_decoder->channels; + unsigned bps = flac_decoder->bits_per_sample; + unsigned total_size = (FLAC__uint32)(total_samples * channels * (bps / 8)); + + if (flac_frame->header.number.sample_number == 0) { + if ((fout_wav_file = fopen(FLAC_WRITE_FILE_NAME, "wb")) == NULL) { + loge("ERROR: opening %s for output\n", FLAC_WRITE_FILE_NAME); + return; + } + if ( + fwrite("RIFF", 1, 4, fout_wav_file) < 4 || + !write_little_endian_uint32(fout_wav_file, total_size + 36) || + fwrite("WAVEfmt ", 1, 8, fout_wav_file) < 8 || + !write_little_endian_uint32(fout_wav_file, 16) || + !write_little_endian_uint16(fout_wav_file, 1) || + !write_little_endian_uint16(fout_wav_file, (FLAC__uint16)channels) || + !write_little_endian_uint32(fout_wav_file, sample_rate) || + !write_little_endian_uint32(fout_wav_file, sample_rate * channels * (bps / 8)) || + !write_little_endian_uint16(fout_wav_file, (FLAC__uint16)(channels * (bps / 8))) || + !write_little_endian_uint16(fout_wav_file, (FLAC__uint16)bps) || + fwrite("data", 1, 4, fout_wav_file) < 4 || + !write_little_endian_uint32(fout_wav_file, total_size)) { + loge("ERROR: write error\n"); + return; + } + } + + /* write decoded PCM samples */ + if (fout_wav_file) { + for (i = 0; i < flac_frame->header.blocksize; i++) { + if ( + !write_little_endian_int16(fout_wav_file, (FLAC__int16)buffer[0][i]) || + !write_little_endian_int16(fout_wav_file, (FLAC__int16)buffer[1][i]) + ) { + loge("ERROR: write error\n"); + return; + } + } + printf("write %u to wav file size %d\n.", flac_decoder->frame_id, + flac_frame->header.blocksize * channels); + } + + if (fout_wav_file && flac_decoder->frame_id >= 200) { + fclose(fout_wav_file); + fout_wav_file = NULL; + } +} +#endif + +static int flac_decoder_put_frame(struct aic_audio_decoder *decoder, + const FLAC__Frame *flac_frame, + const FLAC__int32 *const buffer[]) +{ + char *data; + int i = 0, pos = 0, try_cnt = 100; + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)decoder; + struct aic_audio_frame *frame = NULL; + + if (flac_decoder->sample_rate <= 0 || flac_decoder->channels < 2 || + flac_decoder->frame_count < 1) { + loge("wrong flac decoder params: sample_rate %d, channels %d, frame_count %d.", + flac_decoder->sample_rate, flac_decoder->channels, flac_decoder->frame_count); + return -1; + } + if (flac_decoder->decoder.fm == NULL) { + struct audio_frame_manager_cfg cfg; + cfg.bits_per_sample = flac_decoder->bits_per_sample; + cfg.samples_per_frame = flac_decoder->channels * flac_frame->header.blocksize; + cfg.frame_count = flac_decoder->frame_count; + flac_decoder->decoder.fm = audio_fm_create(&cfg); + if (flac_decoder->decoder.fm == NULL) { + loge("audio_fm_create fail!!!\n"); + } + return -1; + } + + if (flac_decoder->thread_state || flac_decoder->write_end_flag) + return 0; + + /*If all sample data has been received, exit directly*/ + if (flac_decoder->have_samples > flac_decoder->total_samples) + return 0; + + /*Try to get empty frame and write frame data*/ + while (i++ < try_cnt) { + frame = audio_fm_decoder_get_frame(flac_decoder->decoder.fm); + if (frame) + break; + usleep(10000); + } + if (!frame) { + flac_decoder->have_samples += flac_frame->header.blocksize; + loge("get empty cur_sample %d, total_samples %"PRIu64", " + "have_samples %"PRIu64", timeout %d ms.", + flac_frame->header.blocksize, flac_decoder->total_samples, + flac_decoder->have_samples, try_cnt * 10); + return -1; + } + + frame->pts = (flac_decoder->have_samples) * 1000000 / frame->sample_rate; + flac_decoder->have_samples += flac_frame->header.blocksize; + + frame->channels = flac_frame->header.channels; + frame->sample_rate = flac_decoder->sample_rate; + frame->bits_per_sample = flac_decoder->bits_per_sample; + frame->id = flac_decoder->frame_id++; + frame->flag = flac_decoder->have_samples >= flac_decoder->total_samples ? FRAME_FLAG_EOS : 0; + + data = frame->data; + if (frame->flag == FRAME_FLAG_EOS) + flac_decoder->write_end_flag = 1; + + logd("write_pcm frame_id %d, blocksize %d, pts %lld.", flac_decoder->frame_id, + flac_frame->header.blocksize, frame->pts); + logd("write_pcm total_samples %" PRIu64 ", have_samples %" PRIu64 ".", + flac_decoder->total_samples, flac_decoder->have_samples); + + + for (i = 0; i < flac_frame->header.blocksize; i++) { + /* output sample(s) in 16-bit signed little-endian PCM */ + data[pos++] = ((FLAC__int16)buffer[0][i] >> 0) & 0xff; + data[pos++] = ((FLAC__int16)buffer[0][i] >> 8) & 0xff; + if (frame->channels == 2) { + data[pos++] = ((FLAC__int16)buffer[1][i] >> 0) & 0xff; + data[pos++] = ((FLAC__int16)buffer[1][i] >> 8) & 0xff; + } + } + audio_fm_decoder_put_frame(flac_decoder->decoder.fm, frame); + + return 0; +} + +static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *stream_decoder, + FLAC__byte buffer[], + size_t *bytes, + void *client_data) +{ + struct flac_stream_decoder_client *decoder_client = + (struct flac_stream_decoder_client *)client_data; + struct flac_audio_decoder *flac_decoder = + (struct flac_audio_decoder *)decoder_client->decoder; + + const size_t requested_bytes = *bytes; + int data_len = 0; + +wait_next_data: + if (flac_decoder->thread_state != FLAC_THD_START) { + flac_decoder->read_end_flag = 1; + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } + + data_len = mpp_ringbuffer_data_len(flac_decoder->ringbuf); + /*If the data len less than the request len, + *should be wait enough data coming and then run decoder*/ + if (data_len < requested_bytes && flac_decoder->packet_end_flag != FRAME_FLAG_EOS) { + mpp_sem_wait(flac_decoder->ringbuf_sem, MPP_WAIT_FOREVER); + goto wait_next_data; + } else if (data_len == 0 && flac_decoder->packet_end_flag == FRAME_FLAG_EOS) { + logd("flac decoder read the end of stream !!!\n"); + flac_decoder->read_end_flag = 1; + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } + + logd("read_callback request byte %ld, data_len %d.", requested_bytes, data_len); + if (requested_bytes > 0) { + if (data_len < requested_bytes) + *bytes = mpp_ringbuffer_get(flac_decoder->ringbuf, buffer, data_len); + else + *bytes = mpp_ringbuffer_get(flac_decoder->ringbuf, buffer, requested_bytes); + if (*bytes == 0) { + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } else { + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } + } else { + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ + } +} + +static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *stream_decoder, + const FLAC__Frame *frame, + const FLAC__int32 *const buffer[], + void *client_data) +{ + struct aic_audio_decoder *decoder = + ((struct flac_stream_decoder_client *)client_data)->decoder; + + if (frame->header.channels != 2) { + loge("ERROR: This frame contains %u channels (should be 2)\n", frame->header.channels); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if (buffer[0] == NULL) { + loge("ERROR: buffer [0] is NULL\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if (buffer[1] == NULL) { + loge("ERROR: buffer [1] is NULL\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + + /* write decoded PCM samples */ +#ifdef FLAC_WRITE_FILE + flac_decoder_write_file(decoder, frame, buffer); +#endif + flac_decoder_put_frame(decoder, frame, buffer); + + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; +} + +static void metadata_callback(const FLAC__StreamDecoder *stream_decoder, + const FLAC__StreamMetadata *metadata, void *client_data) +{ + struct flac_audio_decoder *flac_decoder = + (struct flac_audio_decoder *)((struct flac_stream_decoder_client *)client_data)->decoder; + + /* print some stats */ + if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { + /* save for later */ + flac_decoder->total_samples = metadata->data.stream_info.total_samples; + flac_decoder->sample_rate = metadata->data.stream_info.sample_rate; + flac_decoder->channels = metadata->data.stream_info.channels; + flac_decoder->bits_per_sample = metadata->data.stream_info.bits_per_sample; + + printf("sample rate : %u Hz\n", flac_decoder->sample_rate); + printf("channels : %u\n", flac_decoder->channels); + printf("bits per sample: %u\n", flac_decoder->bits_per_sample); + printf("total samples : %" PRIu64 "\n", flac_decoder->total_samples); + } +} + +static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) +{ + struct flac_audio_decoder *flac_decoder = + (struct flac_audio_decoder *)((struct flac_stream_decoder_client *)client_data)->decoder; + + if (flac_decoder->thread_state != FLAC_THD_START) + return true; + + if (flac_decoder->read_end_flag && + flac_decoder->have_samples >= flac_decoder->total_samples) { + printf("eof_callback read datalen 0\n"); + return true; + } else { + return false; + } +} + +static void error_callback(const FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderErrorStatus status, void *client_data) +{ + struct flac_audio_decoder *flac_decoder = + (struct flac_audio_decoder *)((struct flac_stream_decoder_client *)client_data)->decoder; + + if (!flac_decoder->read_end_flag && (flac_decoder->thread_state == FLAC_THD_START)) + loge("Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]); +} + +int __flac_decode_init(struct aic_audio_decoder *decoder, struct aic_audio_decode_config *config) +{ + int ret = DEC_OK; + pthread_attr_t attr; + FLAC__StreamDecoderInitStatus init_status; + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)decoder; + + flac_decoder->ringbuf = mpp_ringbuffer_create(FLAC_BUFFER_LEN); + if (!flac_decoder->ringbuf) { + loge("ERROR: allocating flac ringbuffer failed\n"); + return DEC_ERR_NULL_PTR; + } + flac_decoder->flac_buffer_len = FLAC_BUFFER_LEN; + flac_decoder->decoder.pm = audio_pm_create(config); + flac_decoder->frame_count = config->frame_count; + flac_decoder->frame_id = 0; + + /*create flac stream decoder*/ + flac_decoder->stream_decoder = FLAC__stream_decoder_new(); + if (!flac_decoder->stream_decoder) { + loge("ERROR: allocating decoder\n"); + ret = DEC_ERR_NULL_PTR; + goto exit; + } + (void)FLAC__stream_decoder_set_md5_checking(flac_decoder->stream_decoder, true); + + flac_decoder->decoder_client_data.decoder = decoder; + init_status = FLAC__stream_decoder_init_stream(flac_decoder->stream_decoder, + read_callback, + NULL, NULL, NULL, + eof_callback, + write_callback, + metadata_callback, + error_callback, + &flac_decoder->decoder_client_data); + if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + loge("ERROR: initializing decoder: %s\n", + FLAC__StreamDecoderInitStatusString[init_status]); + ret = DEC_ERR_NOT_CREATE; + goto exit; + } + + flac_decoder->ringbuf_sem = mpp_sem_create(); + if (!flac_decoder->ringbuf_sem) { + loge("mpp_sem_create ringbuf sem fail!\n"); + ret = DEC_ERR_NOT_CREATE; + goto exit; + } + + /*create flac stream decoder*/ + pthread_attr_init(&attr); + attr.stacksize = 16 * 1024; + attr.schedparam.sched_priority = 22; + flac_decoder->thread_state = FLAC_THD_START; + ret = pthread_create(&flac_decoder->thread_id, &attr, + flac_decoder_thread, flac_decoder); + + if (ret) { + loge("thread create flac decoder failed %d!\n", ret); + ret = DEC_ERR_NOT_CREATE; + goto exit; + } + + logi("__flac_decode_init success."); + return DEC_OK; + +exit: + if (flac_decoder->ringbuf_sem) { + mpp_sem_delete(flac_decoder->ringbuf_sem); + flac_decoder->ringbuf_sem = NULL; + } + if (flac_decoder->ringbuf) { + mpp_ringbuffer_destroy(flac_decoder->ringbuf); + flac_decoder->ringbuf = NULL; + } + if (flac_decoder->stream_decoder) { + FLAC__stream_decoder_delete(flac_decoder->stream_decoder); + flac_decoder->stream_decoder = NULL; + } + if (flac_decoder->decoder.pm) { + audio_pm_destroy(flac_decoder->decoder.pm); + flac_decoder->decoder.pm = NULL; + } + return ret; +} + +int __flac_decode_destroy(struct aic_audio_decoder *decoder) +{ + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)decoder; + if (!flac_decoder) { + return DEC_ERR_NOT_CREATE; + } + + mpp_sem_signal(flac_decoder->ringbuf_sem); + if (flac_decoder->thread_state == FLAC_THD_START) + flac_decoder->thread_state = FLAC_THD_STOP; + /*wait thread exit and release decoder safety*/ + while(flac_decoder->thread_state != FLAC_THD_EXIT) + usleep(5000); + + if (flac_decoder->ringbuf_sem) { + mpp_sem_delete(flac_decoder->ringbuf_sem); + flac_decoder->ringbuf_sem = NULL; + } + + pthread_join(flac_decoder->thread_id, (void *)NULL); + + if (flac_decoder->ringbuf) { + mpp_ringbuffer_destroy(flac_decoder->ringbuf); + flac_decoder->ringbuf = NULL; + } + if (flac_decoder->stream_decoder) { + FLAC__stream_decoder_delete(flac_decoder->stream_decoder); + flac_decoder->stream_decoder = NULL; + } + if (flac_decoder->decoder.pm) { + audio_pm_destroy(flac_decoder->decoder.pm); + flac_decoder->decoder.pm = NULL; + } + if (flac_decoder->decoder.fm) { + audio_fm_destroy(flac_decoder->decoder.fm); + flac_decoder->decoder.fm = NULL; + } + mpp_free(flac_decoder); + return DEC_OK; +} + +int __flac_decode_frame(struct aic_audio_decoder *decoder) +{ + int ret = DEC_OK; + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)decoder; + if (!flac_decoder) { + return DEC_ERR_NOT_CREATE; + } + if (flac_decoder->thread_state != FLAC_THD_START) { + return DEC_OK; + } + if ((flac_decoder->decoder.fm) && + (audio_fm_get_empty_frame_num(flac_decoder->decoder.fm)) == 0) { + return DEC_NO_EMPTY_FRAME; + } + if (flac_decoder->decoder.pm && + audio_pm_get_ready_packet_num(flac_decoder->decoder.pm) == 0) { + return DEC_NO_READY_PACKET; + } + if (mpp_ringbuffer_space_len(flac_decoder->ringbuf) == 0) { + mpp_sem_signal(flac_decoder->ringbuf_sem); + return DEC_NO_RENDER_FRAME; + } + flac_decoder->curr_packet = audio_pm_dequeue_ready_packet(flac_decoder->decoder.pm); + if (!flac_decoder->curr_packet) { + return DEC_NO_READY_PACKET; + } + + /*Avoid the buffer not enough lead to flac decoder failed*/ + while (mpp_ringbuffer_space_len(flac_decoder->ringbuf) < flac_decoder->curr_packet->size) { + mpp_sem_signal(flac_decoder->ringbuf_sem); + usleep(5000); + } + + ret = mpp_ringbuffer_put(flac_decoder->ringbuf, flac_decoder->curr_packet->data, + flac_decoder->curr_packet->size); + mpp_sem_signal(flac_decoder->ringbuf_sem); + + if (ret != flac_decoder->curr_packet->size) { + loge("ringbuffer put size %d < %d", ret, flac_decoder->curr_packet->size); + } + + flac_decoder->packet_end_flag = flac_decoder->curr_packet->flag; + if (flac_decoder->curr_packet->flag == FRAME_FLAG_EOS) { + /*Active the flac decoder read_callback, avoid read_callback in wait status*/ + mpp_sem_signal(flac_decoder->ringbuf_sem); + usleep(10000); + } + + audio_pm_enqueue_empty_packet(flac_decoder->decoder.pm, flac_decoder->curr_packet); + + return DEC_OK; +} + +int __flac_decode_control(struct aic_audio_decoder *decoder, int cmd, void *param) +{ + return DEC_OK; +} + +int __flac_decode_reset(struct aic_audio_decoder *decoder) +{ + return DEC_OK; +} + +static void *flac_decoder_thread(void *p_decoder_data) +{ + struct flac_audio_decoder *flac_decoder = (struct flac_audio_decoder *)p_decoder_data; + if (!flac_decoder->stream_decoder) { + loge("stream_decoder is not create"); + flac_decoder->thread_state = FLAC_THD_EXIT; + return NULL; + } + FLAC__stream_decoder_process_until_end_of_stream(flac_decoder->stream_decoder); + + flac_decoder->thread_state = FLAC_THD_EXIT; + printf("flac_decoder_thread exit.\n"); + + return NULL; +} + +struct aic_audio_decoder_ops flac_decoder = { + .name = "flac", + .init = __flac_decode_init, + .destroy = __flac_decode_destroy, + .decode = __flac_decode_frame, + .control = __flac_decode_control, + .reset = __flac_decode_reset, +}; + +struct aic_audio_decoder *create_flac_decoder() +{ + struct flac_audio_decoder *s = + (struct flac_audio_decoder *)mpp_alloc(sizeof(struct flac_audio_decoder)); + if (s == NULL) + return NULL; + memset(s, 0, sizeof(struct flac_audio_decoder)); + s->decoder.ops = &flac_decoder; + return &s->decoder; +} diff --git a/packages/artinchip/mpp/middle_media/audio_decoder/include/aic_audio_decoder.h b/packages/artinchip/mpp/middle_media/audio_decoder/include/aic_audio_decoder.h index c8f8cbf0..17202e36 100644 --- a/packages/artinchip/mpp/middle_media/audio_decoder/include/aic_audio_decoder.h +++ b/packages/artinchip/mpp/middle_media/audio_decoder/include/aic_audio_decoder.h @@ -1,9 +1,11 @@ /* -* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd -* -* author: -* Desc: aic_audio_decoder interface -*/ + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: aic_audio_decoder interface + */ #ifndef _AIC_AUDIO_DECODER_H_ @@ -16,6 +18,7 @@ enum aic_audio_codec_type { MPP_CODEC_AUDIO_DECODER_MP3, // decoder MPP_CODEC_AUDIO_DECODER_AAC, MPP_CODEC_AUDIO_DECODER_PCM, + MPP_CODEC_AUDIO_DECODER_FLAC, }; struct aic_audio_frame { diff --git a/packages/artinchip/mpp/middle_media/base/include/aic_stream.h b/packages/artinchip/mpp/middle_media/base/include/aic_stream.h index d43b156c..b24db678 100644 --- a/packages/artinchip/mpp/middle_media/base/include/aic_stream.h +++ b/packages/artinchip/mpp/middle_media/base/include/aic_stream.h @@ -40,6 +40,13 @@ struct aic_stream { ((const uint8_t*)(x))[0]) #endif +#ifndef AIC_RL24 +# define AIC_RL24(x) \ + (((uint32_t)((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif + #ifndef AIC_RL32 # define AIC_RL32(x) \ (((uint32_t)((const uint8_t*)(x))[3] << 24) | \ @@ -48,6 +55,39 @@ struct aic_stream { ((const uint8_t*)(x))[0]) #endif +#ifndef AIC_RB16 +# define AIC_RB16(x) \ + ((((const uint8_t*)(x))[0] << 8) | \ + ((const uint8_t*)(x))[1]) +#endif + +#ifndef AIC_RB24 +# define AIC_RB24(x) \ + (((uint32_t)((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#endif + +#ifndef AIC_RB32 +# define AIC_RB32(x) \ + (((uint32_t)((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#endif + +#ifndef AIC_RB64 +# define AIC_RB64(x) \ + (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#endif + #define aic_stream_read( \ stream, \ buf, \ diff --git a/packages/artinchip/mpp/middle_media/base/parser/aic_parser.c b/packages/artinchip/mpp/middle_media/base/parser/aic_parser.c index 36464456..d1db5e24 100644 --- a/packages/artinchip/mpp/middle_media/base/parser/aic_parser.c +++ b/packages/artinchip/mpp/middle_media/base/parser/aic_parser.c @@ -16,7 +16,9 @@ #ifdef AIC_MPP_AVI_DEMUX #include "aic_avi_parser.h" #endif - +#ifdef AIC_MPP_FLAC_DEMUX +#include "aic_flac_parser.h" +#endif struct aic_parser_create_tbl { char file_type[7]; @@ -33,6 +35,9 @@ struct aic_parser_create_tbl create_tbl[] = { #ifdef AIC_MPP_AVI_DEMUX {"avi", 3, aic_avi_parser_create}, #endif +#ifdef AIC_MPP_FLAC_DEMUX + {"flac", 4, aic_flac_parser_create}, +#endif }; s32 aic_parser_create(unsigned char *uri, struct aic_parser **parser) { diff --git a/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.c b/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.c new file mode 100644 index 00000000..cab46853 --- /dev/null +++ b/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.c @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: aic flac parser + */ + +#include +#include +#include +#include +#include +#include "aic_mov_parser.h" +#include "mpp_log.h" +#include "mpp_mem.h" +#include "mpp_dec_type.h" +#include "aic_stream.h" +#include "flac.h" +#include "aic_flac_parser.h" + +s32 flac_peek(struct aic_parser * parser, struct aic_parser_packet *pkt) +{ + struct aic_flac_parser *flac_parser = (struct aic_flac_parser *)parser; + return flac_peek_packet(flac_parser,pkt); +} + +s32 flac_read(struct aic_parser * parser, struct aic_parser_packet *pkt) +{ + struct aic_flac_parser *flac_parser = (struct aic_flac_parser *)parser; + return flac_read_packet(flac_parser,pkt); +} + +s32 flac_get_media_info(struct aic_parser *parser, struct aic_parser_av_media_info *media) +{ + int i; + struct aic_flac_parser *c = (struct aic_flac_parser *)parser; + + media->has_video = 0; + for (i = 0; i < c->nb_streams; i++) { + struct flac_stream_ctx *st = c->streams[i]; + + if (st->codecpar.codec_type == MPP_MEDIA_TYPE_AUDIO) { + media->has_audio = 1; + media->audio_stream.codec_type = MPP_CODEC_AUDIO_DECODER_FLAC; + media->audio_stream.bits_per_sample = + st->codecpar.bits_per_coded_sample; + media->audio_stream.nb_channel = st->codecpar.channels; + media->audio_stream.sample_rate = st->codecpar.sample_rate; + if (st->codecpar.extradata_size > 0) { + media->audio_stream.extra_data_size = + st->codecpar.extradata_size; + media->audio_stream.extra_data = st->codecpar.extradata; + } + logi("audio bits_per_sample: %d", + st->codecpar.bits_per_coded_sample); + logi("audio channels: %d", st->codecpar.channels); + logi("audio sample_rate: %d", st->codecpar.sample_rate); + logi("audio total_samples: %" PRId64 "", st->total_samples); + } else { + loge("unknown stream(%d) type: %d", i, st->codecpar.codec_type); + } + } + media->file_size = c->file_size; + return 0; +} + +s32 flac_seek(struct aic_parser *parser, s64 time) +{ + struct aic_flac_parser *flac_parser = (struct aic_flac_parser *)parser; + return flac_seek_packet(flac_parser,time); +} + +s32 flac_init(struct aic_parser *parser) +{ + struct aic_flac_parser *flac_parser = (struct aic_flac_parser *)parser; + + if (flac_read_header(flac_parser)) { + loge("flac read header failed"); + return -1; + } + return 0; +} + +s32 flac_destroy(struct aic_parser *parser) +{ + struct aic_flac_parser *flac_parser = (struct aic_flac_parser *)parser; + + if (flac_parser == NULL) { + return -1; + } + flac_close(flac_parser); + aic_stream_close(flac_parser->stream); + mpp_free(flac_parser); + return 0; +} + +s32 aic_flac_parser_create(unsigned char *uri, struct aic_parser **parser) +{ + s32 ret = 0; + struct aic_flac_parser *flac_parser = NULL; + + flac_parser = (struct aic_flac_parser *)mpp_alloc(sizeof(struct aic_flac_parser)); + if (flac_parser == NULL) { + loge("mpp_alloc aic_parser for flac failed!!!!!\n"); + ret = -1; + goto exit; + } + memset(flac_parser, 0, sizeof(struct aic_flac_parser)); + + if (aic_stream_open((char *)uri, &flac_parser->stream, O_RDONLY) < 0) { + loge("stream open %s fail", uri); + ret = -1; + goto exit; + } + + flac_parser->base.get_media_info = flac_get_media_info; + flac_parser->base.peek = flac_peek; + flac_parser->base.read = flac_read; + flac_parser->base.destroy = flac_destroy; + flac_parser->base.seek = flac_seek; + flac_parser->base.init = flac_init; + + *parser = &flac_parser->base; + + return ret; + +exit: + if (flac_parser->stream) { + aic_stream_close(flac_parser->stream); + } + if (flac_parser) { + mpp_free(flac_parser); + } + return ret; +} diff --git a/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.h b/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.h new file mode 100644 index 00000000..b1e22707 --- /dev/null +++ b/packages/artinchip/mpp/middle_media/base/parser/flac/aic_flac_parser.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: aic flac parser + */ + +#ifndef __AIC_FLAC_PARSER_H__ +#define __AIC_FLAC_PARSER_H__ + +#include "aic_parser.h" +#include "aic_stream.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +s32 aic_flac_parser_create(unsigned char* uri, struct aic_parser **parser); + +#ifdef __cplusplus +} +#endif /* End of #ifdef __cplusplus */ + +#endif diff --git a/packages/artinchip/mpp/middle_media/base/parser/flac/flac.c b/packages/artinchip/mpp/middle_media/base/parser/flac/flac.c new file mode 100644 index 00000000..9466773d --- /dev/null +++ b/packages/artinchip/mpp/middle_media/base/parser/flac/flac.c @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: flac parser + */ + +#include "flac.h" +#include "aic_stream.h" +#include "aic_tag.h" +#include "mpp_log.h" +#include "mpp_mem.h" +#include +#include +#include + +#define SEEKPOINT_SIZE 18 +#define FLAC_STREAMINFO_SIZE 34 +#define FLAC_MAX_CHANNELS 8 +#define FLAC_MIN_BLOCKSIZE 16 +#define FLAC_MAX_BLOCKSIZE 65535 +#define FLAC_MIN_FRAME_SIZE 11 + +#define RAW_PACKET_SIZE 1024 + +enum { + FLAC_CHMODE_INDEPENDENT = 0, + FLAC_CHMODE_LEFT_SIDE = 1, + FLAC_CHMODE_RIGHT_SIDE = 2, + FLAC_CHMODE_MID_SIDE = 3, +}; + +enum { + FLAC_METADATA_TYPE_STREAMINFO = 0, + FLAC_METADATA_TYPE_PADDING, + FLAC_METADATA_TYPE_APPLICATION, + FLAC_METADATA_TYPE_SEEKTABLE, + FLAC_METADATA_TYPE_VORBIS_COMMENT, + FLAC_METADATA_TYPE_CUESHEET, + FLAC_METADATA_TYPE_PICTURE, + FLAC_METADATA_TYPE_INVALID = 127 +}; + +static struct flac_stream_ctx *flac_new_stream(struct aic_flac_parser *s) +{ + struct flac_stream_ctx *sc; + + sc = (struct flac_stream_ctx *)mpp_alloc(sizeof(struct flac_stream_ctx)); + if (sc == NULL) { + return NULL; + } + memset(sc, 0, sizeof(struct flac_stream_ctx)); + + sc->index = s->nb_streams; + s->streams[s->nb_streams++] = sc; + + return sc; +} + +static inline void flac_parse_block_header(const uint8_t *block_header, + int *last, int *type, int *size) +{ + int tmp = block_header[0]; + + if (last) + *last = tmp & 0x80; + if (type) + *type = tmp & 0x7F; + if (size) + *size = AIC_RB24(block_header + 1); +} + + +int flac_read_header(struct aic_flac_parser *s) +{ + int ret, metadata_last = 0, metadata_type, metadata_size, found_streaminfo = 0; + uint8_t header[4]; + uint8_t *buffer = NULL; + struct flac_stream_ctx *st = flac_new_stream(s); + if (!st) + return PARSER_NOMEM; + + st->codecpar.codec_type = MPP_MEDIA_TYPE_AUDIO; + st->codecpar.codec_id = MPP_CODEC_AUDIO_DECODER_FLAC; + s->file_size = aic_stream_size(s->stream); + + /* the parameters will be extracted from the compressed bitstream */ + + /* if fLaC marker is not found, assume there is no header */ + if (aic_stream_rl32(s->stream) != MKTAG('f', 'L', 'a', 'C')) { + aic_stream_seek(s->stream, -4, SEEK_CUR); + return PARSER_OK; + } + + /* process metadata blocks */ + while ((aic_stream_tell(s->stream) < s->file_size) && !metadata_last) { + if (aic_stream_read(s->stream, header, 4) != 4) + return PARSER_INVALIDDATA; + + flac_parse_block_header(header, &metadata_last, &metadata_type, + &metadata_size); + switch (metadata_type) { + /* allocate and read metadata block for supported types */ + case FLAC_METADATA_TYPE_STREAMINFO: + buffer = mpp_alloc(metadata_size + 64); + if (!buffer) { + return PARSER_NOMEM; + } + if (aic_stream_read(s->stream, buffer, metadata_size) != metadata_size) { + return PARSER_NODATA; + } + break; + /* skip metadata block for unsupported types */ + default: + ret = aic_stream_skip(s->stream, metadata_size); + if (ret < 0) + return ret; + } + + if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) { + /* STREAMINFO can only occur once */ + if (found_streaminfo) { + return PARSER_INVALIDDATA; + } + if (metadata_size != FLAC_STREAMINFO_SIZE) { + return PARSER_INVALIDDATA; + } + found_streaminfo = 1; + st->codecpar.sample_rate = AIC_RB24(buffer + 10) >> 4; + st->codecpar.channels = ((*(buffer + 12) >> 1) & 0x7) + 1; + st->codecpar.bits_per_coded_sample = ((AIC_RB16(buffer + 12) >> 4) & 0x1f) + 1; + st->total_samples = (AIC_RB64(buffer + 13) >> 24) & ((1ULL << 36) - 1); + mpp_free(buffer); + } + } + + aic_stream_seek(s->stream, 0, SEEK_SET); + + return PARSER_OK; +} + +int flac_close(struct aic_flac_parser *s) +{ + int i; + + for (i = 0; i < s->nb_streams; i++) { + struct flac_stream_ctx *st = s->streams[i]; + if (!st) { + continue; + } + + mpp_free(st); + } + + return PARSER_OK; +} + +int flac_seek_packet(struct aic_flac_parser *s, s64 seek_time) +{ + return PARSER_ERROR; +} + +int flac_peek_packet(struct aic_flac_parser *s, struct aic_parser_packet *pkt) +{ + int64_t pos; + static int64_t count = 0; + + pos = aic_stream_tell(s->stream); + if (pos >= s->file_size) { + logd("Peek PARSER_EOS,%" PRId64 ",%" PRId64 "\n", pos, s->file_size); + return PARSER_EOS; + } + if (pos + RAW_PACKET_SIZE >= s->file_size) + pkt->size = s->file_size - pos; + else + pkt->size = RAW_PACKET_SIZE; + pkt->type = MPP_MEDIA_TYPE_AUDIO; + pkt->pts = count++; + return PARSER_OK; +} + +int flac_read_packet(struct aic_flac_parser *s, struct aic_parser_packet *pkt) +{ + int64_t pos; + int ret; + + pos = aic_stream_tell(s->stream); + if (pos >= s->file_size) { + loge("PARSER_EOS,%" PRId64 ",%" PRId64 "\n", pos, s->file_size); + return PARSER_EOS; + } + + ret = aic_stream_read(s->stream, pkt->data, pkt->size); + pos = aic_stream_tell(s->stream); + if (pos >= s->file_size) { + printf("Read PARSER_EOS,%" PRId64 ",%" PRId64 "\n", pos, s->file_size); + pkt->flag |= PACKET_EOS; + } else { + if (ret != pkt->size) { + loge("hope_len:%d,ret:%d\n", pkt->size, ret); + } + } + return PARSER_OK; +} diff --git a/packages/artinchip/mpp/middle_media/base/parser/flac/flac.h b/packages/artinchip/mpp/middle_media/base/parser/flac/flac.h new file mode 100644 index 00000000..f7ed1ecc --- /dev/null +++ b/packages/artinchip/mpp/middle_media/base/parser/flac/flac.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: flac parser + */ + +#ifndef __FLAC_H__ +#define __FLAC_H__ + +#include "aic_parser.h" +#include +#include "aic_tag.h" + +struct flac_stream_ctx { + int index; + uint64_t total_samples; + struct aic_codec_param codecpar; +}; + +#define FLAC_MAX_TRACK_NUM 1 + +struct aic_flac_parser { + struct aic_parser base; + struct aic_stream *stream; + uint64_t file_size; + int nb_streams; + struct flac_stream_ctx *streams[FLAC_MAX_TRACK_NUM]; +}; + +int flac_read_header(struct aic_flac_parser *s); +int flac_close(struct aic_flac_parser *s); +int flac_peek_packet(struct aic_flac_parser *s, struct aic_parser_packet *pkt); +int flac_seek_packet(struct aic_flac_parser *s, s64 seek_time); +int flac_read_packet(struct aic_flac_parser *s, struct aic_parser_packet *pkt); +#endif diff --git a/packages/artinchip/mpp/middle_media/component/src/mm_audio_render_component.c b/packages/artinchip/mpp/middle_media/component/src/mm_audio_render_component.c index 3b642008..4797c457 100644 --- a/packages/artinchip/mpp/middle_media/component/src/mm_audio_render_component.c +++ b/packages/artinchip/mpp/middle_media/component/src/mm_audio_render_component.c @@ -798,6 +798,21 @@ static void mm_audio_render_set_attr(mm_audio_render_data *p_audio_render_data) p_audio_render_data->dev_id); } + if (p_audio_render_data->volume_change) { + if (p_audio_render_data->render->set_volume( + p_audio_render_data->render, + p_audio_render_data->volume) == 0) { + p_audio_render_data->volume_change = 0; + } else { + loge("set_volume error\n"); + } + } else { + p_audio_render_data->volume = + p_audio_render_data->render->get_volume( + p_audio_render_data->render); + logd("volume :%d\n", p_audio_render_data->volume); + } + /*initial state and attr not changed need do set new attr, avoid cost too much time*/ ret = p_audio_render_data->render->get_attr(p_audio_render_data->render, &ao_attr); ao_attr.bits_per_sample = p_audio_render_data->frame.bits_per_sample; @@ -815,20 +830,6 @@ static void mm_audio_render_set_attr(mm_audio_render_data *p_audio_render_data) ao_attr.smples_per_frame = 32 * 1024; p_audio_render_data->audio_render_attr = ao_attr; - if (p_audio_render_data->volume_change) { - if (p_audio_render_data->render->set_volume( - p_audio_render_data->render, - p_audio_render_data->volume) == 0) { - p_audio_render_data->volume_change = 0; - } else { - loge("set_volume error\n"); - } - } else { - p_audio_render_data->volume = - p_audio_render_data->render->get_volume( - p_audio_render_data->render); - logd("volume :%d\n", p_audio_render_data->volume); - } p_audio_render_data->audio_render_init_flag = 1; logd("[%s:%d]bits_per_sample:%d,channels:%d,sample_rate:%d,pts:"FMT_d64"\n", __FUNCTION__, __LINE__, p_audio_render_data->frame.bits_per_sample, diff --git a/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player.c b/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player.c index 400a1d46..7dd220f0 100644 --- a/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player.c +++ b/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player.c @@ -1,9 +1,11 @@ /* -* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd -* -* author: -* Desc: mini_audio_player -*/ + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: mini_audio_player + */ #include #include "aic_audio_decoder.h" @@ -44,6 +46,7 @@ enum MINI_AUDIO_PLAYER_EVENT { enum PLAYER_FILE_TYPE { PLAYER_FILE_MP3 = 0, PLAYER_FILE_WAV = 1, + PLAYER_FILE_FLAC = 2, }; #define MINI_AUDIO_PLAYER_WAVE_BUFF_SIZE (4*1024) @@ -215,8 +218,8 @@ static int mini_audio_player_open(struct mini_audio_player *player) goto _exit; } } - - + } else if (!strncmp(ptr+1, "flac", 4)) { + player->type = PLAYER_FILE_FLAC; } else { MINI_AUDIO_PLAYER_ERROR("unsupport file type\n"); goto _exit; @@ -241,8 +244,12 @@ static int mini_audio_player_open(struct mini_audio_player *player) player->audio_info.nb_channel = media_info.audio_stream.nb_channel; player->audio_info.bits_per_sample = media_info.audio_stream.bits_per_sample; - if (player->type == PLAYER_FILE_MP3) { - player->decoder = aic_audio_decoder_create(MPP_CODEC_AUDIO_DECODER_MP3); + if (player->type == PLAYER_FILE_MP3 || player->type == PLAYER_FILE_FLAC) { + if (player->type == PLAYER_FILE_MP3) + player->decoder = aic_audio_decoder_create(MPP_CODEC_AUDIO_DECODER_MP3); + else if (player->type == PLAYER_FILE_FLAC) + player->decoder = aic_audio_decoder_create(MPP_CODEC_AUDIO_DECODER_FLAC); + if (player->decoder == NULL) { MINI_AUDIO_PLAYER_ERROR("aic_audio_decoder_create fail\n"); goto _exit; @@ -262,6 +269,14 @@ static int mini_audio_player_open(struct mini_audio_player *player) MINI_AUDIO_PLAYER_ERROR("aic_audio_render_init fail\n"); goto _exit; } + + // set volume + if (player->volume != 0) { + aic_audio_render_set_volume(player->render,player->volume); + } else { + player->volume = aic_audio_render_get_volume(player->render); + } + // set attr attr.bits_per_sample = player->audio_info.bits_per_sample; attr.channels = player->audio_info.nb_channel; @@ -270,12 +285,6 @@ static int mini_audio_player_open(struct mini_audio_player *player) MINI_AUDIO_PLAYER_ERROR("aic_audio_render_set_attr fail\n"); goto _exit; } - // set volume - if (player->volume != 0) { - aic_audio_render_set_volume(player->render,player->volume); - } else { - player->volume = aic_audio_render_get_volume(player->render); - } return 0; _exit: @@ -420,7 +429,11 @@ static void mini_audio_player_entry(void *parameter) eos = 1; } } - aic_audio_decoder_decode(player->decoder); + decoder_ret = aic_audio_decoder_decode(player->decoder); + if (decoder_ret == DEC_NO_RENDER_FRAME) { + need_peek = 0; + usleep(5000); + } decoder_ret = aic_audio_decoder_get_frame(player->decoder,&audio_frame); if (decoder_ret == DEC_OK) { aic_audio_render_rend(player->render,audio_frame.data,audio_frame.size); @@ -428,6 +441,11 @@ static void mini_audio_player_entry(void *parameter) if (audio_frame.flag & PARSER_EOS) { player->state = MINI_AUDIO_PLAYER_STATE_STOPED; } + } else if (eos && DEC_NO_RENDER_FRAME == decoder_ret && + player->state != MINI_AUDIO_PLAYER_STATE_STOPED) { + /*Decoder in multithread conditions, should sleep until all data + *decoding to complete*/ + usleep(5000); } } else {// wav parser_ret = aic_parser_peek(player->parser,&parser_pkt); diff --git a/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player_demo.c b/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player_demo.c index effd449d..332dc612 100644 --- a/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player_demo.c +++ b/packages/artinchip/mpp/middle_media/mini_audio_player/mini_audio_player_demo.c @@ -1,10 +1,11 @@ - /* -* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd -* -* author: -* Desc: audio_player_demo -*/ + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: audio_player_demo + */ #include #include @@ -72,7 +73,7 @@ static int read_dir(char* path, struct audio_file_list *files) if (ptr == NULL) continue; - if (strcmp(ptr, ".mp3") && strcmp(ptr, ".wav")) + if (strcmp(ptr, ".mp3") && strcmp(ptr, ".wav") && strcmp(ptr, ".flac")) continue; printf("name: %s\n", dir_file->d_name); diff --git a/packages/artinchip/mpp/middle_media/player/player_demo.c b/packages/artinchip/mpp/middle_media/player/player_demo.c index 934eac42..e162aa3f 100644 --- a/packages/artinchip/mpp/middle_media/player/player_demo.c +++ b/packages/artinchip/mpp/middle_media/player/player_demo.c @@ -545,6 +545,7 @@ static int player_demo_test(int argc, char **argv) rt_device_t render_dev = RT_NULL; struct aicfb_alpha_config alpha_bak = {0}; struct aicfb_alpha_config alpha = {0}; + struct aicfb_layer_data layer = {0}; rt_device_t uart_dev = RT_NULL; struct video_player_ctx *ctx = NULL; @@ -591,6 +592,16 @@ static int player_demo_test(int argc, char **argv) alpha.value = ctx->alpha_value; rt_device_control(render_dev, AICFB_UPDATE_ALPHA_CONFIG, &alpha); + // store ui layer before playing + if (strcmp(PRJ_CHIP, "d12x") == 0) { + layer.layer_id = AICFB_LAYER_TYPE_UI; + if (rt_device_control(render_dev, AICFB_GET_LAYER_CONFIG, &layer) < 0) { + loge("get ui layer config failed\n"); + ret = -1; + goto _EXIT_; + } + } + #ifdef _THREAD_TRACE_INFO_ memset(&thread_trace_infos,0x00,sizeof(struct thread_trace_info)); for (i = 0; i < 6 ;i++) { @@ -696,6 +707,11 @@ _EXIT_: } } + if (strcmp(PRJ_CHIP, "d12x") == 0 && render_dev) { + // restore ui layer after playing + rt_device_control(render_dev,AICFB_UPDATE_LAYER_CONFIG,&layer); + } + if (render_dev) { //restore alpha rt_device_control(render_dev, AICFB_UPDATE_ALPHA_CONFIG, &alpha_bak); diff --git a/packages/artinchip/mpp/vin/mpp_vin.c b/packages/artinchip/mpp/vin/mpp_vin.c index f164df5a..53d5644e 100644 --- a/packages/artinchip/mpp/vin/mpp_vin.c +++ b/packages/artinchip/mpp/vin/mpp_vin.c @@ -41,7 +41,7 @@ int mpp_vin_init(char *camera) pr_err("Failed to find camera %s\n", camera); return -1; } - if (rt_device_open(g_camera_dev, 'r') < 0) { + if (rt_device_open(g_camera_dev, RT_DEVICE_FLAG_RDONLY) < 0) { pr_err("Failed to open camera %s\n", camera); return -1; } diff --git a/packages/artinchip/ota/ota.c b/packages/artinchip/ota/ota.c index 3844d975..365af9a3 100644 --- a/packages/artinchip/ota/ota.c +++ b/packages/artinchip/ota/ota.c @@ -18,7 +18,7 @@ #include "aic_core.h" #include #include -#include +#include #include #include diff --git a/packages/artinchip/ota/test_ota.c b/packages/artinchip/ota/test_ota.c index 9176d43d..cd5b3c0d 100644 --- a/packages/artinchip/ota/test_ota.c +++ b/packages/artinchip/ota/test_ota.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #define BUFFER_SIZE 256 //Need to be less than 2048 bytes diff --git a/packages/third-party/Kconfig b/packages/third-party/Kconfig index 66f91456..4e7bd739 100644 --- a/packages/third-party/Kconfig +++ b/packages/third-party/Kconfig @@ -30,6 +30,7 @@ source "packages/third-party/sqlite/Kconfig" # for baremetal mode source "packages/third-party/dfs/Kconfig" source "packages/third-party/libmad/Kconfig" +source "packages/third-party/libFLAC/Kconfig" source "packages/third-party/fdtlib/Kconfig" source "packages/third-party/gif/Kconfig" source "packages/third-party/micropython-1.13.0/Kconfig" diff --git a/packages/third-party/awtk-ui/awtk-rtos/awtk-port/lcd_rtos/lcd_disp.c b/packages/third-party/awtk-ui/awtk-rtos/awtk-port/lcd_rtos/lcd_disp.c index b01cbbd6..63f69ff9 100644 --- a/packages/third-party/awtk-ui/awtk-rtos/awtk-port/lcd_rtos/lcd_disp.c +++ b/packages/third-party/awtk-ui/awtk-rtos/awtk-port/lcd_rtos/lcd_disp.c @@ -137,10 +137,26 @@ static void on_app_exit(void) { log_info("on_app_exit\n"); } +static void aic_fb_enable(void) +{ +#ifndef AIC_DISP_COLOR_BLOCK + static bool first_frame = true; + /* enable display power after flush first frame */ + if (first_frame) { + if (g_fb.fb) + mpp_fb_ioctl(g_fb.fb, AICFB_POWERON, 0); + first_frame = false; + } +#endif +} + static ret_t (*lcd_mem_rtos_flush_default)(lcd_t* lcd); static ret_t lcd_mem_rtos_flush(lcd_t* lcd) { fb_info_t* fb = &g_fb; int dummy = 0; + + aic_fb_enable(); + mpp_fb_ioctl(fb->fb, AICFB_WAIT_FOR_VSYNC, &dummy); if (lcd_mem_rtos_flush_default) { lcd_mem_rtos_flush_default(lcd); @@ -156,6 +172,9 @@ static ret_t lcd_swap_sync(lcd_t* lcd) { fb_info_t* fb = &g_fb; mpp_fb_ioctl(fb->fb, AICFB_PAN_DISPLAY, &swap_lcd); + + aic_fb_enable(); + mpp_fb_ioctl(fb->fb, AICFB_WAIT_FOR_VSYNC, 0); swap_lcd = swap_lcd == 1 ? 0 : 1; @@ -468,7 +487,11 @@ static void fbswap_thread(void* ctx) { rt_mutex_release(g_lck_fblist); fbid = ready_fb->fbid; + mpp_fb_ioctl(fb->fb, AICFB_PAN_DISPLAY, &fbid); + + aic_fb_enable(); + mpp_fb_ioctl(fb->fb, AICFB_WAIT_FOR_VSYNC, 0); rt_mutex_take(g_lck_fblist, RT_WAITING_NO); diff --git a/packages/third-party/benchmark/linpack/linpack.c b/packages/third-party/benchmark/linpack/linpack.c index c77e7b0c..0024a5c6 100644 --- a/packages/third-party/benchmark/linpack/linpack.c +++ b/packages/third-party/benchmark/linpack/linpack.c @@ -24,9 +24,20 @@ You must specify one of -DSP or -DDP to compile correctly. You must specify one of -DROLL or -DUNROLL to compile correctly. */ +#include -//#define SP +#ifdef ARCH_RISCV_FPU_S +#define SP +#else +/* + * If the chip does not support floating-point, then this program is executed + * with software double precision floating-point. + */ #define DP +#endif + +#define FABS(x) ((x > 0) ? (x) : (-x)) + #define __NO_OS__ #define UNROLL @@ -35,6 +46,7 @@ You must specify one of -DROLL or -DUNROLL to compile correctly. #define ZERO 0.0 #define ONE 1.0 #define PREC "Single " +#define FLOOR_REAL floorf #endif #ifdef DP @@ -42,6 +54,7 @@ You must specify one of -DROLL or -DUNROLL to compile correctly. #define ZERO 0.0e0 #define ONE 1.0e0 #define PREC "Double " +#define FLOOR_REAL floor #endif #define NTIMES 10 @@ -65,18 +78,18 @@ int print_time (row) int row; { #ifndef AIC_PRINT_FLOAT_CUSTOM - fprintf(stderr,"%11.2f%11.2f%11.2f%11.0f%11.2f%11.2f\n", (double)timer[0][row], - (double)timer[1][row], (double)timer[2][row], (double)timer[3][row], - (double)timer[4][row], (double)timer[5][row]); + fprintf(stderr,"%11.2f%11.2f%11.2f%11.0f%11.2f%11.2f\n", (REAL)timer[0][row], + (REAL)timer[1][row], (REAL)timer[2][row], (REAL)timer[3][row], + (REAL)timer[4][row], (REAL)timer[5][row]); #else /* print float */ - double p_f[6] = {0}; + REAL p_f[6] = {0}; unsigned int p_i1[6] = {0}; unsigned int p_i2[6] = {0}; int i = 0; for (i=0; i<6; i++){ - p_f[i] = (double)timer[i][row]; + p_f[i] = (REAL)timer[i][row]; p_i1[i] = (unsigned int)p_f[i]; p_i2[i] = (unsigned int)((p_f[i]-p_i1[i])*100.0); } @@ -537,12 +550,12 @@ int incx,n; /* code for increment not equal to 1 */ ix = 0; - dmax = fabs((double)dx[0]); + dmax = FABS(dx[0]); ix = ix + incx; for (i = 1; i < n; i++) { - if(fabs((double)dx[ix]) > dmax) { + if(FABS(dx[ix]) > dmax) { itemp = i; - dmax = fabs((double)dx[ix]); + dmax = FABS(dx[ix]); } ix = ix + incx; } @@ -552,11 +565,11 @@ int incx,n; /* code for increment equal to 1 */ itemp = 0; - dmax = fabs((double)dx[0]); + dmax = FABS(dx[0]); for (i = 1; i < n; i++) { - if(fabs((double)dx[i]) > dmax) { + if(FABS(dx[i]) > dmax) { itemp = i; - dmax = fabs((double)dx[i]); + dmax = FABS(dx[i]); } } } @@ -605,9 +618,9 @@ REAL x; while (eps == ZERO) { b = a - ONE; c = b + b + b; - eps = fabs((double)(c-ONE)); + eps = FABS((c-ONE)); } - return(eps*fabs((double)x)); + return(eps*FABS(x)); } /*----------------------*/ @@ -739,6 +752,7 @@ return clock()/1.0e6; } #endif #include +#include #include @@ -853,10 +867,8 @@ void test_linpack() resid = 0.0; normx = 0.0; for (i = 0; i < n; i++) { - resid = (resid > fabs((double)b[i])) - ? resid : fabs((double)b[i]); - normx = (normx > fabs((double)x[i])) - ? normx : fabs((double)x[i]); + resid = (resid > FABS(b[i])) ? resid : FABS(b[i]); + normx = (normx > FABS(x[i])) ? normx : FABS(x[i]); } eps = epslon((REAL)ONE); residn = resid/( n*norma*normx*eps ); @@ -864,8 +876,8 @@ void test_linpack() printf(" norm. resid resid machep"); printf(" x[0]-1 x[n-1]-1\n"); printf(" %8.1f %16.8e%16.8e%16.8e%16.8e\n", - (double)residn, (double)resid, (double)eps, - (double)x[0]-1, (double)x[n-1]-1); + (REAL)residn, (REAL)resid, (REAL)eps, + (REAL)x[0]-1, (REAL)x[n-1]-1); fprintf(stderr," times are reported for matrices of order %5d\n",n); fprintf(stderr," dgefa dgesl total kflops unit"); @@ -999,10 +1011,10 @@ void test_linpack() kf = (timer[3][3] < timer[3][7]) ? timer[3][3] : timer[3][7]; kf = (kf > ZERO) ? (kf + .5) : (kf - .5); - if (fabs((double)kf) < ONE) + if (FABS(kf) < ONE) kflops = 0; else { - kflops = floor(fabs((double)kf)); + kflops = FLOOR_REAL(FABS(kf)); if (kf < ZERO) kflops = -kflops; } diff --git a/packages/third-party/benchmark/stream/stream.c b/packages/third-party/benchmark/stream/stream.c index 1c82dac6..607c176c 100644 --- a/packages/third-party/benchmark/stream/stream.c +++ b/packages/third-party/benchmark/stream/stream.c @@ -177,6 +177,10 @@ # define MAX(x,y) ((x)>(y)?(x):(y)) # endif +#ifdef ARCH_RISCV_FPU_S +#define double float +#endif + #ifndef STREAM_TYPE #define STREAM_TYPE double #endif diff --git a/packages/third-party/benchmark/whetstone/whetstone.c b/packages/third-party/benchmark/whetstone/whetstone.c index 1b35dd23..a5019bc1 100644 --- a/packages/third-party/benchmark/whetstone/whetstone.c +++ b/packages/third-party/benchmark/whetstone/whetstone.c @@ -66,19 +66,44 @@ C********************************************************************** #define CPU_FREQ (hal_clk_get_freq(CLK_CPU)/1000000) /* map the FORTRAN math functions, etc. to the C versions */ -#define DSIN sin -#define DCOS cos -#define DATAN atan -#define DLOG log -#define DEXP exp -#define DSQRT sqrt +#ifdef ARCH_RISCV_FPU_S +#define SP +#else +/* + * If the chip does not support floating-point, then this program is executed + * with software double precision floating-point. + */ +#define DP +#endif + +#ifdef SP +#define REAL float +#define SIN sinf +#define COS cosf +#define ATAN atanf +#define LOG logf +#define EXP expf +#define SQRT sqrtf +#define STR_REAL "Single" +#endif + +#ifdef DP +#define REAL double +#define SIN sin +#define COS cos +#define ATAN atan +#define LOG log +#define EXP exp +#define SQRT sqrt +#define STR_REAL "Double" +#endif #define IF if /* function prototypes */ -void POUT(long N, long J, long K, double X1, double X2, double X3, double X4); -void PA(double E[]); +void POUT(long N, long J, long K, REAL X1, REAL X2, REAL X3, REAL X4); +void PA(REAL E[]); void P0(void); -void P3(double X, double Y, double *Z); +void P3(REAL X, REAL Y, REAL *Z); #define USAGE "usage: whetdc [-c] [loops]\n" static long my_time(int t) @@ -89,7 +114,7 @@ static long my_time(int t) /* COMMON T,T1,T2,E1(4),J,K,L */ -double T,T1,T2,E1[5]; +REAL T,T1,T2,E1[5]; int J,K,L; int @@ -98,7 +123,7 @@ whetstone_main(int argc, char *argv[]) /* used in the FORTRAN version */ long I; long N1, N2, N3, N4, N6, N7, N8, N9, N10, N11; - double X1,X2,X3,X4,X,Y,Z; + REAL X1,X2,X3,X4,X,Y,Z; long LOOP; int II, JJ; @@ -280,8 +305,8 @@ C Y = 0.5; for (I = 1; I <= N7; I++) { - X = T * DATAN(T2*DSIN(X)*DCOS(X)/(DCOS(X+Y)+DCOS(X-Y)-1.0)); - Y = T * DATAN(T2*DSIN(Y)*DCOS(Y)/(DCOS(X+Y)+DCOS(X-Y)-1.0)); + X = T * ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0)); + Y = T * ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0)); } #ifdef PRINTOUT @@ -350,7 +375,7 @@ C X = 0.75; for (I = 1; I <= N11; I++) - X = DSQRT(DEXP(DLOG(X)/T1)); + X = SQRT(EXP(LOG(X)/T1)); #ifdef PRINTOUT IF (JJ==II)POUT(N11,J,K,X,X,X,X); @@ -393,11 +418,11 @@ C-------------------------------------------------------------------- #ifndef AIC_PRINT_FLOAT_CUSTOM if (KIPS >= 1000.0) { - printf("C Converted Double Precision Whetstones: %.1f MIPS\n", KIPS/1000.0); + printf("C Converted %s Precision Whetstones: %.1f MIPS\n", STR_REAL, KIPS/1000.0); printf("Score(CPU %ldMHz): %.2f\n", CPU_FREQ, KIPS/1000.0/CPU_FREQ); } else { - printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS); + printf("C Converted %s Precision Whetstones: %.1f KIPS\n", STR_REAL, KIPS); } #else /* print float */ @@ -409,7 +434,7 @@ C-------------------------------------------------------------------- p_f = KIPS/1000.0; p_i1 = (unsigned int)p_f; p_i2 = (unsigned int)((p_f-p_i1)*10.0); - printf("C Converted Double Precision Whetstones: %d.%d MIPS\n", p_i1, p_i2); + printf("C Converted %s Precision Whetstones: %d.%d MIPS\n", STR_REAL, p_i1, p_i2); p_f = KIPS/1000.0/CPU_FREQ; p_i1 = (unsigned int)p_f; @@ -420,7 +445,7 @@ C-------------------------------------------------------------------- p_f = KIPS; p_i1 = (unsigned int)p_f; p_i2 = (unsigned int)((p_f-p_i1)*10.0); - printf("C Converted Double Precision Whetstones: %d.%d KIPS\n", p_i1, p_i2); + printf("C Converted %s Precision Whetstones: %d.%d KIPS\n", STR_REAL, p_i1, p_i2); } #endif if (continuous) @@ -430,7 +455,7 @@ C-------------------------------------------------------------------- } void -PA(double E[]) +PA(REAL E[]) { J = 0; @@ -454,9 +479,9 @@ P0(void) } void -P3(double X, double Y, double *Z) +P3(REAL X, REAL Y, REAL *Z) { - double X1, Y1; + REAL X1, Y1; X1 = X; Y1 = Y; @@ -467,7 +492,7 @@ P3(double X, double Y, double *Z) #ifdef PRINTOUT void -POUT(long N, long J, long K, double X1, double X2, double X3, double X4) +POUT(long N, long J, long K, REAL X1, REAL X2, REAL X3, REAL X4) { printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n", N, J, K, X1, X2, X3, X4); diff --git a/packages/third-party/cherryusb/Kconfig b/packages/third-party/cherryusb/Kconfig index 460fa416..93dccf1d 100644 --- a/packages/third-party/cherryusb/Kconfig +++ b/packages/third-party/cherryusb/Kconfig @@ -504,14 +504,6 @@ if LPKG_USING_CHERRYUSB bool "ARGB8888" endchoice - config AIC_USB_DISP_SCALE_DOWN_X - int "scale down for X two sides" - default 0 - - config AIC_USB_DISP_SCALE_DOWN_Y - int "scale down for Y two sides" - default 0 - config AIC_USB_DISP_SW_GPIO_EN bool "Using gpio switch" default n diff --git a/packages/third-party/cherryusb/demo/libusbd_display_template_c906fd.a b/packages/third-party/cherryusb/demo/libusbd_display_template_c906fd.a index b5edbfd1..4f9fc557 100644 Binary files a/packages/third-party/cherryusb/demo/libusbd_display_template_c906fd.a and b/packages/third-party/cherryusb/demo/libusbd_display_template_c906fd.a differ diff --git a/packages/third-party/cherryusb/demo/usbd_display_template_entry.c b/packages/third-party/cherryusb/demo/usbd_display_template_entry.c index f7cfa19c..32f2a8d2 100644 --- a/packages/third-party/cherryusb/demo/usbd_display_template_entry.c +++ b/packages/third-party/cherryusb/demo/usbd_display_template_entry.c @@ -50,17 +50,6 @@ uint32_t usb_disp_rotate = AIC_FB_ROTATE_DEGREE; uint32_t usb_disp_rotate = 0; #endif -#ifdef AIC_USB_DISP_SCALE_DOWN_X -uint32_t usb_disp_scale_down_x = AIC_USB_DISP_SCALE_DOWN_X; -#else -uint32_t usb_disp_scale_down_x = 0; -#endif -#ifdef AIC_USB_DISP_SCALE_DOWN_Y -uint32_t usb_disp_scale_down_y = AIC_USB_DISP_SCALE_DOWN_Y; -#else -uint32_t usb_disp_scale_down_y = 0; -#endif - #ifdef AIC_USB_DISP_DEF_DIS uint8_t usb_display_en = 0; #else diff --git a/packages/third-party/cherryusb/demo/video_dvp_template.c b/packages/third-party/cherryusb/demo/video_dvp_template.c index 12e23d51..49945dd2 100644 --- a/packages/third-party/cherryusb/demo/video_dvp_template.c +++ b/packages/third-party/cherryusb/demo/video_dvp_template.c @@ -204,7 +204,7 @@ static int sensor_get_fmt(void) ret = mpp_dvp_ioctl(DVP_IN_G_FMT, &f); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err %d\n", ret); + USB_LOG_ERR("Failed to get sensor format! err %d\n", ret); return -1; } @@ -222,7 +222,7 @@ static int sensor_set_infmt(void) ret = mpp_dvp_ioctl(DVP_IN_S_FMT, &g_uvc_video.src_fmt); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err %d\n", ret); + USB_LOG_ERR("Failed to set DVP in-format! err %d\n", ret); return -1; } @@ -241,7 +241,7 @@ static int sensor_set_outfmt(int width, int height, int format) ret = mpp_dvp_ioctl(DVP_OUT_S_FMT, &f); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err -%d\n", -ret); + USB_LOG_ERR("Failed to set DVP out-format! err -%d\n", -ret); return -1; } return 0; @@ -252,7 +252,7 @@ static int sensor_request_buf(struct vin_video_buf *vbuf) int i = 0; if (mpp_dvp_ioctl(DVP_REQ_BUF, (void *)vbuf) < 0) { - USB_LOG_ERR("ioctl() failed!\n"); + USB_LOG_ERR("Failed to request buf!\n"); return -1; } @@ -265,13 +265,18 @@ static int sensor_request_buf(struct vin_video_buf *vbuf) vbuf->planes[i * vbuf->num_planes + 1].len); } + if (vbuf->num_buffers < 3) { + pr_err("The number of video buf must >= 3!\n"); + return -1; + } + return 0; } static int sensor_queue_buf(int index) { if (mpp_dvp_ioctl(DVP_Q_BUF, (void *)(ptr_t)index) < 0) { - USB_LOG_ERR("ioctl() failed!\n"); + USB_LOG_ERR("Q failed! Maybe buf state is invalid.\n"); return -1; } @@ -284,7 +289,7 @@ static int sensor_dequeue_buf(int *index) ret = mpp_dvp_ioctl(DVP_DQ_BUF, (void *)index); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err %d\n", ret); + USB_LOG_ERR("DQ failed! Maybe cannot receive data from Camera. err %d\n", ret); return -1; } @@ -302,10 +307,10 @@ static int sensor_start(void) ret = mpp_dvp_ioctl(DVP_STREAM_ON, NULL); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err %d\n", ret); + USB_LOG_ERR("Failed to start streaming! err %d\n", ret); return -1; } else { - USB_LOG_DBG("start sensor, ret:%d\n", ret); + USB_LOG_DBG("Start sensor\n"); } return 0; @@ -317,7 +322,7 @@ static int sensor_stop(void) ret = mpp_dvp_ioctl(DVP_STREAM_OFF, NULL); if (ret < 0) { - USB_LOG_ERR("ioctl() failed! err -%d\n", -ret); + USB_LOG_ERR("Failed to start streaming! err -%d\n", -ret); return -1; } diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_amd64_20241015.deb b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_amd64_20241015.deb new file mode 100644 index 00000000..9db61a08 Binary files /dev/null and b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_amd64_20241015.deb differ diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_arm64_20241015.deb b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_arm64_20241015.deb new file mode 100644 index 00000000..7d9ec4b5 Binary files /dev/null and b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/AicUSBDisplay_0.6.2_arm64_20241015.deb differ diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/install_for_linux.sh b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/install_for_linux.sh new file mode 100755 index 00000000..2e138960 --- /dev/null +++ b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/install_for_linux.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2024 ArtInChip Technology Co., Ltd + +MY_NAME=$0 +TOPDIR=$PWD +AIC_UD_PKG="AicUSBDisplay" + +# Return value +ERR_CANCEL=100 +ERR_UNSUPPORTED=110 +ERR_PKG_UNVAILABLE=111 +ERR_NET_UNVAILABLE=112 + +COLOR_BEGIN="\033[" +COLOR_RED="${COLOR_BEGIN}41;37m" +COLOR_YELLOW="${COLOR_BEGIN}43;30m" +COLOR_WHITE="${COLOR_BEGIN}47;30m" +COLOR_END="\033[0m" + +pr_err() +{ + echo -e "${COLOR_RED}*** $*${COLOR_END}" +} + +pr_warn() +{ + echo -e "${COLOR_YELLOW}!!! $*${COLOR_END}" +} + +pr_info() +{ + echo + echo -e "${COLOR_WHITE}>>> $*${COLOR_END}" +} + +check_root() +{ + CUR_USER=$(whoami) + if [ "$CUR_USER" = "root" ]; then + return + fi + sudo -l -U $(whoami) | grep ALL > /dev/null + if [ $? -eq 0 ]; then + return + fi + + pr_warn $MY_NAME "must install package with 'sudo'. " + pr_warn "Your passward will be safe and always used locally." +} + +check_os() +{ + if [ -f /etc/lsb-release ]; then + OS_VER=$(cat /etc/lsb-release | grep RELEASE | awk -F '=' '{print $2}') + OS_TYPE="Ubuntu" + elif [ -f /etc/issue ]; then + cat /etc/issue 2>&1 | grep Debian > /dev/null + if [ $? -eq 0 ]; then + OS_VER=$(cat /etc/issue | awk '{print $3}') + OS_TYPE="Debian" + fi + else + pr_err "Unknow system OS" + exit $ERR_UNSUPPORTED + fi +} + +check_arch() +{ + uname -m | grep aarch64 > /dev/null + if [ $? -eq 0 ]; then + ARCH_TYPE='arm64' + return + fi + + uname -m | grep x86_64 > /dev/null + if [ $? -eq 0 ]; then + ARCH_TYPE='amd64' + return + fi + + pr_err "Unsupported CPU architecture: " + exit $ERR_UNSUPPORTED +} + +check_pi() +{ + uname -r | grep "rpi" > /dev/null + if [ $? -eq 0 ]; then + echo It is Raspberry PI + IS_RPI=YES + XORG_CFG_WAY="sudo raspi-config\n\t-> 6 Advanced Options\n\t\t-> A6 X11/Xwayland\n" + else + XORG_CFG_WAY="sudo vim /etc/gdm3/custom.conf\n\tthen unncomment \"#WaylandEnable=false\"\n" + fi +} + +check_xorg() +{ + ps -ef | grep Xorg | grep -v grep > /dev/null + if [ $? -ne 0 ]; then + pr_err "Only support Xorg server as to now!" + pr_info "Try switch to Xorg in this way:" + echo ------------------------------------------------ + printf "$XORG_CFG_WAY" + echo ------------------------------------------------ + exit $ERR_UNSUPPORTED + fi +} + +check_root +check_os +check_arch +check_pi +check_xorg + +pr_info "Current system is $OS_TYPE $OS_VER $ARCH_TYPE" + +echo +PKG_NAME=$(find . -name "${AIC_UD_PKG}*${ARCH_TYPE}*.deb" | xargs ls -t -1 | head -1) +if [ "x$PKG_NAME" = "x" ]; then + pr_warn "Can not find $AIC_UD_PKG DEB package for current system" + exit $ERR_PKG_UNVAILABLE +else + echo Found $PKG_NAME +fi + +if [ "$OS_TYPE" = "Debian" ] && [ "$OS_VER" -lt "12" ] && [ "x$IS_RPI" = "xYES" ]; then + pr_info Check Xorg ... + XORG_PKG_NAME=$(find . -name "xserver-xorg-core_1.20.11*.deb" | xargs ls -t -1 | head -1) + if [ "x$XORG_PKG_NAME" = "x" ]; then + pr_warn "Can not find Xorg package for $OS_TYPE $OS_VER" + exit $ERR_PKG_UNVAILABLE + else + echo Install $XORG_PKG_NAME first ... + fi + + echo + sudo dpkg -i $XORG_PKG_NAME + if [ $? -ne 0 ]; then + pr_err "Failed to install $XORG_PKG_NAME" + exit $ERR_CANCEL + fi +fi + +pr_info Check dkms ... +sudo apt install dkms +if [ $? -ne 0 ]; then + pr_err "Failed to install dkms" + pr_err "Maybe the software source is not accessable! Please check it" + exit $ERR_NET_UNVAILABLE +fi + +echo +dpkg -s $AIC_UD_PKG | grep "Status" | grep "installed" > /dev/null +if [ $? -eq 0 ]; then + pr_info "$AIC_UD_PKG was already installed, so remove it first ..." + sudo dpkg -r $AIC_UD_PKG +fi + +pr_info Install $PKG_NAME ... +sudo dpkg -i $PKG_NAME +if [ $? -ne 0 ]; then + pr_err "Failed to install $PKG_NAME" + exit $ERR_CANCEL +fi + +pr_info $AIC_UD_PKG installed successfully! diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/uninstall_for_linux.sh b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/uninstall_for_linux.sh new file mode 100755 index 00000000..37e094f4 --- /dev/null +++ b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/uninstall_for_linux.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2024 ArtInChip Technology Co., Ltd + +AIC_UD_PKG="AicUSBDisplay" + +sudo dpkg -r $AIC_UD_PKG diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/xserver-xorg-core_1.20.11-1+deb11u13.1_arm64.deb b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/xserver-xorg-core_1.20.11-1+deb11u13.1_arm64.deb new file mode 100644 index 00000000..714458d5 Binary files /dev/null and b/packages/third-party/cherryusb/tools/aic_usbdisplay/Linux/xserver-xorg-core_1.20.11-1+deb11u13.1_arm64.deb differ diff --git a/packages/third-party/cherryusb/tools/aic_usbdisplay/AicUsbDisplayDriverV0.8.9.exe b/packages/third-party/cherryusb/tools/aic_usbdisplay/Windows/AicUsbDisplayDriverV0.8.9.exe similarity index 100% rename from packages/third-party/cherryusb/tools/aic_usbdisplay/AicUsbDisplayDriverV0.8.9.exe rename to packages/third-party/cherryusb/tools/aic_usbdisplay/Windows/AicUsbDisplayDriverV0.8.9.exe diff --git a/packages/third-party/freetype/Kconfig b/packages/third-party/freetype/Kconfig index b63e1dde..09f66161 100644 --- a/packages/third-party/freetype/Kconfig +++ b/packages/third-party/freetype/Kconfig @@ -7,7 +7,14 @@ if LPKG_USING_FREETYPE bool "Compile using FREETYPE static link library" default n -config TT_DISABLE_LOAD_HDMX - bool "Disable loading hdmx table" - default n + config TT_DISABLE_LOAD_HDMX + bool "Disable loading hdmx table" + default n + +if AIC_PSRAM_SW_SIZE > 0 && AIC_CHIP_D13X + config TT_USE_MEM_PSRAM_SW_HEAP + bool "FreeType using Psram SW Heap" + default n +endif + endif diff --git a/packages/third-party/freetype/include/freetype/config/ftstdlib.h b/packages/third-party/freetype/include/freetype/config/ftstdlib.h index d6091f8b..f51a5610 100644 --- a/packages/third-party/freetype/include/freetype/config/ftstdlib.h +++ b/packages/third-party/freetype/include/freetype/config/ftstdlib.h @@ -100,6 +100,45 @@ #include +#include + +#if defined(KERNEL_BAREMETAL) +#include +#include + +#define FT_FILE int +static inline FT_FILE *ft_fopen(const char *pathname, const char *mode) +{ + (void)mode; + int file; + file = open(pathname, O_RDONLY); + if (file < 0) + return NULL; + else + return (FT_FILE *)(long)file; +} + +static inline int ft_fclose(FT_FILE *stream) +{ + return close((int)(long)stream); +} + +static inline size_t ft_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream) +{ + return read((int)(long)stream, ptr, size * nmemb); +} + +static inline int ft_fseek(FT_FILE *stream, size_t offset, int whence) +{ + return lseek((int)(long)stream, offset, whence); +} + +static inline long ft_ftell(FT_FILE *stream) +{ + return lseek((int)(long)stream, 0, SEEK_CUR); +} + +#else #define FT_FILE FILE #define ft_fclose fclose @@ -107,6 +146,8 @@ #define ft_fread fread #define ft_fseek fseek #define ft_ftell ftell +#endif + #define ft_sprintf sprintf @@ -128,11 +169,56 @@ * */ +#ifndef TT_USE_MEM_PSRAM_SW_HEAP #define ft_scalloc calloc #define ft_sfree free #define ft_smalloc malloc #define ft_srealloc realloc +#else +#include "aic_osal.h" + +static inline void *ft_smalloc(size_t size) +{ + return aicos_malloc(MEM_PSRAM_SW, size); +} + +static inline void *ft_scalloc(size_t count, size_t size) +{ + void *p = ft_smalloc(count * size); + if (p) { + memset(p, 0, count * size); + } + return p; +} + +static inline void ft_sfree(void *rmem) +{ + aicos_free(MEM_PSRAM_SW, rmem); +} + +static inline void *ft_srealloc(void *rmem, size_t newsize) +{ + (void)rmem; + (void)newsize; + return NULL; +} + +static inline void *ft_srealloc_cur(long cur_size, long new_size, void *rmem) +{ + void *p = 0; + if (new_size > cur_size) { + p = ft_smalloc(new_size); + if(p) { + memcpy(p, rmem, cur_size); + ft_sfree(rmem); + } + } else { + p = rmem; + } + return p; +} +#endif /************************************************************************** diff --git a/packages/third-party/freetype/src/base/ftsystem.c b/packages/third-party/freetype/src/base/ftsystem.c index 3013cbda..ad91b358 100644 --- a/packages/third-party/freetype/src/base/ftsystem.c +++ b/packages/third-party/freetype/src/base/ftsystem.c @@ -108,9 +108,13 @@ void* block ) { FT_UNUSED( memory ); +#ifdef TT_USE_MEM_PSRAM_SW_HEAP + return ft_srealloc_cur(cur_size, new_size, block); +#else FT_UNUSED( cur_size ); return ft_srealloc( block, (size_t)new_size ); +#endif } diff --git a/packages/third-party/libFLAC/FLAC/all.h b/packages/third-party/libFLAC/FLAC/all.h new file mode 100644 index 00000000..d06dcd45 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/all.h @@ -0,0 +1,450 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__ALL_H +#define FLAC__ALL_H + +#include "export.h" + +#include "assert.h" +#include "callback.h" +#include "format.h" +#include "metadata.h" +#include "ordinals.h" +#include "stream_decoder.h" +#include "stream_encoder.h" + +/** \mainpage + * + * \section intro Introduction + * + * This is the documentation for the FLAC C and C++ APIs. It is + * highly interconnected; this introduction should give you a top + * level idea of the structure and how to find the information you + * need. As a prerequisite you should have at least a basic + * knowledge of the FLAC format, documented + * here. + * + * \section c_api FLAC C API + * + * The FLAC C API is the interface to libFLAC, a set of structures + * describing the components of FLAC streams, and functions for + * encoding and decoding streams, as well as manipulating FLAC + * metadata in files. The public include files will be installed + * in your include area (for example /usr/include/FLAC/...). + * + * By writing a little code and linking against libFLAC, it is + * relatively easy to add FLAC support to another program. The + * library is licensed under Xiph's BSD license. + * Complete source code of libFLAC as well as the command-line + * encoder and plugins is available and is a useful source of + * examples. + * + * Aside from encoders and decoders, libFLAC provides a powerful + * metadata interface for manipulating metadata in FLAC files. It + * allows the user to add, delete, and modify FLAC metadata blocks + * and it can automatically take advantage of PADDING blocks to avoid + * rewriting the entire FLAC file when changing the size of the + * metadata. + * + * libFLAC usually only requires the standard C library and C math + * library. In particular, threading is not used so there is no + * dependency on a thread library. However, libFLAC does not use + * global variables and should be thread-safe. + * + * libFLAC also supports encoding to and decoding from Ogg FLAC. + * However the metadata editing interfaces currently have limited + * read-only support for Ogg FLAC files. + * + * \section cpp_api FLAC C++ API + * + * The FLAC C++ API is a set of classes that encapsulate the + * structures and functions in libFLAC. They provide slightly more + * functionality with respect to metadata but are otherwise + * equivalent. For the most part, they share the same usage as + * their counterparts in libFLAC, and the FLAC C API documentation + * can be used as a supplement. The public include files + * for the C++ API will be installed in your include area (for + * example /usr/include/FLAC++/...). + * + * libFLAC++ is also licensed under + * Xiph's BSD license. + * + * \section getting_started Getting Started + * + * A good starting point for learning the API is to browse through + * the modules. Modules are logical + * groupings of related functions or classes, which correspond roughly + * to header files or sections of header files. Each module includes a + * detailed description of the general usage of its functions or + * classes. + * + * From there you can go on to look at the documentation of + * individual functions. You can see different views of the individual + * functions through the links in top bar across this page. + * + * If you prefer a more hands-on approach, you can jump right to some + * example code. + * + * \section porting_guide Porting Guide + * + * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink + * has been introduced which gives detailed instructions on how to + * port your code to newer versions of FLAC. + * + * \section embedded_developers Embedded Developers + * + * libFLAC has grown larger over time as more functionality has been + * included, but much of it may be unnecessary for a particular embedded + * implementation. Unused parts may be pruned by some simple editing of + * src/libFLAC/Makefile.am. In general, the decoders, encoders, and + * metadata interface are all independent from each other. + * + * It is easiest to just describe the dependencies: + * + * - All modules depend on the \link flac_format Format \endlink module. + * - The decoders and encoders depend on the bitbuffer. + * - The decoder is independent of the encoder. The encoder uses the + * decoder because of the verify feature, but this can be removed if + * not needed. + * - Parts of the metadata interface require the stream decoder (but not + * the encoder). + * - Ogg support is selectable through the compile time macro + * \c FLAC__HAS_OGG. + * + * For example, if your application only requires the stream decoder, no + * encoder, and no metadata interface, you can remove the stream encoder + * and the metadata interface, which will greatly reduce the size of the + * library. + * + * Also, there are several places in the libFLAC code with comments marked + * with "OPT:" where a \#define can be changed to enable code that might be + * faster on a specific platform. Experimenting with these can yield faster + * binaries. + */ + +/** \defgroup porting Porting Guide for New Versions + * + * This module describes differences in the library interfaces from + * version to version. It assists in the porting of code that uses + * the libraries to newer versions of FLAC. + * + * One simple facility for making porting easier that has been added + * in FLAC 1.1.3 is a set of \#defines in \c export.h of each + * library's includes (e.g. \c include/FLAC/export.h). The + * \#defines mirror the libraries' + * libtool version numbers, + * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT, + * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE. + * These can be used to support multiple versions of an API during the + * transition phase, e.g. + * + * \code + * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 + * legacy code + * #else + * new code + * #endif + * \endcode + * + * The source will work for multiple versions and the legacy code can + * easily be removed when the transition is complete. + * + * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in + * include/FLAC/export.h), which can be used to determine whether or not + * the library has been compiled with support for Ogg FLAC. This is + * simpler than trying to call an Ogg init function and catching the + * error. + */ + +/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3 + * \ingroup porting + * + * \brief + * This module describes porting from FLAC 1.1.2 to FLAC 1.1.3. + * + * The main change between the APIs in 1.1.2 and 1.1.3 is that they have + * been simplified. First, libOggFLAC has been merged into libFLAC and + * libOggFLAC++ has been merged into libFLAC++. Second, both the three + * decoding layers and three encoding layers have been merged into a + * single stream decoder and stream encoder. That is, the functionality + * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged + * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and + * FLAC__FileEncoder into FLAC__StreamEncoder. Only the + * FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means + * is there is now a single API that can be used to encode or decode + * streams to/from native FLAC or Ogg FLAC and the single API can work + * on both seekable and non-seekable streams. + * + * Instead of creating an encoder or decoder of a certain layer, now the + * client will always create a FLAC__StreamEncoder or + * FLAC__StreamDecoder. The old layers are now differentiated by the + * initialization function. For example, for the decoder, + * FLAC__stream_decoder_init() has been replaced by + * FLAC__stream_decoder_init_stream(). This init function takes + * callbacks for the I/O, and the seeking callbacks are optional. This + * allows the client to use the same object for seekable and + * non-seekable streams. For decoding a FLAC file directly, the client + * can use FLAC__stream_decoder_init_file() and pass just a filename + * and fewer callbacks; most of the other callbacks are supplied + * internally. For situations where fopen()ing by filename is not + * possible (e.g. Unicode filenames on Windows) the client can instead + * open the file itself and supply the FILE* to + * FLAC__stream_decoder_init_FILE(). The init functions now returns a + * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState. + * Since the callbacks and client data are now passed to the init + * function, the FLAC__stream_decoder_set_*_callback() functions and + * FLAC__stream_decoder_set_client_data() are no longer needed. The + * rest of the calls to the decoder are the same as before. + * + * There are counterpart init functions for Ogg FLAC, e.g. + * FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls + * and callbacks are the same as for native FLAC. + * + * As an example, in FLAC 1.1.2 a seekable stream decoder would have + * been set up like so: + * + * \code + * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new(); + * if(decoder == NULL) do_something; + * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true); + * [... other settings ...] + * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback); + * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback); + * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback); + * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback); + * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback); + * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback); + * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback); + * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback); + * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data); + * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something; + * \endcode + * + * In FLAC 1.1.3 it is like this: + * + * \code + * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); + * if(decoder == NULL) do_something; + * FLAC__stream_decoder_set_md5_checking(decoder, true); + * [... other settings ...] + * if(FLAC__stream_decoder_init_stream( + * decoder, + * my_read_callback, + * my_seek_callback, // or NULL + * my_tell_callback, // or NULL + * my_length_callback, // or NULL + * my_eof_callback, // or NULL + * my_write_callback, + * my_metadata_callback, // or NULL + * my_error_callback, + * my_client_data + * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; + * \endcode + * + * or you could do; + * + * \code + * [...] + * FILE *file = fopen("somefile.flac","rb"); + * if(file == NULL) do_somthing; + * if(FLAC__stream_decoder_init_FILE( + * decoder, + * file, + * my_write_callback, + * my_metadata_callback, // or NULL + * my_error_callback, + * my_client_data + * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; + * \endcode + * + * or just: + * + * \code + * [...] + * if(FLAC__stream_decoder_init_file( + * decoder, + * "somefile.flac", + * my_write_callback, + * my_metadata_callback, // or NULL + * my_error_callback, + * my_client_data + * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; + * \endcode + * + * Another small change to the decoder is in how it handles unparseable + * streams. Before, when the decoder found an unparseable stream + * (reserved for when the decoder encounters a stream from a future + * encoder that it can't parse), it changed the state to + * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM. Now the decoder instead + * drops sync and calls the error callback with a new error code + * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM. This is + * more robust. If your error callback does not discriminate on the the + * error state, your code does not need to be changed. + * + * The encoder now has a new setting: + * FLAC__stream_encoder_set_apodization(). This is for setting the + * method used to window the data before LPC analysis. You only need to + * add a call to this function if the default is not suitable. There + * are also two new convenience functions that may be useful: + * FLAC__metadata_object_cuesheet_calculate_cddb_id() and + * FLAC__metadata_get_cuesheet(). + * + * The \a bytes parameter to FLAC__StreamDecoderReadCallback, + * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback + * is now \c size_t instead of \c uint32_t. + */ + +/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4 + * \ingroup porting + * + * \brief + * This module describes porting from FLAC 1.1.3 to FLAC 1.1.4. + * + * There were no changes to any of the interfaces from 1.1.3 to 1.1.4. + * There was a slight change in the implementation of + * FLAC__stream_encoder_set_metadata(); the function now makes a copy + * of the \a metadata array of pointers so the client no longer needs + * to maintain it after the call. The objects themselves that are + * pointed to by the array are still not copied though and must be + * maintained until the call to FLAC__stream_encoder_finish(). + */ + +/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0 + * \ingroup porting + * + * \brief + * This module describes porting from FLAC 1.1.4 to FLAC 1.2.0. + * + * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0. + * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added. + * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added. + * + * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN + * has changed to reflect the conversion of one of the reserved bits + * into active use. It used to be \c 2 and now is \c 1. However the + * FLAC frame header length has not changed, so to skip the proper + * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN + + * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN + */ + +/** \defgroup porting_1_3_4_to_1_4_0 Porting from FLAC 1.3.4 to 1.4.0 + * \ingroup porting + * + * \brief + * This module describes porting from FLAC 1.3.4 to FLAC 1.4.0. + * + * \section porting_1_3_4_to_1_4_0_summary Summary + * + * Between FLAC 1.3.4 and FLAC 1.4.0, there have four breaking changes + * - the function get_client_data_from_decoder has been renamed to + * FLAC__get_decoder_client_data + * - some data types in the FLAC__Frame struct have changed + * - all functions resizing metadata blocks now return the object + * untouched if memory allocation fails, whereas previously the + * handling varied and was more or less undefined + * - all functions accepting a filename now take UTF-8 encoded filenames + * on Windows instead of filenames in the current codepage + * + * Furthermore, there have been the following additions + * - the functions FLAC__stream_encoder_set_limit_min_bitrate, + * FLAC__stream_encoder_get_limit_min_bitrate, + * FLAC::encoder::file::set_limit_min_bitrate() and + * FLAC::encoder::file::get_limit_min_bitrate() have been added + * - Added FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA to the + * FLAC__StreamDecoderErrorStatus enum + * + * \section porting_1_3_4_to_1_4_0_breaking Breaking changes + * + * The function \b get_client_data_from_decoder was added in FLAC 1.3.3 + * but did not follow the API naming convention and was not properly + * exported. The function is now renamed and properly integrated as + * FLAC__stream_decoder_get_client_data + * + * To accomodate encoding and decoding 32-bit int PCM, some data types + * in the \b FLAC__frame struct were changed. Specifically, warmup + * in both the FLAC__Subframe_Fixed struc and the FLAC__Subframe_LPC + * struct is changed from FLAC__int32 to FLAC__int64. Also, value + * in the FLAC__Subframe_Constant is changed from FLAC__int32 to + * FLAC__int64. Finally, in FLAC__Subframe_Verbatim struct data is + * changes from a FLAC__int32 array to a union containing a FLAC__int32 + * array and a FLAC__int64 array. Also, a new member is added, + * data_type, which clarifies whether the FLAC__int32 or FLAC__int64 + * array is in use. + * + * Furthermore, the following functions now return the object untouched + * if memory allocation fails, whereas previously the handling varied + * and was more or less undefined + * + * - FLAC__metadata_object_seektable_resize_points + * - FLAC__metadata_object_vorbiscomment_resize_comments + * - FLAC__metadata_object_cuesheet_track_resize_indices + * - FLAC__metadata_object_cuesheet_resize_tracks + * + * The last breaking change is that all API functions taking a filename + * as an argument now, on Windows, must be supplied with that filename + * in the UTF-8 character encoding instead of using the current code + * page. libFLAC internally translates these UTF-8 encoded filenames to + * an appropriate representation to use with _wfopen. On all other + * systems, filename is passed to fopen without any translation, as it + * in libFLAC 1.3.4 and earlier. + * + * \section porting_1_3_4_to_1_4_0_additions Additions + * + * To aid in creating properly streamable FLAC files, a set of functions + * was added to make it possible to enfore a minimum bitrate to files + * created through libFLAC's stream_encoder.h interface. With this + * function enabled the resulting FLAC files have a minimum bitrate of + * 1bit/sample independent of the number of channels, i.e. 48kbit/s for + * 48kHz. This can be beneficial for streaming, as very low bitrates for + * silent sections compressed with 'constant' subframes can result in a + * bitrate of 1kbit/s, creating problems with clients that aren't aware + * of this possibility and buffer too much data. + * + * Finally, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA was added to + * the FLAC__StreamDecoderErrorStatus enum to signal that the decoder + * encountered unreadable metadata. + * + */ + +/** \defgroup flac FLAC C API + * + * The FLAC C API is the interface to libFLAC, a set of structures + * describing the components of FLAC streams, and functions for + * encoding and decoding streams, as well as manipulating FLAC + * metadata in files. + * + * You should start with the format components as all other modules + * are dependent on it. + */ + +#endif diff --git a/packages/third-party/libFLAC/FLAC/assert.h b/packages/third-party/libFLAC/FLAC/assert.h new file mode 100644 index 00000000..a99ced33 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/assert.h @@ -0,0 +1,51 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__ASSERT_H +#define FLAC__ASSERT_H + +/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +#define FLAC__ASSERT(x) if(!(x)) __builtin_abort(); +#define FLAC__ASSERT_DECLARATION(x) x +#else +#ifndef NDEBUG +#include +#define FLAC__ASSERT(x) assert(x) +#define FLAC__ASSERT_DECLARATION(x) x +#else +#define FLAC__ASSERT(x) +#define FLAC__ASSERT_DECLARATION(x) +#endif +#endif + +#endif diff --git a/packages/third-party/libFLAC/FLAC/callback.h b/packages/third-party/libFLAC/FLAC/callback.h new file mode 100644 index 00000000..c2fae4f6 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/callback.h @@ -0,0 +1,190 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__CALLBACK_H +#define FLAC__CALLBACK_H + +#include "ordinals.h" +#include /* for size_t */ + +/** \file include/FLAC/callback.h + * + * \brief + * This module defines the structures for describing I/O callbacks + * to the other FLAC interfaces. + * + * See the detailed documentation for callbacks in the + * \link flac_callbacks callbacks \endlink module. + */ + +/** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures + * \ingroup flac + * + * \brief + * This module defines the structures for describing I/O callbacks + * to the other FLAC interfaces. + * + * The purpose of the I/O callback functions is to create a common way + * for the metadata interfaces to handle I/O. + * + * Originally the metadata interfaces required filenames as the way of + * specifying FLAC files to operate on. This is problematic in some + * environments so there is an additional option to specify a set of + * callbacks for doing I/O on the FLAC file, instead of the filename. + * + * In addition to the callbacks, a FLAC__IOHandle type is defined as an + * opaque structure for a data source. + * + * The callback function prototypes are similar (but not identical) to the + * stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use + * stdio streams to implement the callbacks, you can pass fread, fwrite, and + * fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or + * FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle + * is required. \warning You generally CANNOT directly use fseek or ftell + * for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems + * these use 32-bit offsets and FLAC requires 64-bit offsets to deal with + * large files. You will have to find an equivalent function (e.g. ftello), + * or write a wrapper. The same is true for feof() since this is usually + * implemented as a macro, not as a function whose address can be taken. + * + * \{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the opaque handle type used by the callbacks. Typically + * this is a \c FILE* or address of a file descriptor. + */ +typedef void* FLAC__IOHandle; + +/** Signature for the read callback. + * The signature and semantics match POSIX fread() implementations + * and can generally be used interchangeably. Note that the global + * variable errno from errno.h is read by some libFLAC functions to + * detect read errors. + * + * \param ptr The address of the read buffer. + * \param size The size of the records to be read. + * \param nmemb The number of records to be read. + * \param handle The handle to the data source. + * \retval size_t + * The number of records read. + */ +typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle); + +/** Signature for the write callback. + * The signature and semantics match POSIX fwrite() implementations + * and can generally be used interchangeably. + * + * \param ptr The address of the write buffer. + * \param size The size of the records to be written. + * \param nmemb The number of records to be written. + * \param handle The handle to the data source. + * \retval size_t + * The number of records written. + */ +typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle); + +/** Signature for the seek callback. + * The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT + * EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long' + * and 32-bits wide. + * + * \param handle The handle to the data source. + * \param offset The new position, relative to \a whence + * \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END + * \retval int + * \c 0 on success, \c -1 on error. + */ +typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence); + +/** Signature for the tell callback. + * The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT + * EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long' + * and 32-bits wide. + * + * \param handle The handle to the data source. + * \retval FLAC__int64 + * The current position on success, \c -1 on error. + */ +typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle); + +/** Signature for the EOF callback. + * The signature and semantics mostly match POSIX feof() but WATCHOUT: + * on many systems, feof() is a macro, so in this case a wrapper function + * must be provided instead. + * + * \param handle The handle to the data source. + * \retval int + * \c 0 if not at end of file, nonzero if at end of file. + */ +typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle); + +/** Signature for the close callback. + * The signature and semantics match POSIX fclose() implementations + * and can generally be used interchangeably. + * + * \param handle The handle to the data source. + * \retval int + * \c 0 on success, \c EOF on error. + */ +typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle); + +/** A structure for holding a set of callbacks. + * Each FLAC interface that requires a FLAC__IOCallbacks structure will + * describe which of the callbacks are required. The ones that are not + * required may be set to NULL. + * + * If the seek requirement for an interface is optional, you can signify that + * a data source is not seekable by setting the \a seek field to \c NULL. + * + * See the detailed documentation for callbacks in the + * \link flac_callbacks callbacks \endlink module. + */ +typedef struct { + FLAC__IOCallback_Read read; /**< See FLAC__IOCallbacks */ + FLAC__IOCallback_Write write; /**< See FLAC__IOCallbacks */ + FLAC__IOCallback_Seek seek; /**< See FLAC__IOCallbacks */ + FLAC__IOCallback_Tell tell; /**< See FLAC__IOCallbacks */ + FLAC__IOCallback_Eof eof; /**< See FLAC__IOCallbacks */ + FLAC__IOCallback_Close close; /**< See FLAC__IOCallbacks */ +} FLAC__IOCallbacks; + +/* \} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/FLAC/export.h b/packages/third-party/libFLAC/FLAC/export.h new file mode 100644 index 00000000..3f0a63fb --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/export.h @@ -0,0 +1,115 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__EXPORT_H +#define FLAC__EXPORT_H + +/** \file include/FLAC/export.h + * + * \brief + * This module contains \#defines and symbols for exporting function + * calls, and providing version information and compiled-in features. + * + * See the \link flac_export export \endlink module. + */ + +/** \defgroup flac_export FLAC/export.h: export symbols + * \ingroup flac + * + * \brief + * This module contains \#defines and symbols for exporting function + * calls, and providing version information and compiled-in features. + * + * If you are compiling for Windows (with Visual Studio or MinGW for + * example) and will link to the static library (libFLAC++.lib) you + * should define FLAC__NO_DLL in your project to make sure the symbols + * are exported properly. + * + * \{ + */ + +/** This \#define is used internally in libFLAC and its headers to make + * sure the correct symbols are exported when working with shared + * libraries. On Windows, this \#define is set to __declspec(dllexport) + * when compiling libFLAC into a library and to __declspec(dllimport) + * when the headers are used to link to that DLL. On non-Windows systems + * it is used to set symbol visibility. + * + * Because of this, the define FLAC__NO_DLL must be defined when linking + * to libFLAC statically or linking will fail. + */ +/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln + * files and CMake, which build either static or shared. autotools can + * build static, shared or **both**. Therefore, DLL_EXPORT, which is set + * by libtool, must override FLAC__NO_DLL on building shared components + */ +#if defined(_WIN32) + +#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT)) +#define FLAC_API +#else +#ifdef FLAC_API_EXPORTS +#define FLAC_API __declspec(dllexport) +#else +#define FLAC_API __declspec(dllimport) +#endif +#endif + +#elif defined(FLAC__USE_VISIBILITY_ATTR) +#define FLAC_API __attribute__ ((visibility ("default"))) + +#else +#define FLAC_API + +#endif + +/** These \#defines will mirror the libtool-based library version number, see + * http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning + */ +#define FLAC_API_VERSION_CURRENT 14 +#define FLAC_API_VERSION_REVISION 0 /**< see above */ +#define FLAC_API_VERSION_AGE 2 /**< see above */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */ +extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC; + +#ifdef __cplusplus +} +#endif + +/* \} */ + +#endif diff --git a/packages/third-party/libFLAC/FLAC/format.h b/packages/third-party/libFLAC/FLAC/format.h new file mode 100644 index 00000000..7ba93990 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/format.h @@ -0,0 +1,1032 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__FORMAT_H +#define FLAC__FORMAT_H + +#include "export.h" +#include "ordinals.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file include/FLAC/format.h + * + * \brief + * This module contains structure definitions for the representation + * of FLAC format components in memory. These are the basic + * structures used by the rest of the interfaces. + * + * See the detailed documentation in the + * \link flac_format format \endlink module. + */ + +/** \defgroup flac_format FLAC/format.h: format components + * \ingroup flac + * + * \brief + * This module contains structure definitions for the representation + * of FLAC format components in memory. These are the basic + * structures used by the rest of the interfaces. + * + * First, you should be familiar with the + * FLAC format. Many of the values here + * follow directly from the specification. As a user of libFLAC, the + * interesting parts really are the structures that describe the frame + * header and metadata blocks. + * + * The format structures here are very primitive, designed to store + * information in an efficient way. Reading information from the + * structures is easy but creating or modifying them directly is + * more complex. For the most part, as a user of a library, editing + * is not necessary; however, for metadata blocks it is, so there are + * convenience functions provided in the \link flac_metadata metadata + * module \endlink to simplify the manipulation of metadata blocks. + * + * \note + * It's not the best convention, but symbols ending in _LEN are in bits + * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of + * global variables because they are usually used when declaring byte + * arrays and some compilers require compile-time knowledge of array + * sizes when declared on the stack. + * + * \{ + */ + + +/* + Most of the values described in this file are defined by the FLAC + format specification. There is nothing to tune here. +*/ + +/** The largest legal metadata type code. */ +#define FLAC__MAX_METADATA_TYPE_CODE (126u) + +/** The minimum block size, in samples, permitted by the format. */ +#define FLAC__MIN_BLOCK_SIZE (16u) + +/** The maximum block size, in samples, permitted by the format. */ +#define FLAC__MAX_BLOCK_SIZE (65535u) + +/** The maximum block size, in samples, permitted by the FLAC subset for + * sample rates up to 48kHz. */ +#define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u) + +/** The maximum number of channels permitted by the format. */ +#define FLAC__MAX_CHANNELS (8u) + +/** The minimum sample resolution permitted by the format. */ +#define FLAC__MIN_BITS_PER_SAMPLE (4u) + +/** The maximum sample resolution permitted by the format. */ +#define FLAC__MAX_BITS_PER_SAMPLE (32u) + +/** The maximum sample resolution permitted by libFLAC. + * + * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, + * the reference encoder/decoder used to be limited to 24 bits. This + * value was used to signal that limit. + */ +#define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (32u) + +/** The maximum sample rate permitted by the format. The value is + * ((2 ^ 20) - 1) + */ +#define FLAC__MAX_SAMPLE_RATE (1048575u) + +/** The maximum LPC order permitted by the format. */ +#define FLAC__MAX_LPC_ORDER (32u) + +/** The maximum LPC order permitted by the FLAC subset for sample rates + * up to 48kHz. */ +#define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u) + +/** The minimum quantized linear predictor coefficient precision + * permitted by the format. + */ +#define FLAC__MIN_QLP_COEFF_PRECISION (5u) + +/** The maximum quantized linear predictor coefficient precision + * permitted by the format. + */ +#define FLAC__MAX_QLP_COEFF_PRECISION (15u) + +/** The maximum order of the fixed predictors permitted by the format. */ +#define FLAC__MAX_FIXED_ORDER (4u) + +/** The maximum Rice partition order permitted by the format. */ +#define FLAC__MAX_RICE_PARTITION_ORDER (15u) + +/** The maximum Rice partition order permitted by the FLAC Subset. */ +#define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u) + +/** The version string of the release, stamped onto the libraries and binaries. + * + * \note + * This does not correspond to the shared library version number, which + * is used to determine binary compatibility. + */ +extern FLAC_API const char *FLAC__VERSION_STRING; + +/** The vendor string inserted by the encoder into the VORBIS_COMMENT block. + * This is a NUL-terminated ASCII string; when inserted into the + * VORBIS_COMMENT the trailing null is stripped. + */ +extern FLAC_API const char *FLAC__VENDOR_STRING; + +/** The byte string representation of the beginning of a FLAC stream. */ +extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ + +/** The 32-bit integer big-endian representation of the beginning of + * a FLAC stream. + */ +extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */ + +/** The length of the FLAC signature in bits. */ +extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */ + +/** The length of the FLAC signature in bytes. */ +#define FLAC__STREAM_SYNC_LENGTH (4u) + + +/***************************************************************************** + * + * Subframe structures + * + *****************************************************************************/ + +/*****************************************************************************/ + +/** An enumeration of the available entropy coding methods. */ +typedef enum { + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0, + /**< Residual is coded by partitioning into contexts, each with it's own + * 4-bit Rice parameter. */ + + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 + /**< Residual is coded by partitioning into contexts, each with it's own + * 5-bit Rice parameter. */ +} FLAC__EntropyCodingMethodType; + +/** Maps a FLAC__EntropyCodingMethodType to a C string. + * + * Using a FLAC__EntropyCodingMethodType as the index to this array will + * give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; + + +/** Contents of a Rice partitioned residual + */ +typedef struct { + + uint32_t *parameters; + /**< The Rice parameters for each context. */ + + uint32_t *raw_bits; + /**< Widths for escape-coded partitions. Will be non-zero for escaped + * partitions and zero for unescaped partitions. + */ + + uint32_t capacity_by_order; + /**< The capacity of the \a parameters and \a raw_bits arrays + * specified as an order, i.e. the number of array elements + * allocated is 2 ^ \a capacity_by_order. + */ +} FLAC__EntropyCodingMethod_PartitionedRiceContents; + +/** Header for a Rice partitioned residual. (c.f. format specification) + */ +typedef struct { + + uint32_t order; + /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ + + const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; + /**< The context's Rice parameters and/or raw bits. */ + +} FLAC__EntropyCodingMethod_PartitionedRice; + +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ + +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; +/**< == (1<format specification) + */ +typedef struct { + FLAC__EntropyCodingMethodType type; + union { + FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; + } data; +} FLAC__EntropyCodingMethod; + +extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ + +/*****************************************************************************/ + +/** An enumeration of the available subframe types. */ +typedef enum { + FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ + FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ + FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ + FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */ +} FLAC__SubframeType; + +/** Maps a FLAC__SubframeType to a C string. + * + * Using a FLAC__SubframeType as the index to this array will + * give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__SubframeTypeString[]; + + +/** CONSTANT subframe. (c.f. format specification) + */ +typedef struct { + FLAC__int64 value; /**< The constant signal value. */ +} FLAC__Subframe_Constant; + +/** An enumeration of the possible verbatim subframe data types. */ +typedef enum { + FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32, /**< verbatim subframe has 32-bit int */ + FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64 /**< verbatim subframe has 64-bit int */ +} FLAC__VerbatimSubframeDataType; + + +/** VERBATIM subframe. (c.f. format specification) + */ +typedef struct { + union { + const FLAC__int32 *int32; /**< A FLAC__int32 pointer to verbatim signal. */ + const FLAC__int64 *int64; /**< A FLAC__int64 pointer to verbatim signal. */ + } data; + FLAC__VerbatimSubframeDataType data_type; +} FLAC__Subframe_Verbatim; + + +/** FIXED subframe. (c.f. format specification) + */ +typedef struct { + FLAC__EntropyCodingMethod entropy_coding_method; + /**< The residual coding method. */ + + uint32_t order; + /**< The polynomial order. */ + + FLAC__int64 warmup[FLAC__MAX_FIXED_ORDER]; + /**< Warmup samples to prime the predictor, length == order. */ + + const FLAC__int32 *residual; + /**< The residual signal, length == (blocksize minus order) samples. */ +} FLAC__Subframe_Fixed; + + +/** LPC subframe. (c.f. format specification) + */ +typedef struct { + FLAC__EntropyCodingMethod entropy_coding_method; + /**< The residual coding method. */ + + uint32_t order; + /**< The FIR order. */ + + uint32_t qlp_coeff_precision; + /**< Quantized FIR filter coefficient precision in bits. */ + + int quantization_level; + /**< The qlp coeff shift needed. */ + + FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; + /**< FIR filter coefficients. */ + + FLAC__int64 warmup[FLAC__MAX_LPC_ORDER]; + /**< Warmup samples to prime the predictor, length == order. */ + + const FLAC__int32 *residual; + /**< The residual signal, length == (blocksize minus order) samples. */ +} FLAC__Subframe_LPC; + +extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ + + +/** FLAC subframe structure. (c.f. format specification) + */ +typedef struct { + FLAC__SubframeType type; + union { + FLAC__Subframe_Constant constant; + FLAC__Subframe_Fixed fixed; + FLAC__Subframe_LPC lpc; + FLAC__Subframe_Verbatim verbatim; + } data; + uint32_t wasted_bits; +} FLAC__Subframe; + +/** == 1 (bit) + * + * This used to be a zero-padding bit (hence the name + * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a + * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 + * to mean something else. + */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN; +extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ + +extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ +extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ + +/*****************************************************************************/ + + +/***************************************************************************** + * + * Frame structures + * + *****************************************************************************/ + +/** An enumeration of the available channel assignments. */ +typedef enum { + FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ + FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ + FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ + FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */ +} FLAC__ChannelAssignment; + +/** Maps a FLAC__ChannelAssignment to a C string. + * + * Using a FLAC__ChannelAssignment as the index to this array will + * give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; + +/** An enumeration of the possible frame numbering methods. */ +typedef enum { + FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ + FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */ +} FLAC__FrameNumberType; + +/** Maps a FLAC__FrameNumberType to a C string. + * + * Using a FLAC__FrameNumberType as the index to this array will + * give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; + + +/** FLAC frame header structure. (c.f. format specification) + */ +typedef struct { + uint32_t blocksize; + /**< The number of samples per subframe. */ + + uint32_t sample_rate; + /**< The sample rate in Hz. */ + + uint32_t channels; + /**< The number of channels (== number of subframes). */ + + FLAC__ChannelAssignment channel_assignment; + /**< The channel assignment for the frame. */ + + uint32_t bits_per_sample; + /**< The sample resolution. */ + + FLAC__FrameNumberType number_type; + /**< The numbering scheme used for the frame. As a convenience, the + * decoder will always convert a frame number to a sample number because + * the rules are complex. */ + + union { + FLAC__uint32 frame_number; + FLAC__uint64 sample_number; + } number; + /**< The frame number or sample number of first sample in frame; + * use the \a number_type value to determine which to use. */ + + FLAC__uint8 crc; + /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) + * of the raw frame header bytes, meaning everything before the CRC byte + * including the sync code. + */ +} FLAC__FrameHeader; + +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ +extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ + + +/** FLAC frame footer structure. (c.f. format specification) + */ +typedef struct { + FLAC__uint16 crc; + /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with + * 0) of the bytes before the crc, back to and including the frame header + * sync code. + */ +} FLAC__FrameFooter; + +extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ + + +/** FLAC frame structure. (c.f. format specification) + */ +typedef struct { + FLAC__FrameHeader header; + FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; + FLAC__FrameFooter footer; +} FLAC__Frame; + +/*****************************************************************************/ + + +/***************************************************************************** + * + * Meta-data structures + * + *****************************************************************************/ + +/** An enumeration of the available metadata block types. */ +typedef enum { + + FLAC__METADATA_TYPE_STREAMINFO = 0, + /**< STREAMINFO block */ + + FLAC__METADATA_TYPE_PADDING = 1, + /**< PADDING block */ + + FLAC__METADATA_TYPE_APPLICATION = 2, + /**< APPLICATION block */ + + FLAC__METADATA_TYPE_SEEKTABLE = 3, + /**< SEEKTABLE block */ + + FLAC__METADATA_TYPE_VORBIS_COMMENT = 4, + /**< VORBISCOMMENT block (a.k.a. FLAC tags) */ + + FLAC__METADATA_TYPE_CUESHEET = 5, + /**< CUESHEET block */ + + FLAC__METADATA_TYPE_PICTURE = 6, + /**< PICTURE block */ + + FLAC__METADATA_TYPE_UNDEFINED = 7, + /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */ + + FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE, + /**< No type will ever be greater than this. There is not enough room in the protocol block. */ +} FLAC__MetadataType; + +/** Maps a FLAC__MetadataType to a C string. + * + * Using a FLAC__MetadataType as the index to this array will + * give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__MetadataTypeString[]; + + +/** FLAC STREAMINFO structure. (c.f. format specification) + */ +typedef struct { + uint32_t min_blocksize, max_blocksize; + uint32_t min_framesize, max_framesize; + uint32_t sample_rate; + uint32_t channels; + uint32_t bits_per_sample; + FLAC__uint64 total_samples; + FLAC__byte md5sum[16]; +} FLAC__StreamMetadata_StreamInfo; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */ + +/** The total stream length of the STREAMINFO block in bytes. */ +#define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u) + +/** FLAC PADDING structure. (c.f. format specification) + */ +typedef struct { + int dummy; + /**< Conceptually this is an empty struct since we don't store the + * padding bytes. Empty structs are not allowed by some C compilers, + * hence the dummy. + */ +} FLAC__StreamMetadata_Padding; + + +/** FLAC APPLICATION structure. (c.f. format specification) + */ +typedef struct { + FLAC__byte id[4]; + FLAC__byte *data; +} FLAC__StreamMetadata_Application; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */ + +/** SeekPoint structure used in SEEKTABLE blocks. (c.f. format specification) + */ +typedef struct { + FLAC__uint64 sample_number; + /**< The sample number of the target frame. */ + + FLAC__uint64 stream_offset; + /**< The offset, in bytes, of the target frame with respect to + * beginning of the first frame. */ + + uint32_t frame_samples; + /**< The number of samples in the target frame. */ +} FLAC__StreamMetadata_SeekPoint; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */ + +/** The total stream length of a seek point in bytes. */ +#define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u) + +/** The value used in the \a sample_number field of + * FLAC__StreamMetadataSeekPoint used to indicate a placeholder + * point (== 0xffffffffffffffff). + */ +extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; + + +/** FLAC SEEKTABLE structure. (c.f. format specification) + * + * \note From the format specification: + * - The seek points must be sorted by ascending sample number. + * - Each seek point's sample number must be the first sample of the + * target frame. + * - Each seek point's sample number must be unique within the table. + * - Existence of a SEEKTABLE block implies a correct setting of + * total_samples in the stream_info block. + * - Behavior is undefined when more than one SEEKTABLE block is + * present in a stream. + */ +typedef struct { + uint32_t num_points; + FLAC__StreamMetadata_SeekPoint *points; +} FLAC__StreamMetadata_SeekTable; + + +/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. format specification) + * + * For convenience, the APIs maintain a trailing NUL character at the end of + * \a entry which is not counted toward \a length, i.e. + * \code strlen(entry) == length \endcode + */ +typedef struct { + FLAC__uint32 length; + FLAC__byte *entry; +} FLAC__StreamMetadata_VorbisComment_Entry; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */ + + +/** FLAC VORBIS_COMMENT structure. (c.f. format specification) + */ +typedef struct { + FLAC__StreamMetadata_VorbisComment_Entry vendor_string; + FLAC__uint32 num_comments; + FLAC__StreamMetadata_VorbisComment_Entry *comments; +} FLAC__StreamMetadata_VorbisComment; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */ + + +/** FLAC CUESHEET track index structure. (See the + * format specification for + * the full description of each field.) + */ +typedef struct { + FLAC__uint64 offset; + /**< Offset in samples, relative to the track offset, of the index + * point. + */ + + FLAC__byte number; + /**< The index point number. */ +} FLAC__StreamMetadata_CueSheet_Index; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */ + + +/** FLAC CUESHEET track structure. (See the + * format specification for + * the full description of each field.) + */ +typedef struct { + FLAC__uint64 offset; + /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */ + + FLAC__byte number; + /**< The track number. */ + + char isrc[13]; + /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */ + + uint32_t type:1; + /**< The track type: 0 for audio, 1 for non-audio. */ + + uint32_t pre_emphasis:1; + /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */ + + FLAC__byte num_indices; + /**< The number of track index points. */ + + FLAC__StreamMetadata_CueSheet_Index *indices; + /**< NULL if num_indices == 0, else pointer to array of index points. */ + +} FLAC__StreamMetadata_CueSheet_Track; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */ + + +/** FLAC CUESHEET structure. (See the + * format specification + * for the full description of each field.) + */ +typedef struct { + char media_catalog_number[129]; + /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In + * general, the media catalog number may be 0 to 128 bytes long; any + * unused characters should be right-padded with NUL characters. + */ + + FLAC__uint64 lead_in; + /**< The number of lead-in samples. */ + + FLAC__bool is_cd; + /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */ + + uint32_t num_tracks; + /**< The number of tracks. */ + + FLAC__StreamMetadata_CueSheet_Track *tracks; + /**< NULL if num_tracks == 0, else pointer to array of tracks. */ + +} FLAC__StreamMetadata_CueSheet; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */ + + +/** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */ +typedef enum { + FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */ + FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */ + FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */ + FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */ + FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */ + FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */ + FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */ + FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */ + FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */ + FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */ + FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */ + FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */ + FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */ + FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */ + FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */ + FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */ + FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */ + FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */ + FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */ + FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */ + FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */ + FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED +} FLAC__StreamMetadata_Picture_Type; + +/** Maps a FLAC__StreamMetadata_Picture_Type to a C string. + * + * Using a FLAC__StreamMetadata_Picture_Type as the index to this array + * will give the string equivalent. The contents should not be + * modified. + */ +extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[]; + +/** FLAC PICTURE structure. (See the + * format specification + * for the full description of each field.) + */ +typedef struct { + FLAC__StreamMetadata_Picture_Type type; + /**< The kind of picture stored. */ + + char *mime_type; + /**< Picture data's MIME type, in ASCII printable characters + * 0x20-0x7e, NUL terminated. For best compatibility with players, + * use picture data of MIME type \c image/jpeg or \c image/png. A + * MIME type of '-->' is also allowed, in which case the picture + * data should be a complete URL. In file storage, the MIME type is + * stored as a 32-bit length followed by the ASCII string with no NUL + * terminator, but is converted to a plain C string in this structure + * for convenience. + */ + + FLAC__byte *description; + /**< Picture's description in UTF-8, NUL terminated. In file storage, + * the description is stored as a 32-bit length followed by the UTF-8 + * string with no NUL terminator, but is converted to a plain C string + * in this structure for convenience. + */ + + FLAC__uint32 width; + /**< Picture's width in pixels. */ + + FLAC__uint32 height; + /**< Picture's height in pixels. */ + + FLAC__uint32 depth; + /**< Picture's color depth in bits-per-pixel. */ + + FLAC__uint32 colors; + /**< For indexed palettes (like GIF), picture's number of colors (the + * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). + */ + + FLAC__uint32 data_length; + /**< Length of binary picture data in bytes. */ + + FLAC__byte *data; + /**< Binary picture data. */ + +} FLAC__StreamMetadata_Picture; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */ + + +/** Structure that is used when a metadata block of unknown type is loaded. + * The contents are opaque. The structure is used only internally to + * correctly handle unknown metadata. + */ +typedef struct { + FLAC__byte *data; +} FLAC__StreamMetadata_Unknown; + + +/** FLAC metadata block structure. (c.f. format specification) + */ +typedef struct FLAC__StreamMetadata { + FLAC__MetadataType type; + /**< The type of the metadata block; used determine which member of the + * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED + * then \a data.unknown must be used. */ + + FLAC__bool is_last; + /**< \c true if this metadata block is the last, else \a false */ + + uint32_t length; + /**< Length, in bytes, of the block data as it appears in the stream. */ + + union { + FLAC__StreamMetadata_StreamInfo stream_info; + FLAC__StreamMetadata_Padding padding; + FLAC__StreamMetadata_Application application; + FLAC__StreamMetadata_SeekTable seek_table; + FLAC__StreamMetadata_VorbisComment vorbis_comment; + FLAC__StreamMetadata_CueSheet cue_sheet; + FLAC__StreamMetadata_Picture picture; + FLAC__StreamMetadata_Unknown unknown; + } data; + /**< Polymorphic block data; use the \a type value to determine which + * to use. */ +} FLAC__StreamMetadata; + +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */ +extern FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */ + +/** The total stream length of a metadata block header in bytes. */ +#define FLAC__STREAM_METADATA_HEADER_LENGTH (4u) + +/*****************************************************************************/ + + +/***************************************************************************** + * + * Utility functions + * + *****************************************************************************/ + +/** Tests that a sample rate is valid for FLAC. + * + * \param sample_rate The sample rate to test for compliance. + * \retval FLAC__bool + * \c true if the given sample rate conforms to the specification, else + * \c false. + */ +FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate); + +/** Tests that a blocksize at the given sample rate is valid for the FLAC + * subset. + * + * \param blocksize The blocksize to test for compliance. + * \param sample_rate The sample rate is needed, since the valid subset + * blocksize depends on the sample rate. + * \retval FLAC__bool + * \c true if the given blocksize conforms to the specification for the + * subset at the given sample rate, else \c false. + */ +FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate); + +/** Tests that a sample rate is valid for the FLAC subset. The subset rules + * for valid sample rates are slightly more complex since the rate has to + * be expressible completely in the frame header. + * + * \param sample_rate The sample rate to test for compliance. + * \retval FLAC__bool + * \c true if the given sample rate conforms to the specification for the + * subset, else \c false. + */ +FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate); + +/** Check a Vorbis comment entry name to see if it conforms to the Vorbis + * comment specification. + * + * Vorbis comment names must be composed only of characters from + * [0x20-0x3C,0x3E-0x7D]. + * + * \param name A NUL-terminated string to be checked. + * \assert + * \code name != NULL \endcode + * \retval FLAC__bool + * \c false if entry name is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name); + +/** Check a Vorbis comment entry value to see if it conforms to the Vorbis + * comment specification. + * + * Vorbis comment values must be valid UTF-8 sequences. + * + * \param value A string to be checked. + * \param length A the length of \a value in bytes. May be + * \c (uint32_t)(-1) to indicate that \a value is a plain + * UTF-8 NUL-terminated string. + * \assert + * \code value != NULL \endcode + * \retval FLAC__bool + * \c false if entry name is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length); + +/** Check a Vorbis comment entry to see if it conforms to the Vorbis + * comment specification. + * + * Vorbis comment entries must be of the form 'name=value', and 'name' and + * 'value' must be legal according to + * FLAC__format_vorbiscomment_entry_name_is_legal() and + * FLAC__format_vorbiscomment_entry_value_is_legal() respectively. + * + * \param entry An entry to be checked. + * \param length The length of \a entry in bytes. + * \assert + * \code value != NULL \endcode + * \retval FLAC__bool + * \c false if entry name is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length); + +/** Check a seek table to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * seek table. + * + * \param seek_table A pointer to a seek table to be checked. + * \assert + * \code seek_table != NULL \endcode + * \retval FLAC__bool + * \c false if seek table is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table); + +/** Sort a seek table's seek points according to the format specification. + * This includes a "unique-ification" step to remove duplicates, i.e. + * seek points with identical \a sample_number values. Duplicate seek + * points are converted into placeholder points and sorted to the end of + * the table. + * + * \param seek_table A pointer to a seek table to be sorted. + * \assert + * \code seek_table != NULL \endcode + * \retval uint32_t + * The number of duplicate seek points converted into placeholders. + */ +FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table); + +/** Check a cue sheet to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * cue sheet. + * + * \param cue_sheet A pointer to an existing cue sheet to be checked. + * \param check_cd_da_subset If \c true, check CUESHEET against more + * stringent requirements for a CD-DA (audio) disc. + * \param violation Address of a pointer to a string. If there is a + * violation, a pointer to a string explanation of the + * violation will be returned here. \a violation may be + * \c NULL if you don't need the returned string. Do not + * free the returned string; it will always point to static + * data. + * \assert + * \code cue_sheet != NULL \endcode + * \retval FLAC__bool + * \c false if cue sheet is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation); + +/** Check picture data to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * PICTURE block. + * + * \param picture A pointer to existing picture data to be checked. + * \param violation Address of a pointer to a string. If there is a + * violation, a pointer to a string explanation of the + * violation will be returned here. \a violation may be + * \c NULL if you don't need the returned string. Do not + * free the returned string; it will always point to static + * data. + * \assert + * \code picture != NULL \endcode + * \retval FLAC__bool + * \c false if picture data is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation); + +/* \} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/FLAC/metadata.h b/packages/third-party/libFLAC/FLAC/metadata.h new file mode 100644 index 00000000..e1cd2a8e --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/metadata.h @@ -0,0 +1,2238 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__METADATA_H +#define FLAC__METADATA_H + +#include /* for off_t */ +#include "export.h" +#include "callback.h" +#include "format.h" + +/* -------------------------------------------------------------------- + (For an example of how all these routines are used, see the source + code for the unit tests in src/test_libFLAC/metadata_*.c, or + metaflac in src/metaflac/) + ------------------------------------------------------------------*/ + +/** \file include/FLAC/metadata.h + * + * \brief + * This module provides functions for creating and manipulating FLAC + * metadata blocks in memory, and three progressively more powerful + * interfaces for traversing and editing metadata in FLAC files. + * + * See the detailed documentation for each interface in the + * \link flac_metadata metadata \endlink module. + */ + +/** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces + * \ingroup flac + * + * \brief + * This module provides functions for creating and manipulating FLAC + * metadata blocks in memory, and three progressively more powerful + * interfaces for traversing and editing metadata in native FLAC files. + * Note that currently only the Chain interface (level 2) and some + * functions in level 0 supports Ogg FLAC files, and they are + * read-only i.e. no writing back changed metadata to file. + * + * There are three metadata interfaces of increasing complexity: + * + * Level 0: + * Read-only access to the STREAMINFO, VORBIS_COMMENT, CUESHEET, and + * PICTURE blocks. + * + * Level 1: + * Read-write access to all metadata blocks. This level is write- + * efficient in most cases (more on this below), and uses less memory + * than level 2. + * + * Level 2: + * Read-write access to all metadata blocks. This level is write- + * efficient in all cases, but uses more memory since all metadata for + * the whole file is read into memory and manipulated before writing + * out again. + * + * What do we mean by efficient? Since FLAC metadata appears at the + * beginning of the file, when writing metadata back to a FLAC file + * it is possible to grow or shrink the metadata such that the entire + * file must be rewritten. However, if the size remains the same during + * changes or PADDING blocks are utilized, only the metadata needs to be + * overwritten, which is much faster. + * + * Efficient means the whole file is rewritten at most one time, and only + * when necessary. Level 1 is not efficient only in the case that you + * cause more than one metadata block to grow or shrink beyond what can + * be accommodated by padding. In this case you should probably use level + * 2, which allows you to edit all the metadata for a file in memory and + * write it out all at once. + * + * All levels know how to skip over and not disturb an ID3v2 tag at the + * front of the file. + * + * All levels access files via their filenames. In addition, level 2 + * has additional alternative read and write functions that take an I/O + * handle and callbacks, for situations where access by filename is not + * possible. + * + * In addition to the three interfaces, this module defines functions for + * creating and manipulating various metadata objects in memory. As we see + * from the Format module, FLAC metadata blocks in memory are very primitive + * structures for storing information in an efficient way. Reading + * information from the structures is easy but creating or modifying them + * directly is more complex. The metadata object routines here facilitate + * this by taking care of the consistency and memory management drudgery. + * + * Unless you will be using the level 1 or 2 interfaces to modify existing + * metadata however, you will not probably not need these. + * + * From a dependency standpoint, none of the encoders or decoders require + * the metadata module. This is so that embedded users can strip out the + * metadata module from libFLAC to reduce the size and complexity. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface + * \ingroup flac_metadata + * + * \brief + * The level 0 interface consists of individual routines to read the + * STREAMINFO, VORBIS_COMMENT, CUESHEET, and PICTURE blocks, requiring + * only a filename. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * They try to skip any ID3v2 tag at the head of the file. + * + * \{ + */ + +/** Read the STREAMINFO metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. + * + * \param filename The path to the FLAC or Ogg FLAC file to read. + * \param streaminfo A pointer to space for the STREAMINFO block. Since + * FLAC__StreamMetadata is a simple structure with no + * memory allocation involved, you pass the address of + * an existing structure. It need not be initialized. + * \assert + * \code filename != NULL \endcode + * \code streaminfo != NULL \endcode + * \retval FLAC__bool + * \c true if a valid STREAMINFO block was read from \a filename. Returns + * \c false if there was a memory allocation error, a file decoder error, + * or the file contained no STREAMINFO block. (A memory allocation error + * is possible because this function must set up a file decoder.) + */ +FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo); + +/** Read the VORBIS_COMMENT metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. + * + * \param filename The path to the FLAC or Ogg FLAC file to read. + * \param tags The address where the returned pointer will be + * stored. The \a tags object must be deleted by + * the caller using FLAC__metadata_object_delete(). + * \assert + * \code filename != NULL \endcode + * \code tags != NULL \endcode + * \retval FLAC__bool + * \c true if a valid VORBIS_COMMENT block was read from \a filename, + * and \a *tags will be set to the address of the metadata structure. + * Returns \c false if there was a memory allocation error, a file + * decoder error, or the file contained no VORBIS_COMMENT block, and + * \a *tags will be set to \c NULL. + */ +FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags); + +/** Read the CUESHEET metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. + * + * \param filename The path to the FLAC or Ogg FLAC file to read. + * \param cuesheet The address where the returned pointer will be + * stored. The \a cuesheet object must be deleted by + * the caller using FLAC__metadata_object_delete(). + * \assert + * \code filename != NULL \endcode + * \code cuesheet != NULL \endcode + * \retval FLAC__bool + * \c true if a valid CUESHEET block was read from \a filename, + * and \a *cuesheet will be set to the address of the metadata + * structure. Returns \c false if there was a memory allocation + * error, a file decoder error, or the file contained no CUESHEET + * block, and \a *cuesheet will be set to \c NULL. + */ +FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet); + +/** Read a PICTURE metadata block of the given FLAC file. This + * function will try to skip any ID3v2 tag at the head of the file. + * Since there can be more than one PICTURE block in a file, this + * function takes a number of parameters that act as constraints to + * the search. The PICTURE block with the largest area matching all + * the constraints will be returned, or \a *picture will be set to + * \c NULL if there was no such block. This function does not + * currently support reading from Ogg FLAC files. + * + * \param filename The path to the FLAC file to read. + * \param picture The address where the returned pointer will be + * stored. The \a picture object must be deleted by + * the caller using FLAC__metadata_object_delete(). + * \param type The desired picture type. Use \c -1 to mean + * "any type". + * \param mime_type The desired MIME type, e.g. "image/jpeg". The + * string will be matched exactly. Use \c NULL to + * mean "any MIME type". + * \param description The desired description. The string will be + * matched exactly. Use \c NULL to mean "any + * description". + * \param max_width The maximum width in pixels desired. Use + * \c (uint32_t)(-1) to mean "any width". + * \param max_height The maximum height in pixels desired. Use + * \c (uint32_t)(-1) to mean "any height". + * \param max_depth The maximum color depth in bits-per-pixel desired. + * Use \c (uint32_t)(-1) to mean "any depth". + * \param max_colors The maximum number of colors desired. Use + * \c (uint32_t)(-1) to mean "any number of colors". + * \assert + * \code filename != NULL \endcode + * \code picture != NULL \endcode + * \retval FLAC__bool + * \c true if a valid PICTURE block was read from \a filename, + * and \a *picture will be set to the address of the metadata + * structure. Returns \c false if there was a memory allocation + * error, a file decoder error, or the file contained no PICTURE + * block, and \a *picture will be set to \c NULL. + */ +FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); + +/* \} */ + + +/** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface + * \ingroup flac_metadata + * + * \brief + * The level 1 interface provides read-write access to FLAC file metadata and + * operates directly on the FLAC file. + * + * The general usage of this interface is: + * + * - Create an iterator using FLAC__metadata_simple_iterator_new() + * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check + * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to + * see if the file is writable, or only read access is allowed. + * - Use FLAC__metadata_simple_iterator_next() and + * FLAC__metadata_simple_iterator_prev() to traverse the blocks. + * This is does not read the actual blocks themselves. + * FLAC__metadata_simple_iterator_next() is relatively fast. + * FLAC__metadata_simple_iterator_prev() is slower since it needs to search + * forward from the front of the file. + * - Use FLAC__metadata_simple_iterator_get_block_type() or + * FLAC__metadata_simple_iterator_get_block() to access the actual data at + * the current iterator position. The returned object is yours to modify + * and free. + * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block + * back. You must have write permission to the original file. Make sure to + * read the whole comment to FLAC__metadata_simple_iterator_set_block() + * below. + * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks. + * Use the object creation functions from + * \link flac_metadata_object here \endlink to generate new objects. + * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block + * currently referred to by the iterator, or replace it with padding. + * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when + * finished. + * + * \note + * The FLAC file remains open the whole time between + * FLAC__metadata_simple_iterator_init() and + * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering + * the file during this time. + * + * \note + * Do not modify the \a is_last, \a length, or \a type fields of returned + * FLAC__StreamMetadata objects. These are managed automatically. + * + * \note + * If any of the modification functions + * (FLAC__metadata_simple_iterator_set_block(), + * FLAC__metadata_simple_iterator_delete_block(), + * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false, + * you should delete the iterator as it may no longer be valid. + * + * \{ + */ + +struct FLAC__Metadata_SimpleIterator; +/** The opaque structure definition for the level 1 iterator type. + * See the + * \link flac_metadata_level1 metadata level 1 module \endlink + * for a detailed description. + */ +typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator; + +/** Status type for FLAC__Metadata_SimpleIterator. + * + * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status(). + */ +typedef enum { + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0, + /**< The iterator is in the normal OK state */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, + /**< The data passed into a function violated the function's usage criteria */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE, + /**< The iterator could not open the target file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE, + /**< The iterator could not find the FLAC signature at the start of the file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE, + /**< The iterator tried to write to a file that was not writable */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA, + /**< The iterator encountered input that does not conform to the FLAC metadata specification */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR, + /**< The iterator encountered an error while reading the FLAC file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, + /**< The iterator encountered an error while seeking in the FLAC file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR, + /**< The iterator encountered an error while writing the FLAC file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR, + /**< The iterator encountered an error renaming the FLAC file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR, + /**< The iterator encountered an error removing the temporary file */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR, + /**< Memory allocation failed */ + + FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR + /**< The caller violated an assertion or an unexpected error occurred */ + +} FLAC__Metadata_SimpleIteratorStatus; + +/** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string. + * + * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[]; + + +/** Create a new iterator instance. + * + * \retval FLAC__Metadata_SimpleIterator* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void); + +/** Free an iterator instance. Deletes the object pointed to by \a iterator. + * + * \param iterator A pointer to an existing iterator. + * \assert + * \code iterator != NULL \endcode + */ +FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator); + +/** Get the current status of the iterator. Call this after a function + * returns \c false to get the reason for the error. Also resets the status + * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK. + * + * \param iterator A pointer to an existing iterator. + * \assert + * \code iterator != NULL \endcode + * \retval FLAC__Metadata_SimpleIteratorStatus + * The current status of the iterator. + */ +FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator); + +/** Initialize the iterator to point to the first metadata block in the + * given FLAC file. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * \param iterator A pointer to an existing iterator. + * \param filename The path to the FLAC file. + * \param read_only If \c true, the FLAC file will be opened + * in read-only mode; if \c false, the FLAC + * file will be opened for edit even if no + * edits are performed. + * \param preserve_file_stats If \c true, the owner and modification + * time will be preserved even if the FLAC + * file is written to. + * \assert + * \code iterator != NULL \endcode + * \code filename != NULL \endcode + * \retval FLAC__bool + * \c false if a memory allocation error occurs, the file can't be + * opened, or another error occurs, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats); + +/** Returns \c true if the FLAC file is writable. If \c false, calls to + * FLAC__metadata_simple_iterator_set_block() and + * FLAC__metadata_simple_iterator_insert_block_after() will fail. + * + * \param iterator A pointer to an existing iterator. + * \assert + * \code iterator != NULL \endcode + * \retval FLAC__bool + * See above. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator); + +/** Moves the iterator forward one metadata block, returning \c false if + * already at the end. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__bool + * \c false if already at the last metadata block of the chain, else + * \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator); + +/** Moves the iterator backward one metadata block, returning \c false if + * already at the beginning. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__bool + * \c false if already at the first metadata block of the chain, else + * \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator); + +/** Returns a flag telling if the current metadata block is the last. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__bool + * \c true if the current metadata block is the last in the file, + * else \c false. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator); + +/** Get the offset of the metadata block at the current position. This + * avoids reading the actual block data which can save time for large + * blocks. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval off_t + * The offset of the metadata block at the current iterator position. + * This is the byte offset relative to the beginning of the file of + * the current metadata block's header. + */ +FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator); + +/** Get the type of the metadata block at the current position. This + * avoids reading the actual block data which can save time for large + * blocks. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__MetadataType + * The type of the metadata block at the current iterator position. + */ +FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator); + +/** Get the length of the metadata block at the current position. This + * avoids reading the actual block data which can save time for large + * blocks. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval uint32_t + * The length of the metadata block at the current iterator position. + * The is same length as that in the + * metadata block header, + * i.e. the length of the metadata body that follows the header. + */ +FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator); + +/** Get the application ID of the \c APPLICATION block at the current + * position. This avoids reading the actual block data which can save + * time for large blocks. + * + * \param iterator A pointer to an existing initialized iterator. + * \param id A pointer to a buffer of at least \c 4 bytes where + * the ID will be stored. + * \assert + * \code iterator != NULL \endcode + * \code id != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__bool + * \c true if the ID was successfully read, else \c false, in which + * case you should check FLAC__metadata_simple_iterator_status() to + * find out why. If the status is + * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the + * current metadata block is not an \c APPLICATION block. Otherwise + * if the status is + * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or + * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error + * occurred and the iterator can no longer be used. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id); + +/** Get the metadata block at the current position. You can modify the + * block but must use FLAC__metadata_simple_iterator_set_block() to + * write it back to the FLAC file. + * + * You must call FLAC__metadata_object_delete() on the returned object + * when you are finished with it. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__StreamMetadata* + * The current metadata block, or \c NULL if there was a memory + * allocation error. + */ +FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator); + +/** Write a block back to the FLAC file. This function tries to be + * as efficient as possible; how the block is actually written is + * shown by the following: + * + * Existing block is a STREAMINFO block and the new block is a + * STREAMINFO block: the new block is written in place. Make sure + * you know what you're doing when changing the values of a + * STREAMINFO block. + * + * Existing block is a STREAMINFO block and the new block is a + * not a STREAMINFO block: this is an error since the first block + * must be a STREAMINFO block. Returns \c false without altering the + * file. + * + * Existing block is not a STREAMINFO block and the new block is a + * STREAMINFO block: this is an error since there may be only one + * STREAMINFO block. Returns \c false without altering the file. + * + * Existing block and new block are the same length: the existing + * block will be replaced by the new block, written in place. + * + * Existing block is longer than new block: if use_padding is \c true, + * the existing block will be overwritten in place with the new + * block followed by a PADDING block, if possible, to make the total + * size the same as the existing block. Remember that a padding + * block requires at least four bytes so if the difference in size + * between the new block and existing block is less than that, the + * entire file will have to be rewritten, using the new block's + * exact size. If use_padding is \c false, the entire file will be + * rewritten, replacing the existing block by the new block. + * + * Existing block is shorter than new block: if use_padding is \c true, + * the function will try and expand the new block into the following + * PADDING block, if it exists and doing so won't shrink the PADDING + * block to less than 4 bytes. If there is no following PADDING + * block, or it will shrink to less than 4 bytes, or use_padding is + * \c false, the entire file is rewritten, replacing the existing block + * with the new block. Note that in this case any following PADDING + * block is preserved as is. + * + * After writing the block, the iterator will remain in the same + * place, i.e. pointing to the new block. + * + * \param iterator A pointer to an existing initialized iterator. + * \param block The block to set. + * \param use_padding See above. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \code block != NULL \endcode + * \retval FLAC__bool + * \c true if successful, else \c false. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); + +/** This is similar to FLAC__metadata_simple_iterator_set_block() + * except that instead of writing over an existing block, it appends + * a block after the existing block. \a use_padding is again used to + * tell the function to try an expand into following padding in an + * attempt to avoid rewriting the entire file. + * + * This function will fail and return \c false if given a STREAMINFO + * block. + * + * After writing the block, the iterator will be pointing to the + * new block. + * + * \param iterator A pointer to an existing initialized iterator. + * \param block The block to set. + * \param use_padding See above. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \code block != NULL \endcode + * \retval FLAC__bool + * \c true if successful, else \c false. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); + +/** Deletes the block at the current position. This will cause the + * entire FLAC file to be rewritten, unless \a use_padding is \c true, + * in which case the block will be replaced by an equal-sized PADDING + * block. The iterator will be left pointing to the block before the + * one just deleted. + * + * You may not delete the STREAMINFO block. + * + * \param iterator A pointer to an existing initialized iterator. + * \param use_padding See above. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_simple_iterator_init() + * \retval FLAC__bool + * \c true if successful, else \c false. + */ +FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding); + +/* \} */ + + +/** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface + * \ingroup flac_metadata + * + * \brief + * The level 2 interface provides read-write access to FLAC file metadata; + * all metadata is read into memory, operated on in memory, and then written + * to file, which is more efficient than level 1 when editing multiple blocks. + * + * Currently Ogg FLAC is supported for read only, via + * FLAC__metadata_chain_read_ogg() but a subsequent + * FLAC__metadata_chain_write() will fail. + * + * The general usage of this interface is: + * + * - Create a new chain using FLAC__metadata_chain_new(). A chain is a + * linked list of FLAC metadata blocks. + * - Read all metadata into the chain from a FLAC file using + * FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and + * check the status. + * - Optionally, consolidate the padding using + * FLAC__metadata_chain_merge_padding() or + * FLAC__metadata_chain_sort_padding(). + * - Create a new iterator using FLAC__metadata_iterator_new() + * - Initialize the iterator to point to the first element in the chain + * using FLAC__metadata_iterator_init() + * - Traverse the chain using FLAC__metadata_iterator_next and + * FLAC__metadata_iterator_prev(). + * - Get a block for reading or modification using + * FLAC__metadata_iterator_get_block(). The pointer to the object + * inside the chain is returned, so the block is yours to modify. + * Changes will be reflected in the FLAC file when you write the + * chain. You can also add and delete blocks (see functions below). + * - When done, write out the chain using FLAC__metadata_chain_write(). + * Make sure to read the whole comment to the function below. + * - Delete the chain using FLAC__metadata_chain_delete(). + * + * \note + * Even though the FLAC file is not open while the chain is being + * manipulated, you must not alter the file externally during + * this time. The chain assumes the FLAC file will not change + * between the time of FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg() + * and FLAC__metadata_chain_write(). + * + * \note + * Do not modify the is_last, length, or type fields of returned + * FLAC__StreamMetadata objects. These are managed automatically. + * + * \note + * The metadata objects returned by FLAC__metadata_iterator_get_block() + * are owned by the chain; do not FLAC__metadata_object_delete() them. + * In the same way, blocks passed to FLAC__metadata_iterator_set_block() + * become owned by the chain and they will be deleted when the chain is + * deleted. + * + * \{ + */ + +struct FLAC__Metadata_Chain; +/** The opaque structure definition for the level 2 chain type. + */ +typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain; + +struct FLAC__Metadata_Iterator; +/** The opaque structure definition for the level 2 iterator type. + */ +typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator; + +typedef enum { + FLAC__METADATA_CHAIN_STATUS_OK = 0, + /**< The chain is in the normal OK state */ + + FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT, + /**< The data passed into a function violated the function's usage criteria */ + + FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE, + /**< The chain could not open the target file */ + + FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE, + /**< The chain could not find the FLAC signature at the start of the file */ + + FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE, + /**< The chain tried to write to a file that was not writable */ + + FLAC__METADATA_CHAIN_STATUS_BAD_METADATA, + /**< The chain encountered input that does not conform to the FLAC metadata specification */ + + FLAC__METADATA_CHAIN_STATUS_READ_ERROR, + /**< The chain encountered an error while reading the FLAC file */ + + FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR, + /**< The chain encountered an error while seeking in the FLAC file */ + + FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR, + /**< The chain encountered an error while writing the FLAC file */ + + FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR, + /**< The chain encountered an error renaming the FLAC file */ + + FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR, + /**< The chain encountered an error removing the temporary file */ + + FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR, + /**< Memory allocation failed */ + + FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR, + /**< The caller violated an assertion or an unexpected error occurred */ + + FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS, + /**< One or more of the required callbacks was NULL */ + + FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH, + /**< FLAC__metadata_chain_write() was called on a chain read by + * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), + * or + * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile() + * was called on a chain read by + * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). + * Matching read/write methods must always be used. */ + + FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL + /**< FLAC__metadata_chain_write_with_callbacks() was called when the + * chain write requires a tempfile; use + * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. + * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was + * called when the chain write does not require a tempfile; use + * FLAC__metadata_chain_write_with_callbacks() instead. + * Always check FLAC__metadata_chain_check_if_tempfile_needed() + * before writing via callbacks. */ + +} FLAC__Metadata_ChainStatus; + +/** Maps a FLAC__Metadata_ChainStatus to a C string. + * + * Using a FLAC__Metadata_ChainStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[]; + +/*********** FLAC__Metadata_Chain ***********/ + +/** Create a new chain instance. + * + * \retval FLAC__Metadata_Chain* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void); + +/** Free a chain instance. Deletes the object pointed to by \a chain. + * + * \param chain A pointer to an existing chain. + * \assert + * \code chain != NULL \endcode + */ +FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain); + +/** Get the current status of the chain. Call this after a function + * returns \c false to get the reason for the error. Also resets the + * status to FLAC__METADATA_CHAIN_STATUS_OK. + * + * \param chain A pointer to an existing chain. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__Metadata_ChainStatus + * The current status of the chain. + */ +FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain); + +/** Read all metadata from a FLAC file into the chain. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * \param chain A pointer to an existing chain. + * \param filename The path to the FLAC file to read. + * \assert + * \code chain != NULL \endcode + * \code filename != NULL \endcode + * \retval FLAC__bool + * \c true if a valid list of metadata blocks was read from + * \a filename, else \c false. On failure, check the status with + * FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename); + +/** Read all metadata from an Ogg FLAC file into the chain. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * \note Ogg FLAC metadata data writing is not supported yet and + * FLAC__metadata_chain_write() will fail. + * + * \param chain A pointer to an existing chain. + * \param filename The path to the Ogg FLAC file to read. + * \assert + * \code chain != NULL \endcode + * \code filename != NULL \endcode + * \retval FLAC__bool + * \c true if a valid list of metadata blocks was read from + * \a filename, else \c false. On failure, check the status with + * FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename); + +/** Read all metadata from a FLAC stream into the chain via I/O callbacks. + * + * The \a handle need only be open for reading, but must be seekable. + * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" + * for Windows). + * + * \param chain A pointer to an existing chain. + * \param handle The I/O handle of the FLAC stream to read. The + * handle will NOT be closed after the metadata is read; + * that is the duty of the caller. + * \param callbacks + * A set of callbacks to use for I/O. The mandatory + * callbacks are \a read, \a seek, and \a tell. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if a valid list of metadata blocks was read from + * \a handle, else \c false. On failure, check the status with + * FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); + +/** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks. + * + * The \a handle need only be open for reading, but must be seekable. + * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" + * for Windows). + * + * \note Ogg FLAC metadata data writing is not supported yet and + * FLAC__metadata_chain_write() will fail. + * + * \param chain A pointer to an existing chain. + * \param handle The I/O handle of the Ogg FLAC stream to read. The + * handle will NOT be closed after the metadata is read; + * that is the duty of the caller. + * \param callbacks + * A set of callbacks to use for I/O. The mandatory + * callbacks are \a read, \a seek, and \a tell. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if a valid list of metadata blocks was read from + * \a handle, else \c false. On failure, check the status with + * FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); + +/** Checks if writing the given chain would require the use of a + * temporary file, or if it could be written in place. + * + * Under certain conditions, padding can be utilized so that writing + * edited metadata back to the FLAC file does not require rewriting the + * entire file. If rewriting is required, then a temporary workfile is + * required. When writing metadata using callbacks, you must check + * this function to know whether to call + * FLAC__metadata_chain_write_with_callbacks() or + * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When + * writing with FLAC__metadata_chain_write(), the temporary file is + * handled internally. + * + * \param chain A pointer to an existing chain. + * \param use_padding + * Whether or not padding will be allowed to be used + * during the write. The value of \a use_padding given + * here must match the value later passed to + * FLAC__metadata_chain_write_with_callbacks() or + * FLAC__metadata_chain_write_with_callbacks_with_tempfile(). + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if writing the current chain would require a tempfile, or + * \c false if metadata can be written in place. + */ +FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding); + +/** Write all metadata out to the FLAC file. This function tries to be as + * efficient as possible; how the metadata is actually written is shown by + * the following: + * + * If the current chain is the same size as the existing metadata, the new + * data is written in place. + * + * If the current chain is longer than the existing metadata, and + * \a use_padding is \c true, and the last block is a PADDING block of + * sufficient length, the function will truncate the final padding block + * so that the overall size of the metadata is the same as the existing + * metadata, and then just rewrite the metadata. Otherwise, if not all of + * the above conditions are met, the entire FLAC file must be rewritten. + * If you want to use padding this way it is a good idea to call + * FLAC__metadata_chain_sort_padding() first so that you have the maximum + * amount of padding to work with, unless you need to preserve ordering + * of the PADDING blocks for some reason. + * + * If the current chain is shorter than the existing metadata, and + * \a use_padding is \c true, and the final block is a PADDING block, the padding + * is extended to make the overall size the same as the existing data. If + * \a use_padding is \c true and the last block is not a PADDING block, a new + * PADDING block is added to the end of the new data to make it the same + * size as the existing data (if possible, see the note to + * FLAC__metadata_simple_iterator_set_block() about the four byte limit) + * and the new data is written in place. If none of the above apply or + * \a use_padding is \c false, the entire FLAC file is rewritten. + * + * If \a preserve_file_stats is \c true, the owner and modification time will + * be preserved even if the FLAC file is written. + * + * For this write function to be used, the chain must have been read with + * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not + * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(). + * + * \param chain A pointer to an existing chain. + * \param use_padding See above. + * \param preserve_file_stats See above. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if the write succeeded, else \c false. On failure, + * check the status with FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats); + +/** Write all metadata out to a FLAC stream via callbacks. + * + * (See FLAC__metadata_chain_write() for the details on how padding is + * used to write metadata in place if possible.) + * + * The \a handle must be open for updating and be seekable. The + * equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b" + * for Windows). + * + * For this write function to be used, the chain must have been read with + * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), + * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). + * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned + * \c false. + * + * \param chain A pointer to an existing chain. + * \param use_padding See FLAC__metadata_chain_write() + * \param handle The I/O handle of the FLAC stream to write. The + * handle will NOT be closed after the metadata is + * written; that is the duty of the caller. + * \param callbacks A set of callbacks to use for I/O. The mandatory + * callbacks are \a write and \a seek. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if the write succeeded, else \c false. On failure, + * check the status with FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); + +/** Write all metadata out to a FLAC stream via callbacks. + * + * (See FLAC__metadata_chain_write() for the details on how padding is + * used to write metadata in place if possible.) + * + * This version of the write-with-callbacks function must be used when + * FLAC__metadata_chain_check_if_tempfile_needed() returns true. In + * this function, you must supply an I/O handle corresponding to the + * FLAC file to edit, and a temporary handle to which the new FLAC + * file will be written. It is the caller's job to move this temporary + * FLAC file on top of the original FLAC file to complete the metadata + * edit. + * + * The \a handle must be open for reading and be seekable. The + * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" + * for Windows). + * + * The \a temp_handle must be open for writing. The + * equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb" + * for Windows). It should be an empty stream, or at least positioned + * at the start-of-file (in which case it is the caller's duty to + * truncate it on return). + * + * For this write function to be used, the chain must have been read with + * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), + * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). + * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned + * \c true. + * + * \param chain A pointer to an existing chain. + * \param use_padding See FLAC__metadata_chain_write() + * \param handle The I/O handle of the original FLAC stream to read. + * The handle will NOT be closed after the metadata is + * written; that is the duty of the caller. + * \param callbacks A set of callbacks to use for I/O on \a handle. + * The mandatory callbacks are \a read, \a seek, and + * \a eof. + * \param temp_handle The I/O handle of the FLAC stream to write. The + * handle will NOT be closed after the metadata is + * written; that is the duty of the caller. + * \param temp_callbacks + * A set of callbacks to use for I/O on temp_handle. + * The only mandatory callback is \a write. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if the write succeeded, else \c false. On failure, + * check the status with FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks); + +/** Merge adjacent PADDING blocks into a single block. + * + * \note This function does not write to the FLAC file, it only + * modifies the chain. + * + * \warning Any iterator on the current chain will become invalid after this + * call. You should delete the iterator and get a new one. + * + * \param chain A pointer to an existing chain. + * \assert + * \code chain != NULL \endcode + */ +FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain); + +/** This function will move all PADDING blocks to the end on the metadata, + * then merge them into a single block. + * + * \note This function does not write to the FLAC file, it only + * modifies the chain. + * + * \warning Any iterator on the current chain will become invalid after this + * call. You should delete the iterator and get a new one. + * + * \param chain A pointer to an existing chain. + * \assert + * \code chain != NULL \endcode + */ +FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain); + + +/*********** FLAC__Metadata_Iterator ***********/ + +/** Create a new iterator instance. + * + * \retval FLAC__Metadata_Iterator* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void); + +/** Free an iterator instance. Deletes the object pointed to by \a iterator. + * + * \param iterator A pointer to an existing iterator. + * \assert + * \code iterator != NULL \endcode + */ +FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator); + +/** Initialize the iterator to point to the first metadata block in the + * given chain. + * + * \param iterator A pointer to an existing iterator. + * \param chain A pointer to an existing and initialized (read) chain. + * \assert + * \code iterator != NULL \endcode + * \code chain != NULL \endcode + */ +FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain); + +/** Moves the iterator forward one metadata block, returning \c false if + * already at the end. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__bool + * \c false if already at the last metadata block of the chain, else + * \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator); + +/** Moves the iterator backward one metadata block, returning \c false if + * already at the beginning. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__bool + * \c false if already at the first metadata block of the chain, else + * \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator); + +/** Get the type of the metadata block at the current position. + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__MetadataType + * The type of the metadata block at the current iterator position. + */ +FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator); + +/** Get the metadata block at the current position. You can modify + * the block in place but must write the chain before the changes + * are reflected to the FLAC file. You do not need to call + * FLAC__metadata_iterator_set_block() to reflect the changes; + * the pointer returned by FLAC__metadata_iterator_get_block() + * points directly into the chain. + * + * \warning + * Do not call FLAC__metadata_object_delete() on the returned object; + * to delete a block use FLAC__metadata_iterator_delete_block(). + * + * \param iterator A pointer to an existing initialized iterator. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__StreamMetadata* + * The current metadata block. + */ +FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator); + +/** Set the metadata block at the current position, replacing the existing + * block. The new block passed in becomes owned by the chain and it will be + * deleted when the chain is deleted. + * + * \param iterator A pointer to an existing initialized iterator. + * \param block A pointer to a metadata block. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \code block != NULL \endcode + * \retval FLAC__bool + * \c false if the conditions in the above description are not met, or + * a memory allocation error occurs, otherwise \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); + +/** Removes the current block from the chain. If \a replace_with_padding is + * \c true, the block will instead be replaced with a padding block of equal + * size. You can not delete the STREAMINFO block. The iterator will be + * left pointing to the block before the one just "deleted", even if + * \a replace_with_padding is \c true. + * + * \param iterator A pointer to an existing initialized iterator. + * \param replace_with_padding See above. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__bool + * \c false if the conditions in the above description are not met, + * otherwise \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding); + +/** Insert a new block before the current block. You cannot insert a block + * before the first STREAMINFO block. You cannot insert a STREAMINFO block + * as there can be only one, the one that already exists at the head when you + * read in a chain. The chain takes ownership of the new block and it will be + * deleted when the chain is deleted. The iterator will be left pointing to + * the new block. + * + * \param iterator A pointer to an existing initialized iterator. + * \param block A pointer to a metadata block to insert. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__bool + * \c false if the conditions in the above description are not met, or + * a memory allocation error occurs, otherwise \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); + +/** Insert a new block after the current block. You cannot insert a STREAMINFO + * block as there can be only one, the one that already exists at the head when + * you read in a chain. The chain takes ownership of the new block and it will + * be deleted when the chain is deleted. The iterator will be left pointing to + * the new block. + * + * \param iterator A pointer to an existing initialized iterator. + * \param block A pointer to a metadata block to insert. + * \assert + * \code iterator != NULL \endcode + * \a iterator has been successfully initialized with + * FLAC__metadata_iterator_init() + * \retval FLAC__bool + * \c false if the conditions in the above description are not met, or + * a memory allocation error occurs, otherwise \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); + +/* \} */ + + +/** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods + * \ingroup flac_metadata + * + * \brief + * This module contains methods for manipulating FLAC metadata objects. + * + * Since many are variable length we have to be careful about the memory + * management. We decree that all pointers to data in the object are + * owned by the object and memory-managed by the object. + * + * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete() + * functions to create all instances. When using the + * FLAC__metadata_object_set_*() functions to set pointers to data, set + * \a copy to \c true to have the function make it's own copy of the data, or + * to \c false to give the object ownership of your data. In the latter case + * your pointer must be freeable by free() and will be free()d when the object + * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as + * the data pointer to a FLAC__metadata_object_set_*() function as long as + * the length argument is 0 and the \a copy argument is \c false. + * + * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function + * will return \c NULL in the case of a memory allocation error, otherwise a new + * object. The FLAC__metadata_object_set_*() functions return \c false in the + * case of a memory allocation error. + * + * We don't have the convenience of C++ here, so note that the library relies + * on you to keep the types straight. In other words, if you pass, for + * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to + * FLAC__metadata_object_application_set_data(), you will get an assertion + * failure. + * + * For convenience the FLAC__metadata_object_vorbiscomment_*() functions + * maintain a trailing NUL on each Vorbis comment entry. This is not counted + * toward the length or stored in the stream, but it can make working with plain + * comments (those that don't contain embedded-NULs in the value) easier. + * Entries passed into these functions have trailing NULs added if missing, and + * returned entries are guaranteed to have a trailing NUL. + * + * The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis + * comment entry/name/value will first validate that it complies with the Vorbis + * comment specification and return false if it does not. + * + * There is no need to recalculate the length field on metadata blocks you + * have modified. They will be calculated automatically before they are + * written back to a file. + * + * \{ + */ + + +/** Create a new metadata object instance of the given type. + * + * The object will be "empty"; i.e. values and data pointers will be \c 0, + * with the exception of FLAC__METADATA_TYPE_VORBIS_COMMENT, which will have + * the vendor string set (but zero comments). + * + * Do not pass in a value greater than or equal to + * \a FLAC__METADATA_TYPE_UNDEFINED unless you really know what you're + * doing. + * + * \param type Type of object to create + * \retval FLAC__StreamMetadata* + * \c NULL if there was an error allocating memory or the type code is + * greater than FLAC__MAX_METADATA_TYPE_CODE, else the new instance. + */ +FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type); + +/** Create a copy of an existing metadata object. + * + * The copy is a "deep" copy, i.e. dynamically allocated data within the + * object is also copied. The caller takes ownership of the new block and + * is responsible for freeing it with FLAC__metadata_object_delete(). + * + * \param object Pointer to object to copy. + * \assert + * \code object != NULL \endcode + * \retval FLAC__StreamMetadata* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object); + +/** Free a metadata object. Deletes the object pointed to by \a object. + * + * The delete is a "deep" delete, i.e. dynamically allocated data within the + * object is also deleted. + * + * \param object A pointer to an existing object. + * \assert + * \code object != NULL \endcode + */ +FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object); + +/** Compares two metadata objects. + * + * The compare is "deep", i.e. dynamically allocated data within the + * object is also compared. + * + * \param block1 A pointer to an existing object. + * \param block2 A pointer to an existing object. + * \assert + * \code block1 != NULL \endcode + * \code block2 != NULL \endcode + * \retval FLAC__bool + * \c true if objects are identical, else \c false. + */ +FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2); + +/** Sets the application data of an APPLICATION block. + * + * If \a copy is \c true, a copy of the data is stored; otherwise, the object + * takes ownership of the pointer. The existing data will be freed if this + * function is successful, otherwise the original data will remain if \a copy + * is \c true and malloc() fails. + * + * \note It is safe to pass a const pointer to \a data if \a copy is \c true. + * + * \param object A pointer to an existing APPLICATION object. + * \param data A pointer to the data to set. + * \param length The length of \a data in bytes. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode + * \code (data != NULL && length > 0) || + * (data == NULL && length == 0 && copy == false) \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy); + +/** Resize the seekpoint array. + * + * If the size shrinks, elements will truncated; if it grows, new placeholder + * points will be added to the end. If this function returns false, the + * object is left untouched. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param new_num_points The desired length of the array; may be \c 0. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) || + * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation error, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points); + +/** Set a seekpoint in a seektable. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param point_num Index into seekpoint array to set. + * \param point The point to set. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code object->data.seek_table.num_points > point_num \endcode + */ +FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); + +/** Insert a seekpoint into a seektable. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param point_num Index into seekpoint array to set. + * \param point The point to set. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code object->data.seek_table.num_points >= point_num \endcode + * \retval FLAC__bool + * \c false if memory allocation error, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); + +/** Delete a seekpoint from a seektable. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param point_num Index into seekpoint array to set. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code object->data.seek_table.num_points > point_num \endcode + * \retval FLAC__bool + * \c false if memory allocation error, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num); + +/** Check a seektable to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * seektable. + * + * \param object A pointer to an existing SEEKTABLE object. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \retval FLAC__bool + * \c false if seek table is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object); + +/** Append a number of placeholder points to the end of a seek table. + * + * \note + * As with the other ..._seektable_template_... functions, you should + * call FLAC__metadata_object_seektable_template_sort() when finished + * to make the seek table legal. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param num The number of placeholder points to append. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num); + +/** Append a specific seek point template to the end of a seek table. + * + * \note + * As with the other ..._seektable_template_... functions, you should + * call FLAC__metadata_object_seektable_template_sort() when finished + * to make the seek table legal. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param sample_number The sample number of the seek point template. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number); + +/** Append specific seek point templates to the end of a seek table. + * + * \note + * As with the other ..._seektable_template_... functions, you should + * call FLAC__metadata_object_seektable_template_sort() when finished + * to make the seek table legal. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param sample_numbers An array of sample numbers for the seek points. + * \param num The number of seek point templates to append. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num); + +/** Append a set of evenly-spaced seek point templates to the end of a + * seek table. + * + * \note + * As with the other ..._seektable_template_... functions, you should + * call FLAC__metadata_object_seektable_template_sort() when finished + * to make the seek table legal. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param num The number of placeholder points to append. + * \param total_samples The total number of samples to be encoded; + * the seekpoints will be spaced approximately + * \a total_samples / \a num samples apart. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code total_samples > 0 \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples); + +/** Append a set of evenly-spaced seek point templates to the end of a + * seek table. + * + * \note + * As with the other ..._seektable_template_... functions, you should + * call FLAC__metadata_object_seektable_template_sort() when finished + * to make the seek table legal. + * + * \param object A pointer to an existing SEEKTABLE object. + * \param samples The number of samples apart to space the placeholder + * points. The first point will be at sample \c 0, the + * second at sample \a samples, then 2*\a samples, and + * so on. As long as \a samples and \a total_samples + * are greater than \c 0, there will always be at least + * one seekpoint at sample \c 0. + * \param total_samples The total number of samples to be encoded; + * the seekpoints will be spaced + * \a samples samples apart. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \code samples > 0 \endcode + * \code total_samples > 0 \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples); + +/** Sort a seek table's seek points according to the format specification, + * removing duplicates. + * + * \param object A pointer to a seek table to be sorted. + * \param compact If \c false, behaves like FLAC__format_seektable_sort(). + * If \c true, duplicates are deleted and the seek table is + * shrunk appropriately; the number of placeholder points + * present in the seek table will be the same after the call + * as before. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact); + +/** Sets the vendor string in a VORBIS_COMMENT block. + * + * For convenience, a trailing NUL is added to the entry if it doesn't have + * one already. + * + * If \a copy is \c true, a copy of the entry is stored; otherwise, the object + * takes ownership of the \c entry.entry pointer. + * + * \note If this function returns \c false, the caller still owns the + * pointer. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param entry The entry to set the vendor string to. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code (entry.entry != NULL && entry.length > 0) || + * (entry.entry == NULL && entry.length == 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); + +/** Resize the comment array. + * + * If the size shrinks, elements will truncated; if it grows, new empty + * fields will be added to the end. If this function returns false, the + * object is left untouched. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param new_num_comments The desired length of the array; may be \c 0. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) || + * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments); + +/** Sets a comment in a VORBIS_COMMENT block. + * + * For convenience, a trailing NUL is added to the entry if it doesn't have + * one already. + * + * If \a copy is \c true, a copy of the entry is stored; otherwise, the object + * takes ownership of the \c entry.entry pointer. + * + * \note If this function returns \c false, the caller still owns the + * pointer. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param comment_num Index into comment array to set. + * \param entry The entry to set the comment to. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code comment_num < object->data.vorbis_comment.num_comments \endcode + * \code (entry.entry != NULL && entry.length > 0) || + * (entry.entry == NULL && entry.length == 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); + +/** Insert a comment in a VORBIS_COMMENT block at the given index. + * + * For convenience, a trailing NUL is added to the entry if it doesn't have + * one already. + * + * If \a copy is \c true, a copy of the entry is stored; otherwise, the object + * takes ownership of the \c entry.entry pointer. + * + * \note If this function returns \c false, the caller still owns the + * pointer. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param comment_num The index at which to insert the comment. The comments + * at and after \a comment_num move right one position. + * To append a comment to the end, set \a comment_num to + * \c object->data.vorbis_comment.num_comments . + * \param entry The comment to insert. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code object->data.vorbis_comment.num_comments >= comment_num \endcode + * \code (entry.entry != NULL && entry.length > 0) || + * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); + +/** Appends a comment to a VORBIS_COMMENT block. + * + * For convenience, a trailing NUL is added to the entry if it doesn't have + * one already. + * + * If \a copy is \c true, a copy of the entry is stored; otherwise, the object + * takes ownership of the \c entry.entry pointer. + * + * \note If this function returns \c false, the caller still owns the + * pointer. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param entry The comment to insert. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code (entry.entry != NULL && entry.length > 0) || + * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); + +/** Replaces comments in a VORBIS_COMMENT block with a new one. + * + * For convenience, a trailing NUL is added to the entry if it doesn't have + * one already. + * + * Depending on the value of \a all, either all or just the first comment + * whose field name(s) match the given entry's name will be replaced by the + * given entry. If no comments match, \a entry will simply be appended. + * + * If \a copy is \c true, a copy of the entry is stored; otherwise, the object + * takes ownership of the \c entry.entry pointer. + * + * \note If this function returns \c false, the caller still owns the + * pointer. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param entry The comment to insert. + * \param all If \c true, all comments whose field name matches + * \a entry's field name will be removed, and \a entry will + * be inserted at the position of the first matching + * comment. If \c false, only the first comment whose + * field name matches \a entry's field name will be + * replaced with \a entry. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code (entry.entry != NULL && entry.length > 0) || + * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy); + +/** Delete a comment in a VORBIS_COMMENT block at the given index. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param comment_num The index of the comment to delete. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code object->data.vorbis_comment.num_comments > comment_num \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num); + +/** Creates a Vorbis comment entry from NUL-terminated name and value strings. + * + * On return, the filled-in \a entry->entry pointer will point to malloc()ed + * memory and shall be owned by the caller. For convenience the entry will + * have a terminating NUL. + * + * \param entry A pointer to a Vorbis comment entry. The entry's + * \c entry pointer should not point to allocated + * memory as it will be overwritten. + * \param field_name The field name in ASCII, \c NUL terminated. + * \param field_value The field value in UTF-8, \c NUL terminated. + * \assert + * \code entry != NULL \endcode + * \code field_name != NULL \endcode + * \code field_value != NULL \endcode + * \retval FLAC__bool + * \c false if malloc() fails, or if \a field_name or \a field_value does + * not comply with the Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value); + +/** Splits a Vorbis comment entry into NUL-terminated name and value strings. + * + * The returned pointers to name and value will be allocated by malloc() + * and shall be owned by the caller. + * + * \param entry An existing Vorbis comment entry. + * \param field_name The address of where the returned pointer to the + * field name will be stored. + * \param field_value The address of where the returned pointer to the + * field value will be stored. + * \assert + * \code (entry.entry != NULL && entry.length > 0) \endcode + * \code memchr(entry.entry, '=', entry.length) != NULL \endcode + * \code field_name != NULL \endcode + * \code field_value != NULL \endcode + * \retval FLAC__bool + * \c false if memory allocation fails or \a entry does not comply with the + * Vorbis comment specification, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value); + +/** Check if the given Vorbis comment entry's field name matches the given + * field name. + * + * \param entry An existing Vorbis comment entry. + * \param field_name The field name to check. + * \param field_name_length The length of \a field_name, not including the + * terminating \c NUL. + * \assert + * \code (entry.entry != NULL && entry.length > 0) \endcode + * \retval FLAC__bool + * \c true if the field names match, else \c false + */ +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length); + +/** Find a Vorbis comment with the given field name. + * + * The search begins at entry number \a offset; use an offset of 0 to + * search from the beginning of the comment array. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param offset The offset into the comment array from where to start + * the search. + * \param field_name The field name of the comment to find. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \code field_name != NULL \endcode + * \retval int + * The offset in the comment array of the first comment whose field + * name matches \a field_name, or \c -1 if no match was found. + */ +FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name); + +/** Remove first Vorbis comment matching the given field name. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param field_name The field name of comment to delete. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \retval int + * \c -1 for memory allocation error, \c 0 for no matching entries, + * \c 1 for one matching entry deleted. + */ +FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name); + +/** Remove all Vorbis comments matching the given field name. + * + * \param object A pointer to an existing VORBIS_COMMENT object. + * \param field_name The field name of comments to delete. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode + * \retval int + * \c -1 for memory allocation error, \c 0 for no matching entries, + * else the number of matching entries deleted. + */ +FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name); + +/** Create a new CUESHEET track instance. + * + * The object will be "empty"; i.e. values and data pointers will be \c 0. + * + * \retval FLAC__StreamMetadata_CueSheet_Track* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void); + +/** Create a copy of an existing CUESHEET track object. + * + * The copy is a "deep" copy, i.e. dynamically allocated data within the + * object is also copied. The caller takes ownership of the new object and + * is responsible for freeing it with + * FLAC__metadata_object_cuesheet_track_delete(). + * + * \param object Pointer to object to copy. + * \assert + * \code object != NULL \endcode + * \retval FLAC__StreamMetadata_CueSheet_Track* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object); + +/** Delete a CUESHEET track object + * + * \param object A pointer to an existing CUESHEET track object. + * \assert + * \code object != NULL \endcode + */ +FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object); + +/** Resize a track's index point array. + * + * If the size shrinks, elements will truncated; if it grows, new blank + * indices will be added to the end. If this function returns false, the + * track object is left untouched. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index of the track to modify. NOTE: this is not + * necessarily the same as the track's \a number field. + * \param new_num_indices The desired length of the array; may be \c 0. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks > track_num \endcode + * \code (object->data.cue_sheet.tracks[track_num].indices == NULL && object->data.cue_sheet.tracks[track_num].num_indices == 0) || + * (object->data.cue_sheet.tracks[track_num].indices != NULL && object->data.cue_sheet.tracks[track_num].num_indices > 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation error, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices); + +/** Insert an index point in a CUESHEET track at the given index. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index of the track to modify. NOTE: this is not + * necessarily the same as the track's \a number field. + * \param index_num The index into the track's index array at which to + * insert the index point. NOTE: this is not necessarily + * the same as the index point's \a number field. The + * indices at and after \a index_num move right one + * position. To append an index point to the end, set + * \a index_num to + * \c object->data.cue_sheet.tracks[track_num].num_indices . + * \param index The index point to insert. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks > track_num \endcode + * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index index); + +/** Insert a blank index point in a CUESHEET track at the given index. + * + * A blank index point is one in which all field values are zero. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index of the track to modify. NOTE: this is not + * necessarily the same as the track's \a number field. + * \param index_num The index into the track's index array at which to + * insert the index point. NOTE: this is not necessarily + * the same as the index point's \a number field. The + * indices at and after \a index_num move right one + * position. To append an index point to the end, set + * \a index_num to + * \c object->data.cue_sheet.tracks[track_num].num_indices . + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks > track_num \endcode + * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); + +/** Delete an index point in a CUESHEET track at the given index. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index into the track array of the track to + * modify. NOTE: this is not necessarily the same + * as the track's \a number field. + * \param index_num The index into the track's index array of the index + * to delete. NOTE: this is not necessarily the same + * as the index's \a number field. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks > track_num \endcode + * \code object->data.cue_sheet.tracks[track_num].num_indices > index_num \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); + +/** Resize the track array. + * + * If the size shrinks, elements will truncated; if it grows, new blank + * tracks will be added to the end. If this function returns false, the + * object is left untouched. + * + * \param object A pointer to an existing CUESHEET object. + * \param new_num_tracks The desired length of the array; may be \c 0. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code (object->data.cue_sheet.tracks == NULL && object->data.cue_sheet.num_tracks == 0) || + * (object->data.cue_sheet.tracks != NULL && object->data.cue_sheet.num_tracks > 0) \endcode + * \retval FLAC__bool + * \c false if memory allocation error, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks); + +/** Sets a track in a CUESHEET block. + * + * If \a copy is \c true, a copy of the track is stored; otherwise, the object + * takes ownership of the \a track pointer. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num Index into track array to set. NOTE: this is not + * necessarily the same as the track's \a number field. + * \param track The track to set the track to. You may safely pass in + * a const pointer if \a copy is \c true. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code track_num < object->data.cue_sheet.num_tracks \endcode + * \code (track->indices != NULL && track->num_indices > 0) || + * (track->indices == NULL && track->num_indices == 0) \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); + +/** Insert a track in a CUESHEET block at the given index. + * + * If \a copy is \c true, a copy of the track is stored; otherwise, the object + * takes ownership of the \a track pointer. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index at which to insert the track. NOTE: this + * is not necessarily the same as the track's \a number + * field. The tracks at and after \a track_num move right + * one position. To append a track to the end, set + * \a track_num to \c object->data.cue_sheet.num_tracks . + * \param track The track to insert. You may safely pass in a const + * pointer if \a copy is \c true. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks >= track_num \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); + +/** Insert a blank track in a CUESHEET block at the given index. + * + * A blank track is one in which all field values are zero. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index at which to insert the track. NOTE: this + * is not necessarily the same as the track's \a number + * field. The tracks at and after \a track_num move right + * one position. To append a track to the end, set + * \a track_num to \c object->data.cue_sheet.num_tracks . + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks >= track_num \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num); + +/** Delete a track in a CUESHEET block at the given index. + * + * \param object A pointer to an existing CUESHEET object. + * \param track_num The index into the track array of the track to + * delete. NOTE: this is not necessarily the same + * as the track's \a number field. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \code object->data.cue_sheet.num_tracks > track_num \endcode + * \retval FLAC__bool + * \c false if realloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num); + +/** Check a cue sheet to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * cue sheet. + * + * \param object A pointer to an existing CUESHEET object. + * \param check_cd_da_subset If \c true, check CUESHEET against more + * stringent requirements for a CD-DA (audio) disc. + * \param violation Address of a pointer to a string. If there is a + * violation, a pointer to a string explanation of the + * violation will be returned here. \a violation may be + * \c NULL if you don't need the returned string. Do not + * free the returned string; it will always point to static + * data. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \retval FLAC__bool + * \c false if cue sheet is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation); + +/** Calculate and return the CDDB/freedb ID for a cue sheet. The function + * assumes the cue sheet corresponds to a CD; the result is undefined + * if the cuesheet's is_cd bit is not set. + * + * \param object A pointer to an existing CUESHEET object. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode + * \retval FLAC__uint32 + * The unsigned integer representation of the CDDB/freedb ID + */ +FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object); + +/** Sets the MIME type of a PICTURE block. + * + * If \a copy is \c true, a copy of the string is stored; otherwise, the object + * takes ownership of the pointer. The existing string will be freed if this + * function is successful, otherwise the original string will remain if \a copy + * is \c true and malloc() fails. + * + * \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true. + * + * \param object A pointer to an existing PICTURE object. + * \param mime_type A pointer to the MIME type string. The string must be + * ASCII characters 0x20-0x7e, NUL-terminated. No validation + * is done. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode + * \code (mime_type != NULL) \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy); + +/** Sets the description of a PICTURE block. + * + * If \a copy is \c true, a copy of the string is stored; otherwise, the object + * takes ownership of the pointer. The existing string will be freed if this + * function is successful, otherwise the original string will remain if \a copy + * is \c true and malloc() fails. + * + * \note It is safe to pass a const pointer to \a description if \a copy is \c true. + * + * \param object A pointer to an existing PICTURE object. + * \param description A pointer to the description string. The string must be + * valid UTF-8, NUL-terminated. No validation is done. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode + * \code (description != NULL) \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy); + +/** Sets the picture data of a PICTURE block. + * + * If \a copy is \c true, a copy of the data is stored; otherwise, the object + * takes ownership of the pointer. Also sets the \a data_length field of the + * metadata object to what is passed in as the \a length parameter. The + * existing data will be freed if this function is successful, otherwise the + * original data and data_length will remain if \a copy is \c true and + * malloc() fails. + * + * \note It is safe to pass a const pointer to \a data if \a copy is \c true. + * + * \param object A pointer to an existing PICTURE object. + * \param data A pointer to the data to set. + * \param length The length of \a data in bytes. + * \param copy See above. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode + * \code (data != NULL && length > 0) || + * (data == NULL && length == 0 && copy == false) \endcode + * \retval FLAC__bool + * \c false if \a copy is \c true and malloc() fails, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy); + +/** Check a PICTURE block to see if it conforms to the FLAC specification. + * See the format specification for limits on the contents of the + * PICTURE block. + * + * \param object A pointer to existing PICTURE block to be checked. + * \param violation Address of a pointer to a string. If there is a + * violation, a pointer to a string explanation of the + * violation will be returned here. \a violation may be + * \c NULL if you don't need the returned string. Do not + * free the returned string; it will always point to static + * data. + * \assert + * \code object != NULL \endcode + * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode + * \retval FLAC__bool + * \c false if PICTURE block is illegal, else \c true. + */ +FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation); + + +/** Get the raw (binary) representation of a FLAC__StreamMetadata objeect. + * After use, free() the returned buffer. The length of the buffer is + * the length of the input metadata object plus 4 bytes for the header. + * + * \param object A pointer to metadata block to be converted. + * \assert + * \code object != NULL \endcode + * \retval FLAC__byte* + * \c NULL if there was an error, else a pointer to a buffer holding + * the requested data. + */ +FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object); + + +/** Turn a raw (binary) representation into a FLAC__StreamMetadata objeect. + * The returned object must be deleted with FLAC__metadata_object_delete() + * after use. + * + * \param buffer A pointer to a buffer containing a binary representation + * to be converted to a FLAC__StreamMetadata object + * \param length The length of the supplied buffer + * \retval FLAC__StreamMetadata* + * \c NULL if there was an error, else a pointer to a FLAC__StreamMetadata + * holding the requested data. + */ + +FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length); +/* \} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/FLAC/ordinals.h b/packages/third-party/libFLAC/FLAC/ordinals.h new file mode 100644 index 00000000..d9e442dc --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/ordinals.h @@ -0,0 +1,55 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__ORDINALS_H +#define FLAC__ORDINALS_H + +/* This of course assumes C99 headers */ + +#include +#include + +typedef int8_t FLAC__int8; +typedef uint8_t FLAC__uint8; + +typedef int16_t FLAC__int16; +typedef int32_t FLAC__int32; +typedef int64_t FLAC__int64; +typedef uint16_t FLAC__uint16; +typedef uint32_t FLAC__uint32; +typedef uint64_t FLAC__uint64; + +typedef int FLAC__bool; + +typedef FLAC__uint8 FLAC__byte; + +#endif diff --git a/packages/third-party/libFLAC/FLAC/stream_decoder.h b/packages/third-party/libFLAC/FLAC/stream_decoder.h new file mode 100644 index 00000000..d09575f8 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/stream_decoder.h @@ -0,0 +1,1584 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__STREAM_DECODER_H +#define FLAC__STREAM_DECODER_H + +#include /* for FILE */ +#include "export.h" +#include "format.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** \file include/FLAC/stream_decoder.h + * + * \brief + * This module contains the functions which implement the stream + * decoder. + * + * See the detailed documentation in the + * \link flac_stream_decoder stream decoder \endlink module. + */ + +/** \defgroup flac_decoder FLAC/ \*_decoder.h: decoder interfaces + * \ingroup flac + * + * \brief + * This module describes the decoder layers provided by libFLAC. + * + * The stream decoder can be used to decode complete streams either from + * the client via callbacks, or directly from a file, depending on how + * it is initialized. When decoding via callbacks, the client provides + * callbacks for reading FLAC data and writing decoded samples, and + * handling metadata and errors. If the client also supplies seek-related + * callback, the decoder function for sample-accurate seeking within the + * FLAC input is also available. When decoding from a file, the client + * needs only supply a filename or open \c FILE* and write/metadata/error + * callbacks; the rest of the callbacks are supplied internally. For more + * info see the \link flac_stream_decoder stream decoder \endlink module. + */ + +/** \defgroup flac_stream_decoder FLAC/stream_decoder.h: stream decoder interface + * \ingroup flac_decoder + * + * \brief + * This module contains the functions which implement the stream + * decoder. + * + * The stream decoder can decode native FLAC, and optionally Ogg FLAC + * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. + * + * The basic usage of this decoder is as follows: + * - The program creates an instance of a decoder using + * FLAC__stream_decoder_new(). + * - The program overrides the default settings using + * FLAC__stream_decoder_set_*() functions. + * - The program initializes the instance to validate the settings and + * prepare for decoding using + * - FLAC__stream_decoder_init_stream() or FLAC__stream_decoder_init_FILE() + * or FLAC__stream_decoder_init_file() for native FLAC, + * - FLAC__stream_decoder_init_ogg_stream() or FLAC__stream_decoder_init_ogg_FILE() + * or FLAC__stream_decoder_init_ogg_file() for Ogg FLAC + * - The program calls the FLAC__stream_decoder_process_*() functions + * to decode data, which subsequently calls the callbacks. + * - The program finishes the decoding with FLAC__stream_decoder_finish(), + * which flushes the input and output and resets the decoder to the + * uninitialized state. + * - The instance may be used again or deleted with + * FLAC__stream_decoder_delete(). + * + * In more detail, the program will create a new instance by calling + * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*() + * functions to override the default decoder options, and call + * one of the FLAC__stream_decoder_init_*() functions. + * + * There are three initialization functions for native FLAC, one for + * setting up the decoder to decode FLAC data from the client via + * callbacks, and two for decoding directly from a FLAC file. + * + * For decoding via callbacks, use FLAC__stream_decoder_init_stream(). + * You must also supply several callbacks for handling I/O. Some (like + * seeking) are optional, depending on the capabilities of the input. + * + * For decoding directly from a file, use FLAC__stream_decoder_init_FILE() + * or FLAC__stream_decoder_init_file(). Then you must only supply an open + * \c FILE* or filename and fewer callbacks; the decoder will handle + * the other callbacks internally. + * + * There are three similarly-named init functions for decoding from Ogg + * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the + * library has been built with Ogg support. + * + * Once the decoder is initialized, your program will call one of several + * functions to start the decoding process: + * + * - FLAC__stream_decoder_process_single() - Tells the decoder to process at + * most one metadata block or audio frame and return, calling either the + * metadata callback or write callback, respectively, once. If the decoder + * loses sync it will return with only the error callback being called. + * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder + * to process the stream from the current location and stop upon reaching + * the first audio frame. The client will get one metadata, write, or error + * callback per metadata block, audio frame, or sync error, respectively. + * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder + * to process the stream from the current location until the read callback + * returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or + * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The client will get one metadata, + * write, or error callback per metadata block, audio frame, or sync error, + * respectively. + * + * When the decoder has finished decoding (normally or through an abort), + * the instance is finished by calling FLAC__stream_decoder_finish(), which + * ensures the decoder is in the correct state and frees memory. Then the + * instance may be deleted with FLAC__stream_decoder_delete() or initialized + * again to decode another stream. + * + * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method. + * At any point after the stream decoder has been initialized, the client can + * call this function to seek to an exact sample within the stream. + * Subsequently, the first time the write callback is called it will be + * passed a (possibly partial) block starting at that sample. + * + * If the client cannot seek via the callback interface provided, but still + * has another way of seeking, it can flush the decoder using + * FLAC__stream_decoder_flush() and start feeding data from the new position + * through the read callback. + * + * The stream decoder also provides MD5 signature checking. If this is + * turned on before initialization, FLAC__stream_decoder_finish() will + * report when the decoded MD5 signature does not match the one stored + * in the STREAMINFO block. MD5 checking is automatically turned off + * (until the next FLAC__stream_decoder_reset()) if there is no signature + * in the STREAMINFO block or when a seek is attempted. + * + * The FLAC__stream_decoder_set_metadata_*() functions deserve special + * attention. By default, the decoder only calls the metadata_callback for + * the STREAMINFO block. These functions allow you to tell the decoder + * explicitly which blocks to parse and return via the metadata_callback + * and/or which to skip. Use a FLAC__stream_decoder_set_metadata_respond_all(), + * FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(), + * FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify + * which blocks to return. Remember that metadata blocks can potentially + * be big (for example, cover art) so filtering out the ones you don't + * use can reduce the memory requirements of the decoder. Also note the + * special forms FLAC__stream_decoder_set_metadata_respond_application(id) + * and FLAC__stream_decoder_set_metadata_ignore_application(id) for + * filtering APPLICATION blocks based on the application ID. + * + * STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but + * they still can legally be filtered from the metadata_callback. + * + * \note + * The "set" functions may only be called when the decoder is in the + * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after + * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but + * before FLAC__stream_decoder_init_*(). If this is the case they will + * return \c true, otherwise \c false. + * + * \note + * FLAC__stream_decoder_finish() resets all settings to the constructor + * defaults, including the callbacks. + * + * \{ + */ + + +/** State values for a FLAC__StreamDecoder + * + * The decoder's state can be obtained by calling FLAC__stream_decoder_get_state(). + */ +typedef enum { + + FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0, + /**< The decoder is ready to search for metadata. */ + + FLAC__STREAM_DECODER_READ_METADATA, + /**< The decoder is ready to or is in the process of reading metadata. */ + + FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC, + /**< The decoder is ready to or is in the process of searching for the + * frame sync code. + */ + + FLAC__STREAM_DECODER_READ_FRAME, + /**< The decoder is ready to or is in the process of reading a frame. */ + + FLAC__STREAM_DECODER_END_OF_STREAM, + /**< The decoder has reached the end of the stream. */ + + FLAC__STREAM_DECODER_OGG_ERROR, + /**< An error occurred in the underlying Ogg layer. */ + + FLAC__STREAM_DECODER_SEEK_ERROR, + /**< An error occurred while seeking. The decoder must be flushed + * with FLAC__stream_decoder_flush() or reset with + * FLAC__stream_decoder_reset() before decoding can continue. + */ + + FLAC__STREAM_DECODER_ABORTED, + /**< The decoder was aborted by the read or write callback. */ + + FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR, + /**< An error occurred allocating memory. The decoder is in an invalid + * state and can no longer be used. + */ + + FLAC__STREAM_DECODER_UNINITIALIZED + /**< The decoder is in the uninitialized state; one of the + * FLAC__stream_decoder_init_*() functions must be called before samples + * can be processed. + */ + +} FLAC__StreamDecoderState; + +/** Maps a FLAC__StreamDecoderState to a C string. + * + * Using a FLAC__StreamDecoderState as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderStateString[]; + + +/** Possible return values for the FLAC__stream_decoder_init_*() functions. + */ +typedef enum { + + FLAC__STREAM_DECODER_INIT_STATUS_OK = 0, + /**< Initialization was successful. */ + + FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER, + /**< The library was not compiled with support for the given container + * format. + */ + + FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS, + /**< A required callback was not supplied. */ + + FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR, + /**< An error occurred allocating memory. */ + + FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE, + /**< fopen() failed in FLAC__stream_decoder_init_file() or + * FLAC__stream_decoder_init_ogg_file(). */ + + FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED + /**< FLAC__stream_decoder_init_*() was called when the decoder was + * already initialized, usually because + * FLAC__stream_decoder_finish() was not called. + */ + +} FLAC__StreamDecoderInitStatus; + +/** Maps a FLAC__StreamDecoderInitStatus to a C string. + * + * Using a FLAC__StreamDecoderInitStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[]; + + +/** Return values for the FLAC__StreamDecoder read callback. + */ +typedef enum { + + FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, + /**< The read was OK and decoding can continue. */ + + FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM, + /**< The read was attempted while at the end of the stream. Note that + * the client must only return this value when the read callback was + * called when already at the end of the stream. Otherwise, if the read + * itself moves to the end of the stream, the client should still return + * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on + * the next read callback it should return + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count + * of \c 0. + */ + + FLAC__STREAM_DECODER_READ_STATUS_ABORT + /**< An unrecoverable error occurred. The decoder will return from the process call. */ + +} FLAC__StreamDecoderReadStatus; + +/** Maps a FLAC__StreamDecoderReadStatus to a C string. + * + * Using a FLAC__StreamDecoderReadStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[]; + + +/** Return values for the FLAC__StreamDecoder seek callback. + */ +typedef enum { + + FLAC__STREAM_DECODER_SEEK_STATUS_OK, + /**< The seek was OK and decoding can continue. */ + + FLAC__STREAM_DECODER_SEEK_STATUS_ERROR, + /**< An unrecoverable error occurred. The decoder will return from the process call. */ + + FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED + /**< Client does not support seeking. */ + +} FLAC__StreamDecoderSeekStatus; + +/** Maps a FLAC__StreamDecoderSeekStatus to a C string. + * + * Using a FLAC__StreamDecoderSeekStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[]; + + +/** Return values for the FLAC__StreamDecoder tell callback. + */ +typedef enum { + + FLAC__STREAM_DECODER_TELL_STATUS_OK, + /**< The tell was OK and decoding can continue. */ + + FLAC__STREAM_DECODER_TELL_STATUS_ERROR, + /**< An unrecoverable error occurred. The decoder will return from the process call. */ + + FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED + /**< Client does not support telling the position. */ + +} FLAC__StreamDecoderTellStatus; + +/** Maps a FLAC__StreamDecoderTellStatus to a C string. + * + * Using a FLAC__StreamDecoderTellStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[]; + + +/** Return values for the FLAC__StreamDecoder length callback. + */ +typedef enum { + + FLAC__STREAM_DECODER_LENGTH_STATUS_OK, + /**< The length call was OK and decoding can continue. */ + + FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR, + /**< An unrecoverable error occurred. The decoder will return from the process call. */ + + FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED + /**< Client does not support reporting the length. */ + +} FLAC__StreamDecoderLengthStatus; + +/** Maps a FLAC__StreamDecoderLengthStatus to a C string. + * + * Using a FLAC__StreamDecoderLengthStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[]; + + +/** Return values for the FLAC__StreamDecoder write callback. + */ +typedef enum { + + FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE, + /**< The write was OK and decoding can continue. */ + + FLAC__STREAM_DECODER_WRITE_STATUS_ABORT + /**< An unrecoverable error occurred. The decoder will return from the process call. */ + +} FLAC__StreamDecoderWriteStatus; + +/** Maps a FLAC__StreamDecoderWriteStatus to a C string. + * + * Using a FLAC__StreamDecoderWriteStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[]; + + +/** Possible values passed back to the FLAC__StreamDecoder error callback. + * \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch- + * all. The rest could be caused by bad sync (false synchronization on + * data that is not the start of a frame) or corrupted data. The error + * itself is the decoder's best guess at what happened assuming a correct + * sync. For example \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER + * could be caused by a correct sync on the start of a frame, but some + * data in the frame header was corrupted. Or it could be the result of + * syncing on a point the stream that looked like the starting of a frame + * but was not. \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM + * could be because the decoder encountered a valid frame made by a future + * version of the encoder which it cannot parse, or because of a false + * sync making it appear as though an encountered frame was generated by + * a future encoder. \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA is + * caused by finding data that doesn't fit a metadata block (too large + * or too small) or finding inconsistencies in the metadata, for example + * a PICTURE block with an image that exceeds the size of the metadata + * block. + */ +typedef enum { + + FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC, + /**< An error in the stream caused the decoder to lose synchronization. */ + + FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER, + /**< The decoder encountered a corrupted frame header. */ + + FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH, + /**< The frame's data did not match the CRC in the footer. */ + + FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM, + /**< The decoder encountered reserved fields in use in the stream. */ + + FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA + /**< The decoder encountered a corrupted metadata block. */ + +} FLAC__StreamDecoderErrorStatus; + +/** Maps a FLAC__StreamDecoderErrorStatus to a C string. + * + * Using a FLAC__StreamDecoderErrorStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[]; + + +/*********************************************************************** + * + * class FLAC__StreamDecoder + * + ***********************************************************************/ + +struct FLAC__StreamDecoderProtected; +struct FLAC__StreamDecoderPrivate; +/** The opaque structure definition for the stream decoder type. + * See the \link flac_stream_decoder stream decoder module \endlink + * for a detailed description. + */ +typedef struct { + struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */ + struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */ +} FLAC__StreamDecoder; + +/** Signature for the read callback. + * + * A function pointer matching this signature must be passed to + * FLAC__stream_decoder_init*_stream(). The supplied function will be + * called when the decoder needs more input data. The address of the + * buffer to be filled is supplied, along with the number of bytes the + * buffer can hold. The callback may choose to supply less data and + * modify the byte count but must be careful not to overflow the buffer. + * The callback then returns a status code chosen from + * FLAC__StreamDecoderReadStatus. + * + * Here is an example of a read callback for stdio streams: + * \code + * FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * if(*bytes > 0) { + * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file); + * if(ferror(file)) + * return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + * else if(*bytes == 0) + * return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + * else + * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + * } + * else + * return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + * } + * \endcode + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param buffer A pointer to a location for the callee to store + * data to be decoded. + * \param bytes A pointer to the size of the buffer. On entry + * to the callback, it contains the maximum number + * of bytes that may be stored in \a buffer. The + * callee must set it to the actual number of bytes + * stored (0 in case of error or end-of-stream) before + * returning. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__StreamDecoderReadStatus + * The callee's return status. Note that the callback should return + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if + * zero bytes were read and there is no more data to be read. + */ +typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); + +/** Signature for the seek callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_decoder_init*_stream(). The supplied function will be + * called when the decoder needs to seek the input stream. The decoder + * will pass the absolute byte offset to seek to, 0 meaning the + * beginning of the stream. + * + * Here is an example of a seek callback for stdio streams: + * \code + * FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * if(file == stdin) + * return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; + * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0) + * return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; + * else + * return FLAC__STREAM_DECODER_SEEK_STATUS_OK; + * } + * \endcode + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param absolute_byte_offset The offset from the beginning of the stream + * to seek to. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__StreamDecoderSeekStatus + * The callee's return status. + */ +typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); + +/** Signature for the tell callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_decoder_init*_stream(). The supplied function will be + * called when the decoder wants to know the current position of the + * stream. The callback should return the byte offset from the + * beginning of the stream. + * + * Here is an example of a tell callback for stdio streams: + * \code + * FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * off_t pos; + * if(file == stdin) + * return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; + * else if((pos = ftello(file)) < 0) + * return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + * else { + * *absolute_byte_offset = (FLAC__uint64)pos; + * return FLAC__STREAM_DECODER_TELL_STATUS_OK; + * } + * } + * \endcode + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param absolute_byte_offset A pointer to storage for the current offset + * from the beginning of the stream. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__StreamDecoderTellStatus + * The callee's return status. + */ +typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); + +/** Signature for the length callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_decoder_init*_stream(). The supplied function will be + * called when the decoder wants to know the total length of the stream + * in bytes. + * + * Here is an example of a length callback for stdio streams: + * \code + * FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * struct stat filestats; + * + * if(file == stdin) + * return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; + * else if(fstat(fileno(file), &filestats) != 0) + * return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; + * else { + * *stream_length = (FLAC__uint64)filestats.st_size; + * return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; + * } + * } + * \endcode + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param stream_length A pointer to storage for the length of the stream + * in bytes. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__StreamDecoderLengthStatus + * The callee's return status. + */ +typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); + +/** Signature for the EOF callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_decoder_init*_stream(). The supplied function will be + * called when the decoder needs to know if the end of the stream has + * been reached. + * + * Here is an example of a EOF callback for stdio streams: + * FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data) + * \code + * { + * FILE *file = ((MyClientData*)client_data)->file; + * return feof(file)? true : false; + * } + * \endcode + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__bool + * \c true if the currently at the end of the stream, else \c false. + */ +typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data); + +/** Signature for the write callback. + * + * A function pointer matching this signature must be passed to one of + * the FLAC__stream_decoder_init_*() functions. + * The supplied function will be called when the decoder has decoded a + * single audio frame. The decoder will pass the frame metadata as well + * as an array of pointers (one for each channel) pointing to the + * decoded audio. + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param frame The description of the decoded frame. See + * FLAC__Frame. + * \param buffer An array of pointers to decoded channels of data. + * Each pointer will point to an array of signed + * samples of length \a frame->header.blocksize. + * Channels will be ordered according to the FLAC + * specification; see the documentation for the + * frame header. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + * \retval FLAC__StreamDecoderWriteStatus + * The callee's return status. + */ +typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); + +/** Signature for the metadata callback. + * + * A function pointer matching this signature must be passed to one of + * the FLAC__stream_decoder_init_*() functions. + * The supplied function will be called when the decoder has decoded a + * metadata block. In a valid FLAC file there will always be one + * \c STREAMINFO block, followed by zero or more other metadata blocks. + * These will be supplied by the decoder in the same order as they + * appear in the stream and always before the first audio frame (i.e. + * write callback). The metadata block that is passed in must not be + * modified, and it doesn't live beyond the callback, so you should make + * a copy of it with FLAC__metadata_object_clone() if you will need it + * elsewhere. Since metadata blocks can potentially be large, by + * default the decoder only calls the metadata callback for the + * \c STREAMINFO block; you can instruct the decoder to pass or filter + * other blocks with FLAC__stream_decoder_set_metadata_*() calls. + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param metadata The decoded metadata block. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + */ +typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); + +/** Signature for the error callback. + * + * A function pointer matching this signature must be passed to one of + * the FLAC__stream_decoder_init_*() functions. + * The supplied function will be called whenever an error occurs during + * decoding. + * + * \note In general, FLAC__StreamDecoder functions which change the + * state should not be called on the \a decoder while in the callback. + * + * \param decoder The decoder instance calling the callback. + * \param status The error encountered by the decoder. + * \param client_data The callee's client data set through + * FLAC__stream_decoder_init_*(). + */ +typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); + + +/*********************************************************************** + * + * Class constructor/destructor + * + ***********************************************************************/ + +/** Create a new stream decoder instance. The instance is created with + * default settings; see the individual FLAC__stream_decoder_set_*() + * functions for each setting's default. + * + * \retval FLAC__StreamDecoder* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void); + +/** Free a decoder instance. Deletes the object pointed to by \a decoder. + * + * \param decoder A pointer to an existing decoder. + * \assert + * \code decoder != NULL \endcode + */ +FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder); + + +/*********************************************************************** + * + * Public class method prototypes + * + ***********************************************************************/ + +/** Set the serial number for the FLAC stream within the Ogg container. + * The default behavior is to use the serial number of the first Ogg + * page. Setting a serial number here will explicitly specify which + * stream is to be decoded. + * + * \note + * This does not need to be set for native FLAC decoding. + * + * \default \c use serial number of first page + * \param decoder A decoder instance to set. + * \param serial_number See above. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number); + +/** Set the "MD5 signature checking" flag. If \c true, the decoder will + * compute the MD5 signature of the unencoded audio data while decoding + * and compare it to the signature from the STREAMINFO block, if it + * exists, during FLAC__stream_decoder_finish(). + * + * MD5 signature checking will be turned off (until the next + * FLAC__stream_decoder_reset()) if there is no signature in the + * STREAMINFO block or when a seek is attempted. + * + * Clients that do not use the MD5 check should leave this off to speed + * up decoding. + * + * \default \c false + * \param decoder A decoder instance to set. + * \param value Flag value (see above). + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value); + +/** Direct the decoder to pass on all metadata blocks of type \a type. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \param type See above. + * \assert + * \code decoder != NULL \endcode + * \a type is valid + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); + +/** Direct the decoder to pass on all APPLICATION metadata blocks of the + * given \a id. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \param id See above. + * \assert + * \code decoder != NULL \endcode + * \code id != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); + +/** Direct the decoder to pass on all metadata blocks of any type. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder); + +/** Direct the decoder to filter out all metadata blocks of type \a type. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \param type See above. + * \assert + * \code decoder != NULL \endcode + * \a type is valid + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); + +/** Direct the decoder to filter out all APPLICATION metadata blocks of + * the given \a id. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \param id See above. + * \assert + * \code decoder != NULL \endcode + * \code id != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); + +/** Direct the decoder to filter out all metadata blocks of any type. + * + * \default By default, only the \c STREAMINFO block is returned via the + * metadata callback. + * \param decoder A decoder instance to set. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder); + +/** Get the current decoder state. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__StreamDecoderState + * The current decoder state. + */ +FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder); + +/** Get the current decoder state as a C string. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval const char * + * The decoder state as a C string. Do not modify the contents. + */ +FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder); + +/** Get the "MD5 signature checking" flag. + * This is the value of the setting, not whether or not the decoder is + * currently checking the MD5 (remember, it can be turned off automatically + * by a seek). When the decoder is reset the flag will be restored to the + * value returned by this function. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * See above. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder); + +/** Get the total number of samples in the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the \c STREAMINFO block. A value of \c 0 means "unknown". + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder); + +/** Get the current number of channels in the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the most recently decoded frame header. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder); + +/** Get the current channel assignment in the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the most recently decoded frame header. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__ChannelAssignment + * See above. + */ +FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder); + +/** Get the current sample resolution in the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the most recently decoded frame header. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder); + +/** Get the current sample rate in Hz of the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the most recently decoded frame header. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder); + +/** Get the current blocksize of the stream being decoded. + * Will only be valid after decoding has started and will contain the + * value from the most recently decoded frame header. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder); + +/** Returns the decoder's current read position within the stream. + * The position is the byte offset from the start of the stream. + * Bytes before this position have been fully decoded. Note that + * there may still be undecoded bytes in the decoder's read FIFO. + * The returned position is correct even after a seek. + * + * \warning This function currently only works for native FLAC, + * not Ogg FLAC streams. + * + * \param decoder A decoder instance to query. + * \param position Address at which to return the desired position. + * \assert + * \code decoder != NULL \endcode + * \code position != NULL \endcode + * \retval FLAC__bool + * \c true if successful, \c false if the stream is not native FLAC, + * or there was an error from the 'tell' callback or it returned + * \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position); + +/** Return client_data from decoder. + * The data pointed to by the pointer should not be modified. + * + * \param decoder A decoder instance. + * \retval const void * + * The callee's client data set through FLAC__stream_decoder_init_*(). + * Do not modify the contents. + */ +FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder); + +/** Initialize the decoder instance to decode native FLAC streams. + * + * This flavor of initialization sets up the decoder to decode from a + * native FLAC stream. I/O is performed via callbacks to the client. + * For decoding from a plain file via filename or open FILE*, + * FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE() + * provide a simpler interface. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \param decoder An uninitialized decoder instance. + * \param read_callback See FLAC__StreamDecoderReadCallback. This + * pointer must not be \c NULL. + * \param seek_callback See FLAC__StreamDecoderSeekCallback. This + * pointer may be \c NULL if seeking is not + * supported. If \a seek_callback is not \c NULL then a + * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied. + * Alternatively, a dummy seek callback that just + * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param tell_callback See FLAC__StreamDecoderTellCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy tell callback that just + * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param length_callback See FLAC__StreamDecoderLengthCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a length_callback must also be supplied. + * Alternatively, a dummy length callback that just + * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param eof_callback See FLAC__StreamDecoderEofCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a eof_callback must also be supplied. + * Alternatively, a dummy length callback that just + * returns \c false + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Initialize the decoder instance to decode Ogg FLAC streams. + * + * This flavor of initialization sets up the decoder to decode from a + * FLAC stream in an Ogg container. I/O is performed via callbacks to the + * client. For decoding from a plain file via filename or open FILE*, + * FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE() + * provide a simpler interface. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \note Support for Ogg FLAC in the library is optional. If this + * library has been built without support for Ogg FLAC, this function + * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. + * + * \param decoder An uninitialized decoder instance. + * \param read_callback See FLAC__StreamDecoderReadCallback. This + * pointer must not be \c NULL. + * \param seek_callback See FLAC__StreamDecoderSeekCallback. This + * pointer may be \c NULL if seeking is not + * supported. If \a seek_callback is not \c NULL then a + * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied. + * Alternatively, a dummy seek callback that just + * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param tell_callback See FLAC__StreamDecoderTellCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy tell callback that just + * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param length_callback See FLAC__StreamDecoderLengthCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a length_callback must also be supplied. + * Alternatively, a dummy length callback that just + * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param eof_callback See FLAC__StreamDecoderEofCallback. This + * pointer may be \c NULL if not supported by the client. If + * \a seek_callback is not \c NULL then a + * \a eof_callback must also be supplied. + * Alternatively, a dummy length callback that just + * returns \c false + * may also be supplied, all though this is slightly + * less efficient for the decoder. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Initialize the decoder instance to decode native FLAC files. + * + * This flavor of initialization sets up the decoder to decode from a + * plain native FLAC file. For non-stdio streams, you must use + * FLAC__stream_decoder_init_stream() and provide callbacks for the I/O. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \param decoder An uninitialized decoder instance. + * \param file An open FLAC file. The file should have been + * opened with mode \c "rb" and rewound. The file + * becomes owned by the decoder and should not be + * manipulated by the client while decoding. + * Unless \a file is \c stdin, it will be closed + * when FLAC__stream_decoder_finish() is called. + * Note however that seeking will not work when + * decoding from \c stdin since it is not seekable. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \code file != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE( + FLAC__StreamDecoder *decoder, + FILE *file, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Initialize the decoder instance to decode Ogg FLAC files. + * + * This flavor of initialization sets up the decoder to decode from a + * plain Ogg FLAC file. For non-stdio streams, you must use + * FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \note Support for Ogg FLAC in the library is optional. If this + * library has been built without support for Ogg FLAC, this function + * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. + * + * \param decoder An uninitialized decoder instance. + * \param file An open FLAC file. The file should have been + * opened with mode \c "rb" and rewound. The file + * becomes owned by the decoder and should not be + * manipulated by the client while decoding. + * Unless \a file is \c stdin, it will be closed + * when FLAC__stream_decoder_finish() is called. + * Note however that seeking will not work when + * decoding from \c stdin since it is not seekable. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \code file != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE( + FLAC__StreamDecoder *decoder, + FILE *file, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Initialize the decoder instance to decode native FLAC files. + * + * This flavor of initialization sets up the decoder to decode from a plain + * native FLAC file. If POSIX fopen() semantics are not sufficient, you must + * use FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream() + * and provide callbacks for the I/O. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \param decoder An uninitialized decoder instance. + * \param filename The name of the file to decode from. The file will + * be opened with fopen(). Use \c NULL to decode from + * \c stdin. Note that \c stdin is not seekable. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file( + FLAC__StreamDecoder *decoder, + const char *filename, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Initialize the decoder instance to decode Ogg FLAC files. + * + * This flavor of initialization sets up the decoder to decode from a plain + * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, you must use + * FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream() + * and provide callbacks for the I/O. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * This function should be called after FLAC__stream_decoder_new() and + * FLAC__stream_decoder_set_*() but before any of the + * FLAC__stream_decoder_process_*() functions. Will set and return the + * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA + * if initialization succeeded. + * + * \note Support for Ogg FLAC in the library is optional. If this + * library has been built without support for Ogg FLAC, this function + * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. + * + * \param decoder An uninitialized decoder instance. + * \param filename The name of the file to decode from. The file will + * be opened with fopen(). Use \c NULL to decode from + * \c stdin. Note that \c stdin is not seekable. + * \param write_callback See FLAC__StreamDecoderWriteCallback. This + * pointer must not be \c NULL. + * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param error_callback See FLAC__StreamDecoderErrorCallback. This + * pointer must not be \c NULL. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__StreamDecoderInitStatus + * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamDecoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( + FLAC__StreamDecoder *decoder, + const char *filename, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +); + +/** Finish the decoding process. + * Flushes the decoding buffer, releases resources, resets the decoder + * settings to their defaults, and returns the decoder state to + * FLAC__STREAM_DECODER_UNINITIALIZED. + * + * In the event of a prematurely-terminated decode, it is not strictly + * necessary to call this immediately before FLAC__stream_decoder_delete() + * but it is good practice to match every FLAC__stream_decoder_init_*() + * with a FLAC__stream_decoder_finish(). + * + * \param decoder An uninitialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if MD5 checking is on AND a STREAMINFO block was available + * AND the MD5 signature in the STREAMINFO block was non-zero AND the + * signature does not match the one computed by the decoder; else + * \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder); + +/** Flush the stream input. + * The decoder's input buffer will be cleared and the state set to + * \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC. This will also turn + * off MD5 checking. + * + * \param decoder A decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c true if successful, else \c false if a memory allocation + * error occurs (in which case the state will be set to + * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder); + +/** Reset the decoding process. + * The decoder's input buffer will be cleared and the state set to + * \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. This is similar to + * FLAC__stream_decoder_finish() except that the settings are + * preserved; there is no need to call FLAC__stream_decoder_init_*() + * before decoding again. MD5 checking will be restored to its original + * setting. + * + * If the decoder is seekable, or was initialized with + * FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(), + * the decoder will also attempt to seek to the beginning of the file. + * If this rewind fails, this function will return \c false. It follows + * that FLAC__stream_decoder_reset() cannot be used when decoding from + * \c stdin. + * + * If the decoder was initialized with FLAC__stream_encoder_init*_stream() + * and is not seekable (i.e. no seek callback was provided or the seek + * callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it + * is the duty of the client to start feeding data from the beginning of + * the stream on the next FLAC__stream_decoder_process_*() call. + * + * \param decoder A decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c true if successful, else \c false if a memory allocation occurs + * (in which case the state will be set to + * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR) or a seek error + * occurs (the state will be unchanged). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder); + +/** Decode one metadata block or audio frame. + * This version instructs the decoder to decode a either a single metadata + * block or a single frame and stop, unless the callbacks return a fatal + * error or the read callback returns + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. + * + * As the decoder needs more input it will call the read callback. + * Depending on what was decoded, the metadata or write callback will be + * called with the decoded metadata block or audio frame. + * + * Unless there is a fatal read error or end of stream, this function + * will return once one whole frame is decoded. In other words, if the + * stream is not synchronized or points to a corrupt frame header, the + * decoder will continue to try and resync until it gets to a valid + * frame, then decode one frame, then return. If the decoder points to + * a frame whose frame CRC in the frame footer does not match the + * computed frame CRC, this function will issue a + * FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH error to the + * error callback, and return, having decoded one complete, although + * corrupt, frame. (Such corrupted frames are sent as silence of the + * correct length to the write callback.) + * + * \param decoder An initialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder); + +/** Decode until the end of the metadata. + * This version instructs the decoder to decode from the current position + * and continue until all the metadata has been read, or until the + * callbacks return a fatal error or the read callback returns + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. + * + * As the decoder needs more input it will call the read callback. + * As each metadata block is decoded, the metadata callback will be called + * with the decoded metadata. + * + * \param decoder An initialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder); + +/** Decode until the end of the stream. + * This version instructs the decoder to decode from the current position + * and continue until the end of stream (the read callback returns + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the + * callbacks return a fatal error. + * + * As the decoder needs more input it will call the read callback. + * As each metadata block and frame is decoded, the metadata or write + * callback will be called with the decoded metadata or frame. + * + * \param decoder An initialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder); + +/** Skip one audio frame. + * This version instructs the decoder to 'skip' a single frame and stop, + * unless the callbacks return a fatal error or the read callback returns + * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. + * + * The decoding flow is the same as what occurs when + * FLAC__stream_decoder_process_single() is called to process an audio + * frame, except that this function does not decode the parsed data into + * PCM or call the write callback. The integrity of the frame is still + * checked the same way as in the other process functions. + * + * This function will return once one whole frame is skipped, in the + * same way that FLAC__stream_decoder_process_single() will return once + * one whole frame is decoded. + * + * This function can be used in more quickly determining FLAC frame + * boundaries when decoding of the actual data is not needed, for + * example when an application is separating a FLAC stream into frames + * for editing or storing in a container. To do this, the application + * can use FLAC__stream_decoder_skip_single_frame() to quickly advance + * to the next frame, then use + * FLAC__stream_decoder_get_decode_position() to find the new frame + * boundary. + * + * This function should only be called when the stream has advanced + * past all the metadata, otherwise it will return \c false. + * + * \param decoder An initialized decoder instance not in a metadata + * state. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), or if the decoder + * is in the FLAC__STREAM_DECODER_SEARCH_FOR_METADATA or + * FLAC__STREAM_DECODER_READ_METADATA state, else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder); + +/** Flush the input and seek to an absolute sample. + * Decoding will resume at the given sample. Note that because of + * this, the next write callback may contain a partial block. The + * client must support seeking the input or this function will fail + * and return \c false. Furthermore, if the decoder state is + * \c FLAC__STREAM_DECODER_SEEK_ERROR, then the decoder must be flushed + * with FLAC__stream_decoder_flush() or reset with + * FLAC__stream_decoder_reset() before decoding can continue. + * + * \param decoder A decoder instance. + * \param sample The target sample number to seek to. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c true if successful, else \c false. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample); + +/* \} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/FLAC/stream_encoder.h b/packages/third-party/libFLAC/FLAC/stream_encoder.h new file mode 100644 index 00000000..0c13b0a6 --- /dev/null +++ b/packages/third-party/libFLAC/FLAC/stream_encoder.h @@ -0,0 +1,1903 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__STREAM_ENCODER_H +#define FLAC__STREAM_ENCODER_H + +#include /* for FILE */ +#include "export.h" +#include "format.h" +#include "stream_decoder.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** \file include/FLAC/stream_encoder.h + * + * \brief + * This module contains the functions which implement the stream + * encoder. + * + * See the detailed documentation in the + * \link flac_stream_encoder stream encoder \endlink module. + */ + +/** \defgroup flac_encoder FLAC/ \*_encoder.h: encoder interfaces + * \ingroup flac + * + * \brief + * This module describes the encoder layers provided by libFLAC. + * + * The stream encoder can be used to encode complete streams either to the + * client via callbacks, or directly to a file, depending on how it is + * initialized. When encoding via callbacks, the client provides a write + * callback which will be called whenever FLAC data is ready to be written. + * If the client also supplies a seek callback, the encoder will also + * automatically handle the writing back of metadata discovered while + * encoding, like stream info, seek points offsets, etc. When encoding to + * a file, the client needs only supply a filename or open \c FILE* and an + * optional progress callback for periodic notification of progress; the + * write and seek callbacks are supplied internally. For more info see the + * \link flac_stream_encoder stream encoder \endlink module. + */ + +/** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface + * \ingroup flac_encoder + * + * \brief + * This module contains the functions which implement the stream + * encoder. + * + * The stream encoder can encode to native FLAC, and optionally Ogg FLAC + * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. + * + * The basic usage of this encoder is as follows: + * - The program creates an instance of an encoder using + * FLAC__stream_encoder_new(). + * - The program overrides the default settings using + * FLAC__stream_encoder_set_*() functions. At a minimum, the following + * functions should be called: + * - FLAC__stream_encoder_set_channels() + * - FLAC__stream_encoder_set_bits_per_sample() + * - FLAC__stream_encoder_set_sample_rate() + * - FLAC__stream_encoder_set_ogg_serial_number() (if encoding to Ogg FLAC) + * - FLAC__stream_encoder_set_total_samples_estimate() (if known) + * - If the application wants to control the compression level or set its own + * metadata, then the following should also be called: + * - FLAC__stream_encoder_set_compression_level() + * - FLAC__stream_encoder_set_verify() + * - FLAC__stream_encoder_set_metadata() + * - The rest of the set functions should only be called if the client needs + * exact control over how the audio is compressed; thorough understanding + * of the FLAC format is necessary to achieve good results. + * - The program initializes the instance to validate the settings and + * prepare for encoding using + * - FLAC__stream_encoder_init_stream() or FLAC__stream_encoder_init_FILE() + * or FLAC__stream_encoder_init_file() for native FLAC + * - FLAC__stream_encoder_init_ogg_stream() or FLAC__stream_encoder_init_ogg_FILE() + * or FLAC__stream_encoder_init_ogg_file() for Ogg FLAC + * - The program calls FLAC__stream_encoder_process() or + * FLAC__stream_encoder_process_interleaved() to encode data, which + * subsequently calls the callbacks when there is encoder data ready + * to be written. + * - The program finishes the encoding with FLAC__stream_encoder_finish(), + * which causes the encoder to encode any data still in its input pipe, + * update the metadata with the final encoding statistics if output + * seeking is possible, and finally reset the encoder to the + * uninitialized state. + * - The instance may be used again or deleted with + * FLAC__stream_encoder_delete(). + * + * In more detail, the stream encoder functions similarly to the + * \link flac_stream_decoder stream decoder \endlink, but has fewer + * callbacks and more options. Typically the client will create a new + * instance by calling FLAC__stream_encoder_new(), then set the necessary + * parameters with FLAC__stream_encoder_set_*(), and initialize it by + * calling one of the FLAC__stream_encoder_init_*() functions. + * + * Unlike the decoders, the stream encoder has many options that can + * affect the speed and compression ratio. When setting these parameters + * you should have some basic knowledge of the format (see the + * user-level documentation + * or the formal description). The + * FLAC__stream_encoder_set_*() functions themselves do not validate the + * values as many are interdependent. The FLAC__stream_encoder_init_*() + * functions will do this, so make sure to pay attention to the state + * returned by FLAC__stream_encoder_init_*() to make sure that it is + * FLAC__STREAM_ENCODER_INIT_STATUS_OK. Any parameters that are not set + * before FLAC__stream_encoder_init_*() will take on the defaults from + * the constructor. + * + * There are three initialization functions for native FLAC, one for + * setting up the encoder to encode FLAC data to the client via + * callbacks, and two for encoding directly to a file. + * + * For encoding via callbacks, use FLAC__stream_encoder_init_stream(). + * You must also supply a write callback which will be called anytime + * there is raw encoded data to write. If the client can seek the output + * it is best to also supply seek and tell callbacks, as this allows the + * encoder to go back after encoding is finished to write back + * information that was collected while encoding, like seek point offsets, + * frame sizes, etc. + * + * For encoding directly to a file, use FLAC__stream_encoder_init_FILE() + * or FLAC__stream_encoder_init_file(). Then you must only supply a + * filename or open \c FILE*; the encoder will handle all the callbacks + * internally. You may also supply a progress callback for periodic + * notification of the encoding progress. + * + * There are three similarly-named init functions for encoding to Ogg + * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the + * library has been built with Ogg support. + * + * The call to FLAC__stream_encoder_init_*() currently will also immediately + * call the write callback several times, once with the \c fLaC signature, + * and once for each encoded metadata block. Note that for Ogg FLAC + * encoding you will usually get at least twice the number of callbacks than + * with native FLAC, one for the Ogg page header and one for the page body. + * + * After initializing the instance, the client may feed audio data to the + * encoder in one of two ways: + * + * - Channel separate, through FLAC__stream_encoder_process() - The client + * will pass an array of pointers to buffers, one for each channel, to + * the encoder, each of the same length. The samples need not be + * block-aligned, but each channel should have the same number of samples. + * - Channel interleaved, through + * FLAC__stream_encoder_process_interleaved() - The client will pass a single + * pointer to data that is channel-interleaved (i.e. channel0_sample0, + * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...). + * Again, the samples need not be block-aligned but they must be + * sample-aligned, i.e. the first value should be channel0_sample0 and + * the last value channelN_sampleM. + * + * Note that for either process call, each sample in the buffers should be a + * signed integer, right-justified to the resolution set by + * FLAC__stream_encoder_set_bits_per_sample(). For example, if the resolution + * is 16 bits per sample, the samples should all be in the range [-32768,32767]. + * + * When the client is finished encoding data, it calls + * FLAC__stream_encoder_finish(), which causes the encoder to encode any + * data still in its input pipe, and call the metadata callback with the + * final encoding statistics. Then the instance may be deleted with + * FLAC__stream_encoder_delete() or initialized again to encode another + * stream. + * + * For programs that write their own metadata, but that do not know the + * actual metadata until after encoding, it is advantageous to instruct + * the encoder to write a PADDING block of the correct size, so that + * instead of rewriting the whole stream after encoding, the program can + * just overwrite the PADDING block. If only the maximum size of the + * metadata is known, the program can write a slightly larger padding + * block, then split it after encoding. + * + * Make sure you understand how lengths are calculated. All FLAC metadata + * blocks have a 4 byte header which contains the type and length. This + * length does not include the 4 bytes of the header. See the format page + * for the specification of metadata blocks and their lengths. + * + * \note + * If you are writing the FLAC data to a file via callbacks, make sure it + * is open for update (e.g. mode "w+" for stdio streams). This is because + * after the first encoding pass, the encoder will try to seek back to the + * beginning of the stream, to the STREAMINFO block, to write some data + * there. (If using FLAC__stream_encoder_init*_file() or + * FLAC__stream_encoder_init*_FILE(), the file is managed internally.) + * + * \note + * The "set" functions may only be called when the encoder is in the + * state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after + * FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but + * before FLAC__stream_encoder_init_*(). If this is the case they will + * return \c true, otherwise \c false. + * + * \note + * FLAC__stream_encoder_finish() resets all settings to the constructor + * defaults. + * + * \{ + */ + + +/** State values for a FLAC__StreamEncoder. + * + * The encoder's state can be obtained by calling FLAC__stream_encoder_get_state(). + * + * If the encoder gets into any other state besides \c FLAC__STREAM_ENCODER_OK + * or \c FLAC__STREAM_ENCODER_UNINITIALIZED, it becomes invalid for encoding and + * must be deleted with FLAC__stream_encoder_delete(). + */ +typedef enum { + + FLAC__STREAM_ENCODER_OK = 0, + /**< The encoder is in the normal OK state and samples can be processed. */ + + FLAC__STREAM_ENCODER_UNINITIALIZED, + /**< The encoder is in the uninitialized state; one of the + * FLAC__stream_encoder_init_*() functions must be called before samples + * can be processed. + */ + + FLAC__STREAM_ENCODER_OGG_ERROR, + /**< An error occurred in the underlying Ogg layer. */ + + FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR, + /**< An error occurred in the underlying verify stream decoder; + * check FLAC__stream_encoder_get_verify_decoder_state(). + */ + + FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA, + /**< The verify decoder detected a mismatch between the original + * audio signal and the decoded audio signal. + */ + + FLAC__STREAM_ENCODER_CLIENT_ERROR, + /**< One of the callbacks returned a fatal error. */ + + FLAC__STREAM_ENCODER_IO_ERROR, + /**< An I/O error occurred while opening/reading/writing a file. + * Check \c errno. + */ + + FLAC__STREAM_ENCODER_FRAMING_ERROR, + /**< An error occurred while writing the stream; usually, the + * write_callback returned an error. + */ + + FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR + /**< Memory allocation failed. */ + +} FLAC__StreamEncoderState; + +/** Maps a FLAC__StreamEncoderState to a C string. + * + * Using a FLAC__StreamEncoderState as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderStateString[]; + + +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK 0 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_NOT_COMPILED_WITH_MULTITHREADING_ENABLED 1 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_ALREADY_INITIALIZED 2 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS 3 + +/** Possible return values for the FLAC__stream_encoder_init_*() functions. + */ +typedef enum { + + FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0, + /**< Initialization was successful. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR, + /**< General failure to set up encoder; call FLAC__stream_encoder_get_state() for cause. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER, + /**< The library was not compiled with support for the given container + * format. + */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS, + /**< A required callback was not supplied. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS, + /**< The encoder has an invalid setting for number of channels. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE, + /**< The encoder has an invalid setting for bits-per-sample. + * FLAC supports 4-32 bps. + */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE, + /**< The encoder has an invalid setting for the input sample rate. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE, + /**< The encoder has an invalid setting for the block size. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER, + /**< The encoder has an invalid setting for the maximum LPC order. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION, + /**< The encoder has an invalid setting for the precision of the quantized linear predictor coefficients. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER, + /**< The specified block size is less than the maximum LPC order. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE, + /**< The encoder is bound to the Subset but other settings violate it. */ + + FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA, + /**< The metadata input to the encoder is invalid, in one of the following ways: + * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0 + * - One of the metadata blocks contains an undefined type + * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal() + * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal() + * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block + */ + + FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED + /**< FLAC__stream_encoder_init_*() was called when the encoder was + * already initialized, usually because + * FLAC__stream_encoder_finish() was not called. + */ + +} FLAC__StreamEncoderInitStatus; + +/** Maps a FLAC__StreamEncoderInitStatus to a C string. + * + * Using a FLAC__StreamEncoderInitStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[]; + + +/** Return values for the FLAC__StreamEncoder read callback. + */ +typedef enum { + + FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE, + /**< The read was OK and decoding can continue. */ + + FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM, + /**< The read was attempted at the end of the stream. */ + + FLAC__STREAM_ENCODER_READ_STATUS_ABORT, + /**< An unrecoverable error occurred. */ + + FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED + /**< Client does not support reading back from the output. */ + +} FLAC__StreamEncoderReadStatus; + +/** Maps a FLAC__StreamEncoderReadStatus to a C string. + * + * Using a FLAC__StreamEncoderReadStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[]; + + +/** Return values for the FLAC__StreamEncoder write callback. + */ +typedef enum { + + FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0, + /**< The write was OK and encoding can continue. */ + + FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR + /**< An unrecoverable error occurred. The encoder will return from the process call. */ + +} FLAC__StreamEncoderWriteStatus; + +/** Maps a FLAC__StreamEncoderWriteStatus to a C string. + * + * Using a FLAC__StreamEncoderWriteStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[]; + + +/** Return values for the FLAC__StreamEncoder seek callback. + */ +typedef enum { + + FLAC__STREAM_ENCODER_SEEK_STATUS_OK, + /**< The seek was OK and encoding can continue. */ + + FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR, + /**< An unrecoverable error occurred. */ + + FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED + /**< Client does not support seeking. */ + +} FLAC__StreamEncoderSeekStatus; + +/** Maps a FLAC__StreamEncoderSeekStatus to a C string. + * + * Using a FLAC__StreamEncoderSeekStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[]; + + +/** Return values for the FLAC__StreamEncoder tell callback. + */ +typedef enum { + + FLAC__STREAM_ENCODER_TELL_STATUS_OK, + /**< The tell was OK and encoding can continue. */ + + FLAC__STREAM_ENCODER_TELL_STATUS_ERROR, + /**< An unrecoverable error occurred. */ + + FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED + /**< Client does not support seeking. */ + +} FLAC__StreamEncoderTellStatus; + +/** Maps a FLAC__StreamEncoderTellStatus to a C string. + * + * Using a FLAC__StreamEncoderTellStatus as the index to this array + * will give the string equivalent. The contents should not be modified. + */ +extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[]; + + +/*********************************************************************** + * + * class FLAC__StreamEncoder + * + ***********************************************************************/ + +struct FLAC__StreamEncoderProtected; +struct FLAC__StreamEncoderPrivate; +/** The opaque structure definition for the stream encoder type. + * See the \link flac_stream_encoder stream encoder module \endlink + * for a detailed description. + */ +typedef struct { + struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */ + struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */ +} FLAC__StreamEncoder; + +/** Signature for the read callback. + * + * A function pointer matching this signature must be passed to + * FLAC__stream_encoder_init_ogg_stream() if seeking is supported. + * The supplied function will be called when the encoder needs to read back + * encoded data. This happens during the metadata callback, when the encoder + * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered + * while encoding. The address of the buffer to be filled is supplied, along + * with the number of bytes the buffer can hold. The callback may choose to + * supply less data and modify the byte count but must be careful not to + * overflow the buffer. The callback then returns a status code chosen from + * FLAC__StreamEncoderReadStatus. + * + * Here is an example of a read callback for stdio streams: + * \code + * FLAC__StreamEncoderReadStatus read_cb(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * if(*bytes > 0) { + * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file); + * if(ferror(file)) + * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; + * else if(*bytes == 0) + * return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM; + * else + * return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE; + * } + * else + * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; + * } + * \endcode + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param buffer A pointer to a location for the callee to store + * data to be encoded. + * \param bytes A pointer to the size of the buffer. On entry + * to the callback, it contains the maximum number + * of bytes that may be stored in \a buffer. The + * callee must set it to the actual number of bytes + * stored (0 in case of error or end-of-stream) before + * returning. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_set_client_data(). + * \retval FLAC__StreamEncoderReadStatus + * The callee's return status. + */ +typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data); + +/** Signature for the write callback. + * + * A function pointer matching this signature must be passed to + * FLAC__stream_encoder_init*_stream(). The supplied function will be called + * by the encoder anytime there is raw encoded data ready to write. It may + * include metadata mixed with encoded audio frames and the data is not + * guaranteed to be aligned on frame or metadata block boundaries. + * + * The only duty of the callback is to write out the \a bytes worth of data + * in \a buffer to the current position in the output stream. The arguments + * \a samples and \a current_frame are purely informational. If \a samples + * is greater than \c 0, then \a current_frame will hold the current frame + * number that is being written; otherwise it indicates that the write + * callback is being called to write metadata. + * + * \note + * Unlike when writing to native FLAC, when writing to Ogg FLAC the write + * callback will be called at least twice when writing each audio frame; once + * for the page header and once for the page body, possibly repeating this + * pair of calls several times in a batch with the same value of + * \a current_frame. When writing the page header, as well as in all but the + * first page body write of the batch, the \a samples argument to the write + * callback will be \c 0. The full number of samples of the batch will be + * passed in the first page body write. Furthermore, it is possible that a few + * of these samples are retained in an internal Ogg encoding buffer and not + * actually encoded until the next batch. + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param buffer An array of encoded data of length \a bytes. + * \param bytes The byte length of \a buffer. + * \param samples The number of samples encoded by \a buffer. + * \c 0 has a special meaning; see above. + * \param current_frame The number of the current frame being encoded. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_init_*(). + * \retval FLAC__StreamEncoderWriteStatus + * The callee's return status. + */ +typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); + +/** Signature for the seek callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_encoder_init*_stream(). The supplied function will be called + * when the encoder needs to seek the output stream. The encoder will pass + * the absolute byte offset to seek to, 0 meaning the beginning of the stream. + * + * Here is an example of a seek callback for stdio streams: + * \code + * FLAC__StreamEncoderSeekStatus seek_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * if(file == stdin) + * return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED; + * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0) + * return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR; + * else + * return FLAC__STREAM_ENCODER_SEEK_STATUS_OK; + * } + * \endcode + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param absolute_byte_offset The offset from the beginning of the stream + * to seek to. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_init_*(). + * \retval FLAC__StreamEncoderSeekStatus + * The callee's return status. + */ +typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data); + +/** Signature for the tell callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_encoder_init*_stream(). The supplied function will be called + * when the encoder needs to know the current position of the output stream. + * + * \warning + * The callback must return the true current byte offset of the output to + * which the encoder is writing. If you are buffering the output, make + * sure and take this into account. If you are writing directly to a + * FILE* from your write callback, ftell() is sufficient. If you are + * writing directly to a file descriptor from your write callback, you + * can use lseek(fd, SEEK_CUR, 0). The encoder may later seek back to + * these points to rewrite metadata after encoding. + * + * Here is an example of a tell callback for stdio streams: + * \code + * FLAC__StreamEncoderTellStatus tell_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) + * { + * FILE *file = ((MyClientData*)client_data)->file; + * off_t pos; + * if(file == stdin) + * return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED; + * else if((pos = ftello(file)) < 0) + * return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR; + * else { + * *absolute_byte_offset = (FLAC__uint64)pos; + * return FLAC__STREAM_ENCODER_TELL_STATUS_OK; + * } + * } + * \endcode + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param absolute_byte_offset The address at which to store the current + * position of the output. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_init_*(). + * \retval FLAC__StreamEncoderTellStatus + * The callee's return status. + */ +typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data); + +/** Signature for the metadata callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_encoder_init*_stream(). The supplied function will be called + * once at the end of encoding with the populated STREAMINFO structure. This + * is so the client can seek back to the beginning of the file and write the + * STREAMINFO block with the correct statistics after encoding (like + * minimum/maximum frame size and total samples). + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param metadata The final populated STREAMINFO block. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_init_*(). + */ +typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data); + +/** Signature for the progress callback. + * + * A function pointer matching this signature may be passed to + * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE(). + * The supplied function will be called when the encoder has finished + * writing a frame. The \c total_frames_estimate argument to the + * callback will be based on the value from + * FLAC__stream_encoder_set_total_samples_estimate(). + * + * \note In general, FLAC__StreamEncoder functions which change the + * state should not be called on the \a encoder while in the callback. + * + * \param encoder The encoder instance calling the callback. + * \param bytes_written Bytes written so far. + * \param samples_written Samples written so far. + * \param frames_written Frames written so far. + * \param total_frames_estimate The estimate of the total number of + * frames to be written. + * \param client_data The callee's client data set through + * FLAC__stream_encoder_init_*(). + */ +typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data); + + +/*********************************************************************** + * + * Class constructor/destructor + * + ***********************************************************************/ + +/** Create a new stream encoder instance. The instance is created with + * default settings; see the individual FLAC__stream_encoder_set_*() + * functions for each setting's default. + * + * \retval FLAC__StreamEncoder* + * \c NULL if there was an error allocating memory, else the new instance. + */ +FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void); + +/** Free an encoder instance. Deletes the object pointed to by \a encoder. + * + * \param encoder A pointer to an existing encoder. + * \assert + * \code encoder != NULL \endcode + */ +FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder); + + +/*********************************************************************** + * + * Public class method prototypes + * + ***********************************************************************/ + +/** Set the serial number for the FLAC stream to use in the Ogg container. + * + * \note + * This does not need to be set for native FLAC encoding. + * + * \note + * It is recommended to set a serial number explicitly as the default of '0' + * may collide with other streams. + * + * \default \c 0 + * \param encoder An encoder instance to set. + * \param serial_number See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number); + +/** Set the "verify" flag. If \c true, the encoder will verify it's own + * encoded output by feeding it through an internal decoder and comparing + * the original signal against the decoded signal. If a mismatch occurs, + * the process call will return \c false. Note that this will slow the + * encoding process by the extra time required for decoding and comparison. + * + * \default \c false + * \param encoder An encoder instance to set. + * \param value Flag value (see above). + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value); + +/** Set the Subset flag. If \c true, + * the encoder will comply with the Subset and will check the + * settings during FLAC__stream_encoder_init_*() to see if all settings + * comply. If \c false, the settings may take advantage of the full + * range that the format allows. + * + * Make sure you know what it entails before setting this to \c false. + * + * \default \c true + * \param encoder An encoder instance to set. + * \param value Flag value (see above). + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value); + +/** Set the number of channels to be encoded. + * + * \default \c 2 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the sample resolution of the input to be encoded. + * + * \warning + * Do not feed the encoder data that is wider than the value you + * set here or you will generate an invalid stream. + * + * \default \c 16 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the sample rate (in Hz) of the input to be encoded. + * + * \default \c 44100 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the compression level + * + * The compression level is roughly proportional to the amount of effort + * the encoder expends to compress the file. A higher level usually + * means more computation but higher compression. The default level is + * suitable for most applications. + * + * Currently the levels range from \c 0 (fastest, least compression) to + * \c 8 (slowest, most compression). A value larger than \c 8 will be + * treated as \c 8. + * + * This function automatically calls the following other \c _set_ + * functions with appropriate values, so the client does not need to + * unless it specifically wants to override them: + * - FLAC__stream_encoder_set_do_mid_side_stereo() + * - FLAC__stream_encoder_set_loose_mid_side_stereo() + * - FLAC__stream_encoder_set_apodization() + * - FLAC__stream_encoder_set_max_lpc_order() + * - FLAC__stream_encoder_set_qlp_coeff_precision() + * - FLAC__stream_encoder_set_do_qlp_coeff_prec_search() + * - FLAC__stream_encoder_set_do_escape_coding() + * - FLAC__stream_encoder_set_do_exhaustive_model_search() + * - FLAC__stream_encoder_set_min_residual_partition_order() + * - FLAC__stream_encoder_set_max_residual_partition_order() + * - FLAC__stream_encoder_set_rice_parameter_search_dist() + * + * The actual values set for each level are: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
leveldo mid-side stereoloose mid-side stereoapodizationmax lpc orderqlp coeff precisionqlp coeff prec searchescape codingexhaustive model searchmin residual partition ordermax residual partition orderrice parameter search dist
0 false false tukey(0.5) 0 0 false false false 0 3 0
1 true true tukey(0.5) 0 0 false false false 0 3 0
2 true false tukey(0.5) 0 0 false false false 0 3 0
3 false false tukey(0.5) 6 0 false false false 0 4 0
4 true true tukey(0.5) 8 0 false false false 0 4 0
5 true false tukey(0.5) 8 0 false false false 0 5 0
6 true false subdivide_tukey(2) 8 0 false false false 0 6 0
7 true false subdivide_tukey(2) 12 0 false false false 0 6 0
8 true false subdivide_tukey(3) 12 0 false false false 0 6 0
+ * + * \default \c 5 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the blocksize to use while encoding. + * + * The number of samples to use per frame. Use \c 0 to let the encoder + * estimate a blocksize; this is usually best. + * + * \default \c 0 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set to \c true to enable mid-side encoding on stereo input. The + * number of channels must be 2 for this to have any effect. Set to + * \c false to use only independent channel coding. + * + * \default \c true + * \param encoder An encoder instance to set. + * \param value Flag value (see above). + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value); + +/** Set to \c true to enable adaptive switching between mid-side and + * left-right encoding on stereo input. Set to \c false to use + * exhaustive searching. Setting this to \c true requires + * FLAC__stream_encoder_set_do_mid_side_stereo() to also be set to + * \c true in order to have any effect. + * + * \default \c false + * \param encoder An encoder instance to set. + * \param value Flag value (see above). + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value); + +/** Sets the apodization function(s) the encoder will use when windowing + * audio data for LPC analysis. + * + * The \a specification is a plain ASCII string which specifies exactly + * which functions to use. There may be more than one (up to 32), + * separated by \c ';' characters. Some functions take one or more + * comma-separated arguments in parentheses. + * + * The available functions are \c bartlett, \c bartlett_hann, + * \c blackman, \c blackman_harris_4term_92db, \c connes, \c flattop, + * \c gauss(STDDEV), \c hamming, \c hann, \c kaiser_bessel, \c nuttall, + * \c rectangle, \c triangle, \c tukey(P), \c partial_tukey(n[/ov[/P]]), + * \c punchout_tukey(n[/ov[/P]]), \c subdivide_tukey(n[/P]), \c welch. + * + * For \c gauss(STDDEV), STDDEV specifies the standard deviation + * (0blocksize / (2 ^ order). + * + * Set both min and max values to \c 0 to force a single context, + * whose Rice parameter is based on the residual signal variance. + * Otherwise, set a min and max order, and the encoder will search + * all orders, using the mean of each context for its Rice parameter, + * and use the best. + * + * \default \c 0 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the maximum partition order to search when coding the residual. + * This is used in tandem with + * FLAC__stream_encoder_set_min_residual_partition_order(). + * + * The partition order determines the context size in the residual. + * The context size will be approximately blocksize / (2 ^ order). + * + * Set both min and max values to \c 0 to force a single context, + * whose Rice parameter is based on the residual signal variance. + * Otherwise, set a min and max order, and the encoder will search + * all orders, using the mean of each context for its Rice parameter, + * and use the best. + * + * \default \c 5 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set the maximum number of threads to use during encoding. + * Set to a value different than 1 to enable multithreaded encoding. + * + * Note that enabling multithreading encoding (i.e., setting a value + * different than 1) results in the behaviour of + * FLAC__stream_encoder_finish(), FLAC__stream_encoder_process(), + * FLAC__stream_encoder_process_interleaved() subtly changing. + * For example, calling one of the process functions with enough + * samples to fill a block might not always result in a call to + * the write callback with a frame coding these samples. Instead, + * blocks with samples are distributed among worker threads, + * meaning that the first few calls to those functions will + * return very quickly, while later calls might block if all + * threads are occupied. Also, certain calls to the process + * functions will results in several calls to the write callback, + * while subsequent calls might again return very quickly with no + * calls to the write callback. + * + * Also, a call to FLAC__stream_encoder_finish() blocks while + * waiting for all threads to finish, and therefore might take much + * longer than when not multithreading and result in multiple calls + * to the write callback. + * + * Calls to the write callback are guaranteed to be in the correct + * order. + * + * Currently, passing a value of 0 is synonymous with a value of 1, + * but this might change in the future. + * + * \default \c 1 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK if the number of threads was set correctly, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_NOT_COMPILED_WITH_MULTITHREADING_ENABLED when + * multithreading was not enabled at compilation, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_ALREADY_INITIALIZED when the encoder was + * already initialized, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS when + * the number of threads was larger than the maximum allowed number of threads (currently + * 128). + */ +FLAC_API uint32_t FLAC__stream_encoder_set_num_threads(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Deprecated. Setting this value has no effect. + * + * \default \c 0 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, uint32_t value); + +/** Set an estimate of the total samples that will be encoded. + * This is merely an estimate and may be set to \c 0 if unknown. + * This value will be written to the STREAMINFO block before encoding, + * and can remove the need for the caller to rewrite the value later + * if the value is known before encoding. + * + * \default \c 0 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value); + +/** Set the metadata blocks to be emitted to the stream before encoding. + * A value of \c NULL, \c 0 implies no metadata; otherwise, supply an + * array of pointers to metadata blocks. The array is non-const since + * the encoder may need to change the \a is_last flag inside them, and + * in some cases update seek point offsets. Otherwise, the encoder will + * not modify or free the blocks. It is up to the caller to free the + * metadata blocks after encoding finishes. + * + * \note + * The encoder stores only copies of the pointers in the \a metadata array; + * the metadata blocks themselves must survive at least until after + * FLAC__stream_encoder_finish() returns. Do not free the blocks until then. + * + * \note + * The STREAMINFO block is always written and no STREAMINFO block may + * occur in the supplied array. + * + * \note + * By default the encoder does not create a SEEKTABLE. If one is supplied + * in the \a metadata array, but the client has specified that it does not + * support seeking, then the SEEKTABLE will be written verbatim. However + * by itself this is not very useful as the client will not know the stream + * offsets for the seekpoints ahead of time. In order to get a proper + * seektable the client must support seeking. See next note. + * + * \note + * SEEKTABLE blocks are handled specially. Since you will not know + * the values for the seek point stream offsets, you should pass in + * a SEEKTABLE 'template', that is, a SEEKTABLE object with the + * required sample numbers (or placeholder points), with \c 0 for the + * \a frame_samples and \a stream_offset fields for each point. If the + * client has specified that it supports seeking by providing a seek + * callback to FLAC__stream_encoder_init_stream() or both seek AND read + * callback to FLAC__stream_encoder_init_ogg_stream() (or by using + * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE()), + * then while it is encoding the encoder will fill the stream offsets in + * for you and when encoding is finished, it will seek back and write the + * real values into the SEEKTABLE block in the stream. There are helper + * routines for manipulating seektable template blocks; see metadata.h: + * FLAC__metadata_object_seektable_template_*(). If the client does + * not support seeking, the SEEKTABLE will have inaccurate offsets which + * will slow down or remove the ability to seek in the FLAC stream. + * + * \note + * The encoder instance \b will modify the first \c SEEKTABLE block + * as it transforms the template to a valid seektable while encoding, + * but it is still up to the caller to free all metadata blocks after + * encoding. + * + * \note + * A VORBIS_COMMENT block may be supplied. The vendor string in it + * will be ignored. libFLAC will use it's own vendor string. libFLAC + * will not modify the passed-in VORBIS_COMMENT's vendor string, it + * will simply write it's own into the stream. If no VORBIS_COMMENT + * block is present in the \a metadata array, libFLAC will write an + * empty one, containing only the vendor string. + * + * \note The Ogg FLAC mapping requires that the VORBIS_COMMENT block be + * the second metadata block of the stream. The encoder already supplies + * the STREAMINFO block automatically. If \a metadata does not contain a + * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if + * \a metadata does contain a VORBIS_COMMENT block and it is not the + * first, the init function will reorder \a metadata by moving the + * VORBIS_COMMENT block to the front; the relative ordering of the other + * blocks will remain as they were. + * + * \note The Ogg FLAC mapping limits the number of metadata blocks per + * stream to \c 65535. If \a num_blocks exceeds this the function will + * return \c false. + * + * \default \c NULL, 0 + * \param encoder An encoder instance to set. + * \param metadata See above. + * \param num_blocks See above. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + * \c false if the encoder is already initialized, or if + * \a num_blocks > 65535 if encoding to Ogg FLAC, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, uint32_t num_blocks); + +/** Set to \c true to make the encoder not output frames which contain + * only constant subframes. This is beneficial for streaming + * applications: very small frames can cause problems with buffering + * as bitrates can drop as low 1kbit/s for CDDA audio encoded within + * subset. The minimum bitrate for a FLAC file encoded with this + * function used is raised to 1bit/sample (i.e. 48kbit/s for 48kHz + * material). + * + * \default \c false + * \param encoder An encoder instance to set. + * \param value Flag value (see above). + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if the encoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_limit_min_bitrate(FLAC__StreamEncoder *encoder, FLAC__bool value); + +/** Get the current encoder state. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamEncoderState + * The current encoder state. + */ +FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder); + +/** Get the state of the verify stream decoder. + * Useful when the stream encoder state is + * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamDecoderState + * The verify stream decoder state. + */ +FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder); + +/** Get the current encoder state as a C string. + * This version automatically resolves + * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR by getting the + * verify decoder's state. + * + * \param encoder A encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval const char * + * The encoder state as a C string. Do not modify the contents. + */ +FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder); + +/** Get relevant values about the nature of a verify decoder error. + * Useful when the stream encoder state is + * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. The arguments should + * be addresses in which the stats will be returned, or NULL if value + * is not desired. + * + * \param encoder An encoder instance to query. + * \param absolute_sample The absolute sample number of the mismatch. + * \param frame_number The number of the frame in which the mismatch occurred. + * \param channel The channel in which the mismatch occurred. + * \param sample The number of the sample (relative to the frame) in + * which the mismatch occurred. + * \param expected The expected value for the sample in question. + * \param got The actual value returned by the decoder. + * \assert + * \code encoder != NULL \endcode + */ +FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got); + +/** Get the "verify" flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_verify(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder); + +/** Get the Subset flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_streamable_subset(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder); + +/** Get the number of input channels being processed. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_channels(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder); + +/** Get the input sample resolution setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_bits_per_sample(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder); + +/** Get the input sample rate setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_sample_rate(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder); + +/** Get the blocksize setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_blocksize(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder); + +/** Get the "mid/side stereo coding" flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_get_do_mid_side_stereo(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder); + +/** Get the "adaptive mid/side switching" flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_loose_mid_side_stereo(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder); + +/** Get the maximum LPC order setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_max_lpc_order(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder); + +/** Get the quantized linear predictor coefficient precision setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_qlp_coeff_precision(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder); + +/** Get the qlp coefficient precision search flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_do_qlp_coeff_prec_search(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder); + +/** Get the "escape coding" flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_do_escape_coding(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder); + +/** Get the exhaustive model search flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_do_exhaustive_model_search(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder); + +/** Get the minimum residual partition order setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_min_residual_partition_order(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder); + +/** Get maximum residual partition order setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_max_residual_partition_order(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder); + +/** Get maximum number of threads setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_num_threads(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_num_threads(const FLAC__StreamEncoder *encoder); + +/** Get the Rice parameter search distance setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_rice_parameter_search_dist(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder); + +/** Get the previously set estimate of the total samples to be encoded. + * The encoder merely mimics back the value given to + * FLAC__stream_encoder_set_total_samples_estimate() since it has no + * other way of knowing how many samples the client will encode. + * + * \param encoder An encoder instance to set. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__uint64 + * See FLAC__stream_encoder_get_total_samples_estimate(). + */ +FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder); + +/** Get the "limit_min_bitrate" flag. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * See FLAC__stream_encoder_set_limit_min_bitrate(). + */ +FLAC_API FLAC__bool FLAC__stream_encoder_get_limit_min_bitrate(const FLAC__StreamEncoder *encoder); + +/** Initialize the encoder instance to encode native FLAC streams. + * + * This flavor of initialization sets up the encoder to encode to a + * native FLAC stream. I/O is performed via callbacks to the client. + * For encoding to a plain file via filename or open \c FILE*, + * FLAC__stream_encoder_init_file() and FLAC__stream_encoder_init_FILE() + * provide a simpler interface. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * The call to FLAC__stream_encoder_init_stream() currently will also + * immediately call the write callback several times, once with the \c fLaC + * signature, and once for each encoded metadata block. + * + * \param encoder An uninitialized encoder instance. + * \param write_callback See FLAC__StreamEncoderWriteCallback. This + * pointer must not be \c NULL. + * \param seek_callback See FLAC__StreamEncoderSeekCallback. This + * pointer may be \c NULL if seeking is not + * supported. The encoder uses seeking to go back + * and write some some stream statistics to the + * STREAMINFO block; this is recommended but not + * necessary to create a valid FLAC stream. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy seek callback that just + * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the encoder. + * \param tell_callback See FLAC__StreamEncoderTellCallback. This + * pointer may be \c NULL if seeking is not + * supported. If \a seek_callback is \c NULL then + * this argument will be ignored. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy tell callback that just + * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the encoder. + * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. If the client provides a seek callback, + * this function is not necessary as the encoder + * will automatically seek back and update the + * STREAMINFO block. It may also be \c NULL if the + * client does not support seeking, since it will + * have no way of going back to update the + * STREAMINFO. However the client can still supply + * a callback if it would like to know the details + * from the STREAMINFO. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data); + +/** Initialize the encoder instance to encode Ogg FLAC streams. + * + * This flavor of initialization sets up the encoder to encode to a FLAC + * stream in an Ogg container. I/O is performed via callbacks to the + * client. For encoding to a plain file via filename or open \c FILE*, + * FLAC__stream_encoder_init_ogg_file() and FLAC__stream_encoder_init_ogg_FILE() + * provide a simpler interface. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * The call to FLAC__stream_encoder_init_ogg_stream() currently will also + * immediately call the write callback several times to write the metadata + * packets. + * + * \param encoder An uninitialized encoder instance. + * \param read_callback See FLAC__StreamEncoderReadCallback. This + * pointer must not be \c NULL if \a seek_callback + * is non-NULL since they are both needed to be + * able to write data back to the Ogg FLAC stream + * in the post-encode phase. + * \param write_callback See FLAC__StreamEncoderWriteCallback. This + * pointer must not be \c NULL. + * \param seek_callback See FLAC__StreamEncoderSeekCallback. This + * pointer may be \c NULL if seeking is not + * supported. The encoder uses seeking to go back + * and write some some stream statistics to the + * STREAMINFO block; this is recommended but not + * necessary to create a valid FLAC stream. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy seek callback that just + * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the encoder. + * \param tell_callback See FLAC__StreamEncoderTellCallback. This + * pointer may be \c NULL if seeking is not + * supported. If \a seek_callback is \c NULL then + * this argument will be ignored. If + * \a seek_callback is not \c NULL then a + * \a tell_callback must also be supplied. + * Alternatively, a dummy tell callback that just + * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED + * may also be supplied, all though this is slightly + * less efficient for the encoder. + * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This + * pointer may be \c NULL if the callback is not + * desired. If the client provides a seek callback, + * this function is not necessary as the encoder + * will automatically seek back and update the + * STREAMINFO block. It may also be \c NULL if the + * client does not support seeking, since it will + * have no way of going back to update the + * STREAMINFO. However the client can still supply + * a callback if it would like to know the details + * from the STREAMINFO. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderReadCallback read_callback, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data); + +/** Initialize the encoder instance to encode native FLAC files. + * + * This flavor of initialization sets up the encoder to encode to a + * plain native FLAC file. For non-stdio streams, you must use + * FLAC__stream_encoder_init_stream() and provide callbacks for the I/O. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * \param encoder An uninitialized encoder instance. + * \param file An open file. The file should have been opened + * with mode \c "w+b" and rewound. The file + * becomes owned by the encoder and should not be + * manipulated by the client while encoding. + * Unless \a file is \c stdout, it will be closed + * when FLAC__stream_encoder_finish() is called. + * Note however that a proper SEEKTABLE cannot be + * created when encoding to \c stdout since it is + * not seekable. + * \param progress_callback See FLAC__StreamEncoderProgressCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \code file != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); + +/** Initialize the encoder instance to encode Ogg FLAC files. + * + * This flavor of initialization sets up the encoder to encode to a + * plain Ogg FLAC file. For non-stdio streams, you must use + * FLAC__stream_encoder_init_ogg_stream() and provide callbacks for the I/O. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * \param encoder An uninitialized encoder instance. + * \param file An open file. The file should have been opened + * with mode \c "w+b" and rewound. The file + * becomes owned by the encoder and should not be + * manipulated by the client while encoding. + * Unless \a file is \c stdout, it will be closed + * when FLAC__stream_encoder_finish() is called. + * Note however that a proper SEEKTABLE cannot be + * created when encoding to \c stdout since it is + * not seekable. + * \param progress_callback See FLAC__StreamEncoderProgressCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \code file != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); + +/** Initialize the encoder instance to encode native FLAC files. + * + * This flavor of initialization sets up the encoder to encode to a plain + * FLAC file. If POSIX fopen() semantics are not sufficient you must use + * FLAC__stream_encoder_init_FILE(), or FLAC__stream_encoder_init_stream() + * and provide callbacks for the I/O. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * \param encoder An uninitialized encoder instance. + * \param filename The name of the file to encode to. The file will + * be opened with fopen(). Use \c NULL to encode to + * \c stdout. Note however that a proper SEEKTABLE + * cannot be created when encoding to \c stdout since + * it is not seekable. + * \param progress_callback See FLAC__StreamEncoderProgressCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); + +/** Initialize the encoder instance to encode Ogg FLAC files. + * + * This flavor of initialization sets up the encoder to encode to a plain + * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, you must use + * FLAC__stream_encoder_init_ogg_FILE(), or FLAC__stream_encoder_init_ogg_stream() + * and provide callbacks for the I/O. + * + * On Windows, filename must be a UTF-8 encoded filename, which libFLAC + * internally translates to an appropriate representation to use with + * _wfopen. On all other systems, filename is passed to fopen without + * any translation. + * + * This function should be called after FLAC__stream_encoder_new() and + * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() + * or FLAC__stream_encoder_process_interleaved(). + * initialization succeeded. + * + * \param encoder An uninitialized encoder instance. + * \param filename The name of the file to encode to. The file will + * be opened with fopen(). Use \c NULL to encode to + * \c stdout. Note however that a proper SEEKTABLE + * cannot be created when encoding to \c stdout since + * it is not seekable. + * \param progress_callback See FLAC__StreamEncoderProgressCallback. This + * pointer may be \c NULL if the callback is not + * desired. + * \param client_data This value will be supplied to callbacks in their + * \a client_data argument. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__StreamEncoderInitStatus + * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; + * see FLAC__StreamEncoderInitStatus for the meanings of other return values. + */ +FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); + +/** Finish the encoding process. + * Flushes the encoding buffer, releases resources, resets the encoder + * settings to their defaults, and returns the encoder state to + * FLAC__STREAM_ENCODER_UNINITIALIZED. Note that this can generate + * one or more write callbacks before returning, and will generate + * a metadata callback. + * + * Note that in the course of processing the last frame, errors can + * occur, so the caller should be sure to check the return value to + * ensure the file was encoded properly. + * + * In the event of a prematurely-terminated encode, it is not strictly + * necessary to call this immediately before FLAC__stream_encoder_delete() + * but it is good practice to match every FLAC__stream_encoder_init_*() + * with a FLAC__stream_encoder_finish(). + * + * \param encoder An uninitialized encoder instance. + * \assert + * \code encoder != NULL \endcode + * \retval FLAC__bool + * \c false if an error occurred processing the last frame; or if verify + * mode is set (see FLAC__stream_encoder_set_verify()), there was a + * verify mismatch; else \c true. If \c false, caller should check the + * state with FLAC__stream_encoder_get_state() for more information + * about the error. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder); + +/** Submit data for encoding. + * This version allows you to supply the input data via an array of + * pointers, each pointer pointing to an array of \a samples samples + * representing one channel. The samples need not be block-aligned, + * but each channel should have the same number of samples. Each sample + * should be a signed integer, right-justified to the resolution set by + * FLAC__stream_encoder_set_bits_per_sample(). For example, if the + * resolution is 16 bits per sample, the samples should all be in the + * range [-32768,32767]. + * + * For applications where channel order is important, channels must + * follow the order as described in the + * frame header. + * + * \param encoder An initialized encoder instance in the OK state. + * \param buffer An array of pointers to each channel's signal. + * \param samples The number of samples in one channel. + * \assert + * \code encoder != NULL \endcode + * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode + * \retval FLAC__bool + * \c true if successful, else \c false; in this case, check the + * encoder state with FLAC__stream_encoder_get_state() to see what + * went wrong. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples); + +/** Submit data for encoding. + * This version allows you to supply the input data where the channels + * are interleaved into a single array (i.e. channel0_sample0, + * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...). + * The samples need not be block-aligned but they must be + * sample-aligned, i.e. the first value should be channel0_sample0 + * and the last value channelN_sampleM. Each sample should be a signed + * integer, right-justified to the resolution set by + * FLAC__stream_encoder_set_bits_per_sample(). For example, if the + * resolution is 16 bits per sample, the samples should all be in the + * range [-32768,32767]. + * + * For applications where channel order is important, channels must + * follow the order as described in the + * frame header. + * + * \param encoder An initialized encoder instance in the OK state. + * \param buffer An array of channel-interleaved data (see above). + * \param samples The number of samples in one channel, the same as for + * FLAC__stream_encoder_process(). For example, if + * encoding two channels, \c 1000 \a samples corresponds + * to a \a buffer of 2000 values. + * \assert + * \code encoder != NULL \endcode + * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode + * \retval FLAC__bool + * \c true if successful, else \c false; in this case, check the + * encoder state with FLAC__stream_encoder_get_state() to see what + * went wrong. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples); + +/* \} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/Kconfig b/packages/third-party/libFLAC/Kconfig new file mode 100644 index 00000000..3bafbe4a --- /dev/null +++ b/packages/third-party/libFLAC/Kconfig @@ -0,0 +1,12 @@ + +menuconfig LPKG_USING_LIBFLAC + bool "FLAC: Free Lossless Audio Codec." + default n + +if LPKG_USING_LIBFLAC + + config LPKG_LIBFLAC_DECODER_DEMO + bool "libFLAC decoder demo." + default n + +endif diff --git a/packages/third-party/libFLAC/SConscript b/packages/third-party/libFLAC/SConscript new file mode 100644 index 00000000..4f105c55 --- /dev/null +++ b/packages/third-party/libFLAC/SConscript @@ -0,0 +1,25 @@ +from building import * + +cwd = GetCurrentDir() + +src = Glob('./bitmath.c') +src += Glob('./fixed.c') +src += Glob('./float.c') +src += Glob('./format.c') +src += Glob('./lpc.c') +src += Glob('./md5.c') +src += Glob('./memory.c') +src += Glob('./crc.c') +src += Glob('./cpu.c') +src += Glob('./bitreader.c') +src += Glob('./stream_decoder.c') + +if GetDepend('LPKG_LIBFLAC_DECODER_DEMO'): + src += Glob('./test_decoder.c') + + +CPPPATH = [cwd] +group = DefineGroup('libFLAC', src, depend = ['LPKG_USING_LIBFLAC'], CPPPATH = CPPPATH) + +Return('group') + diff --git a/packages/third-party/libFLAC/bitmath.c b/packages/third-party/libFLAC/bitmath.c new file mode 100644 index 00000000..baf0527a --- /dev/null +++ b/packages/third-party/libFLAC/bitmath.c @@ -0,0 +1,115 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "private/bitmath.h" + +/* An example of what FLAC__bitmath_silog2() computes: + * + * silog2(-10) = 5 + * silog2(- 9) = 5 + * silog2(- 8) = 4 + * silog2(- 7) = 4 + * silog2(- 6) = 4 + * silog2(- 5) = 4 + * silog2(- 4) = 3 + * silog2(- 3) = 3 + * silog2(- 2) = 2 + * silog2(- 1) = 2 + * silog2( 0) = 0 + * silog2( 1) = 2 + * silog2( 2) = 3 + * silog2( 3) = 3 + * silog2( 4) = 4 + * silog2( 5) = 4 + * silog2( 6) = 4 + * silog2( 7) = 4 + * silog2( 8) = 5 + * silog2( 9) = 5 + * silog2( 10) = 5 + */ +uint32_t FLAC__bitmath_silog2(FLAC__int64 v) +{ + if(v == 0) + return 0; + + if(v == -1) + return 2; + + v = (v < 0) ? (-(v+1)) : v; + return FLAC__bitmath_ilog2_wide(v)+2; +} + +/* An example of what FLAC__bitmath_extra_mulbits_unsigned() computes: + * + * extra_mulbits_unsigned( 0) = 0 + * extra_mulbits_unsigned( 1) = 0 + * extra_mulbits_unsigned( 2) = 1 + * extra_mulbits_unsigned( 3) = 2 + * extra_mulbits_unsigned( 4) = 2 + * extra_mulbits_unsigned( 5) = 3 + * extra_mulbits_unsigned( 6) = 3 + * extra_mulbits_unsigned( 7) = 3 + * extra_mulbits_unsigned( 8) = 3 + * extra_mulbits_unsigned( 9) = 4 + * extra_mulbits_unsigned(10) = 4 + * extra_mulbits_unsigned(11) = 4 + * extra_mulbits_unsigned(12) = 4 + * extra_mulbits_unsigned(13) = 4 + * extra_mulbits_unsigned(14) = 4 + * extra_mulbits_unsigned(15) = 4 + * extra_mulbits_unsigned(16) = 4 + * extra_mulbits_unsigned(17) = 5 + * extra_mulbits_unsigned(18) = 5 + * + * The intent of this is to calculate how many extra bits multiplication + * by a certain number requires. So, if a signal fits in a certain number + * of bits (for example 16) than multiplying by a number (for example 1024) + * grows that storage requirement (to 26 in this example). In effect this is + * is the log2 rounded up. + */ +uint32_t FLAC__bitmath_extra_mulbits_unsigned(FLAC__uint32 v) +{ + uint32_t ilog2; + if(v == 0) + return 0; + ilog2 = FLAC__bitmath_ilog2(v); + if(((v >> ilog2) << ilog2) == v) + /* v is power of 2 */ + return ilog2; + else + /* v is not a power of 2, return one higher */ + return ilog2 + 1; +} diff --git a/packages/third-party/libFLAC/bitreader.c b/packages/third-party/libFLAC/bitreader.c new file mode 100644 index 00000000..11f2af48 --- /dev/null +++ b/packages/third-party/libFLAC/bitreader.c @@ -0,0 +1,1052 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include "private/bitmath.h" +#include "private/bitreader.h" +#include "private/crc.h" +#include "private/cpu.h" +#include "private/macros.h" +#include "FLAC/assert.h" +#include "share/compat.h" +#include "share/endswap.h" + +/* Things should be fastest when this matches the machine word size */ +/* WATCHOUT: if you change this you must also change the following #defines down to COUNT_ZERO_MSBS2 below to match */ +/* WATCHOUT: there are a few places where the code will not work unless brword is >= 32 bits wide */ +/* also, some sections currently only have fast versions for 4 or 8 bytes per word */ + +#if (ENABLE_64_BIT_WORDS == 0) + +typedef FLAC__uint32 brword; +#define FLAC__BYTES_PER_WORD 4 /* sizeof brword */ +#define FLAC__BITS_PER_WORD 32 +#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff) +/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */ +#if WORDS_BIGENDIAN +#define SWAP_BE_WORD_TO_HOST(x) (x) +#else +#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x) +#endif +/* counts the # of zero MSBs in a word */ +#define COUNT_ZERO_MSBS(word) FLAC__clz_uint32(word) +#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint32(word) + +#else + +typedef FLAC__uint64 brword; +#define FLAC__BYTES_PER_WORD 8 /* sizeof brword */ +#define FLAC__BITS_PER_WORD 64 +#define FLAC__WORD_ALL_ONES ((FLAC__uint64)FLAC__U64L(0xffffffffffffffff)) +/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */ +#if WORDS_BIGENDIAN +#define SWAP_BE_WORD_TO_HOST(x) (x) +#else +#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x) +#endif +/* counts the # of zero MSBs in a word */ +#define COUNT_ZERO_MSBS(word) FLAC__clz_uint64(word) +#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint64(word) + +#endif + +/* + * This should be at least twice as large as the largest number of words + * required to represent any 'number' (in any encoding) you are going to + * read. With FLAC this is on the order of maybe a few hundred bits. + * If the buffer is smaller than that, the decoder won't be able to read + * in a whole number that is in a variable length encoding (e.g. Rice). + * But to be practical it should be at least 1K bytes. + * + * Increase this number to decrease the number of read callbacks, at the + * expense of using more memory. Or decrease for the reverse effect, + * keeping in mind the limit from the first paragraph. The optimal size + * also depends on the CPU cache size and other factors; some twiddling + * may be necessary to squeeze out the best performance. + */ +static const uint32_t FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */ + +struct FLAC__BitReader { + /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */ + /* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */ + brword *buffer; + uint32_t capacity; /* in words */ + uint32_t words; /* # of completed words in buffer */ + uint32_t bytes; /* # of bytes in incomplete word at buffer[words] */ + uint32_t consumed_words; /* #words ... */ + uint32_t consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */ + uint32_t read_crc16; /* the running frame CRC */ + uint32_t crc16_offset; /* the number of words in the current buffer that should not be CRC'd */ + uint32_t crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */ + FLAC__bool read_limit_set; /* whether reads are limited */ + uint32_t read_limit; /* the remaining size of what can be read */ + uint32_t last_seen_framesync; /* the location of the last seen framesync, if it is in the buffer, in bits from front of buffer */ + FLAC__BitReaderReadCallback read_callback; + void *client_data; +}; + +static inline void crc16_update_word_(FLAC__BitReader *br, brword word) +{ + register uint32_t crc = br->read_crc16; + + for ( ; br->crc16_align < FLAC__BITS_PER_WORD ; br->crc16_align += 8) { + uint32_t shift = FLAC__BITS_PER_WORD - 8 - br->crc16_align ; + crc = FLAC__CRC16_UPDATE ((uint32_t) (shift < FLAC__BITS_PER_WORD ? (word >> shift) & 0xff : 0), crc); + } + + br->read_crc16 = crc; + br->crc16_align = 0; +} + +static inline void crc16_update_block_(FLAC__BitReader *br) +{ + if(br->consumed_words > br->crc16_offset && br->crc16_align) + crc16_update_word_(br, br->buffer[br->crc16_offset++]); + + /* Prevent OOB read due to wrap-around. */ + if (br->consumed_words > br->crc16_offset) { +#if FLAC__BYTES_PER_WORD == 4 + br->read_crc16 = FLAC__crc16_update_words32(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16); +#elif FLAC__BYTES_PER_WORD == 8 + br->read_crc16 = FLAC__crc16_update_words64(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16); +#else + unsigned i; + + for (i = br->crc16_offset; i < br->consumed_words; i++) + crc16_update_word_(br, br->buffer[i]); +#endif + } + + br->crc16_offset = 0; +} + +static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) +{ + uint32_t start, end; + size_t bytes; + FLAC__byte *target; +#if WORDS_BIGENDIAN +#else + brword preswap_backup; +#endif + + /* first shift the unconsumed buffer data toward the front as much as possible */ + if(br->consumed_words > 0) { + /* invalidate last seen framesync */ + br->last_seen_framesync = -1; + + crc16_update_block_(br); /* CRC consumed words */ + + start = br->consumed_words; + end = br->words + (br->bytes? 1:0); + memmove(br->buffer, br->buffer+start, FLAC__BYTES_PER_WORD * (end - start)); + + br->words -= start; + br->consumed_words = 0; + } + + /* + * set the target for reading, taking into account word alignment and endianness + */ + bytes = (br->capacity - br->words) * FLAC__BYTES_PER_WORD - br->bytes; + if(bytes == 0) + return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY */ + target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes; + + /* before reading, if the existing reader looks like this (say brword is 32 bits wide) + * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified) + * buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown laid out as bytes sequentially in memory) + * buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care) + * ^^-------target, bytes=3 + * on LE machines, have to byteswap the odd tail word so nothing is + * overwritten: + */ +#if WORDS_BIGENDIAN +#else + preswap_backup = br->buffer[br->words]; + if(br->bytes) + br->buffer[br->words] = SWAP_BE_WORD_TO_HOST(br->buffer[br->words]); +#endif + + /* now it looks like: + * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 + * buffer[BE]: 11 22 33 44 55 ?? ?? ?? + * buffer[LE]: 44 33 22 11 55 ?? ?? ?? + * ^^-------target, bytes=3 + */ + + /* read in the data; note that the callback may return a smaller number of bytes */ + if(!br->read_callback(target, &bytes, br->client_data)){ + /* Despite the read callback failing, the data in the target + * might be used later, when the buffer is rewound. Therefore + * we revert the swap that was just done */ +#if WORDS_BIGENDIAN +#else + br->buffer[br->words] = preswap_backup; +#endif + return false; + } + + /* after reading bytes 66 77 88 99 AA BB CC DD EE FF from the client: + * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF + * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? + * buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ?? + * now have to byteswap on LE machines: + */ +#if WORDS_BIGENDIAN +#else + end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; + for(start = br->words; start < end; start++) + br->buffer[start] = SWAP_BE_WORD_TO_HOST(br->buffer[start]); +#endif + + /* now it looks like: + * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF + * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? + * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD + * finally we'll update the reader values: + */ + end = br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes; + br->words = end / FLAC__BYTES_PER_WORD; + br->bytes = end % FLAC__BYTES_PER_WORD; + + return true; +} + +/*********************************************************************** + * + * Class constructor/destructor + * + ***********************************************************************/ + +FLAC__BitReader *FLAC__bitreader_new(void) +{ + FLAC__BitReader *br = calloc(1, sizeof(FLAC__BitReader)); + + /* calloc() implies: + memset(br, 0, sizeof(FLAC__BitReader)); + br->buffer = 0; + br->capacity = 0; + br->words = br->bytes = 0; + br->consumed_words = br->consumed_bits = 0; + br->read_callback = 0; + br->client_data = 0; + */ + return br; +} + +void FLAC__bitreader_delete(FLAC__BitReader *br) +{ + FLAC__ASSERT(0 != br); + + FLAC__bitreader_free(br); + free(br); +} + +/*********************************************************************** + * + * Public class methods + * + ***********************************************************************/ + +FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback rcb, void *cd) +{ + FLAC__ASSERT(0 != br); + + br->words = br->bytes = 0; + br->consumed_words = br->consumed_bits = 0; + br->capacity = FLAC__BITREADER_DEFAULT_CAPACITY; + br->buffer = malloc(sizeof(brword) * br->capacity); + if(br->buffer == 0) + return false; + br->read_callback = rcb; + br->client_data = cd; + br->read_limit_set = false; + br->read_limit = -1; + br->last_seen_framesync = -1; + + return true; +} + +void FLAC__bitreader_free(FLAC__BitReader *br) +{ + FLAC__ASSERT(0 != br); + + if(0 != br->buffer) + free(br->buffer); + br->buffer = 0; + br->capacity = 0; + br->words = br->bytes = 0; + br->consumed_words = br->consumed_bits = 0; + br->read_callback = 0; + br->client_data = 0; + br->read_limit_set = false; + br->read_limit = -1; + br->last_seen_framesync = -1; +} + +FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br) +{ + br->words = br->bytes = 0; + br->consumed_words = br->consumed_bits = 0; + br->read_limit_set = false; + br->read_limit = -1; + br->last_seen_framesync = -1; + return true; +} + +void FLAC__bitreader_set_framesync_location(FLAC__BitReader *br) +{ + br->last_seen_framesync = br->consumed_words * FLAC__BYTES_PER_WORD + br->consumed_bits / 8; +} + +FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(FLAC__BitReader *br) +{ + if(br->last_seen_framesync == (uint32_t)-1) { + br->consumed_words = br->consumed_bits = 0; + return false; + } + else { + br->consumed_words = (br->last_seen_framesync + 1) / FLAC__BYTES_PER_WORD; + br->consumed_bits = ((br->last_seen_framesync + 1) % FLAC__BYTES_PER_WORD) * 8; + return true; + } +} + +void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed) +{ + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + FLAC__ASSERT((br->consumed_bits & 7) == 0); + + br->read_crc16 = (uint32_t)seed; + br->crc16_offset = br->consumed_words; + br->crc16_align = br->consumed_bits; +} + +FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br) +{ + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + /* CRC consumed words up to here */ + crc16_update_block_(br); + + FLAC__ASSERT((br->consumed_bits & 7) == 0); + FLAC__ASSERT(br->crc16_align <= br->consumed_bits); + + /* CRC any tail bytes in a partially-consumed word */ + if(br->consumed_bits) { + const brword tail = br->buffer[br->consumed_words]; + for( ; br->crc16_align < br->consumed_bits; br->crc16_align += 8) + br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16); + } + return br->read_crc16; +} + +inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) +{ + return ((br->consumed_bits & 7) == 0); +} + +inline uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) +{ + return 8 - (br->consumed_bits & 7); +} + +inline uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) +{ + return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits; +} + +void FLAC__bitreader_set_limit(FLAC__BitReader *br, uint32_t limit) +{ + br->read_limit = limit; + br->read_limit_set = true; +} + +void FLAC__bitreader_remove_limit(FLAC__BitReader *br) +{ + br->read_limit_set = false; + br->read_limit = -1; +} + +uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br) +{ + FLAC__ASSERT(br->read_limit_set); + return br->read_limit; +} +void FLAC__bitreader_limit_invalidate(FLAC__BitReader *br) +{ + br->read_limit = -1; +} + +FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits) +{ + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + FLAC__ASSERT(bits <= 32); + FLAC__ASSERT((br->capacity*FLAC__BITS_PER_WORD) * 2 >= bits); + FLAC__ASSERT(br->consumed_words <= br->words); + + /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ + FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); + + if(bits == 0) { /* OPT: investigate if this can ever happen, maybe change to assertion */ + *val = 0; + return true; + } + + if(br->read_limit_set && br->read_limit < (uint32_t)-1){ + if(br->read_limit < bits) { + br->read_limit = -1; + return false; + } + else + br->read_limit -= bits; + } + + while((br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits < bits) { + if(!bitreader_read_from_client_(br)) + return false; + } + if(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */ + /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ + if(br->consumed_bits) { + /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ + const uint32_t n = FLAC__BITS_PER_WORD - br->consumed_bits; + const brword word = br->buffer[br->consumed_words]; + const brword mask = br->consumed_bits < FLAC__BITS_PER_WORD ? FLAC__WORD_ALL_ONES >> br->consumed_bits : 0; + if(bits < n) { + uint32_t shift = n - bits; + *val = shift < FLAC__BITS_PER_WORD ? (FLAC__uint32)((word & mask) >> shift) : 0; /* The result has <= 32 non-zero bits */ + br->consumed_bits += bits; + return true; + } + /* (FLAC__BITS_PER_WORD - br->consumed_bits <= bits) ==> (FLAC__WORD_ALL_ONES >> br->consumed_bits) has no more than 'bits' non-zero bits */ + *val = (FLAC__uint32)(word & mask); + bits -= n; + br->consumed_words++; + br->consumed_bits = 0; + if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */ + uint32_t shift = FLAC__BITS_PER_WORD - bits; + *val = bits < 32 ? *val << bits : 0; + *val |= shift < FLAC__BITS_PER_WORD ? (FLAC__uint32)(br->buffer[br->consumed_words] >> shift) : 0; + br->consumed_bits = bits; + } + return true; + } + else { /* br->consumed_bits == 0 */ + const brword word = br->buffer[br->consumed_words]; + if(bits < FLAC__BITS_PER_WORD) { + *val = (FLAC__uint32)(word >> (FLAC__BITS_PER_WORD-bits)); + br->consumed_bits = bits; + return true; + } + /* at this point bits == FLAC__BITS_PER_WORD == 32; because of previous assertions, it can't be larger */ + *val = (FLAC__uint32)word; + br->consumed_words++; + return true; + } + } + else { + /* in this case we're starting our read at a partial tail word; + * the reader has guaranteed that we have at least 'bits' bits + * available to read, which makes this case simpler. + */ + /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ + if(br->consumed_bits) { + /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ + FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8); + *val = (FLAC__uint32)((br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits)); + br->consumed_bits += bits; + return true; + } + else { + *val = (FLAC__uint32)(br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits)); + br->consumed_bits += bits; + return true; + } + } +} + +FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits) +{ + FLAC__uint32 uval, mask; + /* OPT: inline raw uint32 code here, or make into a macro if possible in the .h file */ + if (bits < 1 || ! FLAC__bitreader_read_raw_uint32(br, &uval, bits)) + return false; + /* sign-extend *val assuming it is currently bits wide. */ + /* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */ + mask = bits >= 33 ? 0 : 1lu << (bits - 1); + *val = (uval ^ mask) - mask; + return true; +} + +FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits) +{ + FLAC__uint32 hi, lo; + + if(bits > 32) { + if(!FLAC__bitreader_read_raw_uint32(br, &hi, bits-32)) + return false; + if(!FLAC__bitreader_read_raw_uint32(br, &lo, 32)) + return false; + *val = hi; + *val <<= 32; + *val |= lo; + } + else { + if(!FLAC__bitreader_read_raw_uint32(br, &lo, bits)) + return false; + *val = lo; + } + return true; +} + +FLAC__bool FLAC__bitreader_read_raw_int64(FLAC__BitReader *br, FLAC__int64 *val, uint32_t bits) +{ + FLAC__uint64 uval, mask; + /* OPT: inline raw uint64 code here, or make into a macro if possible in the .h file */ + if (bits < 1 || ! FLAC__bitreader_read_raw_uint64(br, &uval, bits)) + return false; + /* sign-extend *val assuming it is currently bits wide. */ + /* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */ + mask = bits >= 65 ? 0 : 1llu << (bits - 1); + *val = (uval ^ mask) - mask; + return true; +} + +inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) +{ + FLAC__uint32 x8, x32 = 0; + + /* this doesn't need to be that fast as currently it is only used for vorbis comments */ + + if(!FLAC__bitreader_read_raw_uint32(br, &x32, 8)) + return false; + + if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) + return false; + x32 |= (x8 << 8); + + if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) + return false; + x32 |= (x8 << 16); + + if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) + return false; + x32 |= (x8 << 24); + + *val = x32; + return true; +} + +FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits) +{ + /* + * OPT: a faster implementation is possible but probably not that useful + * since this is only called a couple of times in the metadata readers. + */ + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + if(bits > 0) { + const uint32_t n = br->consumed_bits & 7; + uint32_t m; + FLAC__uint32 x; + + if(n != 0) { + m = flac_min(8-n, bits); + if(!FLAC__bitreader_read_raw_uint32(br, &x, m)) + return false; + bits -= m; + } + m = bits / 8; + if(m > 0) { + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(br, m)) + return false; + bits %= 8; + } + if(bits > 0) { + if(!FLAC__bitreader_read_raw_uint32(br, &x, bits)) + return false; + } + } + + return true; +} + +FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals) +{ + FLAC__uint32 x; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br)); + + if(br->read_limit_set && br->read_limit < (uint32_t)-1){ + if(br->read_limit < nvals*8){ + br->read_limit = -1; + return false; + } + } + + /* step 1: skip over partial head word to get word aligned */ + while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */ + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + nvals--; + } + if(0 == nvals) + return true; + + /* step 2: skip whole words in chunks */ + while(nvals >= FLAC__BYTES_PER_WORD) { + if(br->consumed_words < br->words) { + br->consumed_words++; + nvals -= FLAC__BYTES_PER_WORD; + if(br->read_limit_set) + br->read_limit -= FLAC__BITS_PER_WORD; + } + else if(!bitreader_read_from_client_(br)) + return false; + } + /* step 3: skip any remainder from partial tail bytes */ + while(nvals) { + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + nvals--; + } + + return true; +} + +FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals) +{ + FLAC__uint32 x; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br)); + + if(br->read_limit_set && br->read_limit < (uint32_t)-1){ + if(br->read_limit < nvals*8){ + br->read_limit = -1; + return false; + } + } + + /* step 1: read from partial head word to get word aligned */ + while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */ + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + *val++ = (FLAC__byte)x; + nvals--; + } + if(0 == nvals) + return true; + /* step 2: read whole words in chunks */ + while(nvals >= FLAC__BYTES_PER_WORD) { + if(br->consumed_words < br->words) { + const brword word = br->buffer[br->consumed_words++]; +#if FLAC__BYTES_PER_WORD == 4 + val[0] = (FLAC__byte)(word >> 24); + val[1] = (FLAC__byte)(word >> 16); + val[2] = (FLAC__byte)(word >> 8); + val[3] = (FLAC__byte)word; +#elif FLAC__BYTES_PER_WORD == 8 + val[0] = (FLAC__byte)(word >> 56); + val[1] = (FLAC__byte)(word >> 48); + val[2] = (FLAC__byte)(word >> 40); + val[3] = (FLAC__byte)(word >> 32); + val[4] = (FLAC__byte)(word >> 24); + val[5] = (FLAC__byte)(word >> 16); + val[6] = (FLAC__byte)(word >> 8); + val[7] = (FLAC__byte)word; +#else + for(x = 0; x < FLAC__BYTES_PER_WORD; x++) + val[x] = (FLAC__byte)(word >> (8*(FLAC__BYTES_PER_WORD-x-1))); +#endif + val += FLAC__BYTES_PER_WORD; + nvals -= FLAC__BYTES_PER_WORD; + if(br->read_limit_set) + br->read_limit -= FLAC__BITS_PER_WORD; + } + else if(!bitreader_read_from_client_(br)) + return false; + } + /* step 3: read any remainder from partial tail bytes */ + while(nvals) { + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + *val++ = (FLAC__byte)x; + nvals--; + } + + return true; +} + +FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val) +#if 0 /* slow but readable version */ +{ + uint32_t bit; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + *val = 0; + while(1) { + if(!FLAC__bitreader_read_bit(br, &bit)) + return false; + if(bit) + break; + else + *val++; + } + return true; +} +#else +{ + uint32_t i; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + *val = 0; + while(1) { + while(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */ + brword b = br->consumed_bits < FLAC__BITS_PER_WORD ? br->buffer[br->consumed_words] << br->consumed_bits : 0; + if(b) { + i = COUNT_ZERO_MSBS(b); + *val += i; + i++; + br->consumed_bits += i; + if(br->consumed_bits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(br->consumed_bits == FLAC__BITS_PER_WORD) */ + br->consumed_words++; + br->consumed_bits = 0; + } + return true; + } + else { + *val += FLAC__BITS_PER_WORD - br->consumed_bits; + br->consumed_words++; + br->consumed_bits = 0; + /* didn't find stop bit yet, have to keep going... */ + } + } + /* at this point we've eaten up all the whole words; have to try + * reading through any tail bytes before calling the read callback. + * this is a repeat of the above logic adjusted for the fact we + * don't have a whole word. note though if the client is feeding + * us data a byte at a time (unlikely), br->consumed_bits may not + * be zero. + */ + if(br->bytes*8 > br->consumed_bits) { + const uint32_t end = br->bytes * 8; + brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits; + if(b) { + i = COUNT_ZERO_MSBS(b); + *val += i; + i++; + br->consumed_bits += i; + FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD); + return true; + } + else { + *val += end - br->consumed_bits; + br->consumed_bits = end; + FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD); + /* didn't find stop bit yet, have to keep going... */ + } + } + if(!bitreader_read_from_client_(br)) + return false; + } +} +#endif + +#if 0 /* unused */ +FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter) +{ + FLAC__uint32 lsbs = 0, msbs = 0; + uint32_t uval; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + FLAC__ASSERT(parameter <= 31); + + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + + /* read the binary LSBs */ + if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter)) + return false; + + /* compose the value */ + uval = (msbs << parameter) | lsbs; + if(uval & 1) + *val = -((int)(uval >> 1)) - 1; + else + *val = (int)(uval >> 1); + + return true; +} +#endif + +/* this is by far the most heavily used reader call. it ain't pretty but it's fast */ +FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) +#include "deduplication/bitreader_read_rice_signed_block.c" + +#ifdef FLAC__BMI2_SUPPORTED +FLAC__SSE_TARGET("bmi2") +FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) +#include "deduplication/bitreader_read_rice_signed_block.c" +#endif + +#if 0 /* UNUSED */ +FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter) +{ + FLAC__uint32 lsbs = 0, msbs = 0; + uint32_t bit, uval, k; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + k = FLAC__bitmath_ilog2(parameter); + + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + + /* read the binary LSBs */ + if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k)) + return false; + + if(parameter == 1u<= d) { + if(!FLAC__bitreader_read_bit(br, &bit)) + return false; + lsbs <<= 1; + lsbs |= bit; + lsbs -= d; + } + /* compose the value */ + uval = msbs * parameter + lsbs; + } + + /* unfold uint32_t to signed */ + if(uval & 1) + *val = -((int)(uval >> 1)) - 1; + else + *val = (int)(uval >> 1); + + return true; +} + +FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter) +{ + FLAC__uint32 lsbs, msbs = 0; + uint32_t bit, k; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + + k = FLAC__bitmath_ilog2(parameter); + + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + + /* read the binary LSBs */ + if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k)) + return false; + + if(parameter == 1u<= d) { + if(!FLAC__bitreader_read_bit(br, &bit)) + return false; + lsbs <<= 1; + lsbs |= bit; + lsbs -= d; + } + /* compose the value */ + *val = msbs * parameter + lsbs; + } + + return true; +} +#endif /* UNUSED */ + +/* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */ +FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen) +{ + FLAC__uint32 v = 0; + FLAC__uint32 x; + uint32_t i; + + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + if(raw) + raw[(*rawlen)++] = (FLAC__byte)x; + if(!(x & 0x80)) { /* 0xxxxxxx */ + v = x; + i = 0; + } + else if((x & 0xE0) == 0xC0) { /* 110xxxxx */ + v = x & 0x1F; + i = 1; + } + else if((x & 0xF0) == 0xE0) { /* 1110xxxx */ + v = x & 0x0F; + i = 2; + } + else if((x & 0xF8) == 0xF0) { /* 11110xxx */ + v = x & 0x07; + i = 3; + } + else if((x & 0xFC) == 0xF8) { /* 111110xx */ + v = x & 0x03; + i = 4; + } + else if((x & 0xFE) == 0xFC) { /* 1111110x */ + v = x & 0x01; + i = 5; + } + else { + *val = 0xffffffff; + return true; + } + for( ; i; i--) { + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + if(raw) + raw[(*rawlen)++] = (FLAC__byte)x; + if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ + *val = 0xffffffff; + return true; + } + v <<= 6; + v |= (x & 0x3F); + } + *val = v; + return true; +} + +/* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */ +FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen) +{ + FLAC__uint64 v = 0; + FLAC__uint32 x; + uint32_t i; + + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + if(raw) + raw[(*rawlen)++] = (FLAC__byte)x; + if(!(x & 0x80)) { /* 0xxxxxxx */ + v = x; + i = 0; + } + else if((x & 0xE0) == 0xC0) { /* 110xxxxx */ + v = x & 0x1F; + i = 1; + } + else if((x & 0xF0) == 0xE0) { /* 1110xxxx */ + v = x & 0x0F; + i = 2; + } + else if((x & 0xF8) == 0xF0) { /* 11110xxx */ + v = x & 0x07; + i = 3; + } + else if((x & 0xFC) == 0xF8) { /* 111110xx */ + v = x & 0x03; + i = 4; + } + else if((x & 0xFE) == 0xFC) { /* 1111110x */ + v = x & 0x01; + i = 5; + } + else if(x == 0xFE) { /* 11111110 */ + v = 0; + i = 6; + } + else { + *val = FLAC__U64L(0xffffffffffffffff); + return true; + } + for( ; i; i--) { + if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) + return false; + if(raw) + raw[(*rawlen)++] = (FLAC__byte)x; + if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ + *val = FLAC__U64L(0xffffffffffffffff); + return true; + } + v <<= 6; + v |= (x & 0x3F); + } + *val = v; + return true; +} + +/* These functions are declared inline in this file but are also callable as + * externs from elsewhere. + * According to the C99 spec, section 6.7.4, simply providing a function + * prototype in a header file without 'inline' and making the function inline + * in this file should be sufficient. + * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To + * fix that we add extern declarations here. + */ +extern FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); +extern uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); +extern uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); +extern FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); diff --git a/packages/third-party/libFLAC/cpu.c b/packages/third-party/libFLAC/cpu.c new file mode 100644 index 00000000..da82ff9a --- /dev/null +++ b/packages/third-party/libFLAC/cpu.c @@ -0,0 +1,255 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "private/cpu.h" +#include "share/compat.h" +#include +#include + +#if defined _MSC_VER +#include /* for __cpuid() and _xgetbv() */ +#elif defined __GNUC__ && defined HAVE_CPUID_H +#include /* for __get_cpuid() and __get_cpuid_max() */ +#endif + +#ifndef NDEBUG +#include +#define dfprintf flac_fprintf +#else +/* This is bad practice, it should be a static void empty function */ +#define dfprintf(file, format, ...) +#endif + +#if defined(HAVE_SYS_AUXV_H) +#include +#endif + +#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN && !defined FLAC__NO_ASM + +/* these are flags in EDX of CPUID AX=00000001 */ +static const uint32_t FLAC__CPUINFO_X86_CPUID_CMOV = 0x00008000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_MMX = 0x00800000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE = 0x02000000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE2 = 0x04000000; + +/* these are flags in ECX of CPUID AX=00000001 */ +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE3 = 0x00000001; +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSSE3 = 0x00000200; +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE41 = 0x00080000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE42 = 0x00100000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_OSXSAVE = 0x08000000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX = 0x10000000; +static const uint32_t FLAC__CPUINFO_X86_CPUID_FMA = 0x00001000; + +/* these are flags in EBX of CPUID AX=00000007 */ +static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX2 = 0x00000020; +static const uint32_t FLAC__CPUINFO_X86_CPUID_BMI2 = 0x00000100; + +static uint32_t +cpu_xgetbv_x86(void) +{ +#if (defined _MSC_VER || defined __INTEL_COMPILER) && FLAC__AVX_SUPPORTED + return (uint32_t)_xgetbv(0); +#elif defined __GNUC__ + uint32_t lo, hi; + __asm__ volatile (".byte 0x0f, 0x01, 0xd0" : "=a"(lo), "=d"(hi) : "c" (0)); + return lo; +#else + return 0; +#endif +} + +static uint32_t +cpu_have_cpuid(void) +{ +#if defined FLAC__CPU_X86_64 || defined __i686__ || defined __SSE__ || (defined _M_IX86_FP && _M_IX86_FP > 0) + /* target CPU does have CPUID instruction */ + return 1; +#elif defined __GNUC__ && defined HAVE_CPUID_H + if (__get_cpuid_max(0, 0) != 0) + return 1; + else + return 0; +#elif defined _MSC_VER + FLAC__uint32 flags1, flags2; + __asm { + pushfd + pushfd + pop eax + mov flags1, eax + xor eax, 0x200000 + push eax + popfd + pushfd + pop eax + mov flags2, eax + popfd + } + if (((flags1^flags2) & 0x200000) != 0) + return 1; + else + return 0; +#else + return 0; +#endif +} + +static void +cpuinfo_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx) +{ +#if defined _MSC_VER + int cpuinfo[4]; + int ext = level & 0x80000000; + __cpuid(cpuinfo, ext); + if ((uint32_t)cpuinfo[0] >= level) { +#if FLAC__AVX_SUPPORTED + __cpuidex(cpuinfo, level, 0); /* for AVX2 detection */ +#else + __cpuid(cpuinfo, level); /* some old compilers don't support __cpuidex */ +#endif + *eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3]; + return; + } +#elif defined __GNUC__ && defined HAVE_CPUID_H + FLAC__uint32 ext = level & 0x80000000; + __cpuid(ext, *eax, *ebx, *ecx, *edx); + if (*eax >= level) { + __cpuid_count(level, 0, *eax, *ebx, *ecx, *edx); + return; + } +#endif + *eax = *ebx = *ecx = *edx = 0; +} + +#endif + +static void +x86_cpu_info (FLAC__CPUInfo *info) +{ +#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN && !defined FLAC__NO_ASM + FLAC__bool x86_osxsave = false; + FLAC__bool os_avx = false; + FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx; + + info->use_asm = true; /* we assume a minimum of 80386 */ + if (!cpu_have_cpuid()) + return; + + cpuinfo_x86(0, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); + info->x86.intel = (flags_ebx == 0x756E6547 && flags_edx == 0x49656E69 && flags_ecx == 0x6C65746E) ? true : false; /* GenuineIntel */ + cpuinfo_x86(1, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); + + info->x86.cmov = (flags_edx & FLAC__CPUINFO_X86_CPUID_CMOV ) ? true : false; + info->x86.mmx = (flags_edx & FLAC__CPUINFO_X86_CPUID_MMX ) ? true : false; + info->x86.sse = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE ) ? true : false; + info->x86.sse2 = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE2 ) ? true : false; + info->x86.sse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE3 ) ? true : false; + info->x86.ssse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSSE3) ? true : false; + info->x86.sse41 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE41) ? true : false; + info->x86.sse42 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE42) ? true : false; + + if (FLAC__AVX_SUPPORTED) { + x86_osxsave = (flags_ecx & FLAC__CPUINFO_X86_CPUID_OSXSAVE) ? true : false; + info->x86.avx = (flags_ecx & FLAC__CPUINFO_X86_CPUID_AVX ) ? true : false; + info->x86.fma = (flags_ecx & FLAC__CPUINFO_X86_CPUID_FMA ) ? true : false; + cpuinfo_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); + info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_AVX2 ) ? true : false; + info->x86.bmi2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_BMI2 ) ? true : false; + } + +#if defined FLAC__CPU_IA32 + dfprintf(stderr, "CPU info (IA-32):\n"); +#else + dfprintf(stderr, "CPU info (x86-64):\n"); +#endif + dfprintf(stderr, " CMOV ....... %c\n", info->x86.cmov ? 'Y' : 'n'); + dfprintf(stderr, " MMX ........ %c\n", info->x86.mmx ? 'Y' : 'n'); + dfprintf(stderr, " SSE ........ %c\n", info->x86.sse ? 'Y' : 'n'); + dfprintf(stderr, " SSE2 ....... %c\n", info->x86.sse2 ? 'Y' : 'n'); + dfprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n'); + dfprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n'); + dfprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n'); + dfprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n'); + + if (FLAC__AVX_SUPPORTED) { + dfprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n'); + dfprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n'); + dfprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n'); + dfprintf(stderr, " BMI2 ....... %c\n", info->x86.bmi2 ? 'Y' : 'n'); + } + + /* + * now have to check for OS support of AVX instructions + */ + if (FLAC__AVX_SUPPORTED && info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) { + os_avx = true; + } + if (os_avx) { + dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n'); + } + if (!os_avx) { + /* no OS AVX support */ + info->x86.avx = false; + info->x86.avx2 = false; + info->x86.fma = false; + } +#else + info->use_asm = false; +#endif +} + +void FLAC__cpu_info (FLAC__CPUInfo *info) +{ + memset(info, 0, sizeof(*info)); + +#ifdef FLAC__CPU_IA32 + info->type = FLAC__CPUINFO_TYPE_IA32; +#elif defined FLAC__CPU_X86_64 + info->type = FLAC__CPUINFO_TYPE_X86_64; +#else + info->type = FLAC__CPUINFO_TYPE_UNKNOWN; +#endif + + switch (info->type) { + case FLAC__CPUINFO_TYPE_IA32: /* fallthrough */ + case FLAC__CPUINFO_TYPE_X86_64: + x86_cpu_info (info); + break; + default: + info->use_asm = false; + break; + } +} diff --git a/packages/third-party/libFLAC/crc.c b/packages/third-party/libFLAC/crc.c new file mode 100644 index 00000000..bfe76464 --- /dev/null +++ b/packages/third-party/libFLAC/crc.c @@ -0,0 +1,436 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "private/crc.h" + +/* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ + +FLAC__uint8 const FLAC__crc8_table[256] = { + 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, + 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, + 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, + 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, + 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, + 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, + 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, + 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD, + 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, + 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, + 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, + 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, + 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, + 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A, + 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, + 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, + 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, + 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4, + 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, + 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4, + 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, + 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, + 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, + 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34, + 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, + 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63, + 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, + 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, + 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, + 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, + 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, + 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 +}; + +/* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */ + +FLAC__uint16 const FLAC__crc16_table[8][256] = { + { 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, + 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, + 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, + 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, + 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, + 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, + 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, + 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, + 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, + 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, + 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1, + 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, + 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151, + 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162, + 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, + 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, + 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312, + 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321, + 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, + 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, + 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1, + 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2, + 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, + 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381, + 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291, + 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, + 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, + 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1, + 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252, + 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, + 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, + 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 }, + + { 0x0000, 0x8603, 0x8c03, 0x0a00, 0x9803, 0x1e00, 0x1400, 0x9203, + 0xb003, 0x3600, 0x3c00, 0xba03, 0x2800, 0xae03, 0xa403, 0x2200, + 0xe003, 0x6600, 0x6c00, 0xea03, 0x7800, 0xfe03, 0xf403, 0x7200, + 0x5000, 0xd603, 0xdc03, 0x5a00, 0xc803, 0x4e00, 0x4400, 0xc203, + 0x4003, 0xc600, 0xcc00, 0x4a03, 0xd800, 0x5e03, 0x5403, 0xd200, + 0xf000, 0x7603, 0x7c03, 0xfa00, 0x6803, 0xee00, 0xe400, 0x6203, + 0xa000, 0x2603, 0x2c03, 0xaa00, 0x3803, 0xbe00, 0xb400, 0x3203, + 0x1003, 0x9600, 0x9c00, 0x1a03, 0x8800, 0x0e03, 0x0403, 0x8200, + 0x8006, 0x0605, 0x0c05, 0x8a06, 0x1805, 0x9e06, 0x9406, 0x1205, + 0x3005, 0xb606, 0xbc06, 0x3a05, 0xa806, 0x2e05, 0x2405, 0xa206, + 0x6005, 0xe606, 0xec06, 0x6a05, 0xf806, 0x7e05, 0x7405, 0xf206, + 0xd006, 0x5605, 0x5c05, 0xda06, 0x4805, 0xce06, 0xc406, 0x4205, + 0xc005, 0x4606, 0x4c06, 0xca05, 0x5806, 0xde05, 0xd405, 0x5206, + 0x7006, 0xf605, 0xfc05, 0x7a06, 0xe805, 0x6e06, 0x6406, 0xe205, + 0x2006, 0xa605, 0xac05, 0x2a06, 0xb805, 0x3e06, 0x3406, 0xb205, + 0x9005, 0x1606, 0x1c06, 0x9a05, 0x0806, 0x8e05, 0x8405, 0x0206, + 0x8009, 0x060a, 0x0c0a, 0x8a09, 0x180a, 0x9e09, 0x9409, 0x120a, + 0x300a, 0xb609, 0xbc09, 0x3a0a, 0xa809, 0x2e0a, 0x240a, 0xa209, + 0x600a, 0xe609, 0xec09, 0x6a0a, 0xf809, 0x7e0a, 0x740a, 0xf209, + 0xd009, 0x560a, 0x5c0a, 0xda09, 0x480a, 0xce09, 0xc409, 0x420a, + 0xc00a, 0x4609, 0x4c09, 0xca0a, 0x5809, 0xde0a, 0xd40a, 0x5209, + 0x7009, 0xf60a, 0xfc0a, 0x7a09, 0xe80a, 0x6e09, 0x6409, 0xe20a, + 0x2009, 0xa60a, 0xac0a, 0x2a09, 0xb80a, 0x3e09, 0x3409, 0xb20a, + 0x900a, 0x1609, 0x1c09, 0x9a0a, 0x0809, 0x8e0a, 0x840a, 0x0209, + 0x000f, 0x860c, 0x8c0c, 0x0a0f, 0x980c, 0x1e0f, 0x140f, 0x920c, + 0xb00c, 0x360f, 0x3c0f, 0xba0c, 0x280f, 0xae0c, 0xa40c, 0x220f, + 0xe00c, 0x660f, 0x6c0f, 0xea0c, 0x780f, 0xfe0c, 0xf40c, 0x720f, + 0x500f, 0xd60c, 0xdc0c, 0x5a0f, 0xc80c, 0x4e0f, 0x440f, 0xc20c, + 0x400c, 0xc60f, 0xcc0f, 0x4a0c, 0xd80f, 0x5e0c, 0x540c, 0xd20f, + 0xf00f, 0x760c, 0x7c0c, 0xfa0f, 0x680c, 0xee0f, 0xe40f, 0x620c, + 0xa00f, 0x260c, 0x2c0c, 0xaa0f, 0x380c, 0xbe0f, 0xb40f, 0x320c, + 0x100c, 0x960f, 0x9c0f, 0x1a0c, 0x880f, 0x0e0c, 0x040c, 0x820f }, + + { 0x0000, 0x8017, 0x802b, 0x003c, 0x8053, 0x0044, 0x0078, 0x806f, + 0x80a3, 0x00b4, 0x0088, 0x809f, 0x00f0, 0x80e7, 0x80db, 0x00cc, + 0x8143, 0x0154, 0x0168, 0x817f, 0x0110, 0x8107, 0x813b, 0x012c, + 0x01e0, 0x81f7, 0x81cb, 0x01dc, 0x81b3, 0x01a4, 0x0198, 0x818f, + 0x8283, 0x0294, 0x02a8, 0x82bf, 0x02d0, 0x82c7, 0x82fb, 0x02ec, + 0x0220, 0x8237, 0x820b, 0x021c, 0x8273, 0x0264, 0x0258, 0x824f, + 0x03c0, 0x83d7, 0x83eb, 0x03fc, 0x8393, 0x0384, 0x03b8, 0x83af, + 0x8363, 0x0374, 0x0348, 0x835f, 0x0330, 0x8327, 0x831b, 0x030c, + 0x8503, 0x0514, 0x0528, 0x853f, 0x0550, 0x8547, 0x857b, 0x056c, + 0x05a0, 0x85b7, 0x858b, 0x059c, 0x85f3, 0x05e4, 0x05d8, 0x85cf, + 0x0440, 0x8457, 0x846b, 0x047c, 0x8413, 0x0404, 0x0438, 0x842f, + 0x84e3, 0x04f4, 0x04c8, 0x84df, 0x04b0, 0x84a7, 0x849b, 0x048c, + 0x0780, 0x8797, 0x87ab, 0x07bc, 0x87d3, 0x07c4, 0x07f8, 0x87ef, + 0x8723, 0x0734, 0x0708, 0x871f, 0x0770, 0x8767, 0x875b, 0x074c, + 0x86c3, 0x06d4, 0x06e8, 0x86ff, 0x0690, 0x8687, 0x86bb, 0x06ac, + 0x0660, 0x8677, 0x864b, 0x065c, 0x8633, 0x0624, 0x0618, 0x860f, + 0x8a03, 0x0a14, 0x0a28, 0x8a3f, 0x0a50, 0x8a47, 0x8a7b, 0x0a6c, + 0x0aa0, 0x8ab7, 0x8a8b, 0x0a9c, 0x8af3, 0x0ae4, 0x0ad8, 0x8acf, + 0x0b40, 0x8b57, 0x8b6b, 0x0b7c, 0x8b13, 0x0b04, 0x0b38, 0x8b2f, + 0x8be3, 0x0bf4, 0x0bc8, 0x8bdf, 0x0bb0, 0x8ba7, 0x8b9b, 0x0b8c, + 0x0880, 0x8897, 0x88ab, 0x08bc, 0x88d3, 0x08c4, 0x08f8, 0x88ef, + 0x8823, 0x0834, 0x0808, 0x881f, 0x0870, 0x8867, 0x885b, 0x084c, + 0x89c3, 0x09d4, 0x09e8, 0x89ff, 0x0990, 0x8987, 0x89bb, 0x09ac, + 0x0960, 0x8977, 0x894b, 0x095c, 0x8933, 0x0924, 0x0918, 0x890f, + 0x0f00, 0x8f17, 0x8f2b, 0x0f3c, 0x8f53, 0x0f44, 0x0f78, 0x8f6f, + 0x8fa3, 0x0fb4, 0x0f88, 0x8f9f, 0x0ff0, 0x8fe7, 0x8fdb, 0x0fcc, + 0x8e43, 0x0e54, 0x0e68, 0x8e7f, 0x0e10, 0x8e07, 0x8e3b, 0x0e2c, + 0x0ee0, 0x8ef7, 0x8ecb, 0x0edc, 0x8eb3, 0x0ea4, 0x0e98, 0x8e8f, + 0x8d83, 0x0d94, 0x0da8, 0x8dbf, 0x0dd0, 0x8dc7, 0x8dfb, 0x0dec, + 0x0d20, 0x8d37, 0x8d0b, 0x0d1c, 0x8d73, 0x0d64, 0x0d58, 0x8d4f, + 0x0cc0, 0x8cd7, 0x8ceb, 0x0cfc, 0x8c93, 0x0c84, 0x0cb8, 0x8caf, + 0x8c63, 0x0c74, 0x0c48, 0x8c5f, 0x0c30, 0x8c27, 0x8c1b, 0x0c0c }, + + { 0x0000, 0x9403, 0xa803, 0x3c00, 0xd003, 0x4400, 0x7800, 0xec03, + 0x2003, 0xb400, 0x8800, 0x1c03, 0xf000, 0x6403, 0x5803, 0xcc00, + 0x4006, 0xd405, 0xe805, 0x7c06, 0x9005, 0x0406, 0x3806, 0xac05, + 0x6005, 0xf406, 0xc806, 0x5c05, 0xb006, 0x2405, 0x1805, 0x8c06, + 0x800c, 0x140f, 0x280f, 0xbc0c, 0x500f, 0xc40c, 0xf80c, 0x6c0f, + 0xa00f, 0x340c, 0x080c, 0x9c0f, 0x700c, 0xe40f, 0xd80f, 0x4c0c, + 0xc00a, 0x5409, 0x6809, 0xfc0a, 0x1009, 0x840a, 0xb80a, 0x2c09, + 0xe009, 0x740a, 0x480a, 0xdc09, 0x300a, 0xa409, 0x9809, 0x0c0a, + 0x801d, 0x141e, 0x281e, 0xbc1d, 0x501e, 0xc41d, 0xf81d, 0x6c1e, + 0xa01e, 0x341d, 0x081d, 0x9c1e, 0x701d, 0xe41e, 0xd81e, 0x4c1d, + 0xc01b, 0x5418, 0x6818, 0xfc1b, 0x1018, 0x841b, 0xb81b, 0x2c18, + 0xe018, 0x741b, 0x481b, 0xdc18, 0x301b, 0xa418, 0x9818, 0x0c1b, + 0x0011, 0x9412, 0xa812, 0x3c11, 0xd012, 0x4411, 0x7811, 0xec12, + 0x2012, 0xb411, 0x8811, 0x1c12, 0xf011, 0x6412, 0x5812, 0xcc11, + 0x4017, 0xd414, 0xe814, 0x7c17, 0x9014, 0x0417, 0x3817, 0xac14, + 0x6014, 0xf417, 0xc817, 0x5c14, 0xb017, 0x2414, 0x1814, 0x8c17, + 0x803f, 0x143c, 0x283c, 0xbc3f, 0x503c, 0xc43f, 0xf83f, 0x6c3c, + 0xa03c, 0x343f, 0x083f, 0x9c3c, 0x703f, 0xe43c, 0xd83c, 0x4c3f, + 0xc039, 0x543a, 0x683a, 0xfc39, 0x103a, 0x8439, 0xb839, 0x2c3a, + 0xe03a, 0x7439, 0x4839, 0xdc3a, 0x3039, 0xa43a, 0x983a, 0x0c39, + 0x0033, 0x9430, 0xa830, 0x3c33, 0xd030, 0x4433, 0x7833, 0xec30, + 0x2030, 0xb433, 0x8833, 0x1c30, 0xf033, 0x6430, 0x5830, 0xcc33, + 0x4035, 0xd436, 0xe836, 0x7c35, 0x9036, 0x0435, 0x3835, 0xac36, + 0x6036, 0xf435, 0xc835, 0x5c36, 0xb035, 0x2436, 0x1836, 0x8c35, + 0x0022, 0x9421, 0xa821, 0x3c22, 0xd021, 0x4422, 0x7822, 0xec21, + 0x2021, 0xb422, 0x8822, 0x1c21, 0xf022, 0x6421, 0x5821, 0xcc22, + 0x4024, 0xd427, 0xe827, 0x7c24, 0x9027, 0x0424, 0x3824, 0xac27, + 0x6027, 0xf424, 0xc824, 0x5c27, 0xb024, 0x2427, 0x1827, 0x8c24, + 0x802e, 0x142d, 0x282d, 0xbc2e, 0x502d, 0xc42e, 0xf82e, 0x6c2d, + 0xa02d, 0x342e, 0x082e, 0x9c2d, 0x702e, 0xe42d, 0xd82d, 0x4c2e, + 0xc028, 0x542b, 0x682b, 0xfc28, 0x102b, 0x8428, 0xb828, 0x2c2b, + 0xe02b, 0x7428, 0x4828, 0xdc2b, 0x3028, 0xa42b, 0x982b, 0x0c28 }, + + { 0x0000, 0x807b, 0x80f3, 0x0088, 0x81e3, 0x0198, 0x0110, 0x816b, + 0x83c3, 0x03b8, 0x0330, 0x834b, 0x0220, 0x825b, 0x82d3, 0x02a8, + 0x8783, 0x07f8, 0x0770, 0x870b, 0x0660, 0x861b, 0x8693, 0x06e8, + 0x0440, 0x843b, 0x84b3, 0x04c8, 0x85a3, 0x05d8, 0x0550, 0x852b, + 0x8f03, 0x0f78, 0x0ff0, 0x8f8b, 0x0ee0, 0x8e9b, 0x8e13, 0x0e68, + 0x0cc0, 0x8cbb, 0x8c33, 0x0c48, 0x8d23, 0x0d58, 0x0dd0, 0x8dab, + 0x0880, 0x88fb, 0x8873, 0x0808, 0x8963, 0x0918, 0x0990, 0x89eb, + 0x8b43, 0x0b38, 0x0bb0, 0x8bcb, 0x0aa0, 0x8adb, 0x8a53, 0x0a28, + 0x9e03, 0x1e78, 0x1ef0, 0x9e8b, 0x1fe0, 0x9f9b, 0x9f13, 0x1f68, + 0x1dc0, 0x9dbb, 0x9d33, 0x1d48, 0x9c23, 0x1c58, 0x1cd0, 0x9cab, + 0x1980, 0x99fb, 0x9973, 0x1908, 0x9863, 0x1818, 0x1890, 0x98eb, + 0x9a43, 0x1a38, 0x1ab0, 0x9acb, 0x1ba0, 0x9bdb, 0x9b53, 0x1b28, + 0x1100, 0x917b, 0x91f3, 0x1188, 0x90e3, 0x1098, 0x1010, 0x906b, + 0x92c3, 0x12b8, 0x1230, 0x924b, 0x1320, 0x935b, 0x93d3, 0x13a8, + 0x9683, 0x16f8, 0x1670, 0x960b, 0x1760, 0x971b, 0x9793, 0x17e8, + 0x1540, 0x953b, 0x95b3, 0x15c8, 0x94a3, 0x14d8, 0x1450, 0x942b, + 0xbc03, 0x3c78, 0x3cf0, 0xbc8b, 0x3de0, 0xbd9b, 0xbd13, 0x3d68, + 0x3fc0, 0xbfbb, 0xbf33, 0x3f48, 0xbe23, 0x3e58, 0x3ed0, 0xbeab, + 0x3b80, 0xbbfb, 0xbb73, 0x3b08, 0xba63, 0x3a18, 0x3a90, 0xbaeb, + 0xb843, 0x3838, 0x38b0, 0xb8cb, 0x39a0, 0xb9db, 0xb953, 0x3928, + 0x3300, 0xb37b, 0xb3f3, 0x3388, 0xb2e3, 0x3298, 0x3210, 0xb26b, + 0xb0c3, 0x30b8, 0x3030, 0xb04b, 0x3120, 0xb15b, 0xb1d3, 0x31a8, + 0xb483, 0x34f8, 0x3470, 0xb40b, 0x3560, 0xb51b, 0xb593, 0x35e8, + 0x3740, 0xb73b, 0xb7b3, 0x37c8, 0xb6a3, 0x36d8, 0x3650, 0xb62b, + 0x2200, 0xa27b, 0xa2f3, 0x2288, 0xa3e3, 0x2398, 0x2310, 0xa36b, + 0xa1c3, 0x21b8, 0x2130, 0xa14b, 0x2020, 0xa05b, 0xa0d3, 0x20a8, + 0xa583, 0x25f8, 0x2570, 0xa50b, 0x2460, 0xa41b, 0xa493, 0x24e8, + 0x2640, 0xa63b, 0xa6b3, 0x26c8, 0xa7a3, 0x27d8, 0x2750, 0xa72b, + 0xad03, 0x2d78, 0x2df0, 0xad8b, 0x2ce0, 0xac9b, 0xac13, 0x2c68, + 0x2ec0, 0xaebb, 0xae33, 0x2e48, 0xaf23, 0x2f58, 0x2fd0, 0xafab, + 0x2a80, 0xaafb, 0xaa73, 0x2a08, 0xab63, 0x2b18, 0x2b90, 0xabeb, + 0xa943, 0x2938, 0x29b0, 0xa9cb, 0x28a0, 0xa8db, 0xa853, 0x2828 }, + + { 0x0000, 0xf803, 0x7003, 0x8800, 0xe006, 0x1805, 0x9005, 0x6806, + 0x4009, 0xb80a, 0x300a, 0xc809, 0xa00f, 0x580c, 0xd00c, 0x280f, + 0x8012, 0x7811, 0xf011, 0x0812, 0x6014, 0x9817, 0x1017, 0xe814, + 0xc01b, 0x3818, 0xb018, 0x481b, 0x201d, 0xd81e, 0x501e, 0xa81d, + 0x8021, 0x7822, 0xf022, 0x0821, 0x6027, 0x9824, 0x1024, 0xe827, + 0xc028, 0x382b, 0xb02b, 0x4828, 0x202e, 0xd82d, 0x502d, 0xa82e, + 0x0033, 0xf830, 0x7030, 0x8833, 0xe035, 0x1836, 0x9036, 0x6835, + 0x403a, 0xb839, 0x3039, 0xc83a, 0xa03c, 0x583f, 0xd03f, 0x283c, + 0x8047, 0x7844, 0xf044, 0x0847, 0x6041, 0x9842, 0x1042, 0xe841, + 0xc04e, 0x384d, 0xb04d, 0x484e, 0x2048, 0xd84b, 0x504b, 0xa848, + 0x0055, 0xf856, 0x7056, 0x8855, 0xe053, 0x1850, 0x9050, 0x6853, + 0x405c, 0xb85f, 0x305f, 0xc85c, 0xa05a, 0x5859, 0xd059, 0x285a, + 0x0066, 0xf865, 0x7065, 0x8866, 0xe060, 0x1863, 0x9063, 0x6860, + 0x406f, 0xb86c, 0x306c, 0xc86f, 0xa069, 0x586a, 0xd06a, 0x2869, + 0x8074, 0x7877, 0xf077, 0x0874, 0x6072, 0x9871, 0x1071, 0xe872, + 0xc07d, 0x387e, 0xb07e, 0x487d, 0x207b, 0xd878, 0x5078, 0xa87b, + 0x808b, 0x7888, 0xf088, 0x088b, 0x608d, 0x988e, 0x108e, 0xe88d, + 0xc082, 0x3881, 0xb081, 0x4882, 0x2084, 0xd887, 0x5087, 0xa884, + 0x0099, 0xf89a, 0x709a, 0x8899, 0xe09f, 0x189c, 0x909c, 0x689f, + 0x4090, 0xb893, 0x3093, 0xc890, 0xa096, 0x5895, 0xd095, 0x2896, + 0x00aa, 0xf8a9, 0x70a9, 0x88aa, 0xe0ac, 0x18af, 0x90af, 0x68ac, + 0x40a3, 0xb8a0, 0x30a0, 0xc8a3, 0xa0a5, 0x58a6, 0xd0a6, 0x28a5, + 0x80b8, 0x78bb, 0xf0bb, 0x08b8, 0x60be, 0x98bd, 0x10bd, 0xe8be, + 0xc0b1, 0x38b2, 0xb0b2, 0x48b1, 0x20b7, 0xd8b4, 0x50b4, 0xa8b7, + 0x00cc, 0xf8cf, 0x70cf, 0x88cc, 0xe0ca, 0x18c9, 0x90c9, 0x68ca, + 0x40c5, 0xb8c6, 0x30c6, 0xc8c5, 0xa0c3, 0x58c0, 0xd0c0, 0x28c3, + 0x80de, 0x78dd, 0xf0dd, 0x08de, 0x60d8, 0x98db, 0x10db, 0xe8d8, + 0xc0d7, 0x38d4, 0xb0d4, 0x48d7, 0x20d1, 0xd8d2, 0x50d2, 0xa8d1, + 0x80ed, 0x78ee, 0xf0ee, 0x08ed, 0x60eb, 0x98e8, 0x10e8, 0xe8eb, + 0xc0e4, 0x38e7, 0xb0e7, 0x48e4, 0x20e2, 0xd8e1, 0x50e1, 0xa8e2, + 0x00ff, 0xf8fc, 0x70fc, 0x88ff, 0xe0f9, 0x18fa, 0x90fa, 0x68f9, + 0x40f6, 0xb8f5, 0x30f5, 0xc8f6, 0xa0f0, 0x58f3, 0xd0f3, 0x28f0 }, + + { 0x0000, 0x8113, 0x8223, 0x0330, 0x8443, 0x0550, 0x0660, 0x8773, + 0x8883, 0x0990, 0x0aa0, 0x8bb3, 0x0cc0, 0x8dd3, 0x8ee3, 0x0ff0, + 0x9103, 0x1010, 0x1320, 0x9233, 0x1540, 0x9453, 0x9763, 0x1670, + 0x1980, 0x9893, 0x9ba3, 0x1ab0, 0x9dc3, 0x1cd0, 0x1fe0, 0x9ef3, + 0xa203, 0x2310, 0x2020, 0xa133, 0x2640, 0xa753, 0xa463, 0x2570, + 0x2a80, 0xab93, 0xa8a3, 0x29b0, 0xaec3, 0x2fd0, 0x2ce0, 0xadf3, + 0x3300, 0xb213, 0xb123, 0x3030, 0xb743, 0x3650, 0x3560, 0xb473, + 0xbb83, 0x3a90, 0x39a0, 0xb8b3, 0x3fc0, 0xbed3, 0xbde3, 0x3cf0, + 0xc403, 0x4510, 0x4620, 0xc733, 0x4040, 0xc153, 0xc263, 0x4370, + 0x4c80, 0xcd93, 0xcea3, 0x4fb0, 0xc8c3, 0x49d0, 0x4ae0, 0xcbf3, + 0x5500, 0xd413, 0xd723, 0x5630, 0xd143, 0x5050, 0x5360, 0xd273, + 0xdd83, 0x5c90, 0x5fa0, 0xdeb3, 0x59c0, 0xd8d3, 0xdbe3, 0x5af0, + 0x6600, 0xe713, 0xe423, 0x6530, 0xe243, 0x6350, 0x6060, 0xe173, + 0xee83, 0x6f90, 0x6ca0, 0xedb3, 0x6ac0, 0xebd3, 0xe8e3, 0x69f0, + 0xf703, 0x7610, 0x7520, 0xf433, 0x7340, 0xf253, 0xf163, 0x7070, + 0x7f80, 0xfe93, 0xfda3, 0x7cb0, 0xfbc3, 0x7ad0, 0x79e0, 0xf8f3, + 0x0803, 0x8910, 0x8a20, 0x0b33, 0x8c40, 0x0d53, 0x0e63, 0x8f70, + 0x8080, 0x0193, 0x02a3, 0x83b0, 0x04c3, 0x85d0, 0x86e0, 0x07f3, + 0x9900, 0x1813, 0x1b23, 0x9a30, 0x1d43, 0x9c50, 0x9f60, 0x1e73, + 0x1183, 0x9090, 0x93a0, 0x12b3, 0x95c0, 0x14d3, 0x17e3, 0x96f0, + 0xaa00, 0x2b13, 0x2823, 0xa930, 0x2e43, 0xaf50, 0xac60, 0x2d73, + 0x2283, 0xa390, 0xa0a0, 0x21b3, 0xa6c0, 0x27d3, 0x24e3, 0xa5f0, + 0x3b03, 0xba10, 0xb920, 0x3833, 0xbf40, 0x3e53, 0x3d63, 0xbc70, + 0xb380, 0x3293, 0x31a3, 0xb0b0, 0x37c3, 0xb6d0, 0xb5e0, 0x34f3, + 0xcc00, 0x4d13, 0x4e23, 0xcf30, 0x4843, 0xc950, 0xca60, 0x4b73, + 0x4483, 0xc590, 0xc6a0, 0x47b3, 0xc0c0, 0x41d3, 0x42e3, 0xc3f0, + 0x5d03, 0xdc10, 0xdf20, 0x5e33, 0xd940, 0x5853, 0x5b63, 0xda70, + 0xd580, 0x5493, 0x57a3, 0xd6b0, 0x51c3, 0xd0d0, 0xd3e0, 0x52f3, + 0x6e03, 0xef10, 0xec20, 0x6d33, 0xea40, 0x6b53, 0x6863, 0xe970, + 0xe680, 0x6793, 0x64a3, 0xe5b0, 0x62c3, 0xe3d0, 0xe0e0, 0x61f3, + 0xff00, 0x7e13, 0x7d23, 0xfc30, 0x7b43, 0xfa50, 0xf960, 0x7873, + 0x7783, 0xf690, 0xf5a0, 0x74b3, 0xf3c0, 0x72d3, 0x71e3, 0xf0f0 }, + + { 0x0000, 0x1006, 0x200c, 0x300a, 0x4018, 0x501e, 0x6014, 0x7012, + 0x8030, 0x9036, 0xa03c, 0xb03a, 0xc028, 0xd02e, 0xe024, 0xf022, + 0x8065, 0x9063, 0xa069, 0xb06f, 0xc07d, 0xd07b, 0xe071, 0xf077, + 0x0055, 0x1053, 0x2059, 0x305f, 0x404d, 0x504b, 0x6041, 0x7047, + 0x80cf, 0x90c9, 0xa0c3, 0xb0c5, 0xc0d7, 0xd0d1, 0xe0db, 0xf0dd, + 0x00ff, 0x10f9, 0x20f3, 0x30f5, 0x40e7, 0x50e1, 0x60eb, 0x70ed, + 0x00aa, 0x10ac, 0x20a6, 0x30a0, 0x40b2, 0x50b4, 0x60be, 0x70b8, + 0x809a, 0x909c, 0xa096, 0xb090, 0xc082, 0xd084, 0xe08e, 0xf088, + 0x819b, 0x919d, 0xa197, 0xb191, 0xc183, 0xd185, 0xe18f, 0xf189, + 0x01ab, 0x11ad, 0x21a7, 0x31a1, 0x41b3, 0x51b5, 0x61bf, 0x71b9, + 0x01fe, 0x11f8, 0x21f2, 0x31f4, 0x41e6, 0x51e0, 0x61ea, 0x71ec, + 0x81ce, 0x91c8, 0xa1c2, 0xb1c4, 0xc1d6, 0xd1d0, 0xe1da, 0xf1dc, + 0x0154, 0x1152, 0x2158, 0x315e, 0x414c, 0x514a, 0x6140, 0x7146, + 0x8164, 0x9162, 0xa168, 0xb16e, 0xc17c, 0xd17a, 0xe170, 0xf176, + 0x8131, 0x9137, 0xa13d, 0xb13b, 0xc129, 0xd12f, 0xe125, 0xf123, + 0x0101, 0x1107, 0x210d, 0x310b, 0x4119, 0x511f, 0x6115, 0x7113, + 0x8333, 0x9335, 0xa33f, 0xb339, 0xc32b, 0xd32d, 0xe327, 0xf321, + 0x0303, 0x1305, 0x230f, 0x3309, 0x431b, 0x531d, 0x6317, 0x7311, + 0x0356, 0x1350, 0x235a, 0x335c, 0x434e, 0x5348, 0x6342, 0x7344, + 0x8366, 0x9360, 0xa36a, 0xb36c, 0xc37e, 0xd378, 0xe372, 0xf374, + 0x03fc, 0x13fa, 0x23f0, 0x33f6, 0x43e4, 0x53e2, 0x63e8, 0x73ee, + 0x83cc, 0x93ca, 0xa3c0, 0xb3c6, 0xc3d4, 0xd3d2, 0xe3d8, 0xf3de, + 0x8399, 0x939f, 0xa395, 0xb393, 0xc381, 0xd387, 0xe38d, 0xf38b, + 0x03a9, 0x13af, 0x23a5, 0x33a3, 0x43b1, 0x53b7, 0x63bd, 0x73bb, + 0x02a8, 0x12ae, 0x22a4, 0x32a2, 0x42b0, 0x52b6, 0x62bc, 0x72ba, + 0x8298, 0x929e, 0xa294, 0xb292, 0xc280, 0xd286, 0xe28c, 0xf28a, + 0x82cd, 0x92cb, 0xa2c1, 0xb2c7, 0xc2d5, 0xd2d3, 0xe2d9, 0xf2df, + 0x02fd, 0x12fb, 0x22f1, 0x32f7, 0x42e5, 0x52e3, 0x62e9, 0x72ef, + 0x8267, 0x9261, 0xa26b, 0xb26d, 0xc27f, 0xd279, 0xe273, 0xf275, + 0x0257, 0x1251, 0x225b, 0x325d, 0x424f, 0x5249, 0x6243, 0x7245, + 0x0202, 0x1204, 0x220e, 0x3208, 0x421a, 0x521c, 0x6216, 0x7210, + 0x8232, 0x9234, 0xa23e, 0xb238, 0xc22a, 0xd22c, 0xe226, 0xf220 } +}; + +#if 0 +void FLAC__crc16_init_table(void) +{ + int i, j; + FLAC__uint16 polynomial, crc; + polynomial = 0x8005; + + for(i = 0; i <= 0xFF; i++){ + crc = i << 8; + + for(j = 0; j < 8; j++) + crc = (crc << 1) ^ (crc & (1 << 15) ? polynomial : 0); + + FLAC__crc16_table[0][i] = crc; + } + + for(i = 0; i <= 0xFF; i++) + for(j = 1; j < 8; j++) + FLAC__crc16_table[j][i] = FLAC__crc16_table[0][FLAC__crc16_table[j - 1][i] >> 8] ^ (FLAC__crc16_table[j - 1][i] << 8); +} +#endif + +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len) +{ + FLAC__uint8 crc = 0; + + while(len--) + crc = FLAC__crc8_table[crc ^ *data++]; + + return crc; +} + +FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len) +{ + FLAC__uint16 crc = 0; + + while(len >= 8){ + crc ^= data[0] << 8 | data[1]; + + crc = FLAC__crc16_table[7][crc >> 8] ^ FLAC__crc16_table[6][crc & 0xFF] ^ + FLAC__crc16_table[5][data[2] ] ^ FLAC__crc16_table[4][data[3] ] ^ + FLAC__crc16_table[3][data[4] ] ^ FLAC__crc16_table[2][data[5] ] ^ + FLAC__crc16_table[1][data[6] ] ^ FLAC__crc16_table[0][data[7] ]; + + data += 8; + len -= 8; + } + + while(len--) + crc = (crc<<8) ^ FLAC__crc16_table[0][(crc>>8) ^ *data++]; + + return crc; +} + +FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc) +{ + while (len >= 2) { + crc ^= words[0] >> 16; + + crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^ + FLAC__crc16_table[5][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[4][ words[0] & 0xFF] ^ + FLAC__crc16_table[3][ words[1] >> 24 ] ^ FLAC__crc16_table[2][(words[1] >> 16) & 0xFF] ^ + FLAC__crc16_table[1][(words[1] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[1] & 0xFF]; + + words += 2; + len -= 2; + } + + if (len) { + crc ^= words[0] >> 16; + + crc = FLAC__crc16_table[3][crc >> 8 ] ^ FLAC__crc16_table[2][crc & 0xFF ] ^ + FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][words[0] & 0xFF]; + } + + return crc; +} + +FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc) +{ + while (len--) { + crc ^= words[0] >> 48; + + crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^ + FLAC__crc16_table[5][(words[0] >> 40) & 0xFF] ^ FLAC__crc16_table[4][(words[0] >> 32) & 0xFF] ^ + FLAC__crc16_table[3][(words[0] >> 24) & 0xFF] ^ FLAC__crc16_table[2][(words[0] >> 16) & 0xFF] ^ + FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[0] & 0xFF]; + + words++; + } + + return crc; +} diff --git a/packages/third-party/libFLAC/deduplication/bitreader_read_rice_signed_block.c b/packages/third-party/libFLAC/deduplication/bitreader_read_rice_signed_block.c new file mode 100644 index 00000000..75ed47f7 --- /dev/null +++ b/packages/third-party/libFLAC/deduplication/bitreader_read_rice_signed_block.c @@ -0,0 +1,143 @@ +{ + /* try and get br->consumed_words and br->consumed_bits into register; + * must remember to flush them back to *br before calling other + * bitreader functions that use them, and before returning */ + uint32_t cwords, words, lsbs, msbs, x, y, limit; + uint32_t ucbits; /* keep track of the number of unconsumed bits in word */ + brword b; + int *val, *end; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ + FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); + FLAC__ASSERT(parameter < 32); + /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ + + limit = UINT32_MAX >> parameter; /* Maximal msbs that can occur with residual bounded to int32_t */ + + val = vals; + end = vals + nvals; + + if(parameter == 0) { + while(val < end) { + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + /* Checking limit here would be overzealous: coding UINT32_MAX + * with parameter == 0 would take 4GiB */ + *val++ = (int)(msbs >> 1) ^ -(int)(msbs & 1); + } + + return true; + } + + FLAC__ASSERT(parameter > 0); + + cwords = br->consumed_words; + words = br->words; + + /* if we've not consumed up to a partial tail word... */ + if(cwords >= words) { + x = 0; + goto process_tail; + } + + ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; + b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */ + + while(val < end) { + /* read the unary MSBs and end bit */ + x = y = COUNT_ZERO_MSBS2(b); + if(x == FLAC__BITS_PER_WORD) { + x = ucbits; + do { + /* didn't find stop bit yet, have to keep going... */ + cwords++; + if (cwords >= words) + goto incomplete_msbs; + b = br->buffer[cwords]; + y = COUNT_ZERO_MSBS2(b); + x += y; + } while(y == FLAC__BITS_PER_WORD); + } + b <<= y; + b <<= 1; /* account for stop bit */ + ucbits = (ucbits - x - 1) % FLAC__BITS_PER_WORD; + msbs = x; + + if(x > limit) + return false; + + /* read the binary LSBs */ + x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */ + if(parameter <= ucbits) { + ucbits -= parameter; + b <<= parameter; + } else { + /* there are still bits left to read, they will all be in the next word */ + cwords++; + if (cwords >= words) + goto incomplete_lsbs; + b = br->buffer[cwords]; + ucbits += FLAC__BITS_PER_WORD - parameter; + x |= (FLAC__uint32)(b >> ucbits); + b <<= FLAC__BITS_PER_WORD - ucbits; + } + lsbs = x; + + /* compose the value */ + x = (msbs << parameter) | lsbs; + *val++ = (int)(x >> 1) ^ -(int)(x & 1); + + continue; + + /* at this point we've eaten up all the whole words */ +process_tail: + do { + if(0) { +incomplete_msbs: + br->consumed_bits = 0; + br->consumed_words = cwords; + } + + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + msbs += x; + x = ucbits = 0; + + if(0) { +incomplete_lsbs: + br->consumed_bits = 0; + br->consumed_words = cwords; + } + + /* read the binary LSBs */ + if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter - ucbits)) + return false; + lsbs = x | lsbs; + + /* compose the value */ + x = (msbs << parameter) | lsbs; + *val++ = (int)(x >> 1) ^ -(int)(x & 1); + x = 0; + + cwords = br->consumed_words; + words = br->words; + ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; + b = cwords < br->capacity ? br->buffer[cwords] << br->consumed_bits : 0; + } while(cwords >= words && val < end); + } + + if(ucbits == 0 && cwords < words) { + /* don't leave the head word with no unconsumed bits */ + cwords++; + ucbits = FLAC__BITS_PER_WORD; + } + + br->consumed_bits = FLAC__BITS_PER_WORD - ucbits; + br->consumed_words = cwords; + + return true; +} diff --git a/packages/third-party/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c b/packages/third-party/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c new file mode 100644 index 00000000..76419db0 --- /dev/null +++ b/packages/third-party/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c @@ -0,0 +1,14 @@ + int i, j; + (void) lag; + FLAC__ASSERT(lag <= MAX_LAG); + + for(i = 0; i < MAX_LAG; i++) + autoc[i] = 0.0; + + for(i = 0; i < MAX_LAG; i++) + for(j = 0; j <= i; j++) + autoc[j] += (double)data[i] * (double)data[i-j]; + + for(i = MAX_LAG; i < (int)data_len; i++) + for(j = 0; j < MAX_LAG; j++) + autoc[j] += (double)data[i] * (double)data[i-j]; diff --git a/packages/third-party/libFLAC/fixed.c b/packages/third-party/libFLAC/fixed.c new file mode 100644 index 00000000..7fbc818d --- /dev/null +++ b/packages/third-party/libFLAC/fixed.c @@ -0,0 +1,667 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include "share/compat.h" +#include "private/bitmath.h" +#include "private/fixed.h" +#include "private/macros.h" +#include "FLAC/assert.h" + +#ifdef local_abs +#undef local_abs +#endif +#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) + +#ifdef local_abs64 +#undef local_abs64 +#endif +#define local_abs64(x) ((uint64_t)((x)<0? -(x) : (x))) + +#ifdef FLAC__INTEGER_ONLY_LIBRARY +/* rbps stands for residual bits per sample + * + * (ln(2) * err) + * rbps = log (-----------) + * 2 ( n ) + */ +static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n) +{ + FLAC__uint32 rbps; + uint32_t bits; /* the number of bits required to represent a number */ + int fracbits; /* the number of bits of rbps that comprise the fractional part */ + + FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); + FLAC__ASSERT(err > 0); + FLAC__ASSERT(n > 0); + + FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE); + if(err <= n) + return 0; + /* + * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. + * These allow us later to know we won't lose too much precision in the + * fixed-point division (err< 0); + bits = FLAC__bitmath_ilog2(err)+1; + if(bits > 16) { + err >>= (bits-16); + fracbits -= (bits-16); + } + rbps = (FLAC__uint32)err; + + /* Multiply by fixed-point version of ln(2), with 16 fractional bits */ + rbps *= FLAC__FP_LN2; + fracbits += 16; + FLAC__ASSERT(fracbits >= 0); + + /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */ + { + const int f = fracbits & 3; + if(f) { + rbps >>= f; + fracbits -= f; + } + } + + rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); + + if(rbps == 0) + return 0; + + /* + * The return value must have 16 fractional bits. Since the whole part + * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits + * must be >= -3, these assertion allows us to be able to shift rbps + * left if necessary to get 16 fracbits without losing any bits of the + * whole part of rbps. + * + * There is a slight chance due to accumulated error that the whole part + * will require 6 bits, so we use 6 in the assertion. Really though as + * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. + */ + FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); + FLAC__ASSERT(fracbits >= -3); + + /* now shift the decimal point into place */ + if(fracbits < 16) + return rbps << (16-fracbits); + else if(fracbits > 16) + return rbps >> (fracbits-16); + else + return rbps; +} + +static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n) +{ + FLAC__uint32 rbps; + uint32_t bits; /* the number of bits required to represent a number */ + int fracbits; /* the number of bits of rbps that comprise the fractional part */ + + FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); + FLAC__ASSERT(err > 0); + FLAC__ASSERT(n > 0); + + FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE); + if(err <= n) + return 0; + /* + * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. + * These allow us later to know we won't lose too much precision in the + * fixed-point division (err< 0); + bits = FLAC__bitmath_ilog2_wide(err)+1; + if(bits > 16) { + err >>= (bits-16); + fracbits -= (bits-16); + } + rbps = (FLAC__uint32)err; + + /* Multiply by fixed-point version of ln(2), with 16 fractional bits */ + rbps *= FLAC__FP_LN2; + fracbits += 16; + FLAC__ASSERT(fracbits >= 0); + + /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */ + { + const int f = fracbits & 3; + if(f) { + rbps >>= f; + fracbits -= f; + } + } + + rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); + + if(rbps == 0) + return 0; + + /* + * The return value must have 16 fractional bits. Since the whole part + * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits + * must be >= -3, these assertion allows us to be able to shift rbps + * left if necessary to get 16 fracbits without losing any bits of the + * whole part of rbps. + * + * There is a slight chance due to accumulated error that the whole part + * will require 6 bits, so we use 6 in the assertion. Really though as + * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. + */ + FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); + FLAC__ASSERT(fracbits >= -3); + + /* now shift the decimal point into place */ + if(fracbits < 16) + return rbps << (16-fracbits); + else if(fracbits > 16) + return rbps >> (fracbits-16); + else + return rbps; +} +#endif + +#ifndef FLAC__INTEGER_ONLY_LIBRARY +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#else +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#endif +{ + FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; + uint32_t order; +#if 0 + /* This code has been around a long time, and was written when compilers weren't able + * to vectorize code. These days, compilers are better in optimizing the next block + * which is also much more readable + */ + FLAC__int32 last_error_0 = data[-1]; + FLAC__int32 last_error_1 = data[-1] - data[-2]; + FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); + FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); + FLAC__int32 error, save; + uint32_t i; + /* total_error_* are 64-bits to avoid overflow when encoding + * erratic signals when the bits-per-sample and blocksize are + * large. + */ + for(i = 0; i < data_len; i++) { + error = data[i] ; total_error_0 += local_abs(error); save = error; + error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error; + error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error; + error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error; + error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; + } +#else + int i; + for(i = 0; i < (int)data_len; i++) { + total_error_0 += local_abs(data[i]); + total_error_1 += local_abs(data[i] - data[i-1]); + total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]); + total_error_3 += local_abs(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]); + total_error_4 += local_abs(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]); + } +#endif + + + /* prefer lower order */ + if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) + order = 0; + else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) + order = 1; + else if(total_error_2 <= flac_min(total_error_3, total_error_4)) + order = 2; + else if(total_error_3 <= total_error_4) + order = 3; + else + order = 4; + + /* Estimate the expected number of bits per residual signal sample. */ + /* 'total_error*' is linearly related to the variance of the residual */ + /* signal, so we use it directly to compute E(|x|) */ + FLAC__ASSERT(data_len > 0 || total_error_0 == 0); + FLAC__ASSERT(data_len > 0 || total_error_1 == 0); + FLAC__ASSERT(data_len > 0 || total_error_2 == 0); + FLAC__ASSERT(data_len > 0 || total_error_3 == 0); + FLAC__ASSERT(data_len > 0 || total_error_4 == 0); +#ifndef FLAC__INTEGER_ONLY_LIBRARY + residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); +#else + residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_integerized(total_error_0, data_len) : 0; + residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_integerized(total_error_1, data_len) : 0; + residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_integerized(total_error_2, data_len) : 0; + residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_integerized(total_error_3, data_len) : 0; + residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_integerized(total_error_4, data_len) : 0; +#endif + + return order; +} + +#ifndef FLAC__INTEGER_ONLY_LIBRARY +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#else +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#endif +{ + FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; + uint32_t order; + int i; + + for(i = 0; i < (int)data_len; i++) { + total_error_0 += local_abs(data[i]); + total_error_1 += local_abs(data[i] - data[i-1]); + total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]); + total_error_3 += local_abs(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]); + total_error_4 += local_abs(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]); + } + + /* prefer lower order */ + if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) + order = 0; + else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) + order = 1; + else if(total_error_2 <= flac_min(total_error_3, total_error_4)) + order = 2; + else if(total_error_3 <= total_error_4) + order = 3; + else + order = 4; + + /* Estimate the expected number of bits per residual signal sample. */ + /* 'total_error*' is linearly related to the variance of the residual */ + /* signal, so we use it directly to compute E(|x|) */ + FLAC__ASSERT(data_len > 0 || total_error_0 == 0); + FLAC__ASSERT(data_len > 0 || total_error_1 == 0); + FLAC__ASSERT(data_len > 0 || total_error_2 == 0); + FLAC__ASSERT(data_len > 0 || total_error_3 == 0); + FLAC__ASSERT(data_len > 0 || total_error_4 == 0); +#ifndef FLAC__INTEGER_ONLY_LIBRARY + residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); + residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); +#else + residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_wide_integerized(total_error_0, data_len) : 0; + residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_wide_integerized(total_error_1, data_len) : 0; + residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_wide_integerized(total_error_2, data_len) : 0; + residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_wide_integerized(total_error_3, data_len) : 0; + residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_wide_integerized(total_error_4, data_len) : 0; +#endif + + return order; +} + +#ifndef FLAC__INTEGER_ONLY_LIBRARY +#define CHECK_ORDER_IS_VALID(macro_order) \ +if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \ + order = macro_order; \ + smallest_error = total_error_##macro_order ; \ + residual_bits_per_sample[ macro_order ] = (float)((total_error_##macro_order > 0) ? log(M_LN2 * (double)total_error_##macro_order / (double)data_len) / M_LN2 : 0.0); \ +} \ +else \ + residual_bits_per_sample[ macro_order ] = 34.0f; +#else +#define CHECK_ORDER_IS_VALID(macro_order) \ +if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \ + order = macro_order; \ + smallest_error = total_error_##macro_order ; \ + residual_bits_per_sample[ macro_order ] = (total_error_##macro_order > 0) ? local__compute_rbps_wide_integerized(total_error_##macro_order, data_len) : 0; \ +} \ +else \ + residual_bits_per_sample[ macro_order ] = 34 * FLAC__FP_ONE; +#endif + + +#ifndef FLAC__INTEGER_ONLY_LIBRARY +uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#else +uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#endif +{ + FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; + FLAC__uint64 error_0, error_1, error_2, error_3, error_4; + FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true; + uint32_t order = 0; + int i; + + for(i = -4; i < (int)data_len; i++) { + error_0 = local_abs64((FLAC__int64)data[i]); + error_1 = (i > -4) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ; + error_2 = (i > -3) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0; + error_3 = (i > -2) ? local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]) : 0; + error_4 = (i > -1) ? local_abs64((FLAC__int64)data[i] - 4 * (FLAC__int64)data[i-1] + 6 * (FLAC__int64)data[i-2] - 4 * (FLAC__int64)data[i-3] + data[i-4]) : 0; + + total_error_0 += error_0; + total_error_1 += error_1; + total_error_2 += error_2; + total_error_3 += error_3; + total_error_4 += error_4; + + /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ + if(error_0 > INT32_MAX) + order_0_is_valid = false; + if(error_1 > INT32_MAX) + order_1_is_valid = false; + if(error_2 > INT32_MAX) + order_2_is_valid = false; + if(error_3 > INT32_MAX) + order_3_is_valid = false; + if(error_4 > INT32_MAX) + order_4_is_valid = false; + } + + CHECK_ORDER_IS_VALID(0); + CHECK_ORDER_IS_VALID(1); + CHECK_ORDER_IS_VALID(2); + CHECK_ORDER_IS_VALID(3); + CHECK_ORDER_IS_VALID(4); + + return order; +} + +#ifndef FLAC__INTEGER_ONLY_LIBRARY +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#else +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +#endif +{ + FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; + FLAC__uint64 error_0, error_1, error_2, error_3, error_4; + FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true; + uint32_t order = 0; + int i; + + for(i = -4; i < (int)data_len; i++) { + error_0 = local_abs64(data[i]); + error_1 = (i > -4) ? local_abs64(data[i] - data[i-1]) : 0 ; + error_2 = (i > -3) ? local_abs64(data[i] - 2 * data[i-1] + data[i-2]) : 0; + error_3 = (i > -2) ? local_abs64(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]) : 0; + error_4 = (i > -1) ? local_abs64(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]) : 0; + + total_error_0 += error_0; + total_error_1 += error_1; + total_error_2 += error_2; + total_error_3 += error_3; + total_error_4 += error_4; + + /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ + if(error_0 > INT32_MAX) + order_0_is_valid = false; + if(error_1 > INT32_MAX) + order_1_is_valid = false; + if(error_2 > INT32_MAX) + order_2_is_valid = false; + if(error_3 > INT32_MAX) + order_3_is_valid = false; + if(error_4 > INT32_MAX) + order_4_is_valid = false; + } + + CHECK_ORDER_IS_VALID(0); + CHECK_ORDER_IS_VALID(1); + CHECK_ORDER_IS_VALID(2); + CHECK_ORDER_IS_VALID(3); + CHECK_ORDER_IS_VALID(4); + + return order; +} + +void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) +{ + const int idata_len = (int)data_len; + int i; + + switch(order) { + case 0: + FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); + memcpy(residual, data, sizeof(residual[0])*data_len); + break; + case 1: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 2*data[i-1] + data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} + +void FLAC__fixed_compute_residual_wide(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) +{ + const int idata_len = (int)data_len; + int i; + + switch(order) { + case 0: + FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); + memcpy(residual, data, sizeof(residual[0])*data_len); + break; + case 1: + for(i = 0; i < idata_len; i++) + residual[i] = (FLAC__int64)data[i] - data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + residual[i] = (FLAC__int64)data[i] - 2*(FLAC__int64)data[i-1] + data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + residual[i] = (FLAC__int64)data[i] - 3*(FLAC__int64)data[i-1] + 3*(FLAC__int64)data[i-2] - data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + residual[i] = (FLAC__int64)data[i] - 4*(FLAC__int64)data[i-1] + 6*(FLAC__int64)data[i-2] - 4*(FLAC__int64)data[i-3] + data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} + +void FLAC__fixed_compute_residual_wide_33bit(const FLAC__int64 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) +{ + const int idata_len = (int)data_len; + int i; + + switch(order) { + case 0: + for(i = 0; i < idata_len; i++) + residual[i] = data[i]; + break; + case 1: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 2*data[i-1] + data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} + +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) +/* The attribute below is to silence the undefined sanitizer of oss-fuzz. + * Because fuzzing feeds bogus predictors and residual samples to the + * decoder, having overflows in this section is unavoidable. Also, + * because the calculated values are audio path only, there is no + * potential for security problems */ +__attribute__((no_sanitize("signed-integer-overflow"))) +#endif +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]) +{ + int i, idata_len = (int)data_len; + + switch(order) { + case 0: + FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); + memcpy(data, residual, sizeof(residual[0])*data_len); + break; + case 1: + for(i = 0; i < idata_len; i++) + data[i] = residual[i] + data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + data[i] = residual[i] + 2*data[i-1] - data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} + +void FLAC__fixed_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]) +{ + int i, idata_len = (int)data_len; + + switch(order) { + case 0: + FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); + memcpy(data, residual, sizeof(residual[0])*data_len); + break; + case 1: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + (FLAC__int64)data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 2*(FLAC__int64)data[i-1] - (FLAC__int64)data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 3*(FLAC__int64)data[i-1] - 3*(FLAC__int64)data[i-2] + (FLAC__int64)data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 4*(FLAC__int64)data[i-1] - 6*(FLAC__int64)data[i-2] + 4*(FLAC__int64)data[i-3] - (FLAC__int64)data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} + +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) +/* The attribute below is to silence the undefined sanitizer of oss-fuzz. + * Because fuzzing feeds bogus predictors and residual samples to the + * decoder, having overflows in this section is unavoidable. Also, + * because the calculated values are audio path only, there is no + * potential for security problems */ +__attribute__((no_sanitize("signed-integer-overflow"))) +#endif +void FLAC__fixed_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int64 data[]) +{ + int i, idata_len = (int)data_len; + + switch(order) { + case 0: + for(i = 0; i < idata_len; i++) + data[i] = residual[i]; + break; + case 1: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + data[i-1]; + break; + case 2: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 2*data[i-1] - data[i-2]; + break; + case 3: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3]; + break; + case 4: + for(i = 0; i < idata_len; i++) + data[i] = (FLAC__int64)residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4]; + break; + default: + FLAC__ASSERT(0); + } +} diff --git a/packages/third-party/libFLAC/float.c b/packages/third-party/libFLAC/float.c new file mode 100644 index 00000000..3140456e --- /dev/null +++ b/packages/third-party/libFLAC/float.c @@ -0,0 +1,302 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "FLAC/assert.h" +#include "share/compat.h" +#include "private/float.h" + +#ifdef FLAC__INTEGER_ONLY_LIBRARY + +const FLAC__fixedpoint FLAC__FP_ZERO = 0; +const FLAC__fixedpoint FLAC__FP_ONE_HALF = 0x00008000; +const FLAC__fixedpoint FLAC__FP_ONE = 0x00010000; +const FLAC__fixedpoint FLAC__FP_LN2 = 45426; +const FLAC__fixedpoint FLAC__FP_E = 178145; + +/* Lookup tables for Knuth's logarithm algorithm */ +#define LOG2_LOOKUP_PRECISION 16 +static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = { + { + /* + * 0 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00000001, + /* lg(4/3) = */ 0x00000000, + /* lg(8/7) = */ 0x00000000, + /* lg(16/15) = */ 0x00000000, + /* lg(32/31) = */ 0x00000000, + /* lg(64/63) = */ 0x00000000, + /* lg(128/127) = */ 0x00000000, + /* lg(256/255) = */ 0x00000000, + /* lg(512/511) = */ 0x00000000, + /* lg(1024/1023) = */ 0x00000000, + /* lg(2048/2047) = */ 0x00000000, + /* lg(4096/4095) = */ 0x00000000, + /* lg(8192/8191) = */ 0x00000000, + /* lg(16384/16383) = */ 0x00000000, + /* lg(32768/32767) = */ 0x00000000 + }, + { + /* + * 4 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00000010, + /* lg(4/3) = */ 0x00000007, + /* lg(8/7) = */ 0x00000003, + /* lg(16/15) = */ 0x00000001, + /* lg(32/31) = */ 0x00000001, + /* lg(64/63) = */ 0x00000000, + /* lg(128/127) = */ 0x00000000, + /* lg(256/255) = */ 0x00000000, + /* lg(512/511) = */ 0x00000000, + /* lg(1024/1023) = */ 0x00000000, + /* lg(2048/2047) = */ 0x00000000, + /* lg(4096/4095) = */ 0x00000000, + /* lg(8192/8191) = */ 0x00000000, + /* lg(16384/16383) = */ 0x00000000, + /* lg(32768/32767) = */ 0x00000000 + }, + { + /* + * 8 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00000100, + /* lg(4/3) = */ 0x0000006a, + /* lg(8/7) = */ 0x00000031, + /* lg(16/15) = */ 0x00000018, + /* lg(32/31) = */ 0x0000000c, + /* lg(64/63) = */ 0x00000006, + /* lg(128/127) = */ 0x00000003, + /* lg(256/255) = */ 0x00000001, + /* lg(512/511) = */ 0x00000001, + /* lg(1024/1023) = */ 0x00000000, + /* lg(2048/2047) = */ 0x00000000, + /* lg(4096/4095) = */ 0x00000000, + /* lg(8192/8191) = */ 0x00000000, + /* lg(16384/16383) = */ 0x00000000, + /* lg(32768/32767) = */ 0x00000000 + }, + { + /* + * 12 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00001000, + /* lg(4/3) = */ 0x000006a4, + /* lg(8/7) = */ 0x00000315, + /* lg(16/15) = */ 0x0000017d, + /* lg(32/31) = */ 0x000000bc, + /* lg(64/63) = */ 0x0000005d, + /* lg(128/127) = */ 0x0000002e, + /* lg(256/255) = */ 0x00000017, + /* lg(512/511) = */ 0x0000000c, + /* lg(1024/1023) = */ 0x00000006, + /* lg(2048/2047) = */ 0x00000003, + /* lg(4096/4095) = */ 0x00000001, + /* lg(8192/8191) = */ 0x00000001, + /* lg(16384/16383) = */ 0x00000000, + /* lg(32768/32767) = */ 0x00000000 + }, + { + /* + * 16 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00010000, + /* lg(4/3) = */ 0x00006a40, + /* lg(8/7) = */ 0x00003151, + /* lg(16/15) = */ 0x000017d6, + /* lg(32/31) = */ 0x00000bba, + /* lg(64/63) = */ 0x000005d1, + /* lg(128/127) = */ 0x000002e6, + /* lg(256/255) = */ 0x00000172, + /* lg(512/511) = */ 0x000000b9, + /* lg(1024/1023) = */ 0x0000005c, + /* lg(2048/2047) = */ 0x0000002e, + /* lg(4096/4095) = */ 0x00000017, + /* lg(8192/8191) = */ 0x0000000c, + /* lg(16384/16383) = */ 0x00000006, + /* lg(32768/32767) = */ 0x00000003 + }, + { + /* + * 20 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x00100000, + /* lg(4/3) = */ 0x0006a3fe, + /* lg(8/7) = */ 0x00031513, + /* lg(16/15) = */ 0x00017d60, + /* lg(32/31) = */ 0x0000bb9d, + /* lg(64/63) = */ 0x00005d10, + /* lg(128/127) = */ 0x00002e59, + /* lg(256/255) = */ 0x00001721, + /* lg(512/511) = */ 0x00000b8e, + /* lg(1024/1023) = */ 0x000005c6, + /* lg(2048/2047) = */ 0x000002e3, + /* lg(4096/4095) = */ 0x00000171, + /* lg(8192/8191) = */ 0x000000b9, + /* lg(16384/16383) = */ 0x0000005c, + /* lg(32768/32767) = */ 0x0000002e + }, + { + /* + * 24 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x01000000, + /* lg(4/3) = */ 0x006a3fe6, + /* lg(8/7) = */ 0x00315130, + /* lg(16/15) = */ 0x0017d605, + /* lg(32/31) = */ 0x000bb9ca, + /* lg(64/63) = */ 0x0005d0fc, + /* lg(128/127) = */ 0x0002e58f, + /* lg(256/255) = */ 0x0001720e, + /* lg(512/511) = */ 0x0000b8d8, + /* lg(1024/1023) = */ 0x00005c61, + /* lg(2048/2047) = */ 0x00002e2d, + /* lg(4096/4095) = */ 0x00001716, + /* lg(8192/8191) = */ 0x00000b8b, + /* lg(16384/16383) = */ 0x000005c5, + /* lg(32768/32767) = */ 0x000002e3 + }, + { + /* + * 28 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ 0x10000000, + /* lg(4/3) = */ 0x06a3fe5c, + /* lg(8/7) = */ 0x03151301, + /* lg(16/15) = */ 0x017d6049, + /* lg(32/31) = */ 0x00bb9ca6, + /* lg(64/63) = */ 0x005d0fba, + /* lg(128/127) = */ 0x002e58f7, + /* lg(256/255) = */ 0x001720da, + /* lg(512/511) = */ 0x000b8d87, + /* lg(1024/1023) = */ 0x0005c60b, + /* lg(2048/2047) = */ 0x0002e2d7, + /* lg(4096/4095) = */ 0x00017160, + /* lg(8192/8191) = */ 0x0000b8ad, + /* lg(16384/16383) = */ 0x00005c56, + /* lg(32768/32767) = */ 0x00002e2b + } +}; + +#if 0 +static const FLAC__uint64 log2_lookup_wide[] = { + { + /* + * 32 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ FLAC__U64L(0x100000000), + /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c6), + /* lg(8/7) = */ FLAC__U64L(0x31513015), + /* lg(16/15) = */ FLAC__U64L(0x17d60497), + /* lg(32/31) = */ FLAC__U64L(0x0bb9ca65), + /* lg(64/63) = */ FLAC__U64L(0x05d0fba2), + /* lg(128/127) = */ FLAC__U64L(0x02e58f74), + /* lg(256/255) = */ FLAC__U64L(0x01720d9c), + /* lg(512/511) = */ FLAC__U64L(0x00b8d875), + /* lg(1024/1023) = */ FLAC__U64L(0x005c60aa), + /* lg(2048/2047) = */ FLAC__U64L(0x002e2d72), + /* lg(4096/4095) = */ FLAC__U64L(0x00171600), + /* lg(8192/8191) = */ FLAC__U64L(0x000b8ad2), + /* lg(16384/16383) = */ FLAC__U64L(0x0005c55d), + /* lg(32768/32767) = */ FLAC__U64L(0x0002e2ac) + }, + { + /* + * 48 fraction bits + */ + /* undefined */ 0x00000000, + /* lg(2/1) = */ FLAC__U64L(0x1000000000000), + /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c60429), + /* lg(8/7) = */ FLAC__U64L(0x315130157f7a), + /* lg(16/15) = */ FLAC__U64L(0x17d60496cfbb), + /* lg(32/31) = */ FLAC__U64L(0xbb9ca64ecac), + /* lg(64/63) = */ FLAC__U64L(0x5d0fba187cd), + /* lg(128/127) = */ FLAC__U64L(0x2e58f7441ee), + /* lg(256/255) = */ FLAC__U64L(0x1720d9c06a8), + /* lg(512/511) = */ FLAC__U64L(0xb8d8752173), + /* lg(1024/1023) = */ FLAC__U64L(0x5c60aa252e), + /* lg(2048/2047) = */ FLAC__U64L(0x2e2d71b0d8), + /* lg(4096/4095) = */ FLAC__U64L(0x1716001719), + /* lg(8192/8191) = */ FLAC__U64L(0xb8ad1de1b), + /* lg(16384/16383) = */ FLAC__U64L(0x5c55d640d), + /* lg(32768/32767) = */ FLAC__U64L(0x2e2abcf52) + } +}; +#endif + +FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision) +{ + const FLAC__uint32 ONE = (1u << fracbits); + const FLAC__uint32 *table = log2_lookup[fracbits >> 2]; + + FLAC__ASSERT(fracbits < 32); + FLAC__ASSERT((fracbits & 0x3) == 0); + + if(x < ONE) + return 0; + + if(precision > LOG2_LOOKUP_PRECISION) + precision = LOG2_LOOKUP_PRECISION; + + /* Knuth's algorithm for computing logarithms, optimized for base-2 with lookup tables */ + { + FLAC__uint32 y = 0; + FLAC__uint32 z = x >> 1, k = 1; + while (x > ONE && k < precision) { + if (x - z >= ONE) { + x -= z; + z = x >> k; + y += table[k]; + } + else { + z >>= 1; + k++; + } + } + return y; + } +} + +#endif /* defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/packages/third-party/libFLAC/format.c b/packages/third-party/libFLAC/format.c new file mode 100644 index 00000000..19da3cc9 --- /dev/null +++ b/packages/third-party/libFLAC/format.c @@ -0,0 +1,608 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include /* for qsort() */ +#include /* for memset() */ +#include "FLAC/assert.h" +#include "FLAC/format.h" +#include "share/alloc.h" +#include "share/compat.h" +#include "private/format.h" +#include "private/macros.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +FLAC_API const char *FLAC__VERSION_STRING = GIT_COMMIT_TAG; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " GIT_COMMIT_TAG " " GIT_COMMIT_DATE; +# else +FLAC_API const char *FLAC__VERSION_STRING = "git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE; +# endif +#else +/* PACKAGE_VERSION should come from configure */ +FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20230623"; +#endif + +FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; +FLAC_API const uint32_t FLAC__STREAM_SYNC = 0x664C6143; +FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */ + +FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff); + +FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */ + +FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC = 0x3ffe; +FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */ + +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */ + +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1< FLAC__MAX_SAMPLE_RATE) { + return false; + } + else + return true; +} + +FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate) +{ + if(blocksize > 16384) + return false; + else if(sample_rate <= 48000 && blocksize > 4608) + return false; + else + return true; +} + +FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate) +{ + if( // sample rate is not subset if + !FLAC__format_sample_rate_is_valid(sample_rate) || // sample rate is invalid or + sample_rate >= ((1u << 16) * 10) || // sample rate is larger then or equal to 655360 or + (sample_rate >= (1u << 16) && sample_rate % 10 != 0) //sample rate is >= 65536 and not divisible by 10 + ) { + return false; + } + else + return true; +} + +/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ +FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table) +{ + uint32_t i; + FLAC__uint64 prev_sample_number = 0; + FLAC__bool got_prev = false; + + FLAC__ASSERT(0 != seek_table); + + if((FLAC__uint64)(seek_table->num_points) * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) + return false; + + for(i = 0; i < seek_table->num_points; i++) { + if(got_prev) { + if( + seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && + seek_table->points[i].sample_number <= prev_sample_number + ) + return false; + } + prev_sample_number = seek_table->points[i].sample_number; + got_prev = true; + } + + return true; +} + +/* used as the sort predicate for qsort() */ +static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r) +{ + /* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */ + if(l->sample_number == r->sample_number) + return 0; + else if(l->sample_number < r->sample_number) + return -1; + else + return 1; +} + +/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ +FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table) +{ + uint32_t i, j; + FLAC__bool first; + + FLAC__ASSERT(0 != seek_table); + + if (seek_table->num_points == 0) + return 0; + + /* sort the seekpoints */ + qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_); + + /* uniquify the seekpoints */ + first = true; + for(i = j = 0; i < seek_table->num_points; i++) { + if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) { + if(!first) { + if(seek_table->points[i].sample_number == seek_table->points[j-1].sample_number) + continue; + } + } + first = false; + seek_table->points[j++] = seek_table->points[i]; + } + + for(i = j; i < seek_table->num_points; i++) { + seek_table->points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; + seek_table->points[i].stream_offset = 0; + seek_table->points[i].frame_samples = 0; + } + + return j; +} + +/* + * also disallows non-shortest-form encodings, c.f. + * http://www.unicode.org/versions/corrigendum1.html + * and a more clear explanation at the end of this section: + * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + */ +static uint32_t utf8len_(const FLAC__byte *utf8) +{ + FLAC__ASSERT(0 != utf8); + if ((utf8[0] & 0x80) == 0) { + return 1; + } + else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) { + if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */ + return 0; + return 2; + } + else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) { + if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */ + return 0; + /* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */ + if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */ + return 0; + if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */ + return 0; + return 3; + } + else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) { + if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */ + return 0; + return 4; + } + else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) { + if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */ + return 0; + return 5; + } + else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) { + if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */ + return 0; + return 6; + } + else { + return 0; + } +} + +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name) +{ + char c; + for(c = *name; c; c = *(++name)) + if(c < 0x20 || c == 0x3d || c > 0x7d) + return false; + return true; +} + +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length) +{ + if(length == (uint32_t)(-1)) { + while(*value) { + uint32_t n = utf8len_(value); + if(n == 0) + return false; + value += n; + } + } + else { + const FLAC__byte *end = value + length; + while(value < end) { + uint32_t n = utf8len_(value); + if(n == 0) + return false; + value += n; + } + if(value != end) + return false; + } + return true; +} + +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length) +{ + const FLAC__byte *s, *end; + + for(s = entry, end = s + length; s < end && *s != '='; s++) { + if(*s < 0x20 || *s > 0x7D) + return false; + } + if(s == end) + return false; + + s++; /* skip '=' */ + + while(s < end) { + uint32_t n = utf8len_(s); + if(n == 0) + return false; + s += n; + } + if(s != end) + return false; + + return true; +} + +/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ +FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation) +{ + uint32_t i, j; + + if(check_cd_da_subset) { + if(cue_sheet->lead_in < 2 * 44100) { + if(violation) *violation = "CD-DA cue sheet must have a lead-in length of at least 2 seconds"; + return false; + } + if(cue_sheet->lead_in % 588 != 0) { + if(violation) *violation = "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples"; + return false; + } + } + + if(cue_sheet->num_tracks == 0) { + if(violation) *violation = "cue sheet must have at least one track (the lead-out)"; + return false; + } + + if(check_cd_da_subset && cue_sheet->tracks[cue_sheet->num_tracks-1].number != 170) { + if(violation) *violation = "CD-DA cue sheet must have a lead-out track number 170 (0xAA)"; + return false; + } + + for(i = 0; i < cue_sheet->num_tracks; i++) { + if(cue_sheet->tracks[i].number == 0) { + if(violation) *violation = "cue sheet may not have a track number 0"; + return false; + } + + if(check_cd_da_subset) { + if(!((cue_sheet->tracks[i].number >= 1 && cue_sheet->tracks[i].number <= 99) || cue_sheet->tracks[i].number == 170)) { + if(violation) *violation = "CD-DA cue sheet track number must be 1-99 or 170"; + return false; + } + } + + if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) { + if(violation) { + if(i == cue_sheet->num_tracks-1) /* the lead-out track... */ + *violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples"; + else + *violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples"; + } + return false; + } + + if(i < cue_sheet->num_tracks - 1) { + if(cue_sheet->tracks[i].num_indices == 0) { + if(violation) *violation = "cue sheet track must have at least one index point"; + return false; + } + + if(cue_sheet->tracks[i].indices[0].number > 1) { + if(violation) *violation = "cue sheet track's first index number must be 0 or 1"; + return false; + } + } + + for(j = 0; j < cue_sheet->tracks[i].num_indices; j++) { + if(check_cd_da_subset && cue_sheet->tracks[i].indices[j].offset % 588 != 0) { + if(violation) *violation = "CD-DA cue sheet track index offset must be evenly divisible by 588 samples"; + return false; + } + + if(j > 0) { + if(cue_sheet->tracks[i].indices[j].number != cue_sheet->tracks[i].indices[j-1].number + 1) { + if(violation) *violation = "cue sheet track index numbers must increase by 1"; + return false; + } + } + } + } + + return true; +} + +/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ +FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation) +{ + char *p; + FLAC__byte *b; + + for(p = picture->mime_type; *p; p++) { + if(*p < 0x20 || *p > 0x7e) { + if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)"; + return false; + } + } + + for(b = picture->description; *b; ) { + uint32_t n = utf8len_(b); + if(n == 0) { + if(violation) *violation = "description string must be valid UTF-8"; + return false; + } + b += n; + } + + return true; +} + +/* + * These routines are private to libFLAC + */ +#if 0 /* UNUSED */ +uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order) +{ + return + FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order( + FLAC__format_get_max_rice_partition_order_from_blocksize(blocksize), + blocksize, + predictor_order + ); +} +#endif + +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize) +{ + uint32_t max_rice_partition_order = 0; + while(!(blocksize & 1)) { + max_rice_partition_order++; + blocksize >>= 1; + } + return flac_min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order); +} + +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order) +{ + uint32_t max_rice_partition_order = limit; + + while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order) + max_rice_partition_order--; + + FLAC__ASSERT( + (max_rice_partition_order == 0 && blocksize >= predictor_order) || + (max_rice_partition_order > 0 && blocksize >> max_rice_partition_order > predictor_order) + ); + + return max_rice_partition_order; +} + +void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object) +{ + FLAC__ASSERT(0 != object); + + object->parameters = 0; + object->raw_bits = 0; + object->capacity_by_order = 0; +} + +void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object) +{ + FLAC__ASSERT(0 != object); + + if(0 != object->parameters) + free(object->parameters); + if(0 != object->raw_bits) + free(object->raw_bits); + FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object); +} + +#if defined(_MSC_VER) +// silence three MSVC warnings 'result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)' +#pragma warning ( disable : 4334 ) +#endif + +FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order) +{ + FLAC__ASSERT(0 != object); + + if(object->capacity_by_order < max_partition_order || object->parameters == NULL || object->raw_bits == NULL) { + if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order)))) + return false; + if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order)))) + return false; + memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order)); + object->capacity_by_order = max_partition_order; + } + + return true; +} + +#if defined(_MSC_VER) +#pragma warning ( default : 4334 ) +#endif diff --git a/packages/third-party/libFLAC/lpc.c b/packages/third-party/libFLAC/lpc.c new file mode 100644 index 00000000..6c5ff222 --- /dev/null +++ b/packages/third-party/libFLAC/lpc.c @@ -0,0 +1,1633 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include "FLAC/assert.h" +#include "FLAC/format.h" +#include "share/compat.h" +#include "private/bitmath.h" +#include "private/lpc.h" +#include "private/macros.h" + +#if !defined(NDEBUG) || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE +#include +#endif + +#define HAVE_LROUND +/* OPT: #undef'ing this may improve the speed on some architectures */ +#define FLAC__LPC_UNROLLED_FILTER_LOOPS + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#include +static inline long int lround(double x) { + return (long)(x + _copysign(0.5, x)); +} +#elif !defined(HAVE_LROUND) && defined(__GNUC__) +static inline long int lround(double x) { + return (long)(x + __builtin_copysign(0.5, x)); +} +/* If this fails, we are in the presence of a mid 90's compiler, move along... */ +#endif + +void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len) +{ + uint32_t i; + for(i = 0; i < data_len; i++) + out[i] = in[i] * window[i]; +} + +void FLAC__lpc_window_data_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len) +{ + uint32_t i; + for(i = 0; i < data_len; i++) + out[i] = in[i] * window[i]; +} + +void FLAC__lpc_window_data_partial(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift) +{ + uint32_t i, j; + if((part_size + data_shift) < data_len){ + for(i = 0; i < part_size; i++) + out[i] = in[data_shift+i] * window[i]; + i = flac_min(i,data_len - part_size - data_shift); + for(j = data_len - part_size; j < data_len; i++, j++) + out[i] = in[data_shift+i] * window[j]; + if(i < data_len) + out[i] = 0.0f; + } +} + +void FLAC__lpc_window_data_partial_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift) +{ + uint32_t i, j; + if((part_size + data_shift) < data_len){ + for(i = 0; i < part_size; i++) + out[i] = in[data_shift+i] * window[i]; + i = flac_min(i,data_len - part_size - data_shift); + for(j = data_len - part_size; j < data_len; i++, j++) + out[i] = in[data_shift+i] * window[j]; + if(i < data_len) + out[i] = 0.0f; + } +} + +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) +{ + /* a readable, but slower, version */ +#if 0 + double d; + uint32_t i; + + FLAC__ASSERT(lag > 0); + FLAC__ASSERT(lag <= data_len); + + /* + * Technically we should subtract the mean first like so: + * for(i = 0; i < data_len; i++) + * data[i] -= mean; + * but it appears not to make enough of a difference to matter, and + * most signals are already closely centered around zero + */ + while(lag--) { + for(i = lag, d = 0.0; i < data_len; i++) + d += data[i] * (double)data[i - lag]; + autoc[lag] = d; + } +#endif + if (data_len < FLAC__MAX_LPC_ORDER || lag > 16) { + /* + * this version tends to run faster because of better data locality + * ('data_len' is usually much larger than 'lag') + */ + double d; + uint32_t sample, coeff; + const uint32_t limit = data_len - lag; + + FLAC__ASSERT(lag > 0); + FLAC__ASSERT(lag <= data_len); + + for(coeff = 0; coeff < lag; coeff++) + autoc[coeff] = 0.0; + for(sample = 0; sample <= limit; sample++) { + d = data[sample]; + for(coeff = 0; coeff < lag; coeff++) + autoc[coeff] += d * data[sample+coeff]; + } + for(; sample < data_len; sample++) { + d = data[sample]; + for(coeff = 0; coeff < data_len - sample; coeff++) + autoc[coeff] += d * data[sample+coeff]; + } + } + else if(lag <= 8) { + #undef MAX_LAG + #define MAX_LAG 8 + #include "deduplication/lpc_compute_autocorrelation_intrin.c" + } + else if(lag <= 12) { + #undef MAX_LAG + #define MAX_LAG 12 + #include "deduplication/lpc_compute_autocorrelation_intrin.c" + } + else if(lag <= 16) { + #undef MAX_LAG + #define MAX_LAG 16 + #include "deduplication/lpc_compute_autocorrelation_intrin.c" + } + +} + +void FLAC__lpc_compute_lp_coefficients(const double autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]) +{ + uint32_t i, j; + double r, err, lpc[FLAC__MAX_LPC_ORDER]; + + FLAC__ASSERT(0 != max_order); + FLAC__ASSERT(0 < *max_order); + FLAC__ASSERT(*max_order <= FLAC__MAX_LPC_ORDER); + FLAC__ASSERT(autoc[0] != 0.0); + + err = autoc[0]; + + for(i = 0; i < *max_order; i++) { + /* Sum up this iteration's reflection coefficient. */ + r = -autoc[i+1]; + for(j = 0; j < i; j++) + r -= lpc[j] * autoc[i-j]; + r /= err; + + /* Update LPC coefficients and total error. */ + lpc[i]=r; + for(j = 0; j < (i>>1); j++) { + double tmp = lpc[j]; + lpc[j] += r * lpc[i-1-j]; + lpc[i-1-j] += r * tmp; + } + if(i & 1) + lpc[j] += lpc[j] * r; + + err *= (1.0 - r * r); + + /* save this order */ + for(j = 0; j <= i; j++) + lp_coeff[i][j] = (FLAC__real)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */ + error[i] = err; + + /* see SF bug https://sourceforge.net/p/flac/bugs/234/ */ + if(err == 0.0) { + *max_order = i+1; + return; + } + } +} + +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift) +{ + uint32_t i; + double cmax; + FLAC__int32 qmax, qmin; + + FLAC__ASSERT(precision > 0); + FLAC__ASSERT(precision >= FLAC__MIN_QLP_COEFF_PRECISION); + + /* drop one bit for the sign; from here on out we consider only |lp_coeff[i]| */ + precision--; + qmax = 1 << precision; + qmin = -qmax; + qmax--; + + /* calc cmax = max( |lp_coeff[i]| ) */ + cmax = 0.0; + for(i = 0; i < order; i++) { + const double d = fabs(lp_coeff[i]); + if(d > cmax) + cmax = d; + } + + if(cmax <= 0.0) { + /* => coefficients are all 0, which means our constant-detect didn't work */ + return 2; + } + else { + const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN-1)) - 1; + const int min_shiftlimit = -max_shiftlimit - 1; + int log2cmax; + + (void)frexp(cmax, &log2cmax); + log2cmax--; + *shift = (int)precision - log2cmax - 1; + + if(*shift > max_shiftlimit) + *shift = max_shiftlimit; + else if(*shift < min_shiftlimit) + return 1; + } + + if(*shift >= 0) { + double error = 0.0; + FLAC__int32 q; + for(i = 0; i < order; i++) { + error += lp_coeff[i] * (1 << *shift); + q = lround(error); + +#ifdef FLAC__OVERFLOW_DETECT + if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */ + flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]); + else if(q < qmin) + flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q qmax) + q = qmax; + else if(q < qmin) + q = qmin; + error -= q; + qlp_coeff[i] = q; + } + } + /* negative shift is very rare but due to design flaw, negative shift is + * not allowed in the decoder, so it must be handled specially by scaling + * down coeffs + */ + else { + const int nshift = -(*shift); + double error = 0.0; + FLAC__int32 q; +#ifndef NDEBUG + flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift=%d order=%u cmax=%f\n", *shift, order, cmax); +#endif + for(i = 0; i < order; i++) { + error += lp_coeff[i] / (1 << nshift); + q = lround(error); +#ifdef FLAC__OVERFLOW_DETECT + if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */ + flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]); + else if(q < qmin) + flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q qmax) + q = qmax; + else if(q < qmin) + q = qmin; + error -= q; + qlp_coeff[i] = q; + } + *shift = 0; + } + + return 0; +} + +#if defined(_MSC_VER) +// silence MSVC warnings about __restrict modifier +#pragma warning ( disable : 4028 ) +#endif + +void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) +#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) +{ + FLAC__int64 sumo; + uint32_t i, j; + FLAC__int32 sum; + const FLAC__int32 *history; + +#ifdef FLAC__OVERFLOW_DETECT_VERBOSE + flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); + for(i=0;i 0); + + for(i = 0; i < data_len; i++) { + sumo = 0; + sum = 0; + history = data; + for(j = 0; j < order; j++) { + sum += qlp_coeff[j] * (*(--history)); + sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); + if(sumo > 2147483647ll || sumo < -2147483648ll) + flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo); + } + *(residual++) = *(data++) - (sum >> lp_quantization); + } + + /* Here's a slower but clearer version: + for(i = 0; i < data_len; i++) { + sum = 0; + for(j = 0; j < order; j++) + sum += qlp_coeff[j] * data[i-j-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + */ +} +#else /* fully unrolled version for normal use */ +{ + int i; + FLAC__int32 sum; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + /* + * We do unique versions up to 12th order since that's the subset limit. + * Also they are roughly ordered to match frequency of occurrence to + * minimize branching. + */ + if(order <= 12) { + if(order > 8) { + if(order > 10) { + if(order == 12) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[11] * data[i-12]; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 11 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 10) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 9 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + } + else if(order > 4) { + if(order > 6) { + if(order == 8) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 7 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 6) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 5 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + } + else { + if(order > 2) { + if(order == 4) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 3 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 2) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 1 */ + for(i = 0; i < (int)data_len; i++) + residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp_quantization); + } + } + } + } + else { /* order > 12 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * data[i-13]; + sum += qlp_coeff[11] * data[i-12]; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[ 9] * data[i-10]; + sum += qlp_coeff[ 8] * data[i- 9]; + sum += qlp_coeff[ 7] * data[i- 8]; + sum += qlp_coeff[ 6] * data[i- 7]; + sum += qlp_coeff[ 5] * data[i- 6]; + sum += qlp_coeff[ 4] * data[i- 5]; + sum += qlp_coeff[ 3] * data[i- 4]; + sum += qlp_coeff[ 2] * data[i- 3]; + sum += qlp_coeff[ 1] * data[i- 2]; + sum += qlp_coeff[ 0] * data[i- 1]; + } + residual[i] = data[i] - (sum >> lp_quantization); + } + } +} +#endif + +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) +#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) +{ + uint32_t i, j; + FLAC__int64 sum; + const FLAC__int32 *history; + +#ifdef FLAC__OVERFLOW_DETECT_VERBOSE + flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); + for(i=0;i 0); + + for(i = 0; i < data_len; i++) { + sum = 0; + history = data; + for(j = 0; j < order; j++) + sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); + if(FLAC__bitmath_silog2((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) { + flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%" PRId64 ", residual=%" PRId64 "\n", i, *data, (int64_t)(sum >> lp_quantization), ((FLAC__int64)(*data) - (sum >> lp_quantization))); + break; + } + *(residual++) = *(data++) - (FLAC__int32)(sum >> lp_quantization); + } +} +#else /* fully unrolled version for normal use */ +{ + int i; + FLAC__int64 sum; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + /* + * We do unique versions up to 12th order since that's the subset limit. + * Also they are roughly ordered to match frequency of occurrence to + * minimize branching. + */ + if(order <= 12) { + if(order > 8) { + if(order > 10) { + if(order == 12) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 11 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 10) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 9 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + } + else if(order > 4) { + if(order > 6) { + if(order == 8) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 7 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 6) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 5 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + } + else { + if(order > 2) { + if(order == 4) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 3 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + } + else { + if(order == 2) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + residual[i] = data[i] - (sum >> lp_quantization); + } + } + else { /* order == 1 */ + for(i = 0; i < (int)data_len; i++) + residual[i] = data[i] - ((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization); + } + } + } + } + else { /* order > 12 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; + sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; + sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; + sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; + sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; + sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; + sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; + sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; + sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; + sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; + } + residual[i] = data[i] - (sum >> lp_quantization); + } + } +} +#endif + +FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) +{ + int i; + FLAC__int64 sum, residual_to_check; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; /* Falls through. */ + case 12: sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; /* Falls through. */ + case 11: sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; /* Falls through. */ + case 10: sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; /* Falls through. */ + case 9: sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; /* Falls through. */ + case 8: sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; /* Falls through. */ + case 7: sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; /* Falls through. */ + case 6: sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; /* Falls through. */ + case 5: sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; /* Falls through. */ + case 4: sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; /* Falls through. */ + case 3: sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; /* Falls through. */ + case 2: sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; /* Falls through. */ + case 1: sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; + } + residual_to_check = data[i] - (sum >> lp_quantization); + /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ + if(residual_to_check <= INT32_MIN || residual_to_check > INT32_MAX) + return false; + else + residual[i] = residual_to_check; + } + return true; +} + +FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(const FLAC__int64 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) +{ + int i; + FLAC__int64 sum, residual_to_check; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */ + case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ + case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ + case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ + case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ + case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ + case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ + case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ + case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ + case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ + case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ + case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ + case 1: sum += qlp_coeff[ 0] * data[i- 1]; + } + residual_to_check = data[i] - (sum >> lp_quantization); + /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ + if(residual_to_check <= INT32_MIN || residual_to_check > INT32_MAX) + return false; + else + residual[i] = residual_to_check; + } + return true; +} + +#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ + +FLAC__uint64 FLAC__lpc_max_prediction_value_before_shift(uint32_t subframe_bps, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order) +{ + FLAC__uint64 max_abs_sample_value = (FLAC__uint64)(1) << (subframe_bps - 1); + FLAC__uint32 abs_sum_of_qlp_coeff = 0; + uint32_t i; + for(i = 0; i < order; i++) + abs_sum_of_qlp_coeff += abs(qlp_coeff[i]); + return max_abs_sample_value * abs_sum_of_qlp_coeff; +} + +uint32_t FLAC__lpc_max_prediction_before_shift_bps(uint32_t subframe_bps, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order) +{ + /* This used to be subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order) + * but that treats both the samples as well as the predictor as unknown. The + * predictor is known however, so taking the log2 of the sum of the absolute values + * of all coefficients is a more accurate representation of the predictor */ + return FLAC__bitmath_silog2(FLAC__lpc_max_prediction_value_before_shift(subframe_bps, qlp_coeff, order)); +} + + +uint32_t FLAC__lpc_max_residual_bps(uint32_t subframe_bps, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization) +{ + FLAC__uint64 max_abs_sample_value = (FLAC__uint64)(1) << (subframe_bps - 1); + FLAC__uint64 max_prediction_value_after_shift = -1 * ((-1 * (FLAC__int64)FLAC__lpc_max_prediction_value_before_shift(subframe_bps, qlp_coeff, order)) >> lp_quantization); + FLAC__uint64 max_residual_value = max_abs_sample_value + max_prediction_value_after_shift; + return FLAC__bitmath_silog2(max_residual_value); +} + +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) +/* The attribute below is to silence the undefined sanitizer of oss-fuzz. + * Because fuzzing feeds bogus predictors and residual samples to the + * decoder, having overflows in this section is unavoidable. Also, + * because the calculated values are audio path only, there is no + * potential for security problems */ +__attribute__((no_sanitize("signed-integer-overflow"))) +#endif +void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) +#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) +{ + FLAC__int64 sumo; + uint32_t i, j; + FLAC__int32 sum; + const FLAC__int32 *r = residual, *history; + +#ifdef FLAC__OVERFLOW_DETECT_VERBOSE + flac_fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); + for(i=0;i 0); + + for(i = 0; i < data_len; i++) { + sumo = 0; + sum = 0; + history = data; + for(j = 0; j < order; j++) { + sum += qlp_coeff[j] * (*(--history)); + sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); +#ifdef FLAC__OVERFLOW_DETECT + if(sumo > 2147483647ll || sumo < -2147483648ll) + flac_fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo); +#endif + } + *(data++) = *(r++) + (sum >> lp_quantization); + } + + /* Here's a slower but clearer version: + for(i = 0; i < data_len; i++) { + sum = 0; + for(j = 0; j < order; j++) + sum += qlp_coeff[j] * data[i-j-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + */ +} +#else /* fully unrolled version for normal use */ +{ + int i; + FLAC__int32 sum; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + /* + * We do unique versions up to 12th order since that's the subset limit. + * Also they are roughly ordered to match frequency of occurrence to + * minimize branching. + */ + if(order <= 12) { + if(order > 8) { + if(order > 10) { + if(order == 12) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[11] * data[i-12]; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 11 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + } + else { + if(order == 10) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[9] * data[i-10]; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 9 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[8] * data[i-9]; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + } + } + else if(order > 4) { + if(order > 6) { + if(order == 8) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[7] * data[i-8]; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 7 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[6] * data[i-7]; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + } + else { + if(order == 6) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[5] * data[i-6]; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 5 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[4] * data[i-5]; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + } + } + else { + if(order > 2) { + if(order == 4) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[3] * data[i-4]; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 3 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[2] * data[i-3]; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + } + else { + if(order == 2) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + data[i] = residual[i] + (sum >> lp_quantization); + } + } + else { /* order == 1 */ + for(i = 0; i < (int)data_len; i++) + data[i] = residual[i] + ((qlp_coeff[0] * data[i-1]) >> lp_quantization); + } + } + } + } + else { /* order > 12 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * data[i-13]; + sum += qlp_coeff[11] * data[i-12]; + sum += qlp_coeff[10] * data[i-11]; + sum += qlp_coeff[ 9] * data[i-10]; + sum += qlp_coeff[ 8] * data[i- 9]; + sum += qlp_coeff[ 7] * data[i- 8]; + sum += qlp_coeff[ 6] * data[i- 7]; + sum += qlp_coeff[ 5] * data[i- 6]; + sum += qlp_coeff[ 4] * data[i- 5]; + sum += qlp_coeff[ 3] * data[i- 4]; + sum += qlp_coeff[ 2] * data[i- 3]; + sum += qlp_coeff[ 1] * data[i- 2]; + sum += qlp_coeff[ 0] * data[i- 1]; + } + data[i] = residual[i] + (sum >> lp_quantization); + } + } +} +#endif + +void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) +#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) +{ + uint32_t i, j; + FLAC__int64 sum; + const FLAC__int32 *r = residual, *history; + +#ifdef FLAC__OVERFLOW_DETECT_VERBOSE + flac_fprintf(stderr,"FLAC__lpc_restore_signal_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); + for(i=0;i 0); + + for(i = 0; i < data_len; i++) { + sum = 0; + history = data; + for(j = 0; j < order; j++) + sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); +#ifdef FLAC__OVERFLOW_DETECT + if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) { + flac_fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization))); + break; + } +#endif + *(data++) = (FLAC__int32)(*(r++) + (sum >> lp_quantization)); + } +} +#else /* fully unrolled version for normal use */ +{ + int i; + FLAC__int64 sum; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + /* + * We do unique versions up to 12th order since that's the subset limit. + * Also they are roughly ordered to match frequency of occurrence to + * minimize branching. + */ + if(order <= 12) { + if(order > 8) { + if(order > 10) { + if(order == 12) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 11 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + } + else { + if(order == 10) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 9 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + } + } + else if(order > 4) { + if(order > 6) { + if(order == 8) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 7 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + } + else { + if(order == 6) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 5 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + } + } + else { + if(order > 2) { + if(order == 4) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 3 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + } + else { + if(order == 2) { + for(i = 0; i < (int)data_len; i++) { + sum = 0; + sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; + sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } + else { /* order == 1 */ + for(i = 0; i < (int)data_len; i++) + data[i] = (FLAC__int32)(residual[i] + ((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization)); + } + } + } + } + else { /* order > 12 */ + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; + sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; + sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; + sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; + sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; + sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; + sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; + sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; + sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; + sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; + sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; + sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; + sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; + } + data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); + } + } +} +#endif + +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) +/* The attribute below is to silence the undefined sanitizer of oss-fuzz. + * Because fuzzing feeds bogus predictors and residual samples to the + * decoder, having overflows in this section is unavoidable. Also, + * because the calculated values are audio path only, there is no + * potential for security problems */ +__attribute__((no_sanitize("signed-integer-overflow"))) +#endif +void FLAC__lpc_restore_signal_wide_33bit(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int64 * flac_restrict data) +#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) +{ + uint32_t i, j; + FLAC__int64 sum; + const FLAC__int32 *r = residual; + const FLAC__int64 *history; + + FLAC__ASSERT(order > 0); + + for(i = 0; i < data_len; i++) { + sum = 0; + history = data; + for(j = 0; j < order; j++) + sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); +#ifdef FLAC__OVERFLOW_DETECT + if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 33) { + flac_fprintf(stderr,"FLAC__lpc_restore_signal_33bit: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization))); + break; + } +#endif + *(data++) = (FLAC__int64)(*(r++)) + (sum >> lp_quantization); + } +} +#else /* unrolled version for normal use */ +{ + int i; + FLAC__int64 sum; + + FLAC__ASSERT(order > 0); + FLAC__ASSERT(order <= 32); + + for(i = 0; i < (int)data_len; i++) { + sum = 0; + switch(order) { + case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ + case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ + case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ + case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ + case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ + case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ + case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ + case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ + case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ + case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ + case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ + case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ + case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ + case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ + case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ + case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ + case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ + case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ + case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ + case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */ + case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ + case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ + case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ + case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ + case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ + case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ + case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ + case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ + case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ + case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ + case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ + case 1: sum += qlp_coeff[ 0] * data[i- 1]; + } + data[i] = residual[i] + (sum >> lp_quantization); + } +} +#endif + +#if defined(_MSC_VER) +#pragma warning ( default : 4028 ) +#endif + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples) +{ + double error_scale; + + FLAC__ASSERT(total_samples > 0); + + error_scale = 0.5 / (double)total_samples; + + return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale); +} + +double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale) +{ + if(lpc_error > 0.0) { + double bps = (double)0.5 * log(error_scale * lpc_error) / M_LN2; + if(bps >= 0.0) + return bps; + else + return 0.0; + } + else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate floating-point resolution */ + return 1e32; + } + else { + return 0.0; + } +} + +uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order) +{ + uint32_t order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */ + double bits, best_bits, error_scale; + + FLAC__ASSERT(max_order > 0); + FLAC__ASSERT(total_samples > 0); + + error_scale = 0.5 / (double)total_samples; + + best_index = 0; + best_bits = (uint32_t)(-1); + + for(indx = 0, order = 1; indx < max_order; indx++, order++) { + bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[indx], error_scale) * (double)(total_samples - order) + (double)(order * overhead_bits_per_order); + if(bits < best_bits) { + best_index = indx; + best_bits = bits; + } + } + + return best_index+1; /* +1 since indx of lpc_error[] is order-1 */ +} + +#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/packages/third-party/libFLAC/md5.c b/packages/third-party/libFLAC/md5.c new file mode 100644 index 00000000..09933d7e --- /dev/null +++ b/packages/third-party/libFLAC/md5.c @@ -0,0 +1,517 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include /* for malloc() */ +#include /* for memcpy() */ + +#include "private/md5.h" +#include "share/alloc.h" +#include "share/compat.h" +#include "share/endswap.h" + +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + * Changed so as no longer to depend on Colin Plumb's `usual.h' header + * definitions; now uses stuff from dpkg's config.h. + * - Ian Jackson . + * Still in the public domain. + * + * Josh Coalson: made some changes to integrate with libFLAC. + * Still in the public domain. + */ + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f,w,x,y,z,in,s) \ + (w += f(x,y,z) + in, w = (w<>(32-s)) + x) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]) +{ + register FLAC__uint32 a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +#if WORDS_BIGENDIAN +//@@@@@@ OPT: use bswap/intrinsics +static void byteSwap(FLAC__uint32 *buf, uint32_t words) +{ + register FLAC__uint32 x; + do { + x = *buf; + x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); + *buf++ = (x >> 16) | (x << 16); + } while (--words); +} +static void byteSwapX16(FLAC__uint32 *buf) +{ + register FLAC__uint32 x; + + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); + x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf = (x >> 16) | (x << 16); +} +#else +#define byteSwap(buf, words) +#define byteSwapX16(buf) +#endif + +/* + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, uint32_t len) +{ + FLAC__uint32 t; + + /* Update byte count */ + + t = ctx->bytes[0]; + if ((ctx->bytes[0] = t + len) < t) + ctx->bytes[1]++; /* Carry from low to high */ + + t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ + if (t > len) { + memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len); + return; + } + /* First chunk is an odd size */ + memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t); + byteSwapX16(ctx->in); + FLAC__MD5Transform(ctx->buf, ctx->in); + buf += t; + len -= t; + + /* Process data in 64-byte chunks */ + while (len >= 64) { + memcpy(ctx->in, buf, 64); + byteSwapX16(ctx->in); + FLAC__MD5Transform(ctx->buf, ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + memcpy(ctx->in, buf, len); +} + +/* + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void FLAC__MD5Init(FLAC__MD5Context *ctx) +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; + + ctx->bytes[0] = 0; + ctx->bytes[1] = 0; + + ctx->internal_buf.p8 = 0; + ctx->capacity = 0; +} + +/* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx) +{ + int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ + FLAC__byte *p = (FLAC__byte *)ctx->in + count; + + /* Set the first char of padding to 0x80. There is always room. */ + *p++ = 0x80; + + /* Bytes of padding needed to make 56 bytes (-8..55) */ + count = 56 - 1 - count; + + if (count < 0) { /* Padding forces an extra block */ + memset(p, 0, count + 8); + byteSwapX16(ctx->in); + FLAC__MD5Transform(ctx->buf, ctx->in); + p = (FLAC__byte *)ctx->in; + count = 56; + } + memset(p, 0, count); + byteSwap(ctx->in, 14); + + /* Append length in bits and transform */ + ctx->in[14] = ctx->bytes[0] << 3; + ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; + FLAC__MD5Transform(ctx->buf, ctx->in); + + byteSwap(ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + if (0 != ctx->internal_buf.p8) { + free(ctx->internal_buf.p8); + ctx->internal_buf.p8 = 0; + ctx->capacity = 0; + } + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ +} + +/* + * Convert the incoming audio signal to a byte stream + */ +static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) +{ + FLAC__byte *buf_ = mbuf->p8; + FLAC__int16 *buf16 = mbuf->p16; + FLAC__int32 *buf32 = mbuf->p32; + FLAC__int32 a_word; + uint32_t channel, sample; + + /* Storage in the output buffer, buf, is little endian. */ + +#define BYTES_CHANNEL_SELECTOR(bytes, channels) (bytes * 100 + channels) + + /* First do the most commonly used combinations. */ + switch (BYTES_CHANNEL_SELECTOR (bytes_per_sample, channels)) { + /* One byte per sample. */ + case (BYTES_CHANNEL_SELECTOR (1, 1)): + for (sample = 0; sample < samples; sample++) + *buf_++ = signal[0][sample]; + return; + + case (BYTES_CHANNEL_SELECTOR (1, 2)): + for (sample = 0; sample < samples; sample++) { + *buf_++ = signal[0][sample]; + *buf_++ = signal[1][sample]; + } + return; + + case (BYTES_CHANNEL_SELECTOR (1, 4)): + for (sample = 0; sample < samples; sample++) { + *buf_++ = signal[0][sample]; + *buf_++ = signal[1][sample]; + *buf_++ = signal[2][sample]; + *buf_++ = signal[3][sample]; + } + return; + + case (BYTES_CHANNEL_SELECTOR (1, 6)): + for (sample = 0; sample < samples; sample++) { + *buf_++ = signal[0][sample]; + *buf_++ = signal[1][sample]; + *buf_++ = signal[2][sample]; + *buf_++ = signal[3][sample]; + *buf_++ = signal[4][sample]; + *buf_++ = signal[5][sample]; + } + return; + + case (BYTES_CHANNEL_SELECTOR (1, 8)): + for (sample = 0; sample < samples; sample++) { + *buf_++ = signal[0][sample]; + *buf_++ = signal[1][sample]; + *buf_++ = signal[2][sample]; + *buf_++ = signal[3][sample]; + *buf_++ = signal[4][sample]; + *buf_++ = signal[5][sample]; + *buf_++ = signal[6][sample]; + *buf_++ = signal[7][sample]; + } + return; + + /* Two bytes per sample. */ + case (BYTES_CHANNEL_SELECTOR (2, 1)): + for (sample = 0; sample < samples; sample++) + *buf16++ = H2LE_16(signal[0][sample]); + return; + + case (BYTES_CHANNEL_SELECTOR (2, 2)): + for (sample = 0; sample < samples; sample++) { + *buf16++ = H2LE_16(signal[0][sample]); + *buf16++ = H2LE_16(signal[1][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (2, 4)): + for (sample = 0; sample < samples; sample++) { + *buf16++ = H2LE_16(signal[0][sample]); + *buf16++ = H2LE_16(signal[1][sample]); + *buf16++ = H2LE_16(signal[2][sample]); + *buf16++ = H2LE_16(signal[3][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (2, 6)): + for (sample = 0; sample < samples; sample++) { + *buf16++ = H2LE_16(signal[0][sample]); + *buf16++ = H2LE_16(signal[1][sample]); + *buf16++ = H2LE_16(signal[2][sample]); + *buf16++ = H2LE_16(signal[3][sample]); + *buf16++ = H2LE_16(signal[4][sample]); + *buf16++ = H2LE_16(signal[5][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (2, 8)): + for (sample = 0; sample < samples; sample++) { + *buf16++ = H2LE_16(signal[0][sample]); + *buf16++ = H2LE_16(signal[1][sample]); + *buf16++ = H2LE_16(signal[2][sample]); + *buf16++ = H2LE_16(signal[3][sample]); + *buf16++ = H2LE_16(signal[4][sample]); + *buf16++ = H2LE_16(signal[5][sample]); + *buf16++ = H2LE_16(signal[6][sample]); + *buf16++ = H2LE_16(signal[7][sample]); + } + return; + + /* Three bytes per sample. */ + case (BYTES_CHANNEL_SELECTOR (3, 1)): + for (sample = 0; sample < samples; sample++) { + a_word = signal[0][sample]; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; + } + return; + + case (BYTES_CHANNEL_SELECTOR (3, 2)): + for (sample = 0; sample < samples; sample++) { + a_word = signal[0][sample]; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; + a_word = signal[1][sample]; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; + } + return; + + /* Four bytes per sample. */ + case (BYTES_CHANNEL_SELECTOR (4, 1)): + for (sample = 0; sample < samples; sample++) + *buf32++ = H2LE_32(signal[0][sample]); + return; + + case (BYTES_CHANNEL_SELECTOR (4, 2)): + for (sample = 0; sample < samples; sample++) { + *buf32++ = H2LE_32(signal[0][sample]); + *buf32++ = H2LE_32(signal[1][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (4, 4)): + for (sample = 0; sample < samples; sample++) { + *buf32++ = H2LE_32(signal[0][sample]); + *buf32++ = H2LE_32(signal[1][sample]); + *buf32++ = H2LE_32(signal[2][sample]); + *buf32++ = H2LE_32(signal[3][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (4, 6)): + for (sample = 0; sample < samples; sample++) { + *buf32++ = H2LE_32(signal[0][sample]); + *buf32++ = H2LE_32(signal[1][sample]); + *buf32++ = H2LE_32(signal[2][sample]); + *buf32++ = H2LE_32(signal[3][sample]); + *buf32++ = H2LE_32(signal[4][sample]); + *buf32++ = H2LE_32(signal[5][sample]); + } + return; + + case (BYTES_CHANNEL_SELECTOR (4, 8)): + for (sample = 0; sample < samples; sample++) { + *buf32++ = H2LE_32(signal[0][sample]); + *buf32++ = H2LE_32(signal[1][sample]); + *buf32++ = H2LE_32(signal[2][sample]); + *buf32++ = H2LE_32(signal[3][sample]); + *buf32++ = H2LE_32(signal[4][sample]); + *buf32++ = H2LE_32(signal[5][sample]); + *buf32++ = H2LE_32(signal[6][sample]); + *buf32++ = H2LE_32(signal[7][sample]); + } + return; + + default: + break; + } + + /* General version. */ + switch (bytes_per_sample) { + case 1: + for (sample = 0; sample < samples; sample++) + for (channel = 0; channel < channels; channel++) + *buf_++ = signal[channel][sample]; + return; + + case 2: + for (sample = 0; sample < samples; sample++) + for (channel = 0; channel < channels; channel++) + *buf16++ = H2LE_16(signal[channel][sample]); + return; + + case 3: + for (sample = 0; sample < samples; sample++) + for (channel = 0; channel < channels; channel++) { + a_word = signal[channel][sample]; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; a_word >>= 8; + *buf_++ = (FLAC__byte)a_word; + } + return; + + case 4: + for (sample = 0; sample < samples; sample++) + for (channel = 0; channel < channels; channel++) + *buf32++ = H2LE_32(signal[channel][sample]); + return; + + default: + break; + } +} + +/* + * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it. + */ +FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) +{ + const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample; + + /* overflow check */ + if ((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample) + return false; + if ((size_t)channels * (size_t)bytes_per_sample > SIZE_MAX / (size_t)samples) + return false; + + if (ctx->capacity < bytes_needed) { + if (0 == (ctx->internal_buf.p8 = safe_realloc_(ctx->internal_buf.p8, bytes_needed))) { + if (0 == (ctx->internal_buf.p8 = safe_malloc_(bytes_needed))) { + ctx->capacity = 0; + return false; + } + } + ctx->capacity = bytes_needed; + } + + format_input_(&ctx->internal_buf, signal, channels, samples, bytes_per_sample); + + FLAC__MD5Update(ctx, ctx->internal_buf.p8, bytes_needed); + + return true; +} diff --git a/packages/third-party/libFLAC/memory.c b/packages/third-party/libFLAC/memory.c new file mode 100644 index 00000000..963f4ad4 --- /dev/null +++ b/packages/third-party/libFLAC/memory.c @@ -0,0 +1,219 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +#include "private/memory.h" +#include "FLAC/assert.h" +#include "share/compat.h" +#include "share/alloc.h" + +void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) +{ + void *x; + + FLAC__ASSERT(0 != aligned_address); + +#ifdef FLAC__ALIGN_MALLOC_DATA + /* align on 32-byte (256-bit) boundary */ + x = safe_malloc_add_2op_(bytes, /*+*/31L); + *aligned_address = (void*)(((uintptr_t)x + 31L) & -32L); +#else + x = safe_malloc_(bytes); + *aligned_address = x; +#endif + return x; +} + +FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer) +{ + FLAC__int32 *pu; /* unaligned pointer */ + union { /* union needed to comply with C99 pointer aliasing rules */ + FLAC__int32 *pa; /* aligned pointer */ + void *pv; /* aligned pointer alias */ + } u; + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ + return false; + + pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = u.pa; + return true; + } +} + +FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer) +{ + FLAC__uint32 *pu; /* unaligned pointer */ + union { /* union needed to comply with C99 pointer aliasing rules */ + FLAC__uint32 *pa; /* aligned pointer */ + void *pv; /* aligned pointer alias */ + } u; + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ + return false; + + pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = u.pa; + return true; + } +} + +FLAC__bool FLAC__memory_alloc_aligned_int64_array(size_t elements, FLAC__int64 **unaligned_pointer, FLAC__int64 **aligned_pointer) +{ + FLAC__int64 *pu; /* unaligned pointer */ + union { /* union needed to comply with C99 pointer aliasing rules */ + FLAC__int64 *pa; /* aligned pointer */ + void *pv; /* aligned pointer alias */ + } u; + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ + return false; + + pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = u.pa; + return true; + } +} + +FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer) +{ + FLAC__uint64 *pu; /* unaligned pointer */ + union { /* union needed to comply with C99 pointer aliasing rules */ + FLAC__uint64 *pa; /* aligned pointer */ + void *pv; /* aligned pointer alias */ + } u; + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ + return false; + + pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = u.pa; + return true; + } +} + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer) +{ + FLAC__real *pu; /* unaligned pointer */ + union { /* union needed to comply with C99 pointer aliasing rules */ + FLAC__real *pa; /* aligned pointer */ + void *pv; /* aligned pointer alias */ + } u; + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ + return false; + + pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = u.pa; + return true; + } +} + +#endif + +void *safe_malloc_mul_2op_p(size_t size1, size_t size2) +{ + if(!size1 || !size2) + return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ + if(size1 > SIZE_MAX / size2) + return 0; + return malloc(size1*size2); +} diff --git a/packages/third-party/libFLAC/ogg_decoder_aspect.c b/packages/third-party/libFLAC/ogg_decoder_aspect.c new file mode 100644 index 00000000..e602b3ac --- /dev/null +++ b/packages/third-party/libFLAC/ogg_decoder_aspect.c @@ -0,0 +1,251 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include /* for memcpy() */ +#include "FLAC/assert.h" +#include "private/ogg_decoder_aspect.h" +#include "private/ogg_mapping.h" +#include "private/macros.h" + + +/*********************************************************************** + * + * Public class methods + * + ***********************************************************************/ + +FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect) +{ + /* we will determine the serial number later if necessary */ + if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0) + return false; + + if(ogg_sync_init(&aspect->sync_state) != 0) + return false; + + aspect->version_major = ~(0u); + aspect->version_minor = ~(0u); + + aspect->need_serial_number = aspect->use_first_serial_number; + + aspect->end_of_stream = false; + aspect->have_working_page = false; + + return true; +} + +void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect) +{ + (void)ogg_sync_clear(&aspect->sync_state); + (void)ogg_stream_clear(&aspect->stream_state); +} + +void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value) +{ + aspect->use_first_serial_number = false; + aspect->serial_number = value; +} + +void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect) +{ + aspect->use_first_serial_number = true; +} + +void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect) +{ + (void)ogg_stream_reset(&aspect->stream_state); + (void)ogg_sync_reset(&aspect->sync_state); + aspect->end_of_stream = false; + aspect->have_working_page = false; +} + +void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect) +{ + FLAC__ogg_decoder_aspect_flush(aspect); + + if(aspect->use_first_serial_number) + aspect->need_serial_number = true; +} + +FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data) +{ + static const size_t OGG_BYTES_CHUNK = 8192; + const size_t bytes_requested = *bytes; + + /* + * The FLAC decoding API uses pull-based reads, whereas Ogg decoding + * is push-based. In libFLAC, when you ask to decode a frame, the + * decoder will eventually call the read callback to supply some data, + * but how much it asks for depends on how much free space it has in + * its internal buffer. It does not try to grow its internal buffer + * to accommodate a whole frame because then the internal buffer size + * could not be limited, which is necessary in embedded applications. + * + * Ogg however grows its internal buffer until a whole page is present; + * only then can you get decoded data out. So we can't just ask for + * the same number of bytes from Ogg, then pass what's decoded down to + * libFLAC. If what libFLAC is asking for will not contain a whole + * page, then we will get no data from ogg_sync_pageout(), and at the + * same time cannot just read more data from the client for the purpose + * of getting a whole decoded page because the decoded size might be + * larger than libFLAC's internal buffer. + * + * Instead, whenever this read callback wrapper is called, we will + * continually request data from the client until we have at least one + * page, and manage pages internally so that we can send pieces of + * pages down to libFLAC in such a way that we obey its size + * requirement. To limit the amount of callbacks, we will always try + * to read in enough pages to return the full number of bytes + * requested. + */ + *bytes = 0; + while (*bytes < bytes_requested && !aspect->end_of_stream) { + if (aspect->have_working_page) { + if (aspect->have_working_packet) { + size_t n = bytes_requested - *bytes; + if ((size_t)aspect->working_packet.bytes <= n) { + /* the rest of the packet will fit in the buffer */ + n = aspect->working_packet.bytes; + memcpy(buffer, aspect->working_packet.packet, n); + *bytes += n; + buffer += n; + aspect->have_working_packet = false; + } + else { + /* only n bytes of the packet will fit in the buffer */ + memcpy(buffer, aspect->working_packet.packet, n); + *bytes += n; + buffer += n; + aspect->working_packet.packet += n; + aspect->working_packet.bytes -= n; + } + } + else { + /* try and get another packet */ + const int ret = ogg_stream_packetout(&aspect->stream_state, &aspect->working_packet); + if (ret > 0) { + aspect->have_working_packet = true; + /* if it is the first header packet, check for magic and a supported Ogg FLAC mapping version */ + if (aspect->working_packet.bytes > 0 && aspect->working_packet.packet[0] == FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE) { + const FLAC__byte *b = aspect->working_packet.packet; + const uint32_t header_length = + FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + + FLAC__OGG_MAPPING_MAGIC_LENGTH + + FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + + FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH + + FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH; + if (aspect->working_packet.bytes < (long)header_length) + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC; + b += FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH; + if (memcmp(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH)) + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC; + b += FLAC__OGG_MAPPING_MAGIC_LENGTH; + aspect->version_major = (uint32_t)(*b); + b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH; + aspect->version_minor = (uint32_t)(*b); + if (aspect->version_major != 1) + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION; + aspect->working_packet.packet += header_length; + aspect->working_packet.bytes -= header_length; + } + } + else if (ret == 0) { + aspect->have_working_page = false; + } + else { /* ret < 0 */ + /* lost sync, we'll leave the working page for the next call */ + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC; + } + } + } + else { + /* try and get another page */ + const int ret = ogg_sync_pageout(&aspect->sync_state, &aspect->working_page); + if (ret > 0) { + /* got a page, grab the serial number if necessary */ + if(aspect->need_serial_number) { + aspect->stream_state.serialno = aspect->serial_number = ogg_page_serialno(&aspect->working_page); + aspect->need_serial_number = false; + } + if(ogg_stream_pagein(&aspect->stream_state, &aspect->working_page) == 0) { + aspect->have_working_page = true; + aspect->have_working_packet = false; + } + /* else do nothing, could be a page from another stream */ + } + else if (ret == 0) { + /* need more data */ + const size_t ogg_bytes_to_read = flac_max(bytes_requested - *bytes, OGG_BYTES_CHUNK); + char *oggbuf = ogg_sync_buffer(&aspect->sync_state, ogg_bytes_to_read); + + if(0 == oggbuf) { + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR; + } + else { + size_t ogg_bytes_read = ogg_bytes_to_read; + + switch(read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_read, client_data)) { + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK: + break; + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM: + aspect->end_of_stream = true; + break; + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT: + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; + default: + FLAC__ASSERT(0); + } + + if(ogg_sync_wrote(&aspect->sync_state, ogg_bytes_read) < 0) { + /* double protection; this will happen if the read callback returns more bytes than the max requested, which would overflow Ogg's internal buffer */ + FLAC__ASSERT(0); + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR; + } + } + } + else { /* ret < 0 */ + /* lost sync, bail out */ + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC; + } + } + } + + if (aspect->end_of_stream && *bytes == 0) { + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM; + } + + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK; +} diff --git a/packages/third-party/libFLAC/ogg_helper.c b/packages/third-party/libFLAC/ogg_helper.c new file mode 100644 index 00000000..161588f1 --- /dev/null +++ b/packages/third-party/libFLAC/ogg_helper.c @@ -0,0 +1,210 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include /* for malloc() */ +#include /* for memcmp(), memcpy() */ +#include "FLAC/assert.h" +#include "share/alloc.h" +#include "private/ogg_helper.h" +#include "protected/stream_encoder.h" + + +static FLAC__bool full_read_(FLAC__StreamEncoder *encoder, FLAC__byte *buffer, size_t bytes, FLAC__StreamEncoderReadCallback read_callback, void *client_data) +{ + while(bytes > 0) { + size_t bytes_read = bytes; + switch(read_callback(encoder, buffer, &bytes_read, client_data)) { + case FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE: + bytes -= bytes_read; + buffer += bytes_read; + break; + case FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM: + if(bytes_read == 0) { + encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; + return false; + } + bytes -= bytes_read; + buffer += bytes_read; + break; + case FLAC__STREAM_ENCODER_READ_STATUS_ABORT: + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + case FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED: + return false; + default: + /* double protection: */ + FLAC__ASSERT(0); + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + } + } + + return true; +} + +void simple_ogg_page__init(ogg_page *page) +{ + page->header = 0; + page->header_len = 0; + page->body = 0; + page->body_len = 0; +} + +void simple_ogg_page__clear(ogg_page *page) +{ + if(page->header) + free(page->header); + if(page->body) + free(page->body); + simple_ogg_page__init(page); +} + +FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data) +{ + static const uint32_t OGG_HEADER_FIXED_PORTION_LEN = 27; + static const uint32_t OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255; + FLAC__byte crc[4]; + FLAC__StreamEncoderSeekStatus seek_status; + + FLAC__ASSERT(page->header == 0); + FLAC__ASSERT(page->header_len == 0); + FLAC__ASSERT(page->body == 0); + FLAC__ASSERT(page->body_len == 0); + + /* move the stream pointer to the supposed beginning of the page */ + if(0 == seek_callback) + return false; + if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { + if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + } + + /* allocate space for the page header */ + if(0 == (page->header = safe_malloc_(OGG_MAX_HEADER_LEN))) { + encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; + return false; + } + + /* read in the fixed part of the page header (up to but not including + * the segment table */ + if(!full_read_(encoder, page->header, OGG_HEADER_FIXED_PORTION_LEN, read_callback, client_data)) + return false; + + page->header_len = OGG_HEADER_FIXED_PORTION_LEN + page->header[26]; + + /* check to see if it's a correct, "simple" page (one packet only) */ + if( + memcmp(page->header, "OggS", 4) || /* doesn't start with OggS */ + (page->header[5] & 0x01) || /* continued packet */ + memcmp(page->header+6, "\0\0\0\0\0\0\0\0", 8) || /* granulepos is non-zero */ + page->header[26] == 0 /* packet is 0-size */ + ) { + encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; + return false; + } + + /* read in the segment table */ + if(!full_read_(encoder, page->header + OGG_HEADER_FIXED_PORTION_LEN, page->header[26], read_callback, client_data)) + return false; + + { + uint32_t i; + + /* check to see that it specifies a single packet */ + for(i = 0; i < (uint32_t)page->header[26] - 1; i++) { + if(page->header[i + OGG_HEADER_FIXED_PORTION_LEN] != 255) { + encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; + return false; + } + } + + page->body_len = 255 * i + page->header[i + OGG_HEADER_FIXED_PORTION_LEN]; + } + + /* allocate space for the page body */ + if(0 == (page->body = safe_malloc_(page->body_len))) { + encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; + return false; + } + + /* read in the page body */ + if(!full_read_(encoder, page->body, page->body_len, read_callback, client_data)) + return false; + + /* check the CRC */ + memcpy(crc, page->header+22, 4); + ogg_page_checksum_set(page); + if(memcmp(crc, page->header+22, 4)) { + encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; + return false; + } + + return true; +} + +FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data) +{ + FLAC__StreamEncoderSeekStatus seek_status; + + FLAC__ASSERT(page->header != 0); + FLAC__ASSERT(page->header_len != 0); + FLAC__ASSERT(page->body != 0); + FLAC__ASSERT(page->body_len != 0); + + /* move the stream pointer to the supposed beginning of the page */ + if(0 == seek_callback) + return false; + if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { + if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + } + + ogg_page_checksum_set(page); + + /* re-write the page */ + if(write_callback((FLAC__StreamEncoder*)encoder, page->header, page->header_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + } + if(write_callback((FLAC__StreamEncoder*)encoder, page->body, page->body_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { + encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; + return false; + } + + return true; +} diff --git a/packages/third-party/libFLAC/ogg_mapping.c b/packages/third-party/libFLAC/ogg_mapping.c new file mode 100644 index 00000000..a6273c39 --- /dev/null +++ b/packages/third-party/libFLAC/ogg_mapping.c @@ -0,0 +1,48 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "private/ogg_mapping.h" + +const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */ + +const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f; + +const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC"; + +const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */ +const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */ + +const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */ diff --git a/packages/third-party/libFLAC/private/all.h b/packages/third-party/libFLAC/private/all.h new file mode 100644 index 00000000..49d18b39 --- /dev/null +++ b/packages/third-party/libFLAC/private/all.h @@ -0,0 +1,50 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__ALL_H +#define FLAC__PRIVATE__ALL_H + +#include "bitmath.h" +#include "bitreader.h" +#include "bitwriter.h" +#include "cpu.h" +#include "crc.h" +#include "fixed.h" +#include "float.h" +#include "format.h" +#include "lpc.h" +#include "md5.h" +#include "memory.h" +#include "metadata.h" +#include "stream_encoder_framing.h" + +#endif diff --git a/packages/third-party/libFLAC/private/bitmath.h b/packages/third-party/libFLAC/private/bitmath.h new file mode 100644 index 00000000..ca859835 --- /dev/null +++ b/packages/third-party/libFLAC/private/bitmath.h @@ -0,0 +1,211 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__BITMATH_H +#define FLAC__PRIVATE__BITMATH_H + +#include "FLAC/ordinals.h" +#include "FLAC/assert.h" + +#include "share/compat.h" + +#if defined(_MSC_VER) +#include /* for _BitScanReverse* */ +#endif + +/* Will never be emitted for MSVC, GCC, Intel compilers */ +static inline uint32_t FLAC__clz_soft_uint32(FLAC__uint32 word) +{ + static const uint8_t byte_to_unary_table[] = { + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + + return word > 0xffffff ? byte_to_unary_table[word >> 24] : + word > 0xffff ? byte_to_unary_table[word >> 16] + 8 : + word > 0xff ? byte_to_unary_table[word >> 8] + 16 : + byte_to_unary_table[word] + 24; +} + +static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v) +{ +/* Never used with input 0 */ + FLAC__ASSERT(v > 0); +#if defined(__INTEL_COMPILER) + return _bit_scan_reverse(v) ^ 31U; +#elif defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +/* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on + * -march= setting or to a software routine in exotic machines. */ + return __builtin_clz(v); +#elif defined(_MSC_VER) + { + unsigned long idx; + _BitScanReverse(&idx, v); + return idx ^ 31U; + } +#else + return FLAC__clz_soft_uint32(v); +#endif +} + +/* Used when 64-bit bsr/clz is unavailable; can use 32-bit bsr/clz when possible */ +static inline uint32_t FLAC__clz_soft_uint64(FLAC__uint64 word) +{ + return (FLAC__uint32)(word>>32) ? FLAC__clz_uint32((FLAC__uint32)(word>>32)) : + FLAC__clz_uint32((FLAC__uint32)word) + 32; +} + +static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v) +{ + /* Never used with input 0 */ + FLAC__ASSERT(v > 0); +#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + return __builtin_clzll(v); +#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) + { + unsigned long idx; + _BitScanReverse64(&idx, v); + return idx ^ 63U; + } +#else + return FLAC__clz_soft_uint64(v); +#endif +} + +/* These two functions work with input 0 */ +static inline uint32_t FLAC__clz2_uint32(FLAC__uint32 v) +{ + if (!v) + return 32; + return FLAC__clz_uint32(v); +} + +static inline uint32_t FLAC__clz2_uint64(FLAC__uint64 v) +{ + if (!v) + return 64; + return FLAC__clz_uint64(v); +} + +/* An example of what FLAC__bitmath_ilog2() computes: + * + * ilog2( 0) = assertion failure + * ilog2( 1) = 0 + * ilog2( 2) = 1 + * ilog2( 3) = 1 + * ilog2( 4) = 2 + * ilog2( 5) = 2 + * ilog2( 6) = 2 + * ilog2( 7) = 2 + * ilog2( 8) = 3 + * ilog2( 9) = 3 + * ilog2(10) = 3 + * ilog2(11) = 3 + * ilog2(12) = 3 + * ilog2(13) = 3 + * ilog2(14) = 3 + * ilog2(15) = 3 + * ilog2(16) = 4 + * ilog2(17) = 4 + * ilog2(18) = 4 + */ + +static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v) +{ + FLAC__ASSERT(v > 0); +#if defined(__INTEL_COMPILER) + return _bit_scan_reverse(v); +#elif defined(_MSC_VER) + { + unsigned long idx; + _BitScanReverse(&idx, v); + return idx; + } +#else + return FLAC__clz_uint32(v) ^ 31U; +#endif +} + +static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v) +{ + FLAC__ASSERT(v > 0); +#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + return __builtin_clzll(v) ^ 63U; +/* Sorry, only supported in x64/Itanium.. and both have fast FPU which makes integer-only encoder pointless */ +#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) + { + unsigned long idx; + _BitScanReverse64(&idx, v); + return idx; + } +#else +/* Brain-damaged compilers will use the fastest possible way that is, + de Bruijn sequences (http://supertech.csail.mit.edu/papers/debruijn.pdf) + (C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 CC0 (Public domain). +*/ + { + static const uint8_t DEBRUIJN_IDX64[64]={ + 0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40, + 5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57, + 63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56, + 62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58 + }; + v|= v>>1; + v|= v>>2; + v|= v>>4; + v|= v>>8; + v|= v>>16; + v|= v>>32; + v= (v>>1)+1; + return DEBRUIJN_IDX64[v*FLAC__U64L(0x218A392CD3D5DBF)>>58&0x3F]; + } +#endif +} + +uint32_t FLAC__bitmath_silog2(FLAC__int64 v); +uint32_t FLAC__bitmath_extra_mulbits_unsigned(FLAC__uint32 v); + +#endif diff --git a/packages/third-party/libFLAC/private/bitreader.h b/packages/third-party/libFLAC/private/bitreader.h new file mode 100644 index 00000000..93a2cca8 --- /dev/null +++ b/packages/third-party/libFLAC/private/bitreader.h @@ -0,0 +1,101 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__BITREADER_H +#define FLAC__PRIVATE__BITREADER_H + +#include /* for FILE */ +#include "FLAC/ordinals.h" +#include "cpu.h" + +/* + * opaque structure definition + */ +struct FLAC__BitReader; +typedef struct FLAC__BitReader FLAC__BitReader; + +typedef FLAC__bool (*FLAC__BitReaderReadCallback)(FLAC__byte buffer[], size_t *bytes, void *client_data); + +/* + * construction, deletion, initialization, etc functions + */ +FLAC__BitReader *FLAC__bitreader_new(void); +void FLAC__bitreader_delete(FLAC__BitReader *br); +FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback rcb, void *cd); +void FLAC__bitreader_free(FLAC__BitReader *br); /* does not 'free(br)' */ +FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br); +void FLAC__bitreader_set_framesync_location(FLAC__BitReader *br); +FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(FLAC__BitReader *br); + +/* + * CRC functions + */ +void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed); +FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br); + +/* + * info functions + */ +FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); +uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); +uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); +void FLAC__bitreader_set_limit(FLAC__BitReader *br, uint32_t limit); +void FLAC__bitreader_remove_limit(FLAC__BitReader *br); +uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br); +void FLAC__bitreader_limit_invalidate(FLAC__BitReader *br); + +/* + * read functions + */ + +FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_raw_int64(FLAC__BitReader *br, FLAC__int64 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/ +FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */ +FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ +FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ +FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val); +FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter); +FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); +#ifdef FLAC__BMI2_SUPPORTED +FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); +#endif + +#if 0 /* UNUSED */ +FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter); +FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter); +#endif +FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen); +FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen); +#endif diff --git a/packages/third-party/libFLAC/private/bitwriter.h b/packages/third-party/libFLAC/private/bitwriter.h new file mode 100644 index 00000000..08ac0f12 --- /dev/null +++ b/packages/third-party/libFLAC/private/bitwriter.h @@ -0,0 +1,104 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__BITWRITER_H +#define FLAC__PRIVATE__BITWRITER_H + +#include /* for FILE */ +#include "FLAC/ordinals.h" + +/* + * opaque structure definition + */ +struct FLAC__BitWriter; +typedef struct FLAC__BitWriter FLAC__BitWriter; + +/* + * construction, deletion, initialization, etc functions + */ +FLAC__BitWriter *FLAC__bitwriter_new(void); +void FLAC__bitwriter_delete(FLAC__BitWriter *bw); +FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw); +void FLAC__bitwriter_free(FLAC__BitWriter *bw); /* does not 'free(buffer)' */ +void FLAC__bitwriter_clear(FLAC__BitWriter *bw); + +/* + * CRC functions + * + * non-const *bw because they have to cal FLAC__bitwriter_get_buffer() + */ +FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc); +FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc); + +/* + * info functions + */ +FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw); +uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */ + +/* + * direct buffer access + * + * there may be no calls on the bitwriter between get and release. + * the bitwriter continues to own the returned buffer. + * before get, bitwriter MUST be byte aligned: check with FLAC__bitwriter_is_byte_aligned() + */ +FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes); +void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw); + +/* + * write functions + */ +FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_int64(FLAC__BitWriter *bw, FLAC__int64 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/ +FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals); +FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val); +#if 0 /* UNUSED */ +uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter); +uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter); +uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t val, uint32_t parameter); +FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter); +#endif +FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter); +#if 0 /* UNUSED */ +FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter); +FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t val, uint32_t parameter); +#endif +FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val); +FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val); +FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw); + +#endif diff --git a/packages/third-party/libFLAC/private/cpu.h b/packages/third-party/libFLAC/private/cpu.h new file mode 100644 index 00000000..8db00c8d --- /dev/null +++ b/packages/third-party/libFLAC/private/cpu.h @@ -0,0 +1,198 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__CPU_H +#define FLAC__PRIVATE__CPU_H + +#include "FLAC/ordinals.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef FLAC__CPU_X86_64 + +#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) +#define FLAC__CPU_X86_64 +#endif + +#endif + +#ifndef FLAC__CPU_IA32 + +#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86) +#define FLAC__CPU_IA32 +#endif + +#endif + +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + +#if FLAC__HAS_X86INTRIN +/* SSE intrinsics support by ICC/MSVC/GCC */ +#if defined __INTEL_COMPILER + #define FLAC__SSE_TARGET(x) + #define FLAC__SSE_SUPPORTED 1 + #define FLAC__SSE2_SUPPORTED 1 + #if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */ + #define FLAC__SSSE3_SUPPORTED 1 + #define FLAC__SSE4_1_SUPPORTED 1 + #define FLAC__SSE4_2_SUPPORTED 1 + #endif + #ifdef FLAC__USE_AVX + #if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */ + #define FLAC__AVX_SUPPORTED 1 + #endif + #if (__INTEL_COMPILER >= 1300) /* Intel C++ Compiler 13.0 */ + #define FLAC__AVX2_SUPPORTED 1 + #define FLAC__FMA_SUPPORTED 1 + #endif + #endif +#elif defined __clang__ && __has_attribute(__target__) /* clang */ + #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) + #define FLAC__SSE_SUPPORTED 1 + #define FLAC__SSE2_SUPPORTED 1 + #define FLAC__SSSE3_SUPPORTED 1 + #define FLAC__SSE4_1_SUPPORTED 1 + #define FLAC__SSE4_2_SUPPORTED 1 + #ifdef FLAC__USE_AVX + #define FLAC__AVX_SUPPORTED 1 + #define FLAC__AVX2_SUPPORTED 1 + #define FLAC__FMA_SUPPORTED 1 + #define FLAC__BMI2_SUPPORTED 1 + #endif +#elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */ + #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) + #define FLAC__SSE_SUPPORTED 1 + #define FLAC__SSE2_SUPPORTED 1 + #define FLAC__SSSE3_SUPPORTED 1 + #define FLAC__SSE4_1_SUPPORTED 1 + #define FLAC__SSE4_2_SUPPORTED 1 + #ifdef FLAC__USE_AVX + #define FLAC__AVX_SUPPORTED 1 + #define FLAC__AVX2_SUPPORTED 1 + #define FLAC__FMA_SUPPORTED 1 + #define FLAC__BMI2_SUPPORTED 1 + #endif +#elif defined _MSC_VER + #define FLAC__SSE_TARGET(x) + #define FLAC__SSE_SUPPORTED 1 + #define FLAC__SSE2_SUPPORTED 1 + #if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */ + #define FLAC__SSSE3_SUPPORTED 1 + #define FLAC__SSE4_1_SUPPORTED 1 + #define FLAC__SSE4_2_SUPPORTED 1 + #endif + #ifdef FLAC__USE_AVX + #if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */ + #define FLAC__AVX_SUPPORTED 1 + #endif + #if (_MSC_VER >= 1700) /* MS Visual Studio 2012 */ + #define FLAC__AVX2_SUPPORTED 1 + #define FLAC__FMA_SUPPORTED 1 + #endif + #endif +#else + #define FLAC__SSE_TARGET(x) + #ifdef __SSE__ + #define FLAC__SSE_SUPPORTED 1 + #endif + #ifdef __SSE2__ + #define FLAC__SSE2_SUPPORTED 1 + #endif + #ifdef __SSSE3__ + #define FLAC__SSSE3_SUPPORTED 1 + #endif + #ifdef __SSE4_1__ + #define FLAC__SSE4_1_SUPPORTED 1 + #endif + #ifdef __SSE4_2__ + #define FLAC__SSE4_2_SUPPORTED 1 + #endif + #ifdef FLAC__USE_AVX + #ifdef __AVX__ + #define FLAC__AVX_SUPPORTED 1 + #endif + #ifdef __AVX2__ + #define FLAC__AVX2_SUPPORTED 1 + #endif + #ifdef __FMA__ + #define FLAC__FMA_SUPPORTED 1 + #endif + #endif +#endif /* compiler version */ +#endif /* intrinsics support */ + + +#ifndef FLAC__AVX_SUPPORTED +#define FLAC__AVX_SUPPORTED 0 +#endif + +typedef enum { + FLAC__CPUINFO_TYPE_IA32, + FLAC__CPUINFO_TYPE_X86_64, + FLAC__CPUINFO_TYPE_UNKNOWN +} FLAC__CPUInfo_Type; + +typedef struct { + FLAC__bool intel; + + FLAC__bool cmov; + FLAC__bool mmx; + FLAC__bool sse; + FLAC__bool sse2; + + FLAC__bool sse3; + FLAC__bool ssse3; + FLAC__bool sse41; + FLAC__bool sse42; + FLAC__bool avx; + FLAC__bool avx2; + FLAC__bool fma; + FLAC__bool bmi2; +} FLAC__CPUInfo_x86; + +typedef struct { + FLAC__bool use_asm; + FLAC__CPUInfo_Type type; + FLAC__CPUInfo_x86 x86; +} FLAC__CPUInfo; + +void FLAC__cpu_info(FLAC__CPUInfo *info); + +FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void); + +void FLAC__cpu_info_asm_ia32(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx); + +#endif diff --git a/packages/third-party/libFLAC/private/crc.h b/packages/third-party/libFLAC/private/crc.h new file mode 100644 index 00000000..3acc256d --- /dev/null +++ b/packages/third-party/libFLAC/private/crc.h @@ -0,0 +1,60 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__CRC_H +#define FLAC__PRIVATE__CRC_H + +#include "FLAC/ordinals.h" + +/* 8 bit CRC generator, MSB shifted first +** polynomial = x^8 + x^2 + x^1 + x^0 +** init = 0 +*/ +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len); + +/* 16 bit CRC generator, MSB shifted first +** polynomial = x^16 + x^15 + x^2 + x^0 +** init = 0 +*/ +extern FLAC__uint16 const FLAC__crc16_table[8][256]; + +#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)]) +/* this alternate may be faster on some systems/compilers */ +#if 0 +#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)]) & 0xffff) +#endif + +FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len); +FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc); +FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc); + +#endif diff --git a/packages/third-party/libFLAC/private/fixed.h b/packages/third-party/libFLAC/private/fixed.h new file mode 100644 index 00000000..dc4a15da --- /dev/null +++ b/packages/third-party/libFLAC/private/fixed.h @@ -0,0 +1,117 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__FIXED_H +#define FLAC__PRIVATE__FIXED_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "private/cpu.h" +#include "private/float.h" +#include "FLAC/format.h" + +/* + * FLAC__fixed_compute_best_predictor() + * -------------------------------------------------------------------- + * Compute the best fixed predictor and the expected bits-per-sample + * of the residual signal for each order. The _wide() version uses + * 64-bit integers which is statistically necessary when bits-per- + * sample + log2(blocksize) > 30 + * + * IN data[0,data_len-1] + * IN data_len + * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] + */ +#ifndef FLAC__INTEGER_ONLY_LIBRARY +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +# ifndef FLAC__NO_ASM +# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN +# ifdef FLAC__SSE2_SUPPORTED +uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); +# endif +# ifdef FLAC__SSSE3_SUPPORTED +uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +# endif +# ifdef FLAC__SSE4_2_SUPPORTED +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +# endif +# ifdef FLAC__AVX2_SUPPORTED +uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +# endif +# endif +# endif +#else +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +#endif + +/* + * FLAC__fixed_compute_residual() + * -------------------------------------------------------------------- + * Compute the residual signal obtained from sutracting the predicted + * signal from the original. + * + * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) + * IN data_len length of original signal + * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order + * OUT residual[0,data_len-1] residual signal + */ +void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); +void FLAC__fixed_compute_residual_wide(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); +void FLAC__fixed_compute_residual_wide_33bit(const FLAC__int64 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); + +/* + * FLAC__fixed_restore_signal() + * -------------------------------------------------------------------- + * Restore the original signal by summing the residual and the + * predictor. + * + * IN residual[0,data_len-1] residual signal + * IN data_len length of original signal + * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order + * *** IMPORTANT: the caller must pass in the historical samples: + * IN data[-order,-1] previously-reconstructed historical samples + * OUT data[0,data_len-1] original signal + */ +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]); +void FLAC__fixed_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]); +void FLAC__fixed_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int64 data[]); + +#endif diff --git a/packages/third-party/libFLAC/private/float.h b/packages/third-party/libFLAC/private/float.h new file mode 100644 index 00000000..21c832a5 --- /dev/null +++ b/packages/third-party/libFLAC/private/float.h @@ -0,0 +1,95 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__FLOAT_H +#define FLAC__PRIVATE__FLOAT_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "FLAC/ordinals.h" + +/* + * All the code in libFLAC that uses float and double + * should be protected by checks of the macro + * FLAC__INTEGER_ONLY_LIBRARY. + * + */ +#ifndef FLAC__INTEGER_ONLY_LIBRARY +/* + * FLAC__real is the basic floating point type used in LPC analysis. + * + * WATCHOUT: changing FLAC__real will change the signatures of many + * functions that have assembly language equivalents and break them. + */ +typedef float FLAC__real; +#else +/* + * The convention for FLAC__fixedpoint is to use the upper 16 bits + * for the integer part and lower 16 bits for the fractional part. + */ +typedef FLAC__int32 FLAC__fixedpoint; +extern const FLAC__fixedpoint FLAC__FP_ZERO; +extern const FLAC__fixedpoint FLAC__FP_ONE_HALF; +extern const FLAC__fixedpoint FLAC__FP_ONE; +extern const FLAC__fixedpoint FLAC__FP_LN2; +extern const FLAC__fixedpoint FLAC__FP_E; + +#define FLAC__fixedpoint_trunc(x) ((x)>>16) + +#define FLAC__fixedpoint_mul(x, y) ( (FLAC__fixedpoint) ( ((FLAC__int64)(x)*(FLAC__int64)(y)) >> 16 ) ) + +#define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) ) + +/* + * FLAC__fixedpoint_log2() + * -------------------------------------------------------------------- + * Returns the base-2 logarithm of the fixed-point number 'x' using an + * algorithm by Knuth for x >= 1.0 + * + * 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must + * be < 32 and evenly divisible by 4 (0 is OK but not very precise). + * + * 'precision' roughly limits the number of iterations that are done; + * use (uint32_t)(-1) for maximum precision. + * + * If 'x' is less than one -- that is, x < (1< +#endif + +#include "private/cpu.h" +#include "private/float.h" +#include "FLAC/format.h" + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +/* + * FLAC__lpc_window_data() + * -------------------------------------------------------------------- + * Applies the given window to the data. + * OPT: asm implementation + * + * IN in[0,data_len-1] + * IN window[0,data_len-1] + * OUT out[0,lag-1] + * IN data_len + */ +void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len); +void FLAC__lpc_window_data_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len); +void FLAC__lpc_window_data_partial(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift); +void FLAC__lpc_window_data_partial_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift); + +/* + * FLAC__lpc_compute_autocorrelation() + * -------------------------------------------------------------------- + * Compute the autocorrelation for lags between 0 and lag-1. + * Assumes data[] outside of [0,data_len-1] == 0. + * Asserts that lag > 0. + * + * IN data[0,data_len-1] + * IN data_len + * IN 0 < lag <= data_len + * OUT autoc[0,lag-1] + */ +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +#ifndef FLAC__NO_ASM +# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN +# ifdef FLAC__SSE2_SUPPORTED +void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +# endif +# endif +# if defined FLAC__CPU_X86_64 && FLAC__HAS_X86INTRIN +# ifdef FLAC__FMA_SUPPORTED +void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +# endif +# endif +#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN && FLAC__HAS_A64NEONINTRIN +void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); +#endif +#endif /* FLAC__NO_ASM */ + +/* + * FLAC__lpc_compute_lp_coefficients() + * -------------------------------------------------------------------- + * Computes LP coefficients for orders 1..max_order. + * Do not call if autoc[0] == 0.0. This means the signal is zero + * and there is no point in calculating a predictor. + * + * IN autoc[0,max_order] autocorrelation values + * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute + * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order + * *** IMPORTANT: + * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched + * OUT error[0,max_order-1] error for each order (more + * specifically, the variance of + * the error signal times # of + * samples in the signal) + * + * Example: if max_order is 9, the LP coefficients for order 9 will be + * in lp_coeff[8][0,8], the LP coefficients for order 8 will be + * in lp_coeff[7][0,7], etc. + */ +void FLAC__lpc_compute_lp_coefficients(const double autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]); + +/* + * FLAC__lpc_quantize_coefficients() + * -------------------------------------------------------------------- + * Quantizes the LP coefficients. NOTE: precision + bits_per_sample + * must be less than 32 (sizeof(FLAC__int32)*8). + * + * IN lp_coeff[0,order-1] LP coefficients + * IN order LP order + * IN FLAC__MIN_QLP_COEFF_PRECISION < precision + * desired precision (in bits, including sign + * bit) of largest coefficient + * OUT qlp_coeff[0,order-1] quantized coefficients + * OUT shift # of bits to shift right to get approximated + * LP coefficients. NOTE: could be negative. + * RETURN 0 => quantization OK + * 1 => coefficients require too much shifting for *shift to + * fit in the LPC subframe header. 'shift' is unset. + * 2 => coefficients are all zero, which is bad. 'shift' is + * unset. + */ +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift); + +/* + * FLAC__lpc_compute_residual_from_qlp_coefficients() + * -------------------------------------------------------------------- + * Compute the residual signal obtained from sutracting the predicted + * signal from the original. + * + * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) + * IN data_len length of original signal + * IN qlp_coeff[0,order-1] quantized LP coefficients + * IN order > 0 LP order + * IN lp_quantization quantization of LP coefficients in bits + * OUT residual[0,data_len-1] residual signal + */ +void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(const FLAC__int64 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +#ifndef FLAC__NO_ASM +# ifdef FLAC__CPU_ARM64 +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +# endif + +# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN +# ifdef FLAC__SSE2_SUPPORTED +void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +# endif +# ifdef FLAC__SSE4_1_SUPPORTED +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +# endif +# ifdef FLAC__AVX2_SUPPORTED +void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); +# endif +# endif +#endif + +#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ + +FLAC__uint64 FLAC__lpc_max_prediction_value_before_shift(uint32_t subframe_bps, const FLAC__int32 qlp_coeff[], uint32_t order); +uint32_t FLAC__lpc_max_prediction_before_shift_bps(uint32_t subframe_bps, const FLAC__int32 qlp_coeff[], uint32_t order); +uint32_t FLAC__lpc_max_residual_bps(uint32_t subframe_bps, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization); + +/* + * FLAC__lpc_restore_signal() + * -------------------------------------------------------------------- + * Restore the original signal by summing the residual and the + * predictor. + * + * IN residual[0,data_len-1] residual signal + * IN data_len length of original signal + * IN qlp_coeff[0,order-1] quantized LP coefficients + * IN order > 0 LP order + * IN lp_quantization quantization of LP coefficients in bits + * *** IMPORTANT: the caller must pass in the historical samples: + * IN data[-order,-1] previously-reconstructed historical samples + * OUT data[0,data_len-1] original signal + */ +void FLAC__lpc_restore_signal(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int64 data[]); + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +/* + * FLAC__lpc_compute_expected_bits_per_residual_sample() + * -------------------------------------------------------------------- + * Compute the expected number of bits per residual signal sample + * based on the LP error (which is related to the residual variance). + * + * IN lpc_error >= 0.0 error returned from calculating LP coefficients + * IN total_samples > 0 # of samples in residual signal + * RETURN expected bits per sample + */ +double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples); +double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale); + +/* + * FLAC__lpc_compute_best_order() + * -------------------------------------------------------------------- + * Compute the best order from the array of signal errors returned + * during coefficient computation. + * + * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients + * IN max_order > 0 max LP order + * IN total_samples > 0 # of samples in residual signal + * IN overhead_bits_per_order # of bits overhead for each increased LP order + * (includes warmup sample size and quantized LP coefficient) + * RETURN [1,max_order] best order + */ +uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order); + +#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ + +#endif diff --git a/packages/third-party/libFLAC/private/macros.h b/packages/third-party/libFLAC/private/macros.h new file mode 100644 index 00000000..4b94c86a --- /dev/null +++ b/packages/third-party/libFLAC/private/macros.h @@ -0,0 +1,74 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2012-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__MACROS_H +#define FLAC__PRIVATE__MACROS_H + +#if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + +#define flac_max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) + +#define MIN_PASTE(A,B) A##B +#define MIN_IMPL(A,B,L) ({ \ + __typeof__(A) MIN_PASTE(__a,L) = (A); \ + __typeof__(B) MIN_PASTE(__b,L) = (B); \ + MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \ + }) + +#define flac_min(A,B) MIN_IMPL(A,B,__COUNTER__) + +/* Whatever other unix that has sys/param.h */ +#elif defined(HAVE_SYS_PARAM_H) +#include +#if defined(MIN) && defined(MAX) +#define flac_max(a,b) MAX(a,b) +#define flac_min(a,b) MIN(a,b) +#endif + +/* Windows VS has them in stdlib.h.. XXX:Untested */ +#elif defined(_MSC_VER) +#include +#define flac_max(a,b) __max(a,b) +#define flac_min(a,b) __min(a,b) +#endif + +#ifndef flac_min +#define flac_min(x,y) ((x) <= (y) ? (x) : (y)) +#endif + +#ifndef flac_max +#define flac_max(x,y) ((x) >= (y) ? (x) : (y)) +#endif + +#endif diff --git a/packages/third-party/libFLAC/private/md5.h b/packages/third-party/libFLAC/private/md5.h new file mode 100644 index 00000000..f9d79c3e --- /dev/null +++ b/packages/third-party/libFLAC/private/md5.h @@ -0,0 +1,50 @@ +#ifndef FLAC__PRIVATE__MD5_H +#define FLAC__PRIVATE__MD5_H + +/* + * This is the header file for the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + * Changed so as no longer to depend on Colin Plumb's `usual.h' + * header definitions; now uses stuff from dpkg's config.h + * - Ian Jackson . + * Still in the public domain. + * + * Josh Coalson: made some changes to integrate with libFLAC. + * Still in the public domain, with no warranty. + */ + +#include "FLAC/ordinals.h" + +typedef union { + FLAC__byte *p8; + FLAC__int16 *p16; + FLAC__int32 *p32; +} FLAC__multibyte; + +typedef struct { + FLAC__uint32 in[16]; + FLAC__uint32 buf[4]; + FLAC__uint32 bytes[2]; + FLAC__multibyte internal_buf; + size_t capacity; +} FLAC__MD5Context; + +void FLAC__MD5Init(FLAC__MD5Context *context); +void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); + +FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample); + +#endif diff --git a/packages/third-party/libFLAC/private/memory.h b/packages/third-party/libFLAC/private/memory.h new file mode 100644 index 00000000..98452164 --- /dev/null +++ b/packages/third-party/libFLAC/private/memory.h @@ -0,0 +1,58 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__MEMORY_H +#define FLAC__PRIVATE__MEMORY_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include /* for size_t */ + +#include "private/float.h" +#include "FLAC/ordinals.h" /* for FLAC__bool */ + +/* Returns the unaligned address returned by malloc. + * Use free() on this address to deallocate. + */ +void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); +FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_int64_array(size_t elements, FLAC__int64 **unaligned_pointer, FLAC__int64 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); +#ifndef FLAC__INTEGER_ONLY_LIBRARY +FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); +#endif +void *safe_malloc_mul_2op_p(size_t size1, size_t size2); + +#endif diff --git a/packages/third-party/libFLAC/private/metadata.h b/packages/third-party/libFLAC/private/metadata.h new file mode 100644 index 00000000..46874e65 --- /dev/null +++ b/packages/third-party/libFLAC/private/metadata.h @@ -0,0 +1,46 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__METADATA_H +#define FLAC__PRIVATE__METADATA_H + +#include "FLAC/metadata.h" + +/* WATCHOUT: all malloc()ed data in the block is free()ed; this may not + * be a consistent state (e.g. PICTURE) or equivalent to the initial + * state after FLAC__metadata_object_new() + */ +void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object); + +void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object); + +#endif diff --git a/packages/third-party/libFLAC/private/ogg_decoder_aspect.h b/packages/third-party/libFLAC/private/ogg_decoder_aspect.h new file mode 100644 index 00000000..6dbfe9d7 --- /dev/null +++ b/packages/third-party/libFLAC/private/ogg_decoder_aspect.h @@ -0,0 +1,80 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__OGG_DECODER_ASPECT_H +#define FLAC__PRIVATE__OGG_DECODER_ASPECT_H + +#include + +#include "FLAC/ordinals.h" +#include "FLAC/stream_decoder.h" /* for FLAC__StreamDecoderReadStatus */ + +typedef struct FLAC__OggDecoderAspect { + /* these are storage for values that can be set through the API */ + FLAC__bool use_first_serial_number; + long serial_number; + + /* these are for internal state related to Ogg decoding */ + ogg_stream_state stream_state; + ogg_sync_state sync_state; + uint32_t version_major, version_minor; + FLAC__bool need_serial_number; + FLAC__bool end_of_stream; + FLAC__bool have_working_page; /* only if true will the following vars be valid */ + ogg_page working_page; + FLAC__bool have_working_packet; /* only if true will the following vars be valid */ + ogg_packet working_packet; /* as we work through the packet we will move working_packet.packet forward and working_packet.bytes down */ +} FLAC__OggDecoderAspect; + +void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value); +void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect); +FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect); +void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect); +void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect); +void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect); + +typedef enum { + FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK = 0, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR, + FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR +} FLAC__OggDecoderAspectReadStatus; + +typedef FLAC__OggDecoderAspectReadStatus (*FLAC__OggDecoderAspectReadCallbackProxy)(const void *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); + +FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data); + +#endif diff --git a/packages/third-party/libFLAC/private/ogg_helper.h b/packages/third-party/libFLAC/private/ogg_helper.h new file mode 100644 index 00000000..1064cb52 --- /dev/null +++ b/packages/third-party/libFLAC/private/ogg_helper.h @@ -0,0 +1,44 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__OGG_HELPER_H +#define FLAC__PRIVATE__OGG_HELPER_H + +#include +#include "FLAC/stream_encoder.h" /* for FLAC__StreamEncoder */ + +void simple_ogg_page__init(ogg_page *page); +void simple_ogg_page__clear(ogg_page *page); +FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data); +FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data); + +#endif diff --git a/packages/third-party/libFLAC/private/ogg_mapping.h b/packages/third-party/libFLAC/private/ogg_mapping.h new file mode 100644 index 00000000..66f57be1 --- /dev/null +++ b/packages/third-party/libFLAC/private/ogg_mapping.h @@ -0,0 +1,64 @@ +/* libFLAC - Free Lossless Audio Codec + * Copyright (C) 2004-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__OGG_MAPPING_H +#define FLAC__PRIVATE__OGG_MAPPING_H + +#include "FLAC/ordinals.h" + +/** The length of the packet type field in bytes. */ +#define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u) + +extern const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */ + +extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */ + +/** The length of the 'FLAC' magic in bytes. */ +#define FLAC__OGG_MAPPING_MAGIC_LENGTH (4u) + +extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */ + +extern const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */ +extern const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */ + +/** The length of the Ogg FLAC mapping major version number in bytes. */ +#define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u) + +/** The length of the Ogg FLAC mapping minor version number in bytes. */ +#define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u) + +extern const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */ + +/** The length of the #-of-header-packets number bytes. */ +#define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u) + +#endif diff --git a/packages/third-party/libFLAC/private/stream_encoder_framing.h b/packages/third-party/libFLAC/private/stream_encoder_framing.h new file mode 100644 index 00000000..d15b5d49 --- /dev/null +++ b/packages/third-party/libFLAC/private/stream_encoder_framing.h @@ -0,0 +1,46 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H +#define FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H + +#include "FLAC/format.h" +#include "bitwriter.h" + +FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw, FLAC__bool update_vendor_string); +FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); + +#endif diff --git a/packages/third-party/libFLAC/private/window.h b/packages/third-party/libFLAC/private/window.h new file mode 100644 index 00000000..19570aa0 --- /dev/null +++ b/packages/third-party/libFLAC/private/window.h @@ -0,0 +1,74 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2006-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PRIVATE__WINDOW_H +#define FLAC__PRIVATE__WINDOW_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "private/float.h" +#include "FLAC/format.h" + +#ifndef FLAC__INTEGER_ONLY_LIBRARY + +/* + * FLAC__window_*() + * -------------------------------------------------------------------- + * Calculates window coefficients according to different apodization + * functions. + * + * OUT window[0,L-1] + * IN L (number of points in window) + */ +void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_blackman(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_blackman_harris_4term_92db_sidelobe(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_connes(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev); /* 0.0 < stddev <= 0.5 */ +void FLAC__window_hamming(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_hann(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_kaiser_bessel(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_nuttall(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_rectangle(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_triangle(FLAC__real *window, const FLAC__int32 L); +void FLAC__window_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p); +void FLAC__window_partial_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end); +void FLAC__window_punchout_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end); +void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L); + +#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ + +#endif diff --git a/packages/third-party/libFLAC/protected/all.h b/packages/third-party/libFLAC/protected/all.h new file mode 100644 index 00000000..39b5094a --- /dev/null +++ b/packages/third-party/libFLAC/protected/all.h @@ -0,0 +1,39 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2001-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PROTECTED__ALL_H +#define FLAC__PROTECTED__ALL_H + +#include "stream_decoder.h" +#include "stream_encoder.h" + +#endif diff --git a/packages/third-party/libFLAC/protected/stream_decoder.h b/packages/third-party/libFLAC/protected/stream_decoder.h new file mode 100644 index 00000000..7a664938 --- /dev/null +++ b/packages/third-party/libFLAC/protected/stream_decoder.h @@ -0,0 +1,60 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__PROTECTED__STREAM_DECODER_H +#define FLAC__PROTECTED__STREAM_DECODER_H + +#include "FLAC/stream_decoder.h" +#if FLAC__HAS_OGG +#include "private/ogg_decoder_aspect.h" +#endif + +typedef struct FLAC__StreamDecoderProtected { + FLAC__StreamDecoderState state; + FLAC__StreamDecoderInitStatus initstate; + uint32_t channels; + FLAC__ChannelAssignment channel_assignment; + uint32_t bits_per_sample; + uint32_t sample_rate; /* in Hz */ + uint32_t blocksize; /* in samples (per channel) */ + FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */ +#if FLAC__HAS_OGG + FLAC__OggDecoderAspect ogg_decoder_aspect; +#endif +} FLAC__StreamDecoderProtected; + +/* + * Return the number of input bytes consumed + */ +uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); + +#endif diff --git a/packages/third-party/libFLAC/share/alloc.h b/packages/third-party/libFLAC/share/alloc.h new file mode 100644 index 00000000..eedd9769 --- /dev/null +++ b/packages/third-party/libFLAC/share/alloc.h @@ -0,0 +1,322 @@ +/* alloc - Convenience routines for safely allocating memory + * Copyright (C) 2007-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__SHARE__ALLOC_H +#define FLAC__SHARE__ALLOC_H + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early + * before #including this file, otherwise SIZE_MAX might not be defined + */ + +#include /* for SIZE_MAX */ +#ifdef HAVE_STDINT_H +#include /* for SIZE_MAX in case limits.h didn't get it */ +#endif +#include /* for size_t, malloc(), etc */ +#include "share/compat.h" + +#ifndef SIZE_MAX +# ifndef SIZE_T_MAX +# ifdef _MSC_VER +# ifdef _WIN64 +# define SIZE_T_MAX FLAC__U64L(0xffffffffffffffff) +# else +# define SIZE_T_MAX 0xffffffff +# endif +# else +# error +# endif +# endif +# define SIZE_MAX SIZE_T_MAX +#endif + +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + +extern int alloc_check_threshold, alloc_check_counter, alloc_check_keep_failing; + +static inline int alloc_check(void) { + if(alloc_check_threshold == INT32_MAX) + return 0; + else if(alloc_check_counter++ == alloc_check_threshold) + return 1; + else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold)) + return 1; + else { + return 0; + } +} + +#endif + +/* avoid malloc()ing 0 bytes, see: + * https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003 +*/ + +static inline void *safe_malloc_(size_t size) +{ +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Fail if requested */ + if(alloc_check()) + return NULL; +#endif + /* malloc(0) is undefined; FLAC src convention is to always allocate */ + if(!size) + size++; + return malloc(size); +} + +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +static inline void *malloc_(size_t size) +{ + /* Fail if requested */ + if(alloc_check()) + return NULL; + return malloc(size); +} +#else +#define malloc_ malloc +#endif + + + +static inline void *safe_calloc_(size_t nmemb, size_t size) +{ +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Fail if requested */ + if(alloc_check()) + return NULL; +#endif + if(!nmemb || !size) + return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ + return calloc(nmemb, size); +} + +/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */ + +static inline void *safe_malloc_add_2op_(size_t size1, size_t size2) +{ + size2 += size1; + if(size2 < size1) + return 0; + return safe_malloc_(size2); +} + +static inline void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3) +{ + size2 += size1; + if(size2 < size1) + return 0; + size3 += size2; + if(size3 < size2) + return 0; + return safe_malloc_(size3); +} + +static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4) +{ + size2 += size1; + if(size2 < size1) + return 0; + size3 += size2; + if(size3 < size2) + return 0; + size4 += size3; + if(size4 < size3) + return 0; + return safe_malloc_(size4); +} + +void *safe_malloc_mul_2op_(size_t size1, size_t size2) ; + +static inline void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3) +{ + if(!size1 || !size2 || !size3) + return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ + if(size1 > SIZE_MAX / size2) + return 0; + size1 *= size2; + if(size1 > SIZE_MAX / size3) + return 0; + return malloc_(size1*size3); +} + +/* size1*size2 + size3 */ +static inline void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3) +{ + if(!size1 || !size2) + return safe_malloc_(size3); + if(size1 > SIZE_MAX / size2) + return 0; + return safe_malloc_add_2op_(size1*size2, size3); +} + +/* size1 * (size2 + size3) */ +static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3) +{ + if(!size1 || (!size2 && !size3)) + return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ + size2 += size3; + if(size2 < size3) + return 0; + if(size1 > SIZE_MAX / size2) + return 0; + return malloc_(size1*size2); +} + +static inline void *safe_realloc_(void *ptr, size_t size) +{ + void *oldptr; + void *newptr; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Fail if requested */ + if(alloc_check() && size > 0) { + free(ptr); + return NULL; + } +#endif + oldptr = ptr; + newptr = realloc(ptr, size); + if(size > 0 && newptr == 0) + free(oldptr); + return newptr; +} + +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +static inline void *realloc_(void *ptr, size_t size) +{ + /* Fail if requested */ + if(alloc_check()) + return NULL; + return realloc(ptr, size); +} +#else +#define realloc_ realloc +#endif + + +static inline void *safe_realloc_nofree_add_2op_(void *ptr, size_t size1, size_t size2) +{ + size2 += size1; + if(size2 < size1) + return 0; + return realloc_(ptr, size2); +} + +static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3) +{ + size2 += size1; + if(size2 < size1) { + free(ptr); + return 0; + } + size3 += size2; + if(size3 < size2) { + free(ptr); + return 0; + } + return safe_realloc_(ptr, size3); +} + +static inline void *safe_realloc_nofree_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3) +{ + size2 += size1; + if(size2 < size1) + return 0; + size3 += size2; + if(size3 < size2) + return 0; + return realloc_(ptr, size3); +} + +static inline void *safe_realloc_nofree_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4) +{ + size2 += size1; + if(size2 < size1) + return 0; + size3 += size2; + if(size3 < size2) + return 0; + size4 += size3; + if(size4 < size3) + return 0; + return realloc_(ptr, size4); +} + +static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2) +{ + if(!size1 || !size2) + return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ + if(size1 > SIZE_MAX / size2) { + free(ptr); + return 0; + } + return safe_realloc_(ptr, size1*size2); +} + +static inline void *safe_realloc_nofree_mul_2op_(void *ptr, size_t size1, size_t size2) +{ + if(!size1 || !size2) + return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ + if(size1 > SIZE_MAX / size2) + return 0; + return realloc_(ptr, size1*size2); +} + +/* size1 * (size2 + size3) */ +static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3) +{ + if(!size1 || (!size2 && !size3)) + return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ + size2 += size3; + if(size2 < size3) { + free(ptr); + return 0; + } + return safe_realloc_mul_2op_(ptr, size1, size2); +} + +/* size1 * (size2 + size3) */ +static inline void *safe_realloc_nofree_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3) +{ + if(!size1 || (!size2 && !size3)) + return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ + size2 += size3; + if(size2 < size3) + return 0; + return safe_realloc_nofree_mul_2op_(ptr, size1, size2); +} + +#endif diff --git a/packages/third-party/libFLAC/share/compat.h b/packages/third-party/libFLAC/share/compat.h new file mode 100644 index 00000000..9aa94350 --- /dev/null +++ b/packages/third-party/libFLAC/share/compat.h @@ -0,0 +1,248 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2012-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* This is the preferred location of all CPP hackery to make $random_compiler + * work like something approaching a C99 (or maybe more accurately GNU99) + * compiler. + * + * It is assumed that this header will be included after "config.h". + */ + +#ifndef FLAC__SHARE__COMPAT_H +#define FLAC__SHARE__COMPAT_H + +#include +#include +#include + +#if defined _WIN32 && !defined __CYGWIN__ +/* where MSVC puts unlink() */ +# include +#else +# include +#endif + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#include /* for off_t */ +#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ +#define FLAC__OFF_T_MAX INT64_MAX +#if !defined __MINGW32__ +#define fseeko _fseeki64 +#define ftello _ftelli64 +#else /* MinGW */ +#if !defined(HAVE_FSEEKO) +#define fseeko fseeko64 +#define ftello ftello64 +#endif +#endif +#else +#ifndef HAVE_FSEEKO +#define fseeko fseek +#define ftello ftell +#define FLAC__off_t long +#define FLAC__OFF_T_MAX LONG_MAX +#else +#define FLAC__off_t off_t +#define FLAC__OFF_T_MAX OFF_T_MAX +#endif +#endif + + + +#ifdef HAVE_INTTYPES_H +#define __STDC_FORMAT_MACROS +#include +#endif + +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#endif + +#if defined(_MSC_VER) && !defined(__cplusplus) +#define inline __inline +#endif + +#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) +/* MSVS generates VERY slow 32-bit code with __restrict */ +#define flac_restrict __restrict +#elif defined __GNUC__ +#define flac_restrict __restrict__ +#else +#define flac_restrict +#endif + +#define FLAC__U64L(x) x##ULL + +#if defined _MSC_VER || defined __MINGW32__ +#define FLAC__STRCASECMP _stricmp +#define FLAC__STRNCASECMP _strnicmp +#elif defined __BORLANDC__ +#define FLAC__STRCASECMP stricmp +#define FLAC__STRNCASECMP strnicmp +#else +#define FLAC__STRCASECMP strcasecmp +#define FLAC__STRNCASECMP strncasecmp +#endif + +#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ +#include /* for _setmode(), chmod() */ +#include /* for _O_BINARY */ +#else +#include /* for chown(), unlink() */ +#endif + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#if defined __BORLANDC__ +#include /* for utime() */ +#else +#include /* for utime() */ +#endif +#else +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) +#include +#else +#include /* some flavors of BSD (like OS X) require this to get time_t */ +#include /* for utime() */ +#endif +#endif + +#if defined _MSC_VER +# if _MSC_VER >= 1800 +# include +# elif _MSC_VER >= 1600 +/* Visual Studio 2010 has decent C99 support */ +# include +# define PRIu64 "llu" +# define PRId64 "lld" +# define PRIx64 "llx" +# else +# include +# ifndef UINT32_MAX +# define UINT32_MAX _UI32_MAX +# endif +# define PRIu64 "I64u" +# define PRId64 "I64d" +# define PRIx64 "I64x" +# endif +# if defined(_USING_V110_SDK71_) && !defined(_DLL) +# pragma message("WARNING: This compile will NOT FUNCTION PROPERLY on Windows XP. See comments in include/share/compat.h for details") +#define FLAC__USE_FILELENGTHI64 +/* + ************************************************************************************* + * V110_SDK71, in MSVC 2017 also known as v141_xp, is a platform toolset that is supposed + * to target Windows XP. It turns out however that certain functions provided silently fail + * on Windows XP only, which makes debugging challenging. This only occurs when building with + * /MT. This problem has been reported to Microsoft, but there hasn't been a fix for years. See + * https://web.archive.org/web/20170327195018/https://connect.microsoft.com/VisualStudio/feedback/details/1557168/wstat64-returns-1-on-xp-always + * + * It is known that this problem affects the functions _wstat64 (used by flac_stat i.e. + * stat64_utf8) and _fstat64 (i.e. flac_fstat) and therefore affects both libFLAC in + * several places as well as the flac and metaflac command line tools + * + * As the extent of this problem is unknown and Microsoft seems unwilling to fix it, + * users of libFLAC building with Visual Studio are encouraged to not use the /MT compile + * switch when explicitly targeting Windows XP. When use of /MT is deemed necessary with + * this toolset, be sure to check whether your application works properly on Windows XP. + * It is also possible to build for Windows XP with MinGW instead. + ************************************************************************************* +*/ +# endif +#endif /* defined _MSC_VER */ + +#ifdef _WIN32 +/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ + +#include "share/win_utf8_io.h" +#define flac_printf printf_utf8 +#define flac_fprintf fprintf_utf8 +#define flac_vfprintf vfprintf_utf8 +#define flac_fopen fopen_utf8 +#define flac_chmod chmod_utf8 +#define flac_utime utime_utf8 +#define flac_unlink unlink_utf8 +#define flac_rename rename_utf8 +#define flac_stat stat64_utf8 + +#else + +#define flac_printf printf +#define flac_fprintf fprintf +#define flac_vfprintf vfprintf + +#define flac_fopen fopen +#define flac_chmod chmod +#define flac_unlink unlink +#define flac_rename rename +#define flac_stat stat + +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) +#define flac_utime(a, b) utimensat (AT_FDCWD, a, *b, 0) +#else +#define flac_utime utime +#endif +#endif + +#ifdef _WIN32 +#define flac_stat_s __stat64 /* stat struct */ +#define flac_fstat _fstat64 +#else +#define flac_stat_s stat /* stat struct */ +#define flac_fstat fstat +#endif + +#ifdef ANDROID +#include +#endif + +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* FLAC needs to compile and work correctly on systems with a normal ISO C99 + * snprintf as well as Microsoft Visual Studio which has an non-standards + * conformant snprint_s function. + * + * This function wraps the MS version to behave more like the ISO version. + */ +#ifdef __cplusplus +extern "C" { +#endif +int flac_snprintf(char *str, size_t size, const char *fmt, ...); +int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); +#ifdef __cplusplus +}; +#endif + +#endif /* FLAC__SHARE__COMPAT_H */ diff --git a/packages/third-party/libFLAC/share/endswap.h b/packages/third-party/libFLAC/share/endswap.h new file mode 100644 index 00000000..28835b48 --- /dev/null +++ b/packages/third-party/libFLAC/share/endswap.h @@ -0,0 +1,84 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2012-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* It is assumed that this header will be included after "config.h". */ + +#ifdef HAVE_BSWAP32 /* GCC and Clang */ + +/* GCC prior to 4.8 didn't provide bswap16 on x86_64 */ +#ifndef HAVE_BSWAP16 +static inline unsigned short __builtin_bswap16(unsigned short a) +{ + return (a<<8)|(a>>8); +} +#endif + +#define ENDSWAP_16(x) (__builtin_bswap16 (x)) +#define ENDSWAP_32(x) (__builtin_bswap32 (x)) +#define ENDSWAP_64(x) (__builtin_bswap64 (x)) + +#elif defined _MSC_VER /* Windows */ + +#include + +#define ENDSWAP_16(x) (_byteswap_ushort (x)) +#define ENDSWAP_32(x) (_byteswap_ulong (x)) +#define ENDSWAP_64(x) (_byteswap_uint64 (x)) + +#elif defined HAVE_BYTESWAP_H /* Linux */ + +#include + +#define ENDSWAP_16(x) (bswap_16 (x)) +#define ENDSWAP_32(x) (bswap_32 (x)) +#define ENDSWAP_64(x) (bswap_64 (x)) + +#else + +#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8)) +#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24)) +#define ENDSWAP_64(x) ((ENDSWAP_32(((x) >> 32) & 0xFFFFFFFF)) | (ENDSWAP_32((x) & 0xFFFFFFFF) << 32)) + +#endif + + +/* Host to little-endian byte swapping (for MD5 calculation) */ +#if CPU_IS_BIG_ENDIAN + +#define H2LE_16(x) ENDSWAP_16 (x) +#define H2LE_32(x) ENDSWAP_32 (x) + +#else + +#define H2LE_16(x) (x) +#define H2LE_32(x) (x) + +#endif diff --git a/packages/third-party/libFLAC/share/getopt.h b/packages/third-party/libFLAC/share/getopt.h new file mode 100644 index 00000000..66aced0f --- /dev/null +++ b/packages/third-party/libFLAC/share/getopt.h @@ -0,0 +1,184 @@ +/* + NOTE: + I cannot get the vanilla getopt code to work (i.e. compile only what + is needed and not duplicate symbols found in the standard library) + on all the platforms that FLAC supports. In particular the gating + of code with the ELIDE_CODE #define is not accurate enough on systems + that are POSIX but not glibc. If someone has a patch that works on + GNU/Linux, Darwin, AND Solaris please submit it on the project page: + https://sourceforge.net/p/flac/patches/ + + In the meantime I have munged the global symbols and removed gates + around code, while at the same time trying to touch the original as + little as possible. +*/ +/* Declarations for getopt. + Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +#ifndef SHARE__GETOPT_H +#define SHARE__GETOPT_H + +/*[JEC] was:#ifndef __need_getopt*/ +/*[JEC] was:# define _GETOPT_H 1*/ +/*[JEC] was:#endif*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `share__getopt' to the caller. + When `share__getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *share__optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `share__getopt'. + + On entry to `share__getopt', zero means this is the first call; initialize. + + When `share__getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `share__optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int share__optind; + +/* Callers store zero here to inhibit the error message `share__getopt' prints + for unrecognized options. */ + +extern int share__opterr; + +/* Set to an option character which was unrecognized. */ + +extern int share__optopt; + +/*[JEC] was:#ifndef __need_getopt */ +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector + of `struct share__option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + share__no_argument (or 0) if the option does not take an argument, + share__required_argument (or 1) if the option requires an argument, + share__optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `share__optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `share__getopt' + returns the contents of the `val' field. */ + +struct share__option +{ +# if defined __STDC__ && __STDC__ + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct share__option'. */ + +# define share__no_argument 0 +# define share__required_argument 1 +# define share__optional_argument 2 +/*[JEC] was:#endif*/ /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `share__optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `share__optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `share__getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `share__getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `share__getopt'. */ + +/*[JEC] was:#if defined __STDC__ && __STDC__*/ +/*[JEC] was:# ifdef __GNU_LIBRARY__*/ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int share__getopt (int argc, char *const *argv, const char *shortopts); +/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */ +/*[JEC] was:extern int getopt ();*/ +/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */ + +/*[JEC] was:# ifndef __need_getopt*/ +extern int share__getopt_long (int argc, char *const *argv, const char *shortopts, + const struct share__option *longopts, int *longind); +extern int share__getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct share__option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int share___getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct share__option *longopts, int *longind, + int long_only); +/*[JEC] was:# endif*/ +/*[JEC] was:#else*/ /* not __STDC__ */ +/*[JEC] was:extern int getopt ();*/ +/*[JEC] was:# ifndef __need_getopt*/ +/*[JEC] was:extern int getopt_long ();*/ +/*[JEC] was:extern int getopt_long_only ();*/ + +/*[JEC] was:extern int _getopt_internal ();*/ +/*[JEC] was:# endif*/ +/*[JEC] was:#endif*/ /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +/*[JEC] was:#undef __need_getopt*/ + +#endif /* getopt.h */ diff --git a/packages/third-party/libFLAC/share/grabbag.h b/packages/third-party/libFLAC/share/grabbag.h new file mode 100644 index 00000000..585994b8 --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag.h @@ -0,0 +1,30 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SHARE__GRABBAG_H +#define SHARE__GRABBAG_H + +/* These can't be included by themselves, only from within grabbag.h */ +#include "grabbag/cuesheet.h" +#include "grabbag/file.h" +#include "grabbag/picture.h" +#include "grabbag/replaygain.h" +#include "grabbag/seektable.h" + +#endif diff --git a/packages/third-party/libFLAC/share/grabbag/cuesheet.h b/packages/third-party/libFLAC/share/grabbag/cuesheet.h new file mode 100644 index 00000000..e51f7a5c --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag/cuesheet.h @@ -0,0 +1,43 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ + +#ifndef GRABBAG__CUESHEET_H +#define GRABBAG__CUESHEET_H + +#include +#include "FLAC/metadata.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t seconds, uint32_t frames); +void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t *seconds, uint32_t *frames); + +FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, uint32_t *last_line_read, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset); + +void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/share/grabbag/file.h b/packages/third-party/libFLAC/share/grabbag/file.h new file mode 100644 index 00000000..08b71f70 --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag/file.h @@ -0,0 +1,65 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Convenience routines for manipulating files */ + +/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ + +#ifndef GRABAG__FILE_H +#define GRABAG__FILE_H + +/* needed because of off_t */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include /* for off_t */ +#include /* for FILE */ +#include "FLAC/ordinals.h" +#include "share/compat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grabbag__file_copy_metadata(const char *srcpath, const char *destpath); +FLAC__off_t grabbag__file_get_filesize(const char *srcpath); +const char *grabbag__file_get_basename(const char *srcpath); + +/* read_only == false means "make file writable by user" + * read_only == true means "make file read-only for everyone" + */ +FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only); + +/* returns true iff stat() succeeds for both files and they have the same device and inode. */ +/* on windows, uses GetFileInformationByHandle() to compare */ +FLAC__bool grabbag__file_are_same(const char *f1, const char *f2); + +/* attempts to make writable before unlinking */ +FLAC__bool grabbag__file_remove_file(const char *filename); + +/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */ +FILE *grabbag__file_get_binary_stdin(void); +FILE *grabbag__file_get_binary_stdout(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/share/grabbag/picture.h b/packages/third-party/libFLAC/share/grabbag/picture.h new file mode 100644 index 00000000..8a97cc8c --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag/picture.h @@ -0,0 +1,54 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2006-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ + +#ifndef GRABBAG__PICTURE_H +#define GRABBAG__PICTURE_H + +#include "FLAC/metadata.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* spec should be of the form "[TYPE]|MIME_TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE", e.g. + * "|image/jpeg|||cover.jpg" + * "4|image/jpeg||300x300x24|backcover.jpg" + * "|image/png|description|300x300x24/71|cover.png" + * "-->|image/gif||300x300x24/71|http://blah.blah.blah/cover.gif" + * + * empty type means default to FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER + * empty resolution spec means to get from the file (cannot get used with "-->" linked images) + * spec and error_message must not be NULL + */ +FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message); + +typedef struct PictureResolution +{ uint32_t width, height, depth, colors ; +} PictureResolution ; + +FLAC__StreamMetadata *grabbag__picture_from_specification(int type, const char *mime_type, const char * description, + const PictureResolution * res, const char * filepath, const char **error_message); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/share/grabbag/replaygain.h b/packages/third-party/libFLAC/share/grabbag/replaygain.h new file mode 100644 index 00000000..695e22c7 --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag/replaygain.h @@ -0,0 +1,73 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This wraps the replaygain_analysis lib, which is LGPL. This wrapper + * allows analysis of different input resolutions by automatically + * scaling the input signal + */ + +/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ + +#ifndef GRABBAG__REPLAYGAIN_H +#define GRABBAG__REPLAYGAIN_H + +#include "FLAC/metadata.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED; + +extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */ +extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */ +extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */ +extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */ +extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */ + +FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency); + +FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency); + +/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */ +FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples); + +void grabbag__replaygain_get_album(float *gain, float *peak); +void grabbag__replaygain_get_title(float *gain, float *peak); + +/* These three functions return an error string on error, or NULL if successful */ +const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak); +const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak); +const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block); +const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak); +const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak); +const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime); +const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime); +const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime); +const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime); + +FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak); +double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/share/grabbag/seektable.h b/packages/third-party/libFLAC/share/grabbag/seektable.h new file mode 100644 index 00000000..ab42f0ae --- /dev/null +++ b/packages/third-party/libFLAC/share/grabbag/seektable.h @@ -0,0 +1,39 @@ +/* grabbag - Convenience lib for various routines common to several tools + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Convenience routines for working with seek tables */ + +/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ + +#ifndef GRABAG__SEEKTABLE_H +#define GRABAG__SEEKTABLE_H + +#include "FLAC/format.h" + +#ifdef __cplusplus +extern "C" { +#endif + +FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, uint32_t sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/third-party/libFLAC/share/macros.h b/packages/third-party/libFLAC/share/macros.h new file mode 100644 index 00000000..5566d6e4 --- /dev/null +++ b/packages/third-party/libFLAC/share/macros.h @@ -0,0 +1,45 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2013-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +/* FLAC_CHECK_RETURN : Check the return value of the provided function and + * print an error message if it fails (ie returns a value < 0). + * + * Ideally, a library should not print anything, but this macro is only used + * for things that extremely unlikely to fail, like `chown` to a previoulsy + * saved `uid`. + */ + +#define FLAC_CHECK_RETURN(x) \ + { if ((x) < 0) \ + fprintf (stderr, "%s : %s\n", #x, strerror (errno)) ; \ + } diff --git a/packages/third-party/libFLAC/share/private.h b/packages/third-party/libFLAC/share/private.h new file mode 100644 index 00000000..dc5ec12f --- /dev/null +++ b/packages/third-party/libFLAC/share/private.h @@ -0,0 +1,54 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2013-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLAC__SHARE__PRIVATE_H +#define FLAC__SHARE__PRIVATE_H + +/* + * Unpublished debug routines from libFLAC. This should not be used from any + * client code other than code shipped with the FLAC sources. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, int value); +FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); +/* + * The following two routines were intended as debug routines and are not + * in the public headers, but SHOULD NOT CHANGE! It is known they are used + * in some non-audio projects needing every last bit of performance. + * See https://github.com/xiph/flac/issues/547 for details. These projects + * provide their own prototypes, so changing the signature of these + * functions would break building. + */ +FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder); + +#endif /* FLAC__SHARE__PRIVATE_H */ diff --git a/packages/third-party/libFLAC/share/replaygain_analysis.h b/packages/third-party/libFLAC/share/replaygain_analysis.h new file mode 100644 index 00000000..f06a9b29 --- /dev/null +++ b/packages/third-party/libFLAC/share/replaygain_analysis.h @@ -0,0 +1,59 @@ +/* + * ReplayGainAnalysis - analyzes input samples and give the recommended dB change + * Copyright (C) 2001 David Robinson and Glen Sawyer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * concept and filter values by David Robinson (David@Robinson.org) + * -- blame him if you think the idea is flawed + * coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA + * -- blame him if you think this runs too slowly, or the coding is otherwise flawed + * minor cosmetic tweaks to integrate with FLAC by Josh Coalson + * + * For an explanation of the concepts and the basic algorithms involved, go to: + * http://www.replaygain.org/ + */ + +#ifndef GAIN_ANALYSIS_H +#define GAIN_ANALYSIS_H + +#include + +#define GAIN_NOT_ENOUGH_SAMPLES -24601 +#define GAIN_ANALYSIS_ERROR 0 +#define GAIN_ANALYSIS_OK 1 + +#define INIT_GAIN_ANALYSIS_ERROR 0 +#define INIT_GAIN_ANALYSIS_OK 1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef float flac_float_t; /* Type used for filtering */ + +extern flac_float_t ReplayGainReferenceLoudness; /* in dB SPL, currently == 89.0 */ + +int InitGainAnalysis ( long samplefreq ); +int ValidGainFrequency ( long samplefreq ); +int AnalyzeSamples ( const flac_float_t* left_samples, const flac_float_t* right_samples, size_t num_samples, int num_channels ); +flac_float_t GetTitleGain ( void ); +flac_float_t GetAlbumGain ( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* GAIN_ANALYSIS_H */ diff --git a/packages/third-party/libFLAC/share/replaygain_synthesis.h b/packages/third-party/libFLAC/share/replaygain_synthesis.h new file mode 100644 index 00000000..6aa6d865 --- /dev/null +++ b/packages/third-party/libFLAC/share/replaygain_synthesis.h @@ -0,0 +1,52 @@ +/* replaygain_synthesis - Routines for applying ReplayGain to a signal + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H +#define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H + +#include /* for size_t */ +#include "FLAC/format.h" + +#define FLAC_SHARE__MAX_SUPPORTED_CHANNELS FLAC__MAX_CHANNELS + +typedef enum { + NOISE_SHAPING_NONE = 0, + NOISE_SHAPING_LOW = 1, + NOISE_SHAPING_MEDIUM = 2, + NOISE_SHAPING_HIGH = 3 +} NoiseShaping; + +typedef struct { + const float* FilterCoeff; + FLAC__uint64 Mask; + double Add; + float Dither; + float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */ + float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; + int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS]; + unsigned LastHistoryIndex; + NoiseShaping ShapingType; +} DitherContext; + +void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype); + +/* scale = (float) pow(10., (double)replaygain * 0.05); */ +size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context); + +#endif diff --git a/packages/third-party/libFLAC/share/safe_str.h b/packages/third-party/libFLAC/share/safe_str.h new file mode 100644 index 00000000..f0aa5fc9 --- /dev/null +++ b/packages/third-party/libFLAC/share/safe_str.h @@ -0,0 +1,71 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2013-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Safe string handling functions to replace things like strcpy, strncpy, + * strcat, strncat etc. + * All of these functions guarantee a correctly NUL terminated string but + * the string may be truncated if the destination buffer was too short. + */ + +#ifndef FLAC__SHARE_SAFE_STR_H +#define FLAC__SHARE_SAFE_STR_H + +static inline char * +safe_strncat(char *dest, const char *src, size_t dest_size) +{ + char * ret; + + if (dest_size < 1) + return dest; + + /* Assume dist has space for a term character .. */ + ret = strncat(dest, src, dest_size - strlen (dest)); + /* .. but set it explicitly. */ + dest [dest_size - 1] = 0; + + return ret; +} + +static inline char * +safe_strncpy(char *dest, const char *src, size_t dest_size) +{ + char * ret; + + if (dest_size < 1) + return dest; + + ret = strncpy(dest, src, dest_size - 1); + dest [dest_size - 1] = 0; + + return ret; +} + +#endif /* FLAC__SHARE_SAFE_STR_H */ diff --git a/packages/third-party/libFLAC/share/utf8.h b/packages/third-party/libFLAC/share/utf8.h new file mode 100644 index 00000000..7d6650d6 --- /dev/null +++ b/packages/third-party/libFLAC/share/utf8.h @@ -0,0 +1,25 @@ +#ifndef SHARE__UTF8_H +#define SHARE__UTF8_H + +/* + * Convert a string between UTF-8 and the locale's charset. + * Invalid bytes are replaced by '#', and characters that are + * not available in the target encoding are replaced by '?'. + * + * If the locale's charset is not set explicitly then it is + * obtained using nl_langinfo(CODESET), where available, the + * environment variable CHARSET, or assumed to be US-ASCII. + * + * Return value of conversion functions: + * + * -1 : memory allocation failed + * 0 : data was converted exactly + * 1 : valid data was converted approximately (using '?') + * 2 : input was invalid (but still converted, using '#') + * 3 : unknown encoding (but still converted, using '?') + */ + +int utf8_encode(const char *from, char **to); +int utf8_decode(const char *from, char **to); + +#endif diff --git a/packages/third-party/libFLAC/share/win_utf8_io.h b/packages/third-party/libFLAC/share/win_utf8_io.h new file mode 100644 index 00000000..0b4b88ce --- /dev/null +++ b/packages/third-party/libFLAC/share/win_utf8_io.h @@ -0,0 +1,71 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2013-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef _WIN32 + +#ifndef flac__win_utf8_io_h +#define flac__win_utf8_io_h + +#include +#include +#include +#include +#include "FLAC/ordinals.h" + +#ifdef __cplusplus +extern "C" { +#endif + +size_t strlen_utf8(const char *str); +int win_get_console_width(void); + +int get_utf8_argv(int *argc, char ***argv); + +int printf_utf8(const char *format, ...); +int fprintf_utf8(FILE *stream, const char *format, ...); +int vfprintf_utf8(FILE *stream, const char *format, va_list argptr); + +FILE* fopen_utf8(const char *filename, const char *mode); +int stat64_utf8(const char *path, struct __stat64 *buffer); +int chmod_utf8(const char *filename, int pmode); +int utime_utf8(const char *filename, struct utimbuf *times); +int unlink_utf8(const char *filename); +int rename_utf8(const char *oldname, const char *newname); + +#include +HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif +#endif diff --git a/packages/third-party/libFLAC/stream_decoder.c b/packages/third-party/libFLAC/stream_decoder.c new file mode 100644 index 00000000..0a0636cc --- /dev/null +++ b/packages/third-party/libFLAC/stream_decoder.c @@ -0,0 +1,3744 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2000-2009 Josh Coalson + * Copyright (C) 2011-2024 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include /* for malloc() */ +#include /* for memset/memcpy() */ +#include /* for off_t */ +#include /* for stat() */ +#include "share/compat.h" +#include "FLAC/assert.h" +#include "share/alloc.h" +#include "protected/stream_decoder.h" +#include "private/bitreader.h" +#include "private/bitmath.h" +#include "private/cpu.h" +#include "private/crc.h" +#include "private/fixed.h" +#include "private/format.h" +#include "private/lpc.h" +#include "private/md5.h" +#include "private/memory.h" +#include "private/macros.h" +#include "config.h" + +#define FLAC__HAS_OGG 0 + +/* technically this should be in an "export.c" but this is convenient enough */ +FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = FLAC__HAS_OGG; + + +/*********************************************************************** + * + * Private static data + * + ***********************************************************************/ + +static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; + +/*********************************************************************** + * + * Private class method prototypes + * + ***********************************************************************/ + +static void set_defaults_(FLAC__StreamDecoder *decoder); +static FILE *get_binary_stdin_(void); +static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps); +static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id); +static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder); +static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder); +static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); +static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); +static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length); +static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj); +static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj); +static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder); +static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder); +static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode); +static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder); +static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended); +static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder); +static void undo_channel_coding(FLAC__StreamDecoder *decoder); +static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data); +#if FLAC__HAS_OGG +static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes); +static FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); +#endif +static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]); +static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status); +static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample); +#if FLAC__HAS_OGG +static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample); +#endif +static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); +static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); +static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); +static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); +static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data); + +/*********************************************************************** + * + * Private class data + * + ***********************************************************************/ + +typedef struct FLAC__StreamDecoderPrivate { + FLAC__bool is_ogg; + FLAC__StreamDecoderReadCallback read_callback; + FLAC__StreamDecoderSeekCallback seek_callback; + FLAC__StreamDecoderTellCallback tell_callback; + FLAC__StreamDecoderLengthCallback length_callback; + FLAC__StreamDecoderEofCallback eof_callback; + FLAC__StreamDecoderWriteCallback write_callback; + FLAC__StreamDecoderMetadataCallback metadata_callback; + FLAC__StreamDecoderErrorCallback error_callback; + void *client_data; + FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */ + FLAC__BitReader *input; + FLAC__int32 *output[FLAC__MAX_CHANNELS]; + FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */ + FLAC__int64 *side_subframe; + FLAC__bool side_subframe_in_use; + FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents[FLAC__MAX_CHANNELS]; + uint32_t output_capacity, output_channels; + FLAC__uint32 fixed_block_size, next_fixed_block_size; + FLAC__uint64 samples_decoded; + FLAC__bool has_stream_info, has_seek_table; + FLAC__StreamMetadata stream_info; + FLAC__StreamMetadata seek_table; + FLAC__bool metadata_filter[128]; /* MAGIC number 128 == total number of metadata block types == 1 << 7 */ + FLAC__byte *metadata_filter_ids; + size_t metadata_filter_ids_count, metadata_filter_ids_capacity; /* units for both are IDs, not bytes */ + FLAC__Frame frame; + FLAC__bool cached; /* true if there is a byte in lookahead */ + FLAC__CPUInfo cpuinfo; + FLAC__byte header_warmup[2]; /* contains the sync code and reserved bits */ + FLAC__byte lookahead; /* temp storage when we need to look ahead one byte in the stream */ + /* unaligned (original) pointers to allocated data */ + FLAC__int32 *residual_unaligned[FLAC__MAX_CHANNELS]; + FLAC__bool do_md5_checking; /* initially gets protected_->md5_checking but is turned off after a seek or if the metadata has a zero MD5 */ + FLAC__bool internal_reset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding the input */ + FLAC__bool is_seeking; + FLAC__MD5Context md5context; + FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */ + /* (the rest of these are only used for seeking) */ + FLAC__Frame last_frame; /* holds the info of the last frame we decoded or seeked to */ + FLAC__bool last_frame_is_set; + FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */ + FLAC__uint64 last_seen_framesync; /* if tell callback works, the location of the last seen frame sync code, to rewind to if needed */ + FLAC__uint64 target_sample; + uint32_t unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */ + FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */ + FLAC__bool (*local_bitreader_read_rice_signed_block)(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); + FLAC__bool error_has_been_sent; /* To check whether a missing frame has been signalled yet */ +} FLAC__StreamDecoderPrivate; + +/*********************************************************************** + * + * Public static class data + * + ***********************************************************************/ + +FLAC_API const char * const FLAC__StreamDecoderStateString[] = { + "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA", + "FLAC__STREAM_DECODER_READ_METADATA", + "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC", + "FLAC__STREAM_DECODER_READ_FRAME", + "FLAC__STREAM_DECODER_END_OF_STREAM", + "FLAC__STREAM_DECODER_OGG_ERROR", + "FLAC__STREAM_DECODER_SEEK_ERROR", + "FLAC__STREAM_DECODER_ABORTED", + "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR", + "FLAC__STREAM_DECODER_UNINITIALIZED" +}; + +FLAC_API const char * const FLAC__StreamDecoderInitStatusString[] = { + "FLAC__STREAM_DECODER_INIT_STATUS_OK", + "FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER", + "FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS", + "FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR", + "FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE", + "FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED" +}; + +FLAC_API const char * const FLAC__StreamDecoderReadStatusString[] = { + "FLAC__STREAM_DECODER_READ_STATUS_CONTINUE", + "FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM", + "FLAC__STREAM_DECODER_READ_STATUS_ABORT" +}; + +FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[] = { + "FLAC__STREAM_DECODER_SEEK_STATUS_OK", + "FLAC__STREAM_DECODER_SEEK_STATUS_ERROR", + "FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED" +}; + +FLAC_API const char * const FLAC__StreamDecoderTellStatusString[] = { + "FLAC__STREAM_DECODER_TELL_STATUS_OK", + "FLAC__STREAM_DECODER_TELL_STATUS_ERROR", + "FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED" +}; + +FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[] = { + "FLAC__STREAM_DECODER_LENGTH_STATUS_OK", + "FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR", + "FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED" +}; + +FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[] = { + "FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE", + "FLAC__STREAM_DECODER_WRITE_STATUS_ABORT" +}; + +FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[] = { + "FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC", + "FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER", + "FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH", + "FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM", + "FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA" +}; + +/*********************************************************************** + * + * Class constructor/destructor + * + ***********************************************************************/ +FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void) +{ + FLAC__StreamDecoder *decoder; + uint32_t i; + + FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */ + + decoder = safe_calloc_(1, sizeof(FLAC__StreamDecoder)); + if(decoder == 0) { + return 0; + } + + decoder->protected_ = safe_calloc_(1, sizeof(FLAC__StreamDecoderProtected)); + if(decoder->protected_ == 0) { + free(decoder); + return 0; + } + + decoder->private_ = safe_calloc_(1, sizeof(FLAC__StreamDecoderPrivate)); + if(decoder->private_ == 0) { + free(decoder->protected_); + free(decoder); + return 0; + } + + decoder->private_->input = FLAC__bitreader_new(); + if(decoder->private_->input == 0) { + free(decoder->private_); + free(decoder->protected_); + free(decoder); + return 0; + } + + decoder->private_->metadata_filter_ids_capacity = 16; + if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) { + FLAC__bitreader_delete(decoder->private_->input); + free(decoder->private_); + free(decoder->protected_); + free(decoder); + return 0; + } + + for(i = 0; i < FLAC__MAX_CHANNELS; i++) { + decoder->private_->output[i] = 0; + decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; + } + + decoder->private_->side_subframe = 0; + + decoder->private_->output_capacity = 0; + decoder->private_->output_channels = 0; + decoder->private_->has_seek_table = false; + + for(i = 0; i < FLAC__MAX_CHANNELS; i++) + FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_rice_contents[i]); + + decoder->private_->file = 0; + + set_defaults_(decoder); + + decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; + + return decoder; +} + +FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) +{ + uint32_t i; + + if (decoder == NULL) + return ; + + FLAC__ASSERT(0 != decoder->protected_); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->private_->input); + + (void)FLAC__stream_decoder_finish(decoder); + + if(0 != decoder->private_->metadata_filter_ids) + free(decoder->private_->metadata_filter_ids); + + FLAC__bitreader_delete(decoder->private_->input); + + for(i = 0; i < FLAC__MAX_CHANNELS; i++) + FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned_rice_contents[i]); + + free(decoder->private_); + free(decoder->protected_); + free(decoder); +} + +/*********************************************************************** + * + * Public class methods + * + ***********************************************************************/ + +static FLAC__StreamDecoderInitStatus init_stream_internal_( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data, + FLAC__bool is_ogg +) +{ + FLAC__ASSERT(0 != decoder); + + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; + + if(FLAC__HAS_OGG == 0 && is_ogg) + return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER; + + if( + 0 == read_callback || + 0 == write_callback || + 0 == error_callback || + (seek_callback && (0 == tell_callback || 0 == length_callback || 0 == eof_callback)) + ) + return FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; + +#if FLAC__HAS_OGG + decoder->private_->is_ogg = is_ogg; + if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect)) + return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; +#endif + + FLAC__cpu_info(&decoder->private_->cpuinfo); + decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block; + +#ifdef FLAC__BMI2_SUPPORTED + if (decoder->private_->cpuinfo.x86.bmi2) { + decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_bmi2; + } +#endif + + /* from here on, errors are fatal */ + + if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR; + } + + decoder->private_->read_callback = read_callback; + decoder->private_->seek_callback = seek_callback; + decoder->private_->tell_callback = tell_callback; + decoder->private_->length_callback = length_callback; + decoder->private_->eof_callback = eof_callback; + decoder->private_->write_callback = write_callback; + decoder->private_->metadata_callback = metadata_callback; + decoder->private_->error_callback = error_callback; + decoder->private_->client_data = client_data; + decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; + decoder->private_->samples_decoded = 0; + decoder->private_->has_stream_info = false; + decoder->private_->cached = false; + + decoder->private_->do_md5_checking = decoder->protected_->md5_checking; + decoder->private_->is_seeking = false; + + decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind the input */ + if(!FLAC__stream_decoder_reset(decoder)) { + /* above call sets the state for us */ + return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR; + } + + return FLAC__STREAM_DECODER_INIT_STATUS_OK; +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_stream_internal_( + decoder, + read_callback, + seek_callback, + tell_callback, + length_callback, + eof_callback, + write_callback, + metadata_callback, + error_callback, + client_data, + /*is_ogg=*/false + ); +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_stream_internal_( + decoder, + read_callback, + seek_callback, + tell_callback, + length_callback, + eof_callback, + write_callback, + metadata_callback, + error_callback, + client_data, + /*is_ogg=*/true + ); +} + +static FLAC__StreamDecoderInitStatus init_FILE_internal_( + FLAC__StreamDecoder *decoder, + FILE *file, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data, + FLAC__bool is_ogg +) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != file); + + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; + + if(0 == write_callback || 0 == error_callback) + return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; + + /* + * To make sure that our file does not go unclosed after an error, we + * must assign the FILE pointer before any further error can occur in + * this routine. + */ + if(file == stdin) + file = get_binary_stdin_(); /* just to be safe */ + + decoder->private_->file = file; + + return init_stream_internal_( + decoder, + file_read_callback_, + decoder->private_->file == stdin? 0: file_seek_callback_, + decoder->private_->file == stdin? 0: file_tell_callback_, + decoder->private_->file == stdin? 0: file_length_callback_, + file_eof_callback_, + write_callback, + metadata_callback, + error_callback, + client_data, + is_ogg + ); +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE( + FLAC__StreamDecoder *decoder, + FILE *file, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false); +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE( + FLAC__StreamDecoder *decoder, + FILE *file, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true); +} + +static FLAC__StreamDecoderInitStatus init_file_internal_( + FLAC__StreamDecoder *decoder, + const char *filename, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data, + FLAC__bool is_ogg +) +{ + FILE *file; + + FLAC__ASSERT(0 != decoder); + + /* + * To make sure that our file does not go unclosed after an error, we + * have to do the same entrance checks here that are later performed + * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned. + */ + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; + + if(0 == write_callback || 0 == error_callback) + return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; + + file = filename? flac_fopen(filename, "rb") : stdin; + + if(0 == file) + return FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; + + return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, is_ogg); +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file( + FLAC__StreamDecoder *decoder, + const char *filename, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false); +} + +FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( + FLAC__StreamDecoder *decoder, + const char *filename, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data +) +{ + return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true); +} + +FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) +{ + FLAC__bool md5_failed = false; + uint32_t i; + + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + + if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) + return true; + + /* see the comment in FLAC__stream_decoder_reset() as to why we + * always call FLAC__MD5Final() + */ + FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); + + free(decoder->private_->seek_table.data.seek_table.points); + decoder->private_->seek_table.data.seek_table.points = 0; + decoder->private_->has_seek_table = false; + + FLAC__bitreader_free(decoder->private_->input); + for(i = 0; i < FLAC__MAX_CHANNELS; i++) { + /* WATCHOUT: + * FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN() + * require that the output arrays have a buffer of up to 3 zeroes + * in front (at negative indices) for alignment purposes; + * we use 4 to keep the data well-aligned. + */ + if(0 != decoder->private_->output[i]) { + free(decoder->private_->output[i]-4); + decoder->private_->output[i] = 0; + } + if(0 != decoder->private_->residual_unaligned[i]) { + free(decoder->private_->residual_unaligned[i]); + decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; + } + } + if(0 != decoder->private_->side_subframe) { + free(decoder->private_->side_subframe); + decoder->private_->side_subframe = 0; + } + decoder->private_->output_capacity = 0; + decoder->private_->output_channels = 0; + +#if FLAC__HAS_OGG + if(decoder->private_->is_ogg) + FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); +#endif + + if(0 != decoder->private_->file) { + if(decoder->private_->file != stdin) + fclose(decoder->private_->file); + decoder->private_->file = 0; + } + + if(decoder->private_->do_md5_checking) { + if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5sum, 16)) + md5_failed = true; + } + decoder->private_->is_seeking = false; + + set_defaults_(decoder); + + decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; + + return !md5_failed; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long value) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; +#if FLAC__HAS_OGG + /* can't check decoder->private_->is_ogg since that's not set until init time */ + FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); + return true; +#else + (void)value; + return false; +#endif +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + decoder->protected_->md5_checking = value; + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); + /* double protection */ + if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) + return false; + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + decoder->private_->metadata_filter[type] = true; + if(type == FLAC__METADATA_TYPE_APPLICATION) + decoder->private_->metadata_filter_ids_count = 0; + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + FLAC__ASSERT(0 != id); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + + if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) + return true; + + FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); + + if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) { + if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + decoder->private_->metadata_filter_ids_capacity *= 2; + } + + memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); + decoder->private_->metadata_filter_ids_count++; + + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) +{ + uint32_t i; + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_filter[0]); i++) + decoder->private_->metadata_filter[i] = true; + decoder->private_->metadata_filter_ids_count = 0; + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); + /* double protection */ + if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) + return false; + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + decoder->private_->metadata_filter[type] = false; + if(type == FLAC__METADATA_TYPE_APPLICATION) + decoder->private_->metadata_filter_ids_count = 0; + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + FLAC__ASSERT(0 != id); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + + if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) + return true; + + FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); + + if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) { + if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + decoder->private_->metadata_filter_ids_capacity *= 2; + } + + memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); + decoder->private_->metadata_filter_ids_count++; + + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); + decoder->private_->metadata_filter_ids_count = 0; + return true; +} + +FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->state; +} + +FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) +{ + return FLAC__StreamDecoderStateString[decoder->protected_->state]; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->md5_checking; +} + +FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_samples : 0; +} + +FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->channels; +} + +FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->channel_assignment; +} + +FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->bits_per_sample; +} + +FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->sample_rate; +} + +FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + return decoder->protected_->blocksize; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != position); + + if(FLAC__HAS_OGG && decoder->private_->is_ogg) + return false; + + if(0 == decoder->private_->tell_callback) + return false; + if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__STREAM_DECODER_TELL_STATUS_OK) + return false; + /* should never happen since all FLAC frames and metadata blocks are byte aligned, but check just in case */ + if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) + return false; + FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); + *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); + return true; +} + +FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder) +{ + return decoder->private_->client_data; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + + if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) + return false; + + decoder->private_->samples_decoded = 0; + decoder->private_->do_md5_checking = false; + decoder->private_->last_seen_framesync = 0; + decoder->private_->last_frame_is_set = false; + +#if FLAC__HAS_OGG + if(decoder->private_->is_ogg) + FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); +#endif + + if(!FLAC__bitreader_clear(decoder->private_->input)) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + FLAC__ASSERT(0 != decoder->protected_); + + if(!FLAC__stream_decoder_flush(decoder)) { + /* above call sets the state for us */ + return false; + } + +#if FLAC__HAS_OGG + /*@@@ could go in !internal_reset_hack block below */ + if(decoder->private_->is_ogg) + FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); +#endif + + /* Rewind if necessary. If FLAC__stream_decoder_init() is calling us, + * (internal_reset_hack) don't try to rewind since we are already at + * the beginning of the stream and don't want to fail if the input is + * not seekable. + */ + if(!decoder->private_->internal_reset_hack) { + if(decoder->private_->file == stdin) + return false; /* can't rewind stdin, reset fails */ + if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR) + return false; /* seekable and seek fails, reset fails */ + } + + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; + + decoder->private_->has_stream_info = false; + + free(decoder->private_->seek_table.data.seek_table.points); + decoder->private_->seek_table.data.seek_table.points = 0; + decoder->private_->has_seek_table = false; + + decoder->private_->do_md5_checking = decoder->protected_->md5_checking; + /* + * This goes in reset() and not flush() because according to the spec, a + * fixed-blocksize stream must stay that way through the whole stream. + */ + decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; + + /* We initialize the FLAC__MD5Context even though we may never use it. This + * is because md5 checking may be turned on to start and then turned off if + * a seek occurs. So we init the context here and finalize it in + * FLAC__stream_decoder_finish() to make sure things are always cleaned up + * properly. + */ + if(!decoder->private_->internal_reset_hack) { + /* Only finish MD5 context when it has been initialized + * (i.e. when internal_reset_hack is not set) */ + FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); + } + else + decoder->private_->internal_reset_hack = false; + FLAC__MD5Init(&decoder->private_->md5context); + + decoder->private_->first_frame_offset = 0; + decoder->private_->unparseable_frame_count = 0; + decoder->private_->last_seen_framesync = 0; + decoder->private_->last_frame_is_set = false; + decoder->private_->error_has_been_sent = false; + + return true; +} + +FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) +{ + FLAC__bool got_a_frame; + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + + while(1) { + switch(decoder->protected_->state) { + case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: + if(!find_metadata_(decoder)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_METADATA: + if(!read_metadata_(decoder)) + return false; /* above function sets the status for us */ + else + return true; + case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: + if(!frame_sync_(decoder)) + return true; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_FRAME: + if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) + return false; /* above function sets the status for us */ + if(got_a_frame) + return true; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_END_OF_STREAM: + case FLAC__STREAM_DECODER_ABORTED: + return true; + default: + return false; + } + } +} + +FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + + while(1) { + switch(decoder->protected_->state) { + case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: + if(!find_metadata_(decoder)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_METADATA: + if(!read_metadata_(decoder)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: + case FLAC__STREAM_DECODER_READ_FRAME: + case FLAC__STREAM_DECODER_END_OF_STREAM: + case FLAC__STREAM_DECODER_ABORTED: + return true; + default: + return false; + } + } +} + +FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder) +{ + FLAC__bool dummy; + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + + while(1) { + switch(decoder->protected_->state) { + case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: + if(!find_metadata_(decoder)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_METADATA: + if(!read_metadata_(decoder)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: + if(!frame_sync_(decoder)) + return true; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_FRAME: + if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) + return false; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_END_OF_STREAM: + case FLAC__STREAM_DECODER_ABORTED: + return true; + default: + return false; + } + } +} + +FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) +{ + FLAC__bool got_a_frame; + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->protected_); + + while(1) { + switch(decoder->protected_->state) { + case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: + case FLAC__STREAM_DECODER_READ_METADATA: + return false; /* above function sets the status for us */ + case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: + if(!frame_sync_(decoder)) + return true; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_READ_FRAME: + if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) + return false; /* above function sets the status for us */ + if(got_a_frame) + return true; /* above function sets the status for us */ + break; + case FLAC__STREAM_DECODER_END_OF_STREAM: + case FLAC__STREAM_DECODER_ABORTED: + return true; + default: + return false; + } + } +} + +FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample) +{ + FLAC__uint64 length; + + FLAC__ASSERT(0 != decoder); + + if( + decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && + decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && + decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && + decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && + decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM + ) + return false; + + if(0 == decoder->private_->seek_callback) + return false; + + FLAC__ASSERT(decoder->private_->seek_callback); + FLAC__ASSERT(decoder->private_->tell_callback); + FLAC__ASSERT(decoder->private_->length_callback); + FLAC__ASSERT(decoder->private_->eof_callback); + + if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder)) + return false; + + decoder->private_->is_seeking = true; + + /* turn off md5 checking if a seek is attempted */ + decoder->private_->do_md5_checking = false; + + /* get the file length (currently our algorithm needs to know the length so it's also an error to get FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED) */ + if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__STREAM_DECODER_LENGTH_STATUS_OK) { + decoder->private_->is_seeking = false; + return false; + } + + /* if we haven't finished processing the metadata yet, do that so we have the STREAMINFO, SEEK_TABLE, and first_frame_offset */ + if( + decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || + decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA + ) { + if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { + /* above call sets the state for us */ + decoder->private_->is_seeking = false; + return false; + } + /* check this again in case we didn't know total_samples the first time */ + if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder)) { + decoder->private_->is_seeking = false; + return false; + } + } + + { + const FLAC__bool ok = +#if FLAC__HAS_OGG + decoder->private_->is_ogg? + seek_to_absolute_sample_ogg_(decoder, length, sample) : +#endif + seek_to_absolute_sample_(decoder, length, sample) + ; + decoder->private_->is_seeking = false; + return ok; + } +} + +/*********************************************************************** + * + * Protected class methods + * + ***********************************************************************/ + +uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) +{ + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); + return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; +} + +/*********************************************************************** + * + * Private class methods + * + ***********************************************************************/ + +void set_defaults_(FLAC__StreamDecoder *decoder) +{ + decoder->private_->is_ogg = false; + decoder->private_->read_callback = 0; + decoder->private_->seek_callback = 0; + decoder->private_->tell_callback = 0; + decoder->private_->length_callback = 0; + decoder->private_->eof_callback = 0; + decoder->private_->write_callback = 0; + decoder->private_->metadata_callback = 0; + decoder->private_->error_callback = 0; + decoder->private_->client_data = 0; + + memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); + decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; + decoder->private_->metadata_filter_ids_count = 0; + + decoder->protected_->md5_checking = false; + +#if FLAC__HAS_OGG + FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); +#endif +} + +/* + * This will forcibly set stdin to binary mode (for OSes that require it) + */ +FILE *get_binary_stdin_(void) +{ + /* if something breaks here it is probably due to the presence or + * absence of an underscore before the identifiers 'setmode', + * 'fileno', and/or 'O_BINARY'; check your system header files. + */ +#if defined _MSC_VER || defined __MINGW32__ + _setmode(_fileno(stdin), _O_BINARY); +#elif defined __EMX__ + setmode(fileno(stdin), O_BINARY); +#endif + + return stdin; +} + +FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps) +{ + uint32_t i; + FLAC__int32 *tmp; + + if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels && + (bps < 32 || decoder->private_->side_subframe != 0)) + return true; + + /* simply using realloc() is not practical because the number of channels may change mid-stream */ + + for(i = 0; i < FLAC__MAX_CHANNELS; i++) { + if(0 != decoder->private_->output[i]) { + free(decoder->private_->output[i]-4); + decoder->private_->output[i] = 0; + } + if(0 != decoder->private_->residual_unaligned[i]) { + free(decoder->private_->residual_unaligned[i]); + decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; + } + } + + if(0 != decoder->private_->side_subframe) { + free(decoder->private_->side_subframe); + decoder->private_->side_subframe = 0; + } + + for(i = 0; i < channels; i++) { + /* WATCHOUT: + * FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN() + * require that the output arrays have a buffer of up to 3 zeroes + * in front (at negative indices) for alignment purposes; + * we use 4 to keep the data well-aligned. + */ + tmp = safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/); + if(tmp == 0) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + memset(tmp, 0, sizeof(FLAC__int32)*4); + decoder->private_->output[i] = tmp + 4; + + if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decoder->private_->residual[i])) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + } + + if(bps == 32) { + decoder->private_->side_subframe = safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size); + if(decoder->private_->side_subframe == NULL) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + } + + decoder->private_->output_capacity = size; + decoder->private_->output_channels = channels; + + return true; +} + +FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) +{ + size_t i; + + FLAC__ASSERT(0 != decoder); + FLAC__ASSERT(0 != decoder->private_); + + for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) + if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8))) + return true; + + return false; +} + +FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) +{ + FLAC__uint32 x; + uint32_t i, id; + FLAC__bool first = true; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + for(i = id = 0; i < 4; ) { + if(decoder->private_->cached) { + x = (FLAC__uint32)decoder->private_->lookahead; + decoder->private_->cached = false; + } + else { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + } + if(x == FLAC__STREAM_SYNC_STRING[i]) { + first = true; + i++; + id = 0; + continue; + } + + if(id >= 3) + return false; + + if(x == ID3V2_TAG_[id]) { + id++; + i = 0; + if(id == 3) { + if(!skip_id3v2_tag_(decoder)) + return false; /* skip_id3v2_tag_ sets the state for us */ + } + continue; + } + id = 0; + if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ + decoder->private_->header_warmup[0] = (FLAC__byte)x; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + + /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */ + /* else we have to check if the second byte is the end of a sync code */ + if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ + decoder->private_->lookahead = (FLAC__byte)x; + decoder->private_->cached = true; + } + else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */ + decoder->private_->header_warmup[1] = (FLAC__byte)x; + decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; + return true; + } + } + i = 0; + if(first) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + first = false; + } + } + + decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; + return true; +} + +FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) +{ + FLAC__bool is_last; + FLAC__uint32 i, x, type, length; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LEN)) + return false; /* read_callback_ sets the state for us */ + is_last = x? true : false; + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGTH_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(type == FLAC__METADATA_TYPE_STREAMINFO) { + if(!read_metadata_streaminfo_(decoder, is_last, length)) + return false; + + decoder->private_->has_stream_info = true; + if(0 == memcmp(decoder->private_->stream_info.data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16)) + decoder->private_->do_md5_checking = false; + if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] && decoder->private_->metadata_callback) + decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data); + } + else if(type == FLAC__METADATA_TYPE_SEEKTABLE) { + /* just in case we already have a seek table, and reading the next one fails: */ + decoder->private_->has_seek_table = false; + + if(length > 0) { + if(!read_metadata_seektable_(decoder, is_last, length)) + return false; + + decoder->private_->has_seek_table = true; + if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTABLE] && decoder->private_->metadata_callback) + decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data); + } + } + else { + FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; + uint32_t real_length = length; + FLAC__StreamMetadata block; + + memset(&block, 0, sizeof(block)); + block.is_last = is_last; + block.type = (FLAC__MetadataType)type; + block.length = length; + + if(type == FLAC__METADATA_TYPE_APPLICATION) { + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) + return false; /* read_callback_ sets the state for us */ + + if(real_length < FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) { /* underflow check */ + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong error? need to resync?*/ + return false; + } + + real_length -= FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8; + + if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.application.id)) + skip_it = !skip_it; + } + + if(skip_it) { + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) + return false; /* read_callback_ sets the state for us */ + } + else { + FLAC__bool ok = true; + FLAC__bitreader_set_limit(decoder->private_->input, real_length*8); + switch(type) { + case FLAC__METADATA_TYPE_PADDING: + /* skip the padding bytes */ + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) + ok = false; /* read_callback_ sets the state for us */ + break; + case FLAC__METADATA_TYPE_APPLICATION: + /* remember, we read the ID already */ + if(real_length > 0) { + if(0 == (block.data.application.data = malloc(real_length))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + ok = false; + } + else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.data, real_length)) + ok = false; /* read_callback_ sets the state for us */ + } + else + block.data.application.data = 0; + break; + case FLAC__METADATA_TYPE_VORBIS_COMMENT: + if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) + ok = false; + break; + case FLAC__METADATA_TYPE_CUESHEET: + if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) + ok = false; + break; + case FLAC__METADATA_TYPE_PICTURE: + if(!read_metadata_picture_(decoder, &block.data.picture)) + ok = false; + break; + case FLAC__METADATA_TYPE_STREAMINFO: + case FLAC__METADATA_TYPE_SEEKTABLE: + FLAC__ASSERT(0); + break; + default: + if(real_length > 0) { + if(0 == (block.data.unknown.data = malloc(real_length))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + ok = false; + } + else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unknown.data, real_length)) + ok = false; /* read_callback_ sets the state for us */ + } + else + block.data.unknown.data = 0; + break; + } + if(FLAC__bitreader_limit_remaining(decoder->private_->input) > 0) { + /* Content in metadata block didn't fit in block length + * We cannot know whether the length or the content was + * corrupt, so stop parsing metadata */ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA); + if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA) + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + ok = false; + } + FLAC__bitreader_remove_limit(decoder->private_->input); + if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) + decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); + + /* now we have to free any malloc()ed data in the block */ + switch(type) { + case FLAC__METADATA_TYPE_PADDING: + break; + case FLAC__METADATA_TYPE_APPLICATION: + if(0 != block.data.application.data) + free(block.data.application.data); + break; + case FLAC__METADATA_TYPE_VORBIS_COMMENT: + if(0 != block.data.vorbis_comment.vendor_string.entry) + free(block.data.vorbis_comment.vendor_string.entry); + if(block.data.vorbis_comment.num_comments > 0) + for(i = 0; i < block.data.vorbis_comment.num_comments; i++) + if(0 != block.data.vorbis_comment.comments[i].entry) + free(block.data.vorbis_comment.comments[i].entry); + if(0 != block.data.vorbis_comment.comments) + free(block.data.vorbis_comment.comments); + break; + case FLAC__METADATA_TYPE_CUESHEET: + if(block.data.cue_sheet.num_tracks > 0 && 0 != block.data.cue_sheet.tracks) + for(i = 0; i < block.data.cue_sheet.num_tracks; i++) + if(0 != block.data.cue_sheet.tracks[i].indices) + free(block.data.cue_sheet.tracks[i].indices); + if(0 != block.data.cue_sheet.tracks) + free(block.data.cue_sheet.tracks); + break; + case FLAC__METADATA_TYPE_PICTURE: + if(0 != block.data.picture.mime_type) + free(block.data.picture.mime_type); + if(0 != block.data.picture.description) + free(block.data.picture.description); + if(0 != block.data.picture.data) + free(block.data.picture.data); + break; + case FLAC__METADATA_TYPE_STREAMINFO: + case FLAC__METADATA_TYPE_SEEKTABLE: + FLAC__ASSERT(0); + default: + if(0 != block.data.unknown.data) + free(block.data.unknown.data); + break; + } + + if(!ok) /* anything that unsets "ok" should also make sure decoder->protected_->state is updated */ + return false; + } + } + + if(is_last) { + /* if this fails, it's OK, it's just a hint for the seek routine */ + if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) + decoder->private_->first_frame_offset = 0; + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + } + + return true; +} + +FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) +{ + FLAC__uint32 x; + uint32_t bits, used_bits = 0; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; + decoder->private_->stream_info.is_last = is_last; + decoder->private_->stream_info.length = length; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.sample_rate = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.channels = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) + return false; /* read_callback_ sets the state for us */ + used_bits += bits; + + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->stream_info.data.stream_info.md5sum, 16)) + return false; /* read_callback_ sets the state for us */ + used_bits += 16*8; + + /* skip the rest of the block */ + FLAC__ASSERT(used_bits % 8 == 0); + if (length < (used_bits / 8)) + return false; /* read_callback_ sets the state for us */ + length -= (used_bits / 8); + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) + return false; /* read_callback_ sets the state for us */ + + return true; +} + +FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) +{ + FLAC__uint32 i, x; + FLAC__uint64 xx; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; + decoder->private_->seek_table.is_last = is_last; + decoder->private_->seek_table.length = length; + + if(length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH) { + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + + decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; + + /* use realloc since we may pass through here several times (e.g. after seeking) */ + if(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->private_->seek_table.data.seek_table.points, decoder->private_->seek_table.data.seek_table.num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; + + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; + } + length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH); + + FLAC__ASSERT(length == 0); + + return true; +} + +FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length) +{ + FLAC__uint32 i; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + /* read vendor string */ + if (length >= 8) { + length -= 8; /* vendor string length + num comments entries alone take 8 bytes */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + if (length < obj->vendor_string.length) { + obj->vendor_string.length = 0; + obj->vendor_string.entry = 0; + goto skip; + } + else + length -= obj->vendor_string.length; + if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + obj->vendor_string.entry[obj->vendor_string.length] = '\0'; + + /* read num comments */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) + return false; /* read_callback_ sets the state for us */ + + /* read comments */ + if (obj->num_comments > 100000) { + /* Possibly malicious file. */ + obj->num_comments = 0; + return false; + } + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + obj->num_comments = 0; + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + for (i = 0; i < obj->num_comments; i++) { + /* Initialize here just to make sure. */ + obj->comments[i].length = 0; + obj->comments[i].entry = 0; + + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (length < 4) { + obj->num_comments = i; + goto skip; + } + else + length -= 4; + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)) { + obj->num_comments = i; + return false; /* read_callback_ sets the state for us */ + } + if (length < obj->comments[i].length) { + obj->num_comments = i; + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + else + length -= obj->comments[i].length; + if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + obj->num_comments = i; + return false; + } + memset (obj->comments[i].entry, 0, obj->comments[i].length) ; + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { + /* Current i-th entry is bad, so we delete it. */ + free (obj->comments[i].entry) ; + obj->comments[i].entry = NULL ; + obj->num_comments = i; + goto skip; + } + obj->comments[i].entry[obj->comments[i].length] = '\0'; + } + } + } + else { + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + + skip: + if (length > 0) { + /* length > 0 can only happen on files with invalid data in comments */ + if(obj->num_comments < 1) { + free(obj->comments); + obj->comments = NULL; + } + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + + return true; +} + +FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) +{ + FLAC__uint32 i, j, x; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + memset(obj, 0, sizeof(FLAC__StreamMetadata_CueSheet)); + + FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN)) + return false; /* read_callback_ sets the state for us */ + obj->is_cd = x? true : false; + + if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN)) + return false; /* read_callback_ sets the state for us */ + obj->num_tracks = x; + + if(obj->num_tracks > 0) { + if(0 == (obj->tracks = safe_calloc_(obj->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + for(i = 0; i < obj->num_tracks; i++) { + FLAC__StreamMetadata_CueSheet_Track *track = &obj->tracks[i]; + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN)) + return false; /* read_callback_ sets the state for us */ + track->number = (FLAC__byte)x; + + FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + track->type = x; + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN)) + return false; /* read_callback_ sets the state for us */ + track->pre_emphasis = x; + + if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN)) + return false; /* read_callback_ sets the state for us */ + track->num_indices = (FLAC__byte)x; + + if(track->num_indices > 0) { + if(0 == (track->indices = safe_calloc_(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + for(j = 0; j < track->num_indices; j++) { + FLAC__StreamMetadata_CueSheet_Index *indx = &track->indices[j]; + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN)) + return false; /* read_callback_ sets the state for us */ + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN)) + return false; /* read_callback_ sets the state for us */ + indx->number = (FLAC__byte)x; + + if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN)) + return false; /* read_callback_ sets the state for us */ + } + } + } + } + else { /* obj->num_tracks == 0 */ + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + + return true; +} + +FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) +{ + FLAC__uint32 x; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + /* read type */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + if(x < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED) + obj->type = x; + else + obj->type = FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER; + + /* read MIME type */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN)) + return false; /* read_callback_ sets the state for us */ + if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + if(0 == (obj->mime_type = safe_malloc_add_2op_(x, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if(x > 0) { + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mime_type, x)) + return false; /* read_callback_ sets the state for us */ + } + obj->mime_type[x] = '\0'; + + /* read description */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN)) + return false; /* read_callback_ sets the state for us */ + if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + if(0 == (obj->description = safe_malloc_add_2op_(x, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if(x > 0) { + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) + return false; /* read_callback_ sets the state for us */ + } + obj->description[x] = '\0'; + + /* read width */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN)) + return false; /* read_callback_ sets the state for us */ + + /* read height */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN)) + return false; /* read_callback_ sets the state for us */ + + /* read depth */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN)) + return false; /* read_callback_ sets the state for us */ + + /* read colors */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_PICTURE_COLORS_LEN)) + return false; /* read_callback_ sets the state for us */ + + /* read data */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN)) + return false; /* read_callback_ sets the state for us */ + if(FLAC__bitreader_limit_remaining(decoder->private_->input) < obj->data_length){ + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } + if(0 == (obj->data = safe_malloc_(obj->data_length))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if(obj->data_length > 0) { + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_length)) + return false; /* read_callback_ sets the state for us */ + } + + return true; +} + +FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) +{ + FLAC__uint32 x; + uint32_t i, skip; + + /* skip the version and flags bytes */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) + return false; /* read_callback_ sets the state for us */ + /* get the size (in bytes) to skip */ + skip = 0; + for(i = 0; i < 4; i++) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + skip <<= 7; + skip |= (x & 0x7f); + } + /* skip the rest of the tag */ + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) + return false; /* read_callback_ sets the state for us */ + return true; +} + +FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) +{ + FLAC__uint32 x; + FLAC__bool first = true; + + /* make sure we're byte aligned */ + if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input))) + return false; /* read_callback_ sets the state for us */ + } + + while(1) { + if(decoder->private_->cached) { + x = (FLAC__uint32)decoder->private_->lookahead; + decoder->private_->cached = false; + } + else { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + } + if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ + decoder->private_->header_warmup[0] = (FLAC__byte)x; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + + /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */ + /* else we have to check if the second byte is the end of a sync code */ + if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ + decoder->private_->lookahead = (FLAC__byte)x; + decoder->private_->cached = true; + } + else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */ + decoder->private_->header_warmup[1] = (FLAC__byte)x; + decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; + + /* Save location so we can rewind in case the frame turns + * out to be invalid after the header */ + FLAC__bitreader_set_framesync_location(decoder->private_->input); + if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->last_seen_framesync)) + decoder->private_->last_seen_framesync = 0; + return true; + } + } + if(first) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + first = false; + } + } + + return true; +} + +FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode) +{ + uint32_t channel; + uint32_t i; + uint32_t frame_crc; /* the one we calculate from the input stream */ + FLAC__uint32 x; + + *got_a_frame = false; + decoder->private_->side_subframe_in_use = false; + + /* init the CRC */ + frame_crc = 0; + frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); + frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); + FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); + + if(!read_frame_header_(decoder)) + return false; + if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sync on a valid header */ + return true; + if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.header.channels, decoder->private_->frame.header.bits_per_sample)) + return false; + for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { + /* + * first figure the correct bits-per-sample of the subframe + */ + uint32_t bps = decoder->private_->frame.header.bits_per_sample; + switch(decoder->private_->frame.header.channel_assignment) { + case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: + /* no adjustment needed */ + break; + case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + if(channel == 1) + bps++; + break; + case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + if(channel == 0) + bps++; + break; + case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + if(channel == 1) + bps++; + break; + default: + FLAC__ASSERT(0); + } + /* + * now read it + */ + if(!read_subframe_(decoder, channel, bps, do_full_decode)){ + /* read_callback_ sets the state for us */ + if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) { + break; + } else { + return false; + } + } + if(decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME) { + break; + } + } + + if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) + if(!read_zero_padding_(decoder)) + return false; + + /* + * Read the frame CRC-16 from the footer and check + */ + if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { + frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) { + /* read_callback_ sets the state for us */ + if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) + return false; + } +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + } + if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && frame_crc == x) { +#endif + if(do_full_decode) { + /* Undo any special channel coding */ + undo_channel_coding(decoder); + /* Check whether decoded data actually fits bps */ + for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + int shift_bits = 32 - decoder->private_->frame.header.bits_per_sample; + /* Check whether shift_bits MSBs are 'empty' by shifting up and down */ + if((decoder->private_->output[channel][i] < (INT32_MIN >> shift_bits)) || + (decoder->private_->output[channel][i] > (INT32_MAX >> shift_bits))) { + /* Bad frame, emit error */ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + break; + } + } + } + } + } +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + else if (decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { + /* Bad frame, emit error */ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + } +#endif + /* Check whether frames are missing, if so, add silence to compensate */ + if(decoder->private_->last_frame_is_set && decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && !decoder->private_->is_seeking && do_full_decode) { + FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + if(decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.header.blocksize < decoder->private_->frame.header.number.sample_number) { + uint32_t padding_samples_needed = decoder->private_->frame.header.number.sample_number - (decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.header.blocksize); + /* Send an error that we lost sync, but only in case no error + * has been sent yet. This is the case if exactly one or more + * frames are missing, and the frames before and after it + * are complete */ + if(!decoder->private_->error_has_been_sent) + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + /* Do some extra validation to assure last frame an current frame + * header are both valid before adding silence inbetween + * Technically both frames could be valid with differing sample_rates, + * channels and bits_per_sample, but it is quite rare */ + if(decoder->private_->last_frame.header.sample_rate == decoder->private_->frame.header.sample_rate && + decoder->private_->last_frame.header.channels == decoder->private_->frame.header.channels && + decoder->private_->last_frame.header.bits_per_sample == decoder->private_->frame.header.bits_per_sample && + decoder->private_->last_frame.header.blocksize >= 16) { + FLAC__Frame empty_frame; + FLAC__int32 * empty_buffer[FLAC__MAX_CHANNELS] = {NULL}; + empty_frame.header = decoder->private_->last_frame.header; + empty_frame.footer.crc = 0; + for(i = 0; i < empty_frame.header.channels; i++) { + empty_buffer[i] = safe_calloc_(empty_frame.header.blocksize, sizeof(FLAC__int32)); + if(empty_buffer[i] == NULL) { + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + } + /* No repairs larger than 5 seconds or 50 frames are made, to not + * unexpectedly create enormous files when one of the headers was + * corrupt after all */ + if(padding_samples_needed > (5*empty_frame.header.sample_rate)) + padding_samples_needed = 5*empty_frame.header.sample_rate; + if(padding_samples_needed > (50*empty_frame.header.blocksize)) + padding_samples_needed = 50*empty_frame.header.blocksize; + while(padding_samples_needed){ + empty_frame.header.number.sample_number += empty_frame.header.blocksize; + if(padding_samples_needed < empty_frame.header.blocksize) + empty_frame.header.blocksize = padding_samples_needed; + padding_samples_needed -= empty_frame.header.blocksize; + decoder->protected_->blocksize = empty_frame.header.blocksize; + + FLAC__ASSERT(empty_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + decoder->private_->samples_decoded = empty_frame.header.number.sample_number + empty_frame.header.blocksize; + + for(channel = 0; channel < empty_frame.header.channels; channel++) { + empty_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; + empty_frame.subframes[channel].data.constant.value = 0; + empty_frame.subframes[channel].wasted_bits = 0; + } + + if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)empty_buffer) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { + decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); + return false; + } + } + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); + + } + } + } + + decoder->private_->error_has_been_sent = false; + + if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC || decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) { + /* Got corruption, rewind if possible. Return value of seek + * isn't checked, if the seek fails the decoder will continue anyway */ + if(!FLAC__bitreader_rewind_to_after_last_seen_framesync(decoder->private_->input)){ +#ifndef NDEBUG + flac_fprintf(stderr, "Rewinding, seeking necessary\n"); +#endif + if(decoder->private_->seek_callback && decoder->private_->last_seen_framesync){ + /* Last framesync isn't in bitreader anymore, rewind with seek if possible */ +#ifndef NDEBUG + FLAC__uint64 current_decode_position; + if(FLAC__stream_decoder_get_decode_position(decoder, ¤t_decode_position)) + flac_fprintf(stderr, "Bitreader was %" PRIu64 " bytes short\n", current_decode_position-decoder->private_->last_seen_framesync); +#endif + if(decoder->private_->seek_callback(decoder, decoder->private_->last_seen_framesync, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if(!FLAC__bitreader_clear(decoder->private_->input)) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + } + } +#ifndef NDEBUG + else{ + flac_fprintf(stderr, "Rewinding, seeking not necessary\n"); + } +#endif + } + else { + *got_a_frame = true; + + /* we wait to update fixed_block_size until here, when we're sure we've got a proper frame and hence a correct blocksize */ + if(decoder->private_->next_fixed_block_size) + decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; + + /* put the latest values into the public section of the decoder instance */ + decoder->protected_->channels = decoder->private_->frame.header.channels; + decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; + decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; + decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; + decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; + + FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decoder->private_->frame.header.blocksize; + /* write it */ + if(do_full_decode) { + if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { + decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + return false; + } + } + } + + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; +} + +FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) +{ + FLAC__uint32 x; + FLAC__uint64 xx; + uint32_t i, blocksize_hint = 0, sample_rate_hint = 0; + FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */ + uint32_t raw_header_len; + FLAC__bool is_unparseable = false; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + /* init the raw header with the saved bits from synchronization */ + raw_header[0] = decoder->private_->header_warmup[0]; + raw_header[1] = decoder->private_->header_warmup[1]; + raw_header_len = 2; + + /* check to make sure that reserved bit is 0 */ + if(raw_header[1] & 0x02) /* MAGIC NUMBER */ + is_unparseable = true; + + /* + * Note that along the way as we read the header, we look for a sync + * code inside. If we find one it would indicate that our original + * sync was bad since there cannot be a sync code in a valid header. + * + * Three kinds of things can go wrong when reading the frame header: + * 1) We may have sync'ed incorrectly and not landed on a frame header. + * If we don't find a sync code, it can end up looking like we read + * a valid but unparseable header, until getting to the frame header + * CRC. Even then we could get a false positive on the CRC. + * 2) We may have sync'ed correctly but on an unparseable frame (from a + * future encoder). + * 3) We may be on a damaged frame which appears valid but unparseable. + * + * For all these reasons, we try and read a complete frame header as + * long as it seems valid, even if unparseable, up until the frame + * header CRC. + */ + + /* + * read in the raw header as bytes so we can CRC it, and parse it on the way + */ + for(i = 0; i < 2; i++) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ + /* if we get here it means our original sync was erroneous since the sync code cannot appear in the header */ + decoder->private_->lookahead = (FLAC__byte)x; + decoder->private_->cached = true; + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + raw_header[raw_header_len++] = (FLAC__byte)x; + } + + switch(x = raw_header[2] >> 4) { + case 0: + is_unparseable = true; + break; + case 1: + decoder->private_->frame.header.blocksize = 192; + break; + case 2: + case 3: + case 4: + case 5: + decoder->private_->frame.header.blocksize = 576 << (x-2); + break; + case 6: + case 7: + blocksize_hint = x; + break; + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + decoder->private_->frame.header.blocksize = 256 << (x-8); + break; + default: + FLAC__ASSERT(0); + break; + } + + switch(x = raw_header[2] & 0x0f) { + case 0: + if(decoder->private_->has_stream_info) + decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.sample_rate; + else + is_unparseable = true; + break; + case 1: + decoder->private_->frame.header.sample_rate = 88200; + break; + case 2: + decoder->private_->frame.header.sample_rate = 176400; + break; + case 3: + decoder->private_->frame.header.sample_rate = 192000; + break; + case 4: + decoder->private_->frame.header.sample_rate = 8000; + break; + case 5: + decoder->private_->frame.header.sample_rate = 16000; + break; + case 6: + decoder->private_->frame.header.sample_rate = 22050; + break; + case 7: + decoder->private_->frame.header.sample_rate = 24000; + break; + case 8: + decoder->private_->frame.header.sample_rate = 32000; + break; + case 9: + decoder->private_->frame.header.sample_rate = 44100; + break; + case 10: + decoder->private_->frame.header.sample_rate = 48000; + break; + case 11: + decoder->private_->frame.header.sample_rate = 96000; + break; + case 12: + case 13: + case 14: + sample_rate_hint = x; + break; + case 15: + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + default: + FLAC__ASSERT(0); + } + + x = (uint32_t)(raw_header[3] >> 4); + if(x & 8) { + decoder->private_->frame.header.channels = 2; + switch(x & 7) { + case 0: + decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; + break; + case 1: + decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; + break; + case 2: + decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; + break; + default: + is_unparseable = true; + break; + } + } + else { + decoder->private_->frame.header.channels = (uint32_t)x + 1; + decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; + } + + switch(x = (uint32_t)(raw_header[3] & 0x0e) >> 1) { + case 0: + if(decoder->private_->has_stream_info) + decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample; + else + is_unparseable = true; + break; + case 1: + decoder->private_->frame.header.bits_per_sample = 8; + break; + case 2: + decoder->private_->frame.header.bits_per_sample = 12; + break; + case 3: + is_unparseable = true; + break; + case 4: + decoder->private_->frame.header.bits_per_sample = 16; + break; + case 5: + decoder->private_->frame.header.bits_per_sample = 20; + break; + case 6: + decoder->private_->frame.header.bits_per_sample = 24; + break; + case 7: + decoder->private_->frame.header.bits_per_sample = 32; + break; + default: + FLAC__ASSERT(0); + break; + } + +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* check to make sure that reserved bit is 0 */ + if(raw_header[3] & 0x01) /* MAGIC NUMBER */ + is_unparseable = true; +#endif + + /* read the frame's starting sample number (or frame number as the case may be) */ + if( + raw_header[1] & 0x01 || + /*@@@ this clause is a concession to the old way of doing variable blocksize; the only known implementation is flake and can probably be removed without inconveniencing anyone */ + (decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksize != decoder->private_->stream_info.data.stream_info.max_blocksize) + ) { /* variable blocksize */ + if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) + return false; /* read_callback_ sets the state for us */ + if(xx == FLAC__U64L(0xffffffffffffffff)) { /* i.e. non-UTF8 code... */ + decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ + decoder->private_->cached = true; + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; + decoder->private_->frame.header.number.sample_number = xx; + } + else { /* fixed blocksize */ + if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) + return false; /* read_callback_ sets the state for us */ + if(x == 0xffffffff) { /* i.e. non-UTF8 code... */ + decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ + decoder->private_->cached = true; + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; + decoder->private_->frame.header.number.frame_number = x; + } + + if(blocksize_hint) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + raw_header[raw_header_len++] = (FLAC__byte)x; + if(blocksize_hint == 7) { + FLAC__uint32 _x; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) + return false; /* read_callback_ sets the state for us */ + raw_header[raw_header_len++] = (FLAC__byte)_x; + x = (x << 8) | _x; + } + decoder->private_->frame.header.blocksize = x+1; + if(decoder->private_->frame.header.blocksize > 65535) { /* invalid blocksize (65536) specified */ + decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ + decoder->private_->cached = true; + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + } + + if(sample_rate_hint) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + raw_header[raw_header_len++] = (FLAC__byte)x; + if(sample_rate_hint != 12) { + FLAC__uint32 _x; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) + return false; /* read_callback_ sets the state for us */ + raw_header[raw_header_len++] = (FLAC__byte)_x; + x = (x << 8) | _x; + } + if(sample_rate_hint == 12) + decoder->private_->frame.header.sample_rate = x*1000; + else if(sample_rate_hint == 13) + decoder->private_->frame.header.sample_rate = x; + else + decoder->private_->frame.header.sample_rate = x*10; + } + + /* read the CRC-8 byte */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) + return false; /* read_callback_ sets the state for us */ + crc8 = (FLAC__byte)x; + +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + if(FLAC__crc8(raw_header, raw_header_len) != crc8) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } +#endif + + /* calculate the sample number from the frame number if needed */ + decoder->private_->next_fixed_block_size = 0; + if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { + x = decoder->private_->frame.header.number.frame_number; + decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; + if(decoder->private_->fixed_block_size) + decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_block_size * (FLAC__uint64)x; + else if(decoder->private_->has_stream_info) { + if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info.data.stream_info.max_blocksize) { + decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_info.data.stream_info.min_blocksize * (FLAC__uint64)x; + decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blocksize; + } + else + is_unparseable = true; + } + else if(x == 0) { + decoder->private_->frame.header.number.sample_number = 0; + decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; + } + else { + /* can only get here if the stream has invalid frame numbering and no STREAMINFO, so assume it's not the last (possibly short) frame */ + decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.header.blocksize * (FLAC__uint64)x; + } + } + + if(is_unparseable) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + return true; +} + +FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) +{ + FLAC__uint32 x; + FLAC__bool wasted_bits; + uint32_t i; + + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ + return false; /* read_callback_ sets the state for us */ + + wasted_bits = (x & 1); + x &= 0xfe; + + if(wasted_bits) { + uint32_t u; + if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->frame.subframes[channel].wasted_bits = u+1; + if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + bps -= decoder->private_->frame.subframes[channel].wasted_bits; + } + else + decoder->private_->frame.subframes[channel].wasted_bits = 0; + + /* + * Lots of magic numbers here + */ + if(x & 0x80) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + else if(x == 0) { + if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) + return false; + } + else if(x == 2) { + if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) + return false; + } + else if(x < 16) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + else if(x <= 24) { + uint32_t predictor_order = (x>>1)&7; + if(decoder->private_->frame.header.blocksize <= predictor_order){ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + if(!read_subframe_fixed_(decoder, channel, bps, predictor_order, do_full_decode)) + return false; + if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */ + return true; + } + else if(x < 64) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + else { + uint32_t predictor_order = ((x>>1)&31)+1; + if(decoder->private_->frame.header.blocksize <= predictor_order){ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + if(!read_subframe_lpc_(decoder, channel, bps, predictor_order, do_full_decode)) + return false; + if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */ + return true; + } + + if(wasted_bits && do_full_decode) { + x = decoder->private_->frame.subframes[channel].wasted_bits; + if((bps + x) < 33) { + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + uint32_t val = decoder->private_->output[channel][i]; + decoder->private_->output[channel][i] = (val << x); + } + } + else { + /* When there are wasted bits, bps is never 33 and so + * side_subframe is never already in use */ + FLAC__ASSERT(!decoder->private_->side_subframe_in_use); + decoder->private_->side_subframe_in_use = true; + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + uint64_t val = decoder->private_->output[channel][i]; + decoder->private_->side_subframe[i] = (val << x); + } + } + } + + return true; +} + +FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) +{ + FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; + FLAC__int64 x; + uint32_t i; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; + + if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) + return false; /* read_callback_ sets the state for us */ + + subframe->value = x; + + /* decode the subframe */ + if(do_full_decode) { + if(bps <= 32) { + FLAC__int32 *output = decoder->private_->output[channel]; + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) + output[i] = x; + } else { + FLAC__int64 *output = decoder->private_->side_subframe; + decoder->private_->side_subframe_in_use = true; + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) + output[i] = x; + } + } + + return true; +} + +FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) +{ + FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; + FLAC__int64 i64; + FLAC__uint32 u32; + uint32_t u; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; + + subframe->residual = decoder->private_->residual[channel]; + subframe->order = order; + + /* read warm-up samples */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) + return false; /* read_callback_ sets the state for us */ + subframe->warmup[u] = i64; + } + + /* read entropy coding method info */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) + return false; /* read_callback_ sets the state for us */ + if((decoder->private_->frame.header.blocksize >> u32 < order) || + (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->entropy_coding_method.data.partitioned_rice.order = u32; + subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; + break; + default: + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + /* read residual */ + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) + return false; + break; + default: + FLAC__ASSERT(0); + } + + /* decode the subframe */ + if(do_full_decode) { + if(bps < 33){ + uint32_t i; + for(i = 0; i < order; i++) + decoder->private_->output[channel][i] = subframe->warmup[i]; + if(bps+order <= 32) + FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order); + else + FLAC__fixed_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order); + } + else { + decoder->private_->side_subframe_in_use = true; + memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); + FLAC__fixed_restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->side_subframe+order); + } + } + + return true; +} + +FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) +{ + FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; + FLAC__int32 i32; + FLAC__int64 i64; + FLAC__uint32 u32; + uint32_t u; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; + + subframe->residual = decoder->private_->residual[channel]; + subframe->order = order; + + /* read warm-up samples */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) + return false; /* read_callback_ sets the state for us */ + subframe->warmup[u] = i64; + } + + /* read qlp coeff precision */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)) + return false; /* read_callback_ sets the state for us */ + if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->qlp_coeff_precision = u32+1; + + /* read qlp shift */ + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN)) + return false; /* read_callback_ sets the state for us */ + if(i32 < 0) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->quantization_level = i32; + + /* read quantized lp coefficiencts */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) + return false; /* read_callback_ sets the state for us */ + subframe->qlp_coeff[u] = i32; + } + + /* read entropy coding method info */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) + return false; /* read_callback_ sets the state for us */ + if((decoder->private_->frame.header.blocksize >> u32 < order) || + (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->entropy_coding_method.data.partitioned_rice.order = u32; + subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; + break; + default: + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + /* read residual */ + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) + return false; + break; + default: + FLAC__ASSERT(0); + } + + /* decode the subframe */ + if(do_full_decode) { + if(bps <= 32) { + uint32_t i; + for(i = 0; i < order; i++) + decoder->private_->output[channel][i] = subframe->warmup[i]; + if(FLAC__lpc_max_residual_bps(bps, subframe->qlp_coeff, order, subframe->quantization_level) <= 32 && + FLAC__lpc_max_prediction_before_shift_bps(bps, subframe->qlp_coeff, order) <= 32) + FLAC__lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + else + FLAC__lpc_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + } + else { + decoder->private_->side_subframe_in_use = true; + memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); + FLAC__lpc_restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->side_subframe+order); + } + } + + return true; +} + +FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) +{ + FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; + uint32_t i; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; + + if(bps < 33) { + FLAC__int32 x, *residual = decoder->private_->residual[channel]; + + subframe->data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; + subframe->data.int32 = residual; + + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) + return false; /* read_callback_ sets the state for us */ + residual[i] = x; + } + + /* decode the subframe */ + if(do_full_decode) + memcpy(decoder->private_->output[channel], subframe->data.int32, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize); + } + else { + FLAC__int64 x, *side = decoder->private_->side_subframe; + + subframe->data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64; + subframe->data.int64 = side; + decoder->private_->side_subframe_in_use = true; + + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) + return false; /* read_callback_ sets the state for us */ + side[i] = x; + } + } + + return true; +} + +FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended) +{ + FLAC__uint32 rice_parameter; + int i; + uint32_t partition, sample, u; + const uint32_t partitions = 1u << partition_order; + const uint32_t partition_samples = decoder->private_->frame.header.blocksize >> partition_order; + const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; + const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; + + /* invalid predictor and partition orders mush be handled in the callers */ + FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.header.blocksize >= predictor_order); + + if(!FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, flac_max(6u, partition_order))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + + sample = 0; + for(partition = 0; partition < partitions; partition++) { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) + return false; /* read_callback_ sets the state for us */ + partitioned_rice_contents->parameters[partition] = rice_parameter; + if(rice_parameter < pesc) { + partitioned_rice_contents->raw_bits[partition] = 0; + u = (partition == 0) ? partition_samples - predictor_order : partition_samples; + if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter)){ + if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { + /* no error was set, read_callback_ didn't set it, so + * invalid rice symbol was found */ + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + else + return false; /* read_callback_ sets the state for us */ + } + sample += u; + } + else { + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN)) + return false; /* read_callback_ sets the state for us */ + partitioned_rice_contents->raw_bits[partition] = rice_parameter; + if(rice_parameter == 0) { + for(u = (partition == 0)? predictor_order : 0; u < partition_samples; u++, sample++) + residual[sample] = 0; + } + else{ + for(u = (partition == 0)? predictor_order : 0; u < partition_samples; u++, sample++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) + return false; /* read_callback_ sets the state for us */ + residual[sample] = i; + } + } + } + } + + return true; +} + +FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) +{ + if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { + FLAC__uint32 zero = 0; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input))) + return false; /* read_callback_ sets the state for us */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + if(zero != 0) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + } +#endif + } + return true; +} + +FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data) +{ + FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; + + if( +#if FLAC__HAS_OGG + /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */ + !decoder->private_->is_ogg && +#endif + decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data) + ) { + *bytes = 0; + decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; + return false; + } + else if(*bytes > 0) { + /* While seeking, it is possible for our seek to land in the + * middle of audio data that looks exactly like a frame header + * from a future version of an encoder. When that happens, our + * error callback will get an + * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its + * unparseable_frame_count. But there is a remote possibility + * that it is properly synced at such a "future-codec frame", + * so to make sure, we wait to see many "unparseable" errors in + * a row before bailing out. + */ + if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { + decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + return false; + } + else { + const FLAC__StreamDecoderReadStatus status = +#if FLAC__HAS_OGG + decoder->private_->is_ogg? + read_callback_ogg_aspect_(decoder, buffer, bytes) : +#endif + decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) + ; + if(status == FLAC__STREAM_DECODER_READ_STATUS_ABORT) { + decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + return false; + } + else if(*bytes == 0) { + if( + status == FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM || + ( +#if FLAC__HAS_OGG + /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */ + !decoder->private_->is_ogg && +#endif + decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data) + ) + ) { + decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; + return false; + } + else + return true; + } + else + return true; + } + } + else { + /* abort to avoid a deadlock */ + decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + return false; + } + /* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around + * for Ogg FLAC. This is because the ogg decoder aspect can lose sync + * and at the same time hit the end of the stream (for example, seeking + * to a point that is after the beginning of the last Ogg page). There + * is no way to report an Ogg sync loss through the callbacks (see note + * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0. + * So to keep the decoder from stopping at this point we gate the call + * to the eof_callback and let the Ogg decoder aspect set the + * end-of-stream state when it is needed. + */ +} + +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) +/* The attribute below is to silence the undefined sanitizer of oss-fuzz. + * Because fuzzing feeds bogus predictors and residual samples to the + * decoder, having overflows in this section is unavoidable. Also, + * because the calculated values are audio path only, there is no + * potential for security problems */ +__attribute__((no_sanitize("signed-integer-overflow"))) +#endif +void undo_channel_coding(FLAC__StreamDecoder *decoder) { + uint32_t i; + switch(decoder->private_->frame.header.channel_assignment) { + case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: + /* do nothing */ + break; + case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) + if(decoder->private_->side_subframe_in_use) + decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subframe[i]; + else + decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i]; + break; + case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) + if(decoder->private_->side_subframe_in_use) + decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subframe[i]; + else + decoder->private_->output[0][i] += decoder->private_->output[1][i]; + break; + case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: + FLAC__ASSERT(decoder->private_->frame.header.channels == 2); + FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); + for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { + if(!decoder->private_->side_subframe_in_use){ + FLAC__int32 mid, side; + mid = decoder->private_->output[0][i]; + side = decoder->private_->output[1][i]; + mid = ((uint32_t) mid) << 1; + mid |= (side & 1); /* i.e. if 'side' is odd... */ + decoder->private_->output[0][i] = (mid + side) >> 1; + decoder->private_->output[1][i] = (mid - side) >> 1; + } + else { /* bps == 32 */ + FLAC__int64 mid; + mid = ((uint64_t)decoder->private_->output[0][i]) << 1; + mid |= (decoder->private_->side_subframe[i] & 1); /* i.e. if 'side' is odd... */ + decoder->private_->output[0][i] = (mid + decoder->private_->side_subframe[i]) >> 1; + decoder->private_->output[1][i] = (mid - decoder->private_->side_subframe[i]) >> 1; + } + } + break; + default: + FLAC__ASSERT(0); + break; + } +} + +#if FLAC__HAS_OGG +FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes) +{ + switch(FLAC__ogg_decoder_aspect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback_proxy_, decoder, decoder->private_->client_data)) { + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK: + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + /* we don't really have a way to handle lost sync via read + * callback so we'll let it pass and let the underlying + * FLAC decoder catch the error + */ + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC: + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM: + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC: + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION: + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT: + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR: + case FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR: + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + default: + FLAC__ASSERT(0); + /* double protection */ + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } +} + +FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) +{ + FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; + + switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { + case FLAC__STREAM_DECODER_READ_STATUS_CONTINUE: + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK; + case FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM: + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM; + case FLAC__STREAM_DECODER_READ_STATUS_ABORT: + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; + default: + /* double protection: */ + FLAC__ASSERT(0); + return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; + } +} +#endif + +FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]) +{ + decoder->private_->last_frame = *frame; /* save the frame */ + decoder->private_->last_frame_is_set = true; + if(decoder->private_->is_seeking) { + FLAC__uint64 this_frame_sample = frame->header.number.sample_number; + FLAC__uint64 next_frame_sample = this_frame_sample + (FLAC__uint64)frame->header.blocksize; + FLAC__uint64 target_sample = decoder->private_->target_sample; + + FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + +#if FLAC__HAS_OGG + decoder->private_->got_a_frame = true; +#endif + if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */ + uint32_t delta = (uint32_t)(target_sample - this_frame_sample); + /* kick out of seek mode */ + decoder->private_->is_seeking = false; + /* shift out the samples before target_sample */ + if(delta > 0) { + uint32_t channel; + const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; + for(channel = 0; channel < frame->header.channels; channel++) { + newbuffer[channel] = buffer[channel] + delta; + decoder->private_->last_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; + decoder->private_->last_frame.subframes[channel].data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; + decoder->private_->last_frame.subframes[channel].data.verbatim.data.int32 = newbuffer[channel]; + } + decoder->private_->last_frame.header.blocksize -= delta; + decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; + /* write the relevant samples */ + return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decoder->private_->client_data); + } + else { + /* write the relevant samples */ + return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); + } + } + else { + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + } + } + else { + /* + * If we never got STREAMINFO, turn off MD5 checking to save + * cycles since we don't have a sum to compare to anyway + */ + if(!decoder->private_->has_stream_info) + decoder->private_->do_md5_checking = false; + if(decoder->private_->do_md5_checking) { + if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->header.blocksize, (frame->header.bits_per_sample+7) / 8)) + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); + } +} + +void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status) +{ + if(!decoder->private_->is_seeking) { + decoder->private_->error_has_been_sent = true; + decoder->private_->error_callback(decoder, status, decoder->private_->client_data); + } + else if(status == FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM) + decoder->private_->unparseable_frame_count++; +} + +FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample) +{ + FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample; + FLAC__int64 pos = -1; + int i; + uint32_t approx_bytes_per_frame; + FLAC__bool first_seek = true, seek_from_lower_bound = false; + const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); + const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; + const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; + const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; + const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; + /* take these from the current frame in case they've changed mid-stream */ + uint32_t channels = FLAC__stream_decoder_get_channels(decoder); + uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); + const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->private_->seek_table.data.seek_table : 0; + + /* use values from stream info if we didn't decode a frame */ + if(channels == 0) + channels = decoder->private_->stream_info.data.stream_info.channels; + if(bps == 0) + bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; + + /* we are just guessing here */ + if(max_framesize > 0) + approx_bytes_per_frame = (max_framesize + min_framesize) / 2 + 1; + /* + * Check if it's a known fixed-blocksize stream. Note that though + * the spec doesn't allow zeroes in the STREAMINFO block, we may + * never get a STREAMINFO block when decoding so the value of + * min_blocksize might be zero. + */ + else if(min_blocksize == max_blocksize && min_blocksize > 0) { + /* note there are no () around 'bps/8' to keep precision up since it's an integer calculation */ + approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64; + } + else + approx_bytes_per_frame = 4096 * channels * bps/8 + 64; + + /* + * First, we set an upper and lower bound on where in the + * stream we will search. For now we take the current position + * as one bound and, depending on where the target position lies, + * the beginning of the first frame or the end of the stream as + * the other bound. + */ + lower_bound = first_frame_offset; + lower_bound_sample = 0; + upper_bound = stream_length; + upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/; + + if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && + decoder->private_->samples_decoded != 0) { + if(target_sample < decoder->private_->samples_decoded) { + if(FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) + upper_bound_sample = decoder->private_->samples_decoded; + } else { + if(FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) + lower_bound_sample = decoder->private_->samples_decoded; + } + } + + /* + * Now we refine the bounds if we have a seektable with + * suitable points. Note that according to the spec they + * must be ordered by ascending sample number. + * + * Note: to protect against invalid seek tables we will ignore points + * that have frame_samples==0 or sample_number>=total_samples. Also, + * because math is limited to 64-bit ints, seekpoints with an offset + * larger than 2^63 (8 exbibyte) are rejected. + */ + if(seek_table) { + FLAC__uint64 new_lower_bound = lower_bound; + FLAC__uint64 new_upper_bound = upper_bound; + FLAC__uint64 new_lower_bound_sample = lower_bound_sample; + FLAC__uint64 new_upper_bound_sample = upper_bound_sample; + + /* find the closest seek point <= target_sample, if it exists */ + for(i = (int)seek_table->num_points - 1; i >= 0; i--) { + if( + seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && + seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */ + (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */ + seek_table->points[i].sample_number <= target_sample + ) + break; + } + if(i >= 0) { /* i.e. we found a suitable seek point... */ + new_lower_bound = first_frame_offset + seek_table->points[i].stream_offset; + new_lower_bound_sample = seek_table->points[i].sample_number; + } + + /* find the closest seek point > target_sample, if it exists */ + for(i = 0; i < (int)seek_table->num_points; i++) { + if( + seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && + seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */ + (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */ + seek_table->points[i].sample_number > target_sample + ) + break; + } + if(i < (int)seek_table->num_points) { /* i.e. we found a suitable seek point... */ + new_upper_bound = first_frame_offset + seek_table->points[i].stream_offset; + new_upper_bound_sample = seek_table->points[i].sample_number; + } + /* final protection against unsorted seek tables; keep original values if bogus */ + if(new_upper_bound >= new_lower_bound) { + lower_bound = new_lower_bound; + upper_bound = new_upper_bound; + lower_bound_sample = new_lower_bound_sample; + upper_bound_sample = new_upper_bound_sample; + } + } + + FLAC__ASSERT(upper_bound_sample >= lower_bound_sample); + /* there are 2 insidious ways that the following equality occurs, which + * we need to fix: + * 1) total_samples is 0 (unknown) and target_sample is 0 + * 2) total_samples is 0 (unknown) and target_sample happens to be + * exactly equal to the last seek point in the seek table; this + * means there is no seek point above it, and upper_bound_samples + * remains equal to the estimate (of target_samples) we made above + * in either case it does not hurt to move upper_bound_sample up by 1 + */ + if(upper_bound_sample == lower_bound_sample) + upper_bound_sample++; + + decoder->private_->target_sample = target_sample; + while(1) { + /* check whether decoder is still valid so bad state isn't overwritten + * with seek error */ + if(decoder->protected_->state == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR || + decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) + return false; + /* check if the bounds are still ok */ + if (lower_bound_sample >= upper_bound_sample || + lower_bound > upper_bound || + upper_bound >= INT64_MAX) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if(seek_from_lower_bound) { + pos = lower_bound; + } + else { +#ifndef FLAC__INTEGER_ONLY_LIBRARY + pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(target_sample - lower_bound_sample) / (double)(upper_bound_sample - lower_bound_sample) * (double)(upper_bound - lower_bound)) - approx_bytes_per_frame; +#else + /* a little less accurate: */ + if(upper_bound - lower_bound < 0xffffffff) + pos = (FLAC__int64)lower_bound + (FLAC__int64)(((target_sample - lower_bound_sample) * (upper_bound - lower_bound)) / (upper_bound_sample - lower_bound_sample)) - approx_bytes_per_frame; + else { /* @@@ WATCHOUT, ~2TB limit */ + FLAC__uint64 ratio = (1<<16) / (upper_bound_sample - lower_bound_sample); + pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8) * ratio)) - approx_bytes_per_frame; + } +#endif + } + if(pos >= (FLAC__int64)upper_bound) + pos = (FLAC__int64)upper_bound - 1; + if(pos < (FLAC__int64)lower_bound) + pos = (FLAC__int64)lower_bound; + if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if(!FLAC__stream_decoder_flush(decoder)) { + /* above call sets the state for us */ + return false; + } + /* Now we need to get a frame. First we need to reset our + * unparseable_frame_count; if we get too many unparseable + * frames in a row, the read callback will return + * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing + * FLAC__stream_decoder_process_single() to return false. + */ + decoder->private_->unparseable_frame_count = 0; + if(!FLAC__stream_decoder_process_single(decoder) || decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED || 0 == decoder->private_->samples_decoded) { + /* No frame could be decoded */ + if(decoder->protected_->state != FLAC__STREAM_DECODER_ABORTED && decoder->private_->eof_callback(decoder, decoder->private_->client_data) && !seek_from_lower_bound){ + /* decoder has hit end of stream while processing corrupt + * frame. To remedy this, try decoding a frame at the lower + * bound so the seek after that hopefully ends up somewhere + * else */ + seek_from_lower_bound = true; + continue; + } + else { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + } + seek_from_lower_bound = false; + + /* our write callback will change the state when it gets to the target frame */ + /* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so we need to check for that also */ + if(!decoder->private_->is_seeking) + break; + + FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + this_frame_sample = decoder->private_->last_frame.header.number.sample_number; + + if(this_frame_sample + decoder->private_->last_frame.header.blocksize >= upper_bound_sample && !first_seek) { + if (pos == (FLAC__int64)lower_bound) { + /* can't move back any more than the first frame, something is fatally wrong */ + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + /* our last move backwards wasn't big enough, try again */ + approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16; + continue; + } + /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */ + first_seek = false; + + /* make sure we are not seeking in corrupted stream */ + if (this_frame_sample < lower_bound_sample) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + + /* we need to narrow the search */ + if(target_sample < this_frame_sample) { + upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; +/*@@@@@@ what will decode position be if at end of stream? */ + if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + approx_bytes_per_frame = (uint32_t)(2 * (upper_bound - pos) / 3 + 16); + } + else { /* target_sample >= this_frame_sample + this frame's blocksize */ + lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; + if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + approx_bytes_per_frame = (uint32_t)(2 * (lower_bound - pos) / 3 + 16); + } + } + + return true; +} + +#if FLAC__HAS_OGG +FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample) +{ + FLAC__uint64 left_pos = 0, right_pos = stream_length; + FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); + FLAC__uint64 this_frame_sample = (FLAC__uint64)0 - 1; + FLAC__uint64 pos = 0; /* only initialized to avoid compiler warning */ + FLAC__bool did_a_seek; + uint32_t iteration = 0; + + /* In the first iterations, we will calculate the target byte position + * by the distance from the target sample to left_sample and + * right_sample (let's call it "proportional search"). After that, we + * will switch to binary search. + */ + uint32_t BINARY_SEARCH_AFTER_ITERATION = 2; + + /* We will switch to a linear search once our current sample is less + * than this number of samples ahead of the target sample + */ + static const FLAC__uint64 LINEAR_SEARCH_WITHIN_SAMPLES = FLAC__MAX_BLOCK_SIZE * 2; + + /* If the total number of samples is unknown, use a large value, and + * force binary search immediately. + */ + if(right_sample == 0) { + right_sample = (FLAC__uint64)(-1); + BINARY_SEARCH_AFTER_ITERATION = 0; + } + + decoder->private_->target_sample = target_sample; + for( ; ; iteration++) { + /* Do sanity checks on bounds */ + if(right_pos <= left_pos || right_pos - left_pos < 9) { + /* FLAC frame is at least 9 byte in size */ + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if (iteration == 0 || this_frame_sample > target_sample || target_sample - this_frame_sample > LINEAR_SEARCH_WITHIN_SAMPLES) { + if (iteration >= BINARY_SEARCH_AFTER_ITERATION) { + pos = (right_pos + left_pos) / 2; + } + else { +#ifndef FLAC__INTEGER_ONLY_LIBRARY + pos = (FLAC__uint64)((double)(target_sample - left_sample) / (double)(right_sample - left_sample) * (double)(right_pos - left_pos)); +#else + /* a little less accurate: */ + if ((target_sample-left_sample <= 0xffffffff) && (right_pos-left_pos <= 0xffffffff)) + pos = (FLAC__int64)(((target_sample-left_sample) * (right_pos-left_pos)) / (right_sample-left_sample)); + else /* @@@ WATCHOUT, ~2TB limit */ + pos = (FLAC__int64)((((target_sample-left_sample)>>8) * ((right_pos-left_pos)>>8)) / ((right_sample-left_sample)>>16)); +#endif + /* @@@ TODO: might want to limit pos to some distance + * before EOF, to make sure we land before the last frame, + * thereby getting a this_frame_sample and so having a better + * estimate. + */ + } + + /* physical seek */ + if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if(!FLAC__stream_decoder_flush(decoder)) { + /* above call sets the state for us */ + return false; + } + did_a_seek = true; + } + else + did_a_seek = false; + + decoder->private_->got_a_frame = false; + if(!FLAC__stream_decoder_process_single(decoder) || + decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + if(!decoder->private_->got_a_frame) { + if(did_a_seek) { + /* this can happen if we seek to a point after the last frame; we drop + * to binary search right away in this case to avoid any wasted + * iterations of proportional search. + */ + right_pos = pos; + BINARY_SEARCH_AFTER_ITERATION = 0; + } + else { + /* this can probably only happen if total_samples is unknown and the + * target_sample is past the end of the stream + */ + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + } + /* our write callback will change the state when it gets to the target frame */ + else if(!decoder->private_->is_seeking) { + break; + } + else { + this_frame_sample = decoder->private_->last_frame.header.number.sample_number; + FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); + + if (did_a_seek) { + if (this_frame_sample <= target_sample) { + /* The 'equal' case should not happen, since + * FLAC__stream_decoder_process_single() + * should recognize that it has hit the + * target sample and we would exit through + * the 'break' above. + */ + FLAC__ASSERT(this_frame_sample != target_sample); + + left_sample = this_frame_sample; + /* sanity check to avoid infinite loop */ + if (left_pos == pos) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + left_pos = pos; + } + else { + right_sample = this_frame_sample; + /* sanity check to avoid infinite loop */ + if (right_pos == pos) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + right_pos = pos; + } + } + } + } + + return true; +} +#endif + +FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) +{ + (void)client_data; + + if(*bytes > 0) { + *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); + if(ferror(decoder->private_->file)) + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + else if(*bytes == 0) + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + else + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } + else + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ +} + +FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) +{ + (void)client_data; + + if(decoder->private_->file == stdin) + return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; + else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) + return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; + else + return FLAC__STREAM_DECODER_SEEK_STATUS_OK; +} + +FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) +{ + FLAC__off_t pos; + (void)client_data; + + if(decoder->private_->file == stdin) + return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; + else if((pos = ftello(decoder->private_->file)) < 0) + return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + else { + *absolute_byte_offset = (FLAC__uint64)pos; + return FLAC__STREAM_DECODER_TELL_STATUS_OK; + } +} + +FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) +{ + struct flac_stat_s filestats; + (void)client_data; + + if(decoder->private_->file == stdin) + return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; + +#ifndef FLAC__USE_FILELENGTHI64 + if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) +#else + filestats.st_size = _filelengthi64(fileno(decoder->private_->file)); + if(filestats.st_size < 0) +#endif + return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; + else { + *stream_length = (FLAC__uint64)filestats.st_size; + return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; + } +} + +FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) +{ + (void)client_data; + + return feof(decoder->private_->file)? true : false; +} diff --git a/packages/third-party/libFLAC/test_decoder.c b/packages/third-party/libFLAC/test_decoder.c new file mode 100644 index 00000000..5c49162d --- /dev/null +++ b/packages/third-party/libFLAC/test_decoder.c @@ -0,0 +1,384 @@ +/* + * Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Author: + * Desc: flac decoder test + */ + +#ifdef HAVE_CONFIG_H +# include +#endif +#include +#include +#include +#include +#include +#include /* for stat() */ +#include "share/compat.h" +#include "FLAC/stream_decoder.h" + +#define FLAC_DECODER_SINGLE_MODE +static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); +#ifndef FLAC_DECODER_SINGLE_MODE +static FLAC__StreamDecoderSeekStatus seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); +static FLAC__StreamDecoderTellStatus tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); +static FLAC__StreamDecoderLengthStatus length_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); +static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data); +#endif +static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); +static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); +static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); + +static FLAC__uint64 total_samples = 0; +static unsigned sample_rate = 0; +static unsigned channels = 0; +static unsigned bps = 0; +static FLAC__off_t flacfilesize = 0; + +typedef struct { + FILE *fin_file; + FILE *fout_file; + FLAC__bool eos; +} StreamDecoderClientData; + +FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 x) +{ + return ((fputc(x, f) != EOF) && (fputc(x >> 8, f) != EOF)); +} + +FLAC__bool write_little_endian_int16(FILE *f, FLAC__int16 x) +{ + return write_little_endian_uint16(f, (FLAC__uint16)x); +} + +FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x) +{ + return ((fputc(x, f) != EOF) && \ + (fputc(x >> 8, f) != EOF) && \ + (fputc(x >> 16, f) != EOF) && \ + (fputc(x >> 24, f) != EOF)); +} + +int flac_decoder_file_demo(int argc, char *argv[]) +{ + FLAC__bool ok = true; + FLAC__StreamDecoder *decoder = 0; + FLAC__StreamDecoderInitStatus init_status; + StreamDecoderClientData decoder_client_data; + FILE *fout; + + if(argc != 3) { + fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]); + return 1; + } + + if((fout = fopen(argv[2], "wb")) == NULL) { + fprintf(stderr, "ERROR: opening %s for output\n", argv[2]); + return 1; + } + + if((decoder = FLAC__stream_decoder_new()) == NULL) { + fprintf(stderr, "ERROR: allocating decoder\n"); + fclose(fout); + return 1; + } + (void)FLAC__stream_decoder_set_md5_checking(decoder, true); + + decoder_client_data.fout_file = fout; + init_status = FLAC__stream_decoder_init_file(decoder, argv[1], write_callback, metadata_callback, error_callback, /*client_data=*/&decoder_client_data); + if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); + ok = false; + } + if(ok) { + ok = FLAC__stream_decoder_process_until_end_of_stream(decoder); + fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED"); + fprintf(stderr, " state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]); + } + + FLAC__stream_decoder_delete(decoder); + fclose(fout); + + return 0; +} + +int flac_decoder_stream_demo(int argc, char *argv[]) +{ + FLAC__bool ok = true; + FLAC__StreamDecoder *decoder = 0; + FLAC__StreamDecoderInitStatus init_status; + FILE *fin_file, *fout_file; + struct flac_stat_s filestats; + StreamDecoderClientData decoder_client_data; + struct timespec tm_before, tm_after; + + if(argc != 3) { + fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]); + return 1; + } + + if(flac_stat(argv[1], &filestats) != 0) + return 1; + else + flacfilesize = filestats.st_size; + + if((fin_file = fopen(argv[1], "rb")) == NULL) { + fprintf(stderr, "ERROR: opening %s for infile\n", argv[1]); + return 1; + } + if((fout_file = fopen(argv[2], "wb")) == NULL) { + fprintf(stderr, "ERROR: opening %s for output\n", argv[2]); + fclose(fin_file); + return 1; + } + if((decoder = FLAC__stream_decoder_new()) == NULL) { + fprintf(stderr, "ERROR: allocating decoder\n"); + fclose(fin_file); + fclose(fout_file); + return 1; + } + (void)FLAC__stream_decoder_set_md5_checking(decoder, true); + + decoder_client_data.eos = 0; + decoder_client_data.fin_file = fin_file; + decoder_client_data.fout_file = fout_file; + +#ifdef FLAC_DECODER_SINGLE_MODE + init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, /*eof_callback*/NULL, + write_callback, metadata_callback, error_callback, /*client_data=*/&decoder_client_data); +#else + init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, seek_callback, tell_callback, length_callback, eof_callback, + write_callback, metadata_callback, error_callback, /*client_data=*/&decoder_client_data); +#endif + if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); + ok = false; + } + if(ok) { +#ifdef FLAC_DECODER_SINGLE_MODE + while(!decoder_client_data.eos) { + clock_gettime(CLOCK_REALTIME, &tm_before); + if(!FLAC__stream_decoder_process_single(decoder)) + printf("ERROR: decoder single failed\n"); + clock_gettime(CLOCK_REALTIME, &tm_after); + printf("decoder state: %s, time_cost: %" PRIu64 "us\n", + FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)], + (tm_after.tv_sec - tm_before.tv_sec) * 1000000 + + (tm_after.tv_nsec - tm_before.tv_nsec) / 1000); + } +#else + ok = FLAC__stream_decoder_process_until_end_of_stream(decoder); + fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED"); + fprintf(stderr, " state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]); +#endif + } + + FLAC__stream_decoder_delete(decoder); + fclose(fout_file); + fclose(fin_file); + return 0; +} + +static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fin_file; + const size_t requested_bytes = *bytes; + + (void)decoder; + + if(0 == f) { + printf("ERROR: client_data in read callback is NULL\n"); + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } + + if(feof(f)) { + *bytes = 0; + ((StreamDecoderClientData*)client_data)->eos = 1; + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } else if(requested_bytes > 0) { + *bytes = fread(buffer, 1, requested_bytes, f); + if(*bytes == 0) { + if(feof(f)) { + ((StreamDecoderClientData*)client_data)->eos = 1; + printf("FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM\n"); + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } else { + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } + } else { + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } + } else { + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ + } +} + +#ifndef FLAC_DECODER_SINGLE_MODE +static FLAC__StreamDecoderSeekStatus seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fin_file; + + (void)decoder; + + if(0 == f) { + printf("ERROR: client_data in seek callback is NULL\n"); + return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; + } + + if(fseeko(f, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) { + return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; + } + + return FLAC__STREAM_DECODER_SEEK_STATUS_OK; +} + +static FLAC__StreamDecoderTellStatus tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fin_file; + FLAC__off_t offset; + + (void)decoder; + + if(0 == f) { + printf("ERROR: client_data in tell callback is NULL\n"); + return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + } + + + offset = ftello(f); + *absolute_byte_offset = (FLAC__uint64)offset; + + if(offset < 0) { + return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + } + + return FLAC__STREAM_DECODER_TELL_STATUS_OK; +} + + +static FLAC__StreamDecoderLengthStatus length_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fin_file; + + (void)decoder; + + if(0 == f) { + printf("ERROR: client_data in length callback is NULL\n"); + return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; + } + + *stream_length = (FLAC__uint64)flacfilesize; + return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; +} + +static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fin_file; + FLAC__bool eof; + (void)decoder; + + if(0 == f) { + printf("ERROR: client_data in eof callback is NULL\n"); + return true; + } + eof = feof(f); + if (eof) + ((StreamDecoderClientData*)client_data)->eos = 1; + return eof; +} +#endif + +FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) +{ + FILE *f = (FILE*)((StreamDecoderClientData*)client_data)->fout_file; + const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps/8)); + size_t i; + + (void)decoder; + + if(total_samples == 0) { + fprintf(stderr, "ERROR: this example only works for FLAC files that have a total_samples count in STREAMINFO\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if(channels != 2 || bps != 16) { + fprintf(stderr, "ERROR: this example only supports 16bit stereo streams\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if(frame->header.channels != 2) { + fprintf(stderr, "ERROR: This frame contains %u channels (should be 2)\n", frame->header.channels); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if(buffer[0] == NULL) { + fprintf(stderr, "ERROR: buffer [0] is NULL\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if(buffer[1] == NULL) { + fprintf(stderr, "ERROR: buffer [1] is NULL\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + + /* write WAVE header before we write the first frame */ + if(frame->header.number.sample_number == 0) { + if( + fwrite("RIFF", 1, 4, f) < 4 || + !write_little_endian_uint32(f, total_size + 36) || + fwrite("WAVEfmt ", 1, 8, f) < 8 || + !write_little_endian_uint32(f, 16) || + !write_little_endian_uint16(f, 1) || + !write_little_endian_uint16(f, (FLAC__uint16)channels) || + !write_little_endian_uint32(f, sample_rate) || + !write_little_endian_uint32(f, sample_rate * channels * (bps/8)) || + !write_little_endian_uint16(f, (FLAC__uint16)(channels * (bps/8))) || /* block align */ + !write_little_endian_uint16(f, (FLAC__uint16)bps) || + fwrite("data", 1, 4, f) < 4 || + !write_little_endian_uint32(f, total_size) + ) { + fprintf(stderr, "ERROR: write error\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + } + + /* write decoded PCM samples */ + for(i = 0; i < frame->header.blocksize; i++) { + if( + !write_little_endian_int16(f, (FLAC__int16)buffer[0][i]) || /* left channel */ + !write_little_endian_int16(f, (FLAC__int16)buffer[1][i]) /* right channel */ + ) { + fprintf(stderr, "ERROR: write error\n"); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + } + + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; +} + +void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +{ + (void)decoder, (void)client_data; + + /* print some stats */ + if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { + /* save for later */ + total_samples = metadata->data.stream_info.total_samples; + sample_rate = metadata->data.stream_info.sample_rate; + channels = metadata->data.stream_info.channels; + bps = metadata->data.stream_info.bits_per_sample; + + fprintf(stderr, "sample rate : %u Hz\n", sample_rate); + fprintf(stderr, "channels : %u\n", channels); + fprintf(stderr, "bits per sample: %u\n", bps); + fprintf(stderr, "total samples : %" PRIu64 "\n", total_samples); + } +} + +void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) +{ + (void)decoder, (void)client_data; + + fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]); +} + +MSH_CMD_EXPORT(flac_decoder_file_demo, flac decoder file test); +MSH_CMD_EXPORT(flac_decoder_stream_demo, flac decoder stream test); diff --git a/packages/third-party/littlefs/lfs.c b/packages/third-party/littlefs/lfs.c index 99024fb6..b0e3bf69 100644 --- a/packages/third-party/littlefs/lfs.c +++ b/packages/third-party/littlefs/lfs.c @@ -5266,6 +5266,19 @@ cleanup: #endif +#ifdef RT_DEBUG +static bool lfs_mlist_isopen(struct lfs_mlist *head, + struct lfs_mlist *node) +{ + for (struct lfs_mlist **p = &head; *p; p = &(*p)->next) { + if (*p == (struct lfs_mlist*)node) { + return true; + } + } + + return false; +} +#endif /// Public API wrappers /// diff --git a/packages/third-party/littlefs/lfs_config.h b/packages/third-party/littlefs/lfs_config.h index 94c1cc1b..5e41b44b 100644 --- a/packages/third-party/littlefs/lfs_config.h +++ b/packages/third-party/littlefs/lfs_config.h @@ -51,20 +51,8 @@ extern "C" #endif // Runtime assertions -#if !defined(LFS_NO_ASSERT) && defined(RT_DEBUG) +#ifndef LFS_NO_ASSERT #define LFS_ASSERT(test) RT_ASSERT(test) - -static bool lfs_mlist_isopen(struct lfs_mlist *head, - struct lfs_mlist *node) { - for (struct lfs_mlist **p = &head; *p; p = &(*p)->next) { - if (*p == (struct lfs_mlist*)node) { - return true; - } - } - - return false; -} - #else #define LFS_ASSERT(test) #endif diff --git a/packages/third-party/lwip/contrib/ports/drv/aic/aic_mac.h b/packages/third-party/lwip/contrib/ports/drv/aic/aic_mac.h index 245a5070..b5dd174b 100644 --- a/packages/third-party/lwip/contrib/ports/drv/aic/aic_mac.h +++ b/packages/third-party/lwip/contrib/ports/drv/aic/aic_mac.h @@ -152,7 +152,7 @@ typedef struct { /* 5 Ethernet driver receive buffers are used (in a chained linked list)*/ #ifndef ETH_RXBUFNB -#define ETH_RXBUFNB 16 /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_RXBUFNB 4 /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ #endif #ifndef ETH_TX_BUF_SIZE @@ -161,7 +161,7 @@ typedef struct { /* 5 ethernet driver transmit buffers are used (in a chained linked list)*/ #ifndef ETH_TXBUFNB -#define ETH_TXBUFNB 16 /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_TXBUFNB 4 /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ #endif #define AICMAC_PBUF_SIZE LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) diff --git a/packages/third-party/ota_downloader/src/http_ota.c b/packages/third-party/ota_downloader/src/http_ota.c index 0281cd37..e4ce98bf 100644 --- a/packages/third-party/ota_downloader/src/http_ota.c +++ b/packages/third-party/ota_downloader/src/http_ota.c @@ -19,7 +19,7 @@ #include "webclient.h" #include #include -#include +#include #ifdef LPKG_USING_HTTP_OTA diff --git a/packages/third-party/protobuf-c/examples/amessage_decode_from_file.c b/packages/third-party/protobuf-c/examples/amessage_decode_from_file.c index 1718d20d..457f8a96 100644 --- a/packages/third-party/protobuf-c/examples/amessage_decode_from_file.c +++ b/packages/third-party/protobuf-c/examples/amessage_decode_from_file.c @@ -1,7 +1,8 @@ #include #include #include -#include +#include +#include #include "amessage.pb-c.h" diff --git a/packages/third-party/protobuf-c/examples/amessage_encode_to_file.c b/packages/third-party/protobuf-c/examples/amessage_encode_to_file.c index 2d7fb078..2c7289d4 100644 --- a/packages/third-party/protobuf-c/examples/amessage_encode_to_file.c +++ b/packages/third-party/protobuf-c/examples/amessage_encode_to_file.c @@ -1,7 +1,8 @@ #include #include #include -#include +#include +#include #include "amessage.pb-c.h" @@ -24,7 +25,7 @@ static void protobuf_encode_to_file(int argc, char *argv[]) encode_msg.has_a = 1; encode_msg.a = atoi(argv[1]); encode_msg.has_b = 1; - encode_msg.b = atoi(argv[2]); + encode_msg.b = atoi(argv[2]); msg_len = amessage__get_packed_size(&encode_msg); buffer = malloc(msg_len); diff --git a/target/configs/d12x_demo68-nand_baremetal_bootloader_defconfig b/target/configs/d12x_demo68-nand_baremetal_bootloader_defconfig index f6feae75..b331dcb0 100644 --- a/target/configs/d12x_demo68-nand_baremetal_bootloader_defconfig +++ b/target/configs/d12x_demo68-nand_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -145,6 +147,7 @@ CONFIG_AIC_UART1_FLAG=259 CONFIG_AIC_DEV_UART1_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART1_RX_MODE_INT is not set CONFIG_AIC_DEV_UART1_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_PWM0 is not set @@ -294,6 +297,11 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=100 +CONFIG_AIC_SCREEN_CROP_WIDTH=480 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_MDI is not set @@ -390,9 +398,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x180000 # @@ -421,6 +428,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y # CONFIG_AICUPG_USB_ENABLE is not set CONFIG_AICUPG_SDCARD_ENABLE=y @@ -500,6 +508,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d12x_demo68-nand_rt-thread_helloworld_defconfig b/target/configs/d12x_demo68-nand_rt-thread_helloworld_defconfig index 30b36bec..a2a9401b 100644 --- a/target/configs/d12x_demo68-nand_rt-thread_helloworld_defconfig +++ b/target/configs/d12x_demo68-nand_rt-thread_helloworld_defconfig @@ -54,10 +54,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -69,6 +67,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=8 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -82,6 +81,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -340,6 +341,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -1307,6 +1309,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1328,6 +1331,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1344,6 +1348,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1388,6 +1393,7 @@ CONFIG_AIC_NFLT_USED_LIB=y CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set diff --git a/target/configs/d12x_demo68-nor_baremetal_bootloader_defconfig b/target/configs/d12x_demo68-nor_baremetal_bootloader_defconfig index 0904521d..cf3609bd 100644 --- a/target/configs/d12x_demo68-nor_baremetal_bootloader_defconfig +++ b/target/configs/d12x_demo68-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -145,6 +147,7 @@ CONFIG_AIC_UART1_FLAG=259 CONFIG_AIC_DEV_UART1_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART1_RX_MODE_INT is not set CONFIG_AIC_DEV_UART1_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_PWM0 is not set @@ -290,6 +293,11 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=100 +CONFIG_AIC_SCREEN_CROP_WIDTH=480 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_MDI is not set @@ -386,9 +394,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0xC0000 # @@ -417,6 +424,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY=y +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y # CONFIG_AICUPG_USB_ENABLE is not set CONFIG_AICUPG_SDCARD_ENABLE=y @@ -497,6 +505,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d12x_demo68-nor_rt-thread_helloworld_defconfig b/target/configs/d12x_demo68-nor_rt-thread_helloworld_defconfig index 607ba485..7347594a 100644 --- a/target/configs/d12x_demo68-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d12x_demo68-nor_rt-thread_helloworld_defconfig @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -77,6 +75,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=8 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -90,6 +89,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -212,8 +213,7 @@ CONFIG_AIC_USING_I2C0=y # # CONFIG_AIC_DEV_I2C0_ADDR_BIT is not set CONFIG_AIC_DEV_I2C0_10BIT=0 -# CONFIG_AIC_DEV_I2C0_SPEED is not set -CONFIG_AIC_DEV_I2C0_100K_SPEED=0 +CONFIG_AIC_DEV_I2C0_SPEED=400000 # CONFIG_AIC_DEV_I2C0_BUS_MODE is not set CONFIG_AIC_DEV_I2C0_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -376,6 +376,7 @@ CONFIG_AIC_SIMPLE_PANEL=y # CONFIG_AIC_PANEL_RGB_NT35560 is not set # CONFIG_AIC_PANEL_RGB_ST77922 is not set # CONFIG_AIC_PANEL_SRGB_HX8238 is not set +# CONFIG_AIC_PANEL_LCOS_HX7033 is not set # # display timing of simple panel @@ -393,6 +394,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -1393,6 +1395,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1414,6 +1417,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1430,6 +1434,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set CONFIG_LPKG_USING_USERID=y @@ -1457,9 +1462,11 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set diff --git a/target/configs/d12x_hmi-nor_baremetal_bootloader_defconfig b/target/configs/d12x_hmi-nor_baremetal_bootloader_defconfig index 65e8bfa3..a9990f38 100644 --- a/target/configs/d12x_hmi-nor_baremetal_bootloader_defconfig +++ b/target/configs/d12x_hmi-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -75,6 +77,7 @@ CONFIG_AIC_DISP_RGB_DRV_V12=y # CONFIG_AIC_TSEN_DRV is not set # CONFIG_AIC_GPAI_DRV is not set # CONFIG_AIC_PWM_DRV is not set +# CONFIG_AIC_HRTIMER_DRV is not set CONFIG_AIC_SID_DRV=y CONFIG_AIC_SID_DRV_V12=y CONFIG_AIC_SID_DRV_VER="12" @@ -102,20 +105,20 @@ CONFIG_AIC_USING_UART1=y # CONFIG_AIC_USING_UART3 is not set # -# Uart0 Parameter +# UART0 Parameter # CONFIG_AIC_CLK_UART0_FREQ=53454545 CONFIG_AIC_DEV_UART0_BAUDRATE=115200 CONFIG_AIC_DEV_UART0_DATABITS=8 CONFIG_AIC_DEV_UART0_STOPBITS=1 CONFIG_AIC_DEV_UART0_PARITY=0 +CONFIG_AIC_DEV_UART0_RS232=y +# CONFIG_AIC_DEV_UART0_RS485 is not set CONFIG_AIC_DEV_UART0_MODE_RS232=y # CONFIG_AIC_DEV_UART0_MODE_RS232_AUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485 is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485_COMPACT_IO is not set CONFIG_AIC_DEV_UART0_MODE=0 # CONFIG_AIC_UART0_DMA_ENABLE_FLAG is not set CONFIG_AIC_UART0_FLAG=259 @@ -124,32 +127,37 @@ CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y CONFIG_AIC_DEV_UART0_RX_MODE=0 # -# Uart1 Parameter +# UART1 Parameter # CONFIG_AIC_CLK_UART1_FREQ=53454545 CONFIG_AIC_DEV_UART1_BAUDRATE=115200 CONFIG_AIC_DEV_UART1_DATABITS=8 CONFIG_AIC_DEV_UART1_STOPBITS=1 CONFIG_AIC_DEV_UART1_PARITY=0 +CONFIG_AIC_DEV_UART1_RS232=y +# CONFIG_AIC_DEV_UART1_RS485 is not set CONFIG_AIC_DEV_UART1_MODE_RS232=y # CONFIG_AIC_DEV_UART1_MODE_RS232_AUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART1_MODE_RS232_UNAUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART1_MODE_RS232_SW_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART1_MODE_RS232_SW_HW_FLOW_CTRL is not set -# CONFIG_AIC_DEV_UART1_MODE_RS485 is not set -# CONFIG_AIC_DEV_UART1_MODE_RS485_COMPACT_IO is not set CONFIG_AIC_DEV_UART1_MODE=0 # CONFIG_AIC_UART1_DMA_ENABLE_FLAG is not set CONFIG_AIC_UART1_FLAG=259 CONFIG_AIC_DEV_UART1_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART1_RX_MODE_INT is not set CONFIG_AIC_DEV_UART1_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_PWM0 is not set # CONFIG_AIC_USING_PWM1 is not set -# CONFIG_AIC_USING_PWM2 is not set -# CONFIG_AIC_USING_PWM3 is not set + +# +# Using HRTIMER +# +# CONFIG_AIC_USING_HRTIMER0 is not set +# CONFIG_AIC_USING_HRTIMER1 is not set # CONFIG_AIC_USING_CAN0 is not set # CONFIG_AIC_USING_CAN1 is not set # CONFIG_AIC_USING_CIR is not set @@ -253,7 +261,6 @@ CONFIG_AICFB_RGB565=y CONFIG_AICFB_FORMAT=0x0e # CONFIG_AIC_PAN_DISPLAY is not set # CONFIG_AIC_DISP_COLOR_BLOCK is not set -# CONFIG_AIC_DISPLAY_DITHER is not set CONFIG_AICFB_ROTATE_0=y # CONFIG_AICFB_ROTATE_90 is not set # CONFIG_AICFB_ROTATE_180 is not set @@ -265,6 +272,9 @@ CONFIG_AIC_FB_ROTATE_DEGREE=0 # CONFIG_AIC_SIMPLE_PANEL=y # CONFIG_AIC_PANEL_RGB_ST7701S is not set +# CONFIG_AIC_PANEL_RGB_GC9A01A is not set +# CONFIG_AIC_PANEL_RGB_NT35560 is not set +# CONFIG_AIC_PANEL_RGB_ST77922 is not set # CONFIG_AIC_PANEL_SRGB_HX8238 is not set # @@ -283,10 +293,16 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=100 +CONFIG_AIC_SCREEN_CROP_WIDTH=480 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_MDI is not set # CONFIG_AIC_USING_AUDIO is not set +# CONFIG_AIC_USING_TOUCH is not set # # System Related: @@ -315,6 +331,12 @@ CONFIG_AIC_PSRAM_SW_SIZE=0x300000 # CONFIG_AIC_XIP is not set CONFIG_AIC_INTERRUPTSTACK_SIZE=4096 +# +# Support another Flash +# +CONFIG_AIC_FLASH_NUM_ONE=y +# CONFIG_AIC_FLASH_NUM_TWO is not set + # # Clocks options # @@ -372,9 +394,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0xC0000 # @@ -402,6 +423,8 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # # Upgrading # +# CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y # CONFIG_AICUPG_USB_ENABLE is not set CONFIG_AICUPG_SDCARD_ENABLE=y @@ -424,6 +447,7 @@ CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR=y +CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE=0 CONFIG_AIC_BOOTLOADER_CMD_FB_CONSOLE=y # CONFIG_AIC_BOOTLOADER_CMD_ONLY_FB_CONSOLE is not set # CONFIG_AIC_BOOTLOADER_CMD_PSRAM_TEST is not set @@ -465,18 +489,26 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_BEEP is not set # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set -# CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set # CONFIG_LPKG_USING_LIBMODBUS is not set # CONFIG_LPKG_USING_PTPD is not set +# CONFIG_LPKG_USING_CJSON is not set +# CONFIG_LPKG_USING_MBEDTLS is not set +# CONFIG_LPKG_USING_AT24CXX is not set +# CONFIG_LPKG_USING_ZLIB is not set +# CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set +# CONFIG_LPKG_USING_MICROPYTHON is not set # # ArtInChip packages options @@ -484,7 +516,11 @@ CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_MPP is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set +# CONFIG_LPKG_USING_USERID is not set # CONFIG_LPKG_USING_PINMUX_CHECHK is not set +# CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_BURN_IN is not set +# CONFIG_AIC_USING_IPMANAGER is not set # # Drivers options @@ -502,6 +538,7 @@ CONFIG_AIC_USING_UMM_HEAP=y CONFIG_AIC_UMM_HEAP_BARE_DRV=y # CONFIG_TLSF_MEM_HEAP is not set # CONFIG_AIC_GPIO_IRQ_DRV_EN is not set +# CONFIG_AIC_I2C_INTERRUPT_MODE is not set CONFIG_AIC_SPINOR_DRV=y # CONFIG_AIC_SPINAND_DRV is not set # CONFIG_AIC_SPINAND_CONT_READ is not set @@ -513,30 +550,7 @@ CONFIG_AIC_SPINOR_DRV=y CONFIG_LPKG_USING_SFUD=y CONFIG_BOOTLOADER_SFUD_USING_FLASH_INFO_TABLE=y # CONFIG_AIC_NFTL_SUPPORT is not set - -# -# Touch Panel Support -# - -# -# Gt911 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GT911 is not set - -# -# Ft7411 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_FT7411 is not set - -# -# GSL1680 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GSL1680 is not set - -# -# RTP touch panel options -# -# CONFIG_AIC_USING_RTP is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support @@ -558,6 +572,7 @@ CONFIG_AIC_LOG_LEVEL=4 # CONFIG_AIC_UART_DRV_DEBUG is not set # CONFIG_AIC_QSPI_DRV_DEBUG is not set # CONFIG_AIC_SPINOR_SFUD_DEBUG is not set +CONFIG_AIC_SPINOR_SFUD_WP_DEBUG=y # CONFIG_AIC_FB_DRV_DEBUG is not set # CONFIG_AIC_CACHE_LINE_DEBUG is not set @@ -566,16 +581,22 @@ CONFIG_AIC_LOG_LEVEL=4 # # CONFIG_AIC_CMU_DRV_TEST is not set # CONFIG_AIC_GPIO_DRV_TEST is not set +# CONFIG_AIC_GPIO_TWINKLE_TEST is not set +# CONFIG_AIC_GPIO_KEY_TEST is not set # CONFIG_AIC_DMA_DRV_TEST is not set # CONFIG_AIC_UART_DRV_TEST is not set # CONFIG_AIC_QSPI_DRV_TEST is not set CONFIG_AIC_SPINOR_DRV_TEST=y CONFIG_AIC_SDMC_DRV_TEST=y +# CONFIG_AIC_MMC_BARE_TEST is not set CONFIG_AIC_MTD_BARE_TEST=y # CONFIG_AIC_FILE_CRC32_TEST is not set # CONFIG_AIC_MTD_LOAD_FILE_TEST is not set # CONFIG_AIC_DISPLAY_TEST is not set # CONFIG_AIC_WDT_DRV_TEST is not set # CONFIG_AIC_MONKEY_TEST is not set +# CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_SID_BARE_TEST is not set # CONFIG_AIC_IOPMP_TEST is not set +# CONFIG_AIC_MEM_API_TEST is not set +# CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d12x_hmi-nor_rt-thread_helloworld_defconfig b/target/configs/d12x_hmi-nor_rt-thread_helloworld_defconfig index b3496c1f..d3006a6e 100644 --- a/target/configs/d12x_hmi-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d12x_hmi-nor_rt-thread_helloworld_defconfig @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -77,6 +75,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=2 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -90,6 +89,8 @@ CONFIG_AIC_CHIP_D12X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V12=y CONFIG_AIC_CMU_DRV_VER="12" @@ -139,6 +140,7 @@ CONFIG_AIC_GE_DRV_VER="11" CONFIG_AIC_VE_DRV=y CONFIG_AIC_VE_DRV_V40=y CONFIG_AIC_VE_DRV_VER="40" +# CONFIG_AIC_MDI_DRV is not set # CONFIG_AIC_ADCIM_DRV is not set # CONFIG_AIC_RTP_DRV is not set # CONFIG_AIC_TSEN_DRV is not set @@ -223,8 +225,7 @@ CONFIG_AIC_USING_I2C0=y # # CONFIG_AIC_DEV_I2C0_ADDR_BIT is not set CONFIG_AIC_DEV_I2C0_10BIT=0 -# CONFIG_AIC_DEV_I2C0_SPEED is not set -CONFIG_AIC_DEV_I2C0_100K_SPEED=0 +CONFIG_AIC_DEV_I2C0_SPEED=400000 # CONFIG_AIC_DEV_I2C0_BUS_MODE is not set CONFIG_AIC_DEV_I2C0_SLAVE_MODE=0 CONFIG_AIC_USING_PWM0=y @@ -338,15 +339,11 @@ CONFIG_AICFB_RGB565=y CONFIG_AICFB_FORMAT=0x0e CONFIG_AIC_PAN_DISPLAY=y # CONFIG_AIC_DISP_COLOR_BLOCK is not set -CONFIG_AIC_DISPLAY_DITHER=y CONFIG_AICFB_ROTATE_0=y # CONFIG_AICFB_ROTATE_90 is not set # CONFIG_AICFB_ROTATE_180 is not set # CONFIG_AICFB_ROTATE_270 is not set CONFIG_AIC_FB_ROTATE_DEGREE=0 -CONFIG_AIC_OUTPUT_DEPTH_16=y -# CONFIG_AIC_OUTPUT_DEPTH_18 is not set -CONFIG_AIC_DISP_OUTPUT_DEPTH=1 # # Display Panels @@ -357,6 +354,7 @@ CONFIG_AIC_SIMPLE_PANEL=y # CONFIG_AIC_PANEL_RGB_NT35560 is not set # CONFIG_AIC_PANEL_RGB_ST77922 is not set # CONFIG_AIC_PANEL_SRGB_HX8238 is not set +# CONFIG_AIC_PANEL_LCOS_HX7033 is not set # # display timing of simple panel @@ -375,6 +373,7 @@ CONFIG_AIC_PWM_BACKLIGHT=y CONFIG_AIC_PWM_BACKLIGHT_CHANNEL=0 CONFIG_AIC_PWM_BRIGHTNESS_LEVEL=80 # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -386,6 +385,7 @@ CONFIG_AIC_GE_DITHER=y CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y +# CONFIG_AIC_USING_MDI is not set CONFIG_AIC_USING_AUDIO=y # @@ -1381,6 +1381,9 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1402,6 +1405,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1418,6 +1422,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1442,9 +1447,11 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1514,5 +1521,6 @@ CONFIG_AIC_WDT_DRV_TEST=y # CONFIG_AIC_PWM_TEST is not set # CONFIG_AIC_MONKEY_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set # CONFIG_AIC_MEM_API_TEST is not set # CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d13x_demo68-nor_baremetal_bootloader_defconfig b/target/configs/d13x_demo68-nor_baremetal_bootloader_defconfig index 69c33ebc..b06e4f6c 100644 --- a/target/configs/d13x_demo68-nor_baremetal_bootloader_defconfig +++ b/target/configs/d13x_demo68-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -99,7 +101,7 @@ CONFIG_AIC_SID_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y CONFIG_AIC_USING_UART1=y @@ -153,6 +155,7 @@ CONFIG_AIC_UART1_FLAG=259 CONFIG_AIC_DEV_UART1_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART1_RX_MODE_INT is not set CONFIG_AIC_DEV_UART1_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -204,7 +207,7 @@ CONFIG_AIC_DEV_UART1_RX_MODE=0 # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -247,13 +250,13 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_WLAN_ASR is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -318,20 +321,20 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=260 +CONFIG_AIC_SCREEN_CROP_WIDTH=1024 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y CONFIG_AIC_USING_WRI=y @@ -416,7 +419,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -458,9 +461,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0xC0000 # @@ -496,6 +498,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -579,6 +582,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d13x_demo68-nor_rt-thread_helloworld_defconfig b/target/configs/d13x_demo68-nor_rt-thread_helloworld_defconfig index f7423993..c6b17135 100644 --- a/target/configs/d13x_demo68-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d13x_demo68-nor_rt-thread_helloworld_defconfig @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -77,6 +75,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=8 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -90,6 +89,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -186,7 +187,7 @@ CONFIG_AIC_PSADC_CH_NUM=16 # # -# Interface Related: +# Interface Related: # # CONFIG_AIC_USING_UART0 is not set CONFIG_AIC_USING_UART1=y @@ -224,8 +225,7 @@ CONFIG_AIC_USING_I2C2=y # # CONFIG_AIC_DEV_I2C2_ADDR_BIT is not set CONFIG_AIC_DEV_I2C2_10BIT=0 -# CONFIG_AIC_DEV_I2C2_SPEED is not set -CONFIG_AIC_DEV_I2C2_100K_SPEED=0 +CONFIG_AIC_DEV_I2C2_SPEED=400000 # CONFIG_AIC_DEV_I2C2_BUS_MODE is not set CONFIG_AIC_DEV_I2C2_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -276,7 +276,7 @@ CONFIG_AIC_USING_CAN0=y # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -316,7 +316,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # CONFIG_AIC_USING_TSEN=y @@ -367,7 +367,7 @@ CONFIG_AIC_GPAI7_PERIOD_TIME=18000 CONFIG_AIC_GPAI7_ADC_ACQ=0x2f # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -432,6 +432,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -444,11 +445,6 @@ CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -467,10 +463,10 @@ CONFIG_AIC_AUDIO_DMIC=y CONFIG_AIC_USING_TOUCH=y # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -551,7 +547,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1509,6 +1505,9 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1530,6 +1529,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1546,6 +1546,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1569,9 +1570,11 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1648,5 +1651,6 @@ CONFIG_AIC_PSADC_TEST=y # CONFIG_AIC_MONKEY_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set # CONFIG_AIC_MEM_API_TEST is not set # CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d13x_demo88-nand_baremetal_bootloader_defconfig b/target/configs/d13x_demo88-nand_baremetal_bootloader_defconfig index 6743427c..3d25cc98 100644 --- a/target/configs/d13x_demo88-nand_baremetal_bootloader_defconfig +++ b/target/configs/d13x_demo88-nand_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -99,7 +101,7 @@ CONFIG_AIC_SID_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -131,6 +133,7 @@ CONFIG_AIC_UART0_FLAG=259 CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -182,7 +185,7 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -226,13 +229,13 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_WLAN_ASR is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -268,7 +271,7 @@ CONFIG_AICFB_RGB565=y # CONFIG_AICFB_ARGB1555 is not set CONFIG_AICFB_FORMAT=0x0e # CONFIG_AIC_PAN_DISPLAY is not set -CONFIG_AIC_DISP_COLOR_BLOCK=y +# CONFIG_AIC_DISP_COLOR_BLOCK is not set CONFIG_AICFB_ROTATE_0=y # CONFIG_AICFB_ROTATE_90 is not set # CONFIG_AICFB_ROTATE_180 is not set @@ -297,20 +300,20 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=260 +CONFIG_AIC_SCREEN_CROP_WIDTH=1024 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y CONFIG_AIC_USING_WRI=y @@ -395,7 +398,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -436,9 +439,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40480000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x380000 # @@ -474,6 +476,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -556,6 +559,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d13x_demo88-nand_rt-thread_helloworld_defconfig b/target/configs/d13x_demo88-nand_rt-thread_helloworld_defconfig index 32c2364e..cdd07e70 100644 --- a/target/configs/d13x_demo88-nand_rt-thread_helloworld_defconfig +++ b/target/configs/d13x_demo88-nand_rt-thread_helloworld_defconfig @@ -63,10 +63,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -92,6 +90,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -120,7 +120,9 @@ CONFIG_AIC_QSPI_DRV_VER="11" CONFIG_AIC_XSPI_DRV=y CONFIG_AIC_XSPI_DRV_V10=y # CONFIG_AIC_AXICFG_DRV is not set -# CONFIG_AIC_WRI_DRV is not set +CONFIG_AIC_WRI_DRV=y +CONFIG_AIC_WRI_DRV_V11=y +CONFIG_AIC_WRI_DRV_VER="11" CONFIG_AIC_RTC_DRV=y CONFIG_AIC_RTC_DRV_V11=y CONFIG_AIC_RTC_DRV_VER="11" @@ -171,7 +173,7 @@ CONFIG_AIC_AUDIO_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -258,13 +260,9 @@ CONFIG_AIC_DEV_I2C2_SLAVE_MODE=0 # CONFIG_AIC_USB_OTG_DRV is not set # CONFIG_AIC_USING_USB0 is not set # CONFIG_AIC_USING_GMAC0 is not set -# CONFIG_AIC_DEV_GMAC0_RMII is not set -# CONFIG_AIC_DEV_GMAC0_RGMII is not set -# CONFIG_AIC_DEV_GMAC0_PHY_EXTCLK is not set -# CONFIG_AIC_DEV_GMAC0_PHY_INTCLK is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -305,13 +303,13 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -376,6 +374,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -388,11 +387,6 @@ CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -411,10 +405,10 @@ CONFIG_AIC_AUDIO_DMIC=y CONFIG_AIC_USING_TOUCH=y # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -495,7 +489,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1468,6 +1462,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y CONFIG_LPKG_USING_GIF=y # CONFIG_GIF_COLOR_FORMAT_ARGB8888 is not set diff --git a/target/configs/d13x_demo88-nor_baremetal_bootloader_defconfig b/target/configs/d13x_demo88-nor_baremetal_bootloader_defconfig index 30a43d71..ce435e69 100644 --- a/target/configs/d13x_demo88-nor_baremetal_bootloader_defconfig +++ b/target/configs/d13x_demo88-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -99,7 +101,7 @@ CONFIG_AIC_SID_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -131,6 +133,7 @@ CONFIG_AIC_UART0_FLAG=259 CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -182,7 +185,7 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -225,13 +228,13 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_WLAN_ASR is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -296,20 +299,20 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=260 +CONFIG_AIC_SCREEN_CROP_WIDTH=1024 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y CONFIG_AIC_USING_WRI=y @@ -394,7 +397,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -435,9 +438,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0xC0000 # @@ -473,6 +475,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -556,6 +559,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d13x_demo88-nor_rt-thread_helloworld_defconfig b/target/configs/d13x_demo88-nor_rt-thread_helloworld_defconfig index ce0a44f1..92ffe0fe 100644 --- a/target/configs/d13x_demo88-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d13x_demo88-nor_rt-thread_helloworld_defconfig @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -77,6 +75,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=8 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -90,6 +89,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -186,7 +187,7 @@ CONFIG_AIC_PSADC_CH_NUM=16 # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -224,8 +225,7 @@ CONFIG_AIC_USING_I2C2=y # # CONFIG_AIC_DEV_I2C2_ADDR_BIT is not set CONFIG_AIC_DEV_I2C2_10BIT=0 -# CONFIG_AIC_DEV_I2C2_SPEED is not set -CONFIG_AIC_DEV_I2C2_100K_SPEED=0 +CONFIG_AIC_DEV_I2C2_SPEED=400000 # CONFIG_AIC_DEV_I2C2_BUS_MODE is not set CONFIG_AIC_DEV_I2C2_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -276,7 +276,7 @@ CONFIG_AIC_USING_CAN0=y # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -316,7 +316,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # CONFIG_AIC_USING_TSEN=y @@ -367,7 +367,7 @@ CONFIG_AIC_GPAI7_PERIOD_TIME=18000 CONFIG_AIC_GPAI7_ADC_ACQ=0x2f # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -432,6 +432,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -444,11 +445,6 @@ CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -467,10 +463,10 @@ CONFIG_AIC_AUDIO_DMIC=y CONFIG_AIC_USING_TOUCH=y # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -551,7 +547,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1508,6 +1504,9 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1529,6 +1528,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1545,6 +1545,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1568,9 +1569,11 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1647,5 +1650,6 @@ CONFIG_AIC_PSADC_TEST=y # CONFIG_AIC_MONKEY_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set # CONFIG_AIC_MEM_API_TEST is not set # CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d13x_kunlunpi88-nor_baremetal_bootloader_defconfig b/target/configs/d13x_kunlunpi88-nor_baremetal_bootloader_defconfig index bed252ee..b8242d0b 100644 --- a/target/configs/d13x_kunlunpi88-nor_baremetal_bootloader_defconfig +++ b/target/configs/d13x_kunlunpi88-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -132,6 +134,7 @@ CONFIG_AIC_UART0_FLAG=259 CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -325,14 +328,14 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=100 +CONFIG_AIC_SCREEN_CROP_WIDTH=480 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set @@ -464,9 +467,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x40300100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x40340000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0xC0000 # @@ -502,6 +504,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -585,6 +588,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d13x_kunlunpi88-nor_rt-thread_helloworld_defconfig b/target/configs/d13x_kunlunpi88-nor_rt-thread_helloworld_defconfig index e14f74e3..92f20a37 100644 --- a/target/configs/d13x_kunlunpi88-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d13x_kunlunpi88-nor_rt-thread_helloworld_defconfig @@ -55,10 +55,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -70,6 +68,8 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=16 CONFIG_LV_CACHE_IMG_NUM=4 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set +# CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" # @@ -82,6 +82,8 @@ CONFIG_AIC_CHIP_D13X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -169,7 +171,7 @@ CONFIG_AIC_AUDIO_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y CONFIG_AIC_USING_UART1=y @@ -245,8 +247,7 @@ CONFIG_AIC_USING_I2C2=y # # CONFIG_AIC_DEV_I2C0_ADDR_BIT is not set CONFIG_AIC_DEV_I2C0_10BIT=0 -# CONFIG_AIC_DEV_I2C0_SPEED is not set -CONFIG_AIC_DEV_I2C0_100K_SPEED=0 +CONFIG_AIC_DEV_I2C0_SPEED=400000 # CONFIG_AIC_DEV_I2C0_BUS_MODE is not set CONFIG_AIC_DEV_I2C0_SLAVE_MODE=0 @@ -255,8 +256,7 @@ CONFIG_AIC_DEV_I2C0_SLAVE_MODE=0 # # CONFIG_AIC_DEV_I2C2_ADDR_BIT is not set CONFIG_AIC_DEV_I2C2_10BIT=0 -# CONFIG_AIC_DEV_I2C2_SPEED is not set -CONFIG_AIC_DEV_I2C2_100K_SPEED=0 +CONFIG_AIC_DEV_I2C2_SPEED=400000 # CONFIG_AIC_DEV_I2C2_BUS_MODE is not set CONFIG_AIC_DEV_I2C2_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -307,7 +307,7 @@ CONFIG_AIC_USING_PWM2=y # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -347,13 +347,13 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # CONFIG_AIC_USING_DE=y @@ -409,7 +409,6 @@ CONFIG_AICFB_RGB565=y CONFIG_AICFB_FORMAT=0x0e CONFIG_AIC_PAN_DISPLAY=y CONFIG_AIC_DISP_COLOR_BLOCK=y -# CONFIG_AIC_DISPLAY_DITHER is not set CONFIG_AICFB_ROTATE_0=y # CONFIG_AICFB_ROTATE_90 is not set # CONFIG_AICFB_ROTATE_180 is not set @@ -425,6 +424,7 @@ CONFIG_AIC_SIMPLE_PANEL=y # CONFIG_AIC_PANEL_RGB_NT35560 is not set # CONFIG_AIC_PANEL_RGB_ST77922 is not set # CONFIG_AIC_PANEL_SRGB_HX8238 is not set +# CONFIG_AIC_PANEL_LCOS_HX7033 is not set # # display timing of simple panel @@ -443,6 +443,7 @@ CONFIG_AIC_PWM_BACKLIGHT=y CONFIG_AIC_PWM_BACKLIGHT_CHANNEL=2 CONFIG_AIC_PWM_BRIGHTNESS_LEVEL=80 # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -455,20 +456,6 @@ CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y CONFIG_AIC_USING_DVP=y - -# -# Camera Support -# -CONFIG_AIC_USING_CAMERA=y -# CONFIG_AIC_USING_CAMERA_OV7670 is not set -CONFIG_AIC_USING_CAMERA_OV5640=y -# CONFIG_AIC_USING_CAMERA_OV2659 is not set -# CONFIG_AIC_USING_CAMERA_OV2640 is not set -# CONFIG_AIC_USING_CAMERA_GM7150 is not set -# CONFIG_AIC_USING_CAMERA_TP2825 is not set -CONFIG_AIC_CAMERA_I2C_CHAN=0 -CONFIG_AIC_CAMERA_RST_PIN="PA.2" -CONFIG_AIC_CAMERA_PWDN_PIN="PA.3" # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -487,10 +474,10 @@ CONFIG_AIC_AUDIO_SPK_1=y CONFIG_AIC_USING_TOUCH=y # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -572,7 +559,7 @@ CONFIG_AIC_CLK_OUT1_FREQ=25000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1511,8 +1498,10 @@ CONFIG_LPKG_I2C_TOOLS_PATH="/packages/peripherals/i2c-tools" # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set CONFIG_LPKG_USING_FREETYPE=y # CONFIG_LPKG_USING_FREETYPE_STATIC is not set +# CONFIG_TT_DISABLE_LOAD_HDMX is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set # CONFIG_LPKG_USING_LIBMODBUS is not set @@ -1533,6 +1522,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1549,6 +1539,7 @@ CONFIG_AIC_MPP_VIN=y CONFIG_AIC_MPP_VIN_BUF_SIZE=1843264 # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1573,9 +1564,24 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set +CONFIG_AIC_USING_CAMERA=y +# CONFIG_AIC_USING_CAMERA_OV7670 is not set +CONFIG_AIC_USING_CAMERA_OV5640=y +# CONFIG_AIC_USING_CAMERA_OV2659 is not set +# CONFIG_AIC_USING_CAMERA_OV2640 is not set +# CONFIG_AIC_USING_CAMERA_GC0308 is not set +# CONFIG_AIC_USING_CAMERA_GC032A is not set +# CONFIG_AIC_USING_CAMERA_GM7150 is not set +# CONFIG_AIC_USING_CAMERA_SC030IOT is not set +# CONFIG_AIC_USING_CAMERA_TP2825 is not set +CONFIG_AIC_CAMERA_I2C_CHAN=0 +CONFIG_AIC_CAMERA_RST_PIN="PA.2" +CONFIG_AIC_CAMERA_PWDN_PIN="PA.3" CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1639,7 +1645,9 @@ CONFIG_AIC_UART_DRV_TEST=y # CONFIG_AIC_VE_TEST is not set CONFIG_AIC_AUDIO_DRV_TEST=y # CONFIG_AIC_I2C_DRV_TEST is not set +# CONFIG_AIC_CAMERA_DRV_TEST is not set CONFIG_AIC_DVP_TEST=y +# CONFIG_AIC_TP_DRV_TEST is not set # CONFIG_AIC_WDT_DRV_TEST is not set # CONFIG_AIC_ZLIB_TEST is not set # CONFIG_AIC_PWM_TEST is not set diff --git a/target/configs/d21x_d215-demo88-nand_baremetal_bootloader_defconfig b/target/configs/d21x_d215-demo88-nand_baremetal_bootloader_defconfig index cb9f1d32..29b8cd6c 100644 --- a/target/configs/d21x_d215-demo88-nand_baremetal_bootloader_defconfig +++ b/target/configs/d21x_d215-demo88-nand_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -105,20 +107,20 @@ CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART7 is not set # -# Uart0 Parameter +# UART0 Parameter # CONFIG_AIC_CLK_UART0_FREQ=48000000 CONFIG_AIC_DEV_UART0_BAUDRATE=115200 CONFIG_AIC_DEV_UART0_DATABITS=8 CONFIG_AIC_DEV_UART0_STOPBITS=1 CONFIG_AIC_DEV_UART0_PARITY=0 +CONFIG_AIC_DEV_UART0_RS232=y +# CONFIG_AIC_DEV_UART0_RS485 is not set CONFIG_AIC_DEV_UART0_MODE_RS232=y # CONFIG_AIC_DEV_UART0_MODE_RS232_AUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485 is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485_COMPACT_IO is not set CONFIG_AIC_DEV_UART0_MODE=0 # CONFIG_AIC_UART0_DMA_ENABLE_FLAG is not set CONFIG_AIC_UART0_FLAG=259 @@ -166,9 +168,11 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_CAN0 is not set # CONFIG_AIC_USING_CAN1 is not set # CONFIG_AIC_USING_CIR is not set +# CONFIG_AIC_USB_OTG_DRV is not set # CONFIG_AIC_USING_USB0 is not set # CONFIG_AIC_USING_USB1 is not set # CONFIG_AIC_USING_GMAC0 is not set +# CONFIG_AIC_USING_GMAC1 is not set # # Storage Related: @@ -213,6 +217,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_WLAN_REALTEK is not set # CONFIG_WIFI_USING_SDIOWIFI_ATBM is not set +# CONFIG_AIC_WLAN_ASR is not set # # Analog Related: @@ -227,20 +232,16 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set +# CONFIG_AIC_USING_TOUCH is not set # # System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -309,9 +310,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 # @@ -339,13 +339,15 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # # Upgrading # +# CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set CONFIG_AICUPG_SDCARD_ENABLE=y CONFIG_AICUPG_SDCARD_CONTROLLER_ID=1 CONFIG_AICUPG_UDISK_ENABLE=y -# CONFIG_AICUPG_UDISK_VERSION3_SUPPORT is not set +CONFIG_AICUPG_UDISK_CHECK_TIMEOUT=1000 CONFIG_AICUPG_USB_CONTROLLER_MAX_NUM=1 CONFIG_AICUPG_MMC_ARTINCHIP=y CONFIG_AICUPG_NAND_ARTINCHIP=y @@ -362,7 +364,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NAND=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # # Debug @@ -403,16 +404,23 @@ CONFIG_AIC_BOOTLOADER_CMD_PART=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set # CONFIG_LPKG_USING_LIBMODBUS is not set # CONFIG_LPKG_USING_PTPD is not set # CONFIG_LPKG_USING_CJSON is not set +# CONFIG_LPKG_USING_MBEDTLS is not set +# CONFIG_LPKG_USING_AT24CXX is not set +# CONFIG_LPKG_USING_ZLIB is not set +# CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set +# CONFIG_LPKG_USING_MICROPYTHON is not set # # ArtInChip packages options @@ -429,6 +437,8 @@ CONFIG_AIC_AB_SYSTEM_INTERFACE=y # CONFIG_LPKG_USING_USERID is not set # CONFIG_LPKG_USING_PINMUX_CHECHK is not set # CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_BURN_IN is not set +# CONFIG_AIC_USING_IPMANAGER is not set # # Drivers options @@ -474,35 +484,7 @@ CONFIG_SPI_NAND_WINBOND=y CONFIG_AIC_NFTL_SUPPORT=y CONFIG_AIC_NFLT_USED_LIB=y # CONFIG_AIC_NFLT_TEST is not set - -# -# Touch Panel Support -# - -# -# Gt911 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GT911 is not set - -# -# Ft7411 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_FT7411 is not set - -# -# GSL1680 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GSL1680 is not set - -# -# RTP touch panel options -# -# CONFIG_AIC_USING_RTP is not set - -# -# St16xx touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_ST16XX is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support @@ -533,6 +515,7 @@ CONFIG_AIC_LOG_LEVEL=4 # CONFIG_AIC_CMU_DRV_TEST is not set # CONFIG_AIC_GPIO_DRV_TEST is not set # CONFIG_AIC_GPIO_TWINKLE_TEST is not set +# CONFIG_AIC_GPIO_KEY_TEST is not set # CONFIG_AIC_DMA_DRV_TEST is not set # CONFIG_AIC_UART_DRV_TEST is not set # CONFIG_AIC_RTC_DRV_TEST is not set diff --git a/target/configs/d21x_d215-demo88-nand_rt-thread_helloworld_defconfig b/target/configs/d21x_d215-demo88-nand_rt-thread_helloworld_defconfig index f5572264..1792f09d 100644 --- a/target/configs/d21x_d215-demo88-nand_rt-thread_helloworld_defconfig +++ b/target/configs/d21x_d215-demo88-nand_rt-thread_helloworld_defconfig @@ -63,10 +63,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set # CONFIG_AIC_LVGL_DEMO_HUB_DEMO is not set # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -102,6 +100,8 @@ CONFIG_PRJ_CUSTOM_LDS="" CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -462,6 +462,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.19" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -473,11 +474,6 @@ CONFIG_AIC_GE_DITHER=y # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set CONFIG_AIC_USING_AUDIO=y @@ -1530,9 +1526,8 @@ CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_AUTO=y # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_JPEG is not set # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_RGB565 is not set # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_ARGB8888 is not set -CONFIG_AIC_USB_DISP_SCALE_DOWN_X=0 -CONFIG_AIC_USB_DISP_SCALE_DOWN_Y=0 # CONFIG_AIC_USB_DISP_SW_GPIO_EN is not set +CONFIG_AIC_USB_DISP_INIT_DELAY_MS=0 # CONFIG_LPKG_CHERRYUSB_DEVICE_DISPLAY_FPS is not set CONFIG_LPKG_CHERRYUSB_DEVICE_COMPOSITE=y CONFIG_LPKG_CHERRYUSB_DEVICE_COMPOSITE_TEMPLATE=y @@ -1651,6 +1646,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d21x_d215-demo88-nor_baremetal_bootloader_defconfig b/target/configs/d21x_d215-demo88-nor_baremetal_bootloader_defconfig index 2e6bc3e3..535ead65 100644 --- a/target/configs/d21x_d215-demo88-nor_baremetal_bootloader_defconfig +++ b/target/configs/d21x_d215-demo88-nor_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -105,20 +107,20 @@ CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART7 is not set # -# Uart0 Parameter +# UART0 Parameter # CONFIG_AIC_CLK_UART0_FREQ=48000000 CONFIG_AIC_DEV_UART0_BAUDRATE=115200 CONFIG_AIC_DEV_UART0_DATABITS=8 CONFIG_AIC_DEV_UART0_STOPBITS=1 CONFIG_AIC_DEV_UART0_PARITY=0 +CONFIG_AIC_DEV_UART0_RS232=y +# CONFIG_AIC_DEV_UART0_RS485 is not set CONFIG_AIC_DEV_UART0_MODE_RS232=y # CONFIG_AIC_DEV_UART0_MODE_RS232_AUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL is not set # CONFIG_AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485 is not set -# CONFIG_AIC_DEV_UART0_MODE_RS485_COMPACT_IO is not set CONFIG_AIC_DEV_UART0_MODE=0 # CONFIG_AIC_UART0_DMA_ENABLE_FLAG is not set CONFIG_AIC_UART0_FLAG=259 @@ -166,9 +168,11 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_CAN0 is not set # CONFIG_AIC_USING_CAN1 is not set # CONFIG_AIC_USING_CIR is not set +# CONFIG_AIC_USB_OTG_DRV is not set # CONFIG_AIC_USING_USB0 is not set # CONFIG_AIC_USING_USB1 is not set # CONFIG_AIC_USING_GMAC0 is not set +# CONFIG_AIC_USING_GMAC1 is not set # # Storage Related: @@ -212,6 +216,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_WLAN_REALTEK is not set # CONFIG_WIFI_USING_SDIOWIFI_ATBM is not set +# CONFIG_AIC_WLAN_ASR is not set # # Analog Related: @@ -226,20 +231,16 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set +# CONFIG_AIC_USING_TOUCH is not set # # System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -308,9 +309,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 # @@ -338,6 +338,8 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # # Upgrading # +# CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -360,7 +362,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NOR=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # # Debug @@ -401,15 +402,23 @@ CONFIG_AIC_BOOTLOADER_CMD_PART=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set # CONFIG_LPKG_USING_LIBMODBUS is not set # CONFIG_LPKG_USING_PTPD is not set +# CONFIG_LPKG_USING_CJSON is not set +# CONFIG_LPKG_USING_MBEDTLS is not set +# CONFIG_LPKG_USING_AT24CXX is not set +# CONFIG_LPKG_USING_ZLIB is not set +# CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set +# CONFIG_LPKG_USING_MICROPYTHON is not set # # ArtInChip packages options @@ -426,6 +435,8 @@ CONFIG_AIC_AB_SYSTEM_INTERFACE=y # CONFIG_LPKG_USING_USERID is not set # CONFIG_LPKG_USING_PINMUX_CHECHK is not set # CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_BURN_IN is not set +# CONFIG_AIC_USING_IPMANAGER is not set # # Drivers options @@ -443,6 +454,7 @@ CONFIG_AIC_USING_UMM_HEAP=y CONFIG_AIC_UMM_HEAP_BARE_DRV=y # CONFIG_TLSF_MEM_HEAP is not set # CONFIG_AIC_GPIO_IRQ_DRV_EN is not set +# CONFIG_AIC_I2C_INTERRUPT_MODE is not set CONFIG_AIC_SPINOR_DRV=y # CONFIG_AIC_SPINAND_DRV is not set # CONFIG_AIC_SPINAND_CONT_READ is not set @@ -454,30 +466,7 @@ CONFIG_AIC_SPINOR_DRV=y CONFIG_LPKG_USING_SFUD=y CONFIG_BOOTLOADER_SFUD_USING_FLASH_INFO_TABLE=y # CONFIG_AIC_NFTL_SUPPORT is not set - -# -# Touch Panel Support -# - -# -# Gt911 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GT911 is not set - -# -# Ft7411 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_FT7411 is not set - -# -# GSL1680 touch panel options -# -# CONFIG_AIC_TOUCH_PANEL_GSL1680 is not set - -# -# RTP touch panel options -# -# CONFIG_AIC_USING_RTP is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support @@ -500,6 +489,7 @@ CONFIG_AIC_LOG_LEVEL=4 # CONFIG_AIC_RTC_DRV_DEBUG is not set # CONFIG_AIC_QSPI_DRV_DEBUG is not set # CONFIG_AIC_SPINOR_SFUD_DEBUG is not set +CONFIG_AIC_SPINOR_SFUD_WP_DEBUG=y # CONFIG_AIC_CACHE_LINE_DEBUG is not set # @@ -508,12 +498,14 @@ CONFIG_AIC_LOG_LEVEL=4 # CONFIG_AIC_CMU_DRV_TEST is not set # CONFIG_AIC_GPIO_DRV_TEST is not set # CONFIG_AIC_GPIO_TWINKLE_TEST is not set +# CONFIG_AIC_GPIO_KEY_TEST is not set # CONFIG_AIC_DMA_DRV_TEST is not set # CONFIG_AIC_UART_DRV_TEST is not set # CONFIG_AIC_RTC_DRV_TEST is not set # CONFIG_AIC_QSPI_DRV_TEST is not set CONFIG_AIC_SPINOR_DRV_TEST=y CONFIG_AIC_SDMC_DRV_TEST=y +# CONFIG_AIC_MMC_BARE_TEST is not set CONFIG_AIC_MTD_BARE_TEST=y # CONFIG_AIC_FILE_CRC32_TEST is not set # CONFIG_AIC_MTD_LOAD_FILE_TEST is not set @@ -521,3 +513,5 @@ CONFIG_AIC_MTD_BARE_TEST=y # CONFIG_AIC_MONKEY_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_IOPMP_TEST is not set +# CONFIG_AIC_MEM_API_TEST is not set +# CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d21x_d215-demo88-nor_rt-thread_helloworld_defconfig b/target/configs/d21x_d215-demo88-nor_rt-thread_helloworld_defconfig index 8b2331e6..3dea890e 100644 --- a/target/configs/d21x_d215-demo88-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d21x_d215-demo88-nor_rt-thread_helloworld_defconfig @@ -28,7 +28,7 @@ CONFIG_AIC_USING_FS_IMAGE_0=y CONFIG_AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_0=y # CONFIG_AIC_USING_FS_IMAGE_TYPE_UFFS_FOR_0 is not set # CONFIG_AIC_USING_FS_IMAGE_TYPE_LITTLEFS_FOR_0 is not set -CONFIG_AIC_FS_IMAGE_DIR_0="packages/third-party/cherryusb/tools/aic_usbdisplay" +CONFIG_AIC_FS_IMAGE_DIR_0="packages/third-party/cherryusb/tools/aic_usbdisplay/Windows" CONFIG_AIC_FS_IMAGE_NAME_0="rodata.fatfs" CONFIG_AIC_FATFS_AUTO_SIZE_FOR_0=y CONFIG_AIC_FATFS_DEFAULT_VOLAB_0=y @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set # CONFIG_AIC_LVGL_DEMO_HUB_DEMO is not set # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -88,6 +86,7 @@ CONFIG_LV_USB_OSD_SCREEN_LOCK_MODE=0 CONFIG_LV_USB_OSD_SCREEN_BLANK_TIME_AFTER_LOCK=300 CONFIG_LV_USB_OSD_SETTINGS_MENU=y CONFIG_LV_USB_OSD_SETTINGS_WAKEUP_KEY="PD.6" +# CONFIG_LV_USB_OSD_PLAY_VIDEO is not set CONFIG_LVGL_STORAGE_PATH="/data/lvgl_data" # @@ -99,6 +98,8 @@ CONFIG_PRJ_CUSTOM_LDS="" CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -409,6 +410,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.19" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -420,11 +422,6 @@ CONFIG_AIC_GE_DITHER=y # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set CONFIG_AIC_USING_AUDIO=y @@ -1458,8 +1455,6 @@ CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_AUTO=y # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_JPEG is not set # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_RGB565 is not set # CONFIG_LPKG_CHERRYUSB_USB_TRANSFER_ARGB8888 is not set -CONFIG_AIC_USB_DISP_SCALE_DOWN_X=0 -CONFIG_AIC_USB_DISP_SCALE_DOWN_Y=0 # CONFIG_AIC_USB_DISP_SW_GPIO_EN is not set CONFIG_AIC_USB_DISP_INIT_DELAY_MS=0 # CONFIG_LPKG_CHERRYUSB_DEVICE_DISPLAY_FPS is not set @@ -1539,6 +1534,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d21x_demo100-nor_baremetal_bootloader_defconfig b/target/configs/d21x_demo100-nor_baremetal_bootloader_defconfig index 7b39ab72..d304e36e 100644 --- a/target/configs/d21x_demo100-nor_baremetal_bootloader_defconfig +++ b/target/configs/d21x_demo100-nor_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -127,6 +129,7 @@ CONFIG_AIC_UART0_FLAG=259 CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -256,25 +259,6 @@ CONFIG_AIC_LVDS_LINK_1=y # CONFIG_AIC_LVDS_DOUBLE_SCREEN is not set # CONFIG_AIC_LVDS_DUAL_LINK is not set CONFIG_AIC_LVDS_LINK_MODE=1 -# CONFIG_PRGB_MODE is not set -# CONFIG_SRGB_MODE is not set -# CONFIG_AIC_PRGB_24BIT is not set -# CONFIG_AIC_PRGB_18BIT_LD is not set -# CONFIG_AIC_PRGB_18BIT_HD is not set -# CONFIG_AIC_PRGB_16BIT_LD is not set -# CONFIG_AIC_PRGB_16BIT_HD is not set -# CONFIG_AIC_SRGB_8BIT is not set -# CONFIG_AIC_SRGB_6BIT is not set -# CONFIG_DATA_ORDER_RGB is not set -# CONFIG_DATA_ORDER_RBG is not set -# CONFIG_DATA_ORDER_BGR is not set -# CONFIG_DATA_ORDER_BRG is not set -# CONFIG_DATA_ORDER_GRB is not set -# CONFIG_DATA_ORDER_GBR is not set -# CONFIG_AIC_DEGREE_0 is not set -# CONFIG_AIC_DEGREE_90 is not set -# CONFIG_AIC_DEGREE_180 is not set -# CONFIG_AIC_DEGREE_270 is not set # CONFIG_AICFB_ARGB8888 is not set # CONFIG_AICFB_ABGR8888 is not set # CONFIG_AICFB_XRGB8888 is not set @@ -283,7 +267,7 @@ CONFIG_AICFB_RGB565=y # CONFIG_AICFB_ARGB1555 is not set CONFIG_AICFB_FORMAT=0x0e # CONFIG_AIC_PAN_DISPLAY is not set -CONFIG_AIC_DISP_COLOR_BLOCK=y +# CONFIG_AIC_DISP_COLOR_BLOCK is not set CONFIG_AICFB_ROTATE_0=y # CONFIG_AICFB_ROTATE_90 is not set # CONFIG_AICFB_ROTATE_180 is not set @@ -294,11 +278,6 @@ CONFIG_AIC_FB_ROTATE_DEGREE=0 # Display Panels # CONFIG_AIC_SIMPLE_PANEL=y -# CONFIG_AIC_PANEL_RGB_ST7701S is not set -# CONFIG_AIC_PANEL_RGB_GC9A01A is not set -# CONFIG_AIC_PANEL_RGB_NT35560 is not set -# CONFIG_AIC_PANEL_RGB_ST77922 is not set -# CONFIG_AIC_PANEL_SRGB_HX8238 is not set # CONFIG_AIC_PANEL_BRIDGE_LT8911 is not set # @@ -317,14 +296,14 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.19" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=260 +CONFIG_AIC_SCREEN_CROP_WIDTH=1024 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set @@ -403,10 +382,9 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 -CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 +CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x400000 # # Console @@ -434,6 +412,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -515,6 +494,7 @@ CONFIG_AIC_BOOTLOADER_CMD_FB_CONSOLE=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -559,6 +539,7 @@ CONFIG_AIC_SPINOR_DRV=y CONFIG_LPKG_USING_SFUD=y CONFIG_BOOTLOADER_SFUD_USING_FLASH_INFO_TABLE=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support diff --git a/target/configs/d21x_demo100-nor_rt-thread_helloworld_defconfig b/target/configs/d21x_demo100-nor_rt-thread_helloworld_defconfig index 6002175d..34578e02 100644 --- a/target/configs/d21x_demo100-nor_rt-thread_helloworld_defconfig +++ b/target/configs/d21x_demo100-nor_rt-thread_helloworld_defconfig @@ -62,10 +62,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -77,6 +75,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=32 CONFIG_LV_CACHE_IMG_NUM=15 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -89,6 +88,8 @@ CONFIG_PRJ_CUSTOM_LDS="" CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -235,8 +236,7 @@ CONFIG_AIC_USING_I2C3=y # # CONFIG_AIC_DEV_I2C3_ADDR_BIT is not set CONFIG_AIC_DEV_I2C3_10BIT=0 -# CONFIG_AIC_DEV_I2C3_SPEED is not set -CONFIG_AIC_DEV_I2C3_100K_SPEED=0 +CONFIG_AIC_DEV_I2C3_SPEED=400000 # CONFIG_AIC_DEV_I2C3_BUS_MODE is not set CONFIG_AIC_DEV_I2C3_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -418,6 +418,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PE.19" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -429,28 +430,14 @@ CONFIG_AIC_GE_DITHER=y # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set -CONFIG_AIC_USING_AUDIO=y - -# -# Audio Parameter -# -CONFIG_AIC_AUDIO_PLAYBACK=y -# CONFIG_AIC_AUDIO_PDM_MODULATION_MODE is not set -CONFIG_AIC_AUDIO_PA_ENABLE_GPIO="PA.7" +# CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_AUDIO_EN_PIN_HIGH is not set -CONFIG_AIC_AUDIO_EN_PIN_LOW=y +# CONFIG_AIC_AUDIO_EN_PIN_LOW is not set # CONFIG_AIC_AUDIO_SPK_0 is not set -CONFIG_AIC_AUDIO_SPK_1=y +# CONFIG_AIC_AUDIO_SPK_1 is not set # CONFIG_AIC_AUDIO_SPK_0_1 is not set -CONFIG_AIC_AUDIO_DMIC=y -# CONFIG_AIC_AUDIO_AMIC is not set CONFIG_AIC_USING_TOUCH=y # @@ -1433,6 +1420,9 @@ CONFIG_LPKG_LITTLEFS_VER="latest" # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1454,6 +1444,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1470,6 +1461,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1493,9 +1485,11 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1568,5 +1562,6 @@ CONFIG_AIC_RTC_DRV_TEST=y # CONFIG_AIC_MONKEY_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set # CONFIG_AIC_MEM_API_TEST is not set # CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d21x_demo128-nand_baremetal_bootloader_defconfig b/target/configs/d21x_demo128-nand_baremetal_bootloader_defconfig index 84175ced..70a043c9 100644 --- a/target/configs/d21x_demo128-nand_baremetal_bootloader_defconfig +++ b/target/configs/d21x_demo128-nand_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -127,6 +129,7 @@ CONFIG_AIC_UART0_FLAG=259 CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y # CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set # CONFIG_AIC_USING_I2C0 is not set # CONFIG_AIC_USING_I2C1 is not set # CONFIG_AIC_USING_I2C2 is not set @@ -294,14 +297,14 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PC.7" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +CONFIG_AIC_SCREEN_CROP=y +CONFIG_AIC_SCREEN_CROP_POS_X=0 +CONFIG_AIC_SCREEN_CROP_POS_Y=260 +CONFIG_AIC_SCREEN_CROP_WIDTH=1024 +CONFIG_AIC_SCREEN_CROP_HEIGHT=80 # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set @@ -380,10 +383,9 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 -CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 +CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x400000 # # Console @@ -411,6 +413,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -491,6 +494,7 @@ CONFIG_AIC_BOOTLOADER_CMD_FB_CONSOLE=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -557,6 +561,7 @@ CONFIG_SPI_NAND_WINBOND=y CONFIG_AIC_NFTL_SUPPORT=y CONFIG_AIC_NFLT_USED_LIB=y # CONFIG_AIC_NFLT_TEST is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support diff --git a/target/configs/d21x_demo128-nand_rt-thread_helloworld_defconfig b/target/configs/d21x_demo128-nand_rt-thread_helloworld_defconfig index b60b5b66..17fd4aff 100644 --- a/target/configs/d21x_demo128-nand_rt-thread_helloworld_defconfig +++ b/target/configs/d21x_demo128-nand_rt-thread_helloworld_defconfig @@ -63,10 +63,8 @@ CONFIG_AIC_LVGL_DEMO=y # CONFIG_AIC_LVGL_METER_DEMO is not set CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_VSCODE_DEMO is not set -# CONFIG_AIC_LVGL_86BOX_DEMO is not set # CONFIG_AIC_LVGL_LAUNCHER_DEMO is not set # CONFIG_AIC_LVGL_DASHBOARD_DEMO is not set -# CONFIG_AIC_LVGL_DASHBOARD_SMALL_DEMO is not set # CONFIG_AIC_LVGL_ELEVATOR_DEMO is not set # CONFIG_AIC_LVGL_SLIDE_DEMO is not set # CONFIG_AIC_LVGL_SIMPLE_PLAYER_DEMO is not set @@ -78,6 +76,7 @@ CONFIG_AIC_LVGL_DEMO_HUB_DEMO=y # CONFIG_AIC_LVGL_IMAGE_DEMO is not set CONFIG_LV_COLOR_DEPTH=32 CONFIG_LV_CACHE_IMG_NUM=15 +# CONFIG_LV_DISPLAY_ROTATE_EN is not set # CONFIG_AIC_USE_TOUCH_MONKEY_TEST is not set CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" @@ -90,6 +89,8 @@ CONFIG_PRJ_CUSTOM_LDS="" CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -240,8 +241,7 @@ CONFIG_AIC_USING_I2C3=y # # CONFIG_AIC_DEV_I2C3_ADDR_BIT is not set CONFIG_AIC_DEV_I2C3_10BIT=0 -# CONFIG_AIC_DEV_I2C3_SPEED is not set -CONFIG_AIC_DEV_I2C3_100K_SPEED=0 +CONFIG_AIC_DEV_I2C3_SPEED=400000 # CONFIG_AIC_DEV_I2C3_BUS_MODE is not set CONFIG_AIC_DEV_I2C3_SLAVE_MODE=0 # CONFIG_AIC_USING_PWM0 is not set @@ -413,6 +413,7 @@ CONFIG_AIC_GPIO_BACKLIGHT=y CONFIG_AIC_PANEL_ENABLE_GPIO="PC.7" # CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set # CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set CONFIG_AIC_USING_GE=y # @@ -424,11 +425,6 @@ CONFIG_AIC_GE_DITHER=y # CONFIG_CTRL_GE_CLK_IN_FRAME is not set CONFIG_AIC_USING_VE=y # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set CONFIG_AIC_USING_AUDIO=y @@ -1429,6 +1425,9 @@ CONFIG_LPKG_CHERRYUSB_HOST_MSC=y # CONFIG_LPKG_USING_MEMLEAK_CHECK is not set # CONFIG_LPKG_USING_WEBCLIENT is not set # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1450,6 +1449,7 @@ CONFIG_LPKG_USING_MAD_0151b=y # CONFIG_LPKG_USING_MAD_FPM_SPARC is not set # CONFIG_LPKG_USING_MAD_FPM_PPC is not set CONFIG_LPKG_USING_MAD_FPM_DEFAULT=y +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1466,6 +1466,7 @@ CONFIG_AIC_MPP_PLAYER_INTERFACE=y # CONFIG_AIC_MPP_VIN_DEV is not set # CONFIG_AIC_MPP_FB_TEST is not set # CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set CONFIG_LPKG_USING_ENV=y # CONFIG_AIC_ENV_INTERFACE is not set # CONFIG_LPKG_USING_USERID is not set @@ -1507,9 +1508,11 @@ CONFIG_SPI_NAND_WINBOND=y CONFIG_AIC_NFTL_SUPPORT=y CONFIG_AIC_NFLT_USED_LIB=y # CONFIG_AIC_NFLT_TEST is not set +# CONFIG_AIC_BT_BT8858A is not set CONFIG_AIC_USING_CTP=y # CONFIG_AIC_USING_RTP is not set # CONFIG_AIC_TOUCH_PANEL_AXS15260 is not set +# CONFIG_AIC_TOUCH_PANEL_C145HAX01 is not set # CONFIG_AIC_TOUCH_PANEL_CST826 is not set # CONFIG_AIC_TOUCH_PANEL_CST3240 is not set # CONFIG_AIC_TOUCH_PANEL_FT7411 is not set @@ -1582,5 +1585,6 @@ CONFIG_AIC_DISPLAY_TEST=y # CONFIG_AIC_CE_DRV_TEST is not set # CONFIG_AIC_SOFT_AES_TEST is not set # CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set # CONFIG_AIC_MEM_API_TEST is not set # CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/d21x_demo88-nand_baremetal_bootloader_defconfig b/target/configs/d21x_demo88-nand_baremetal_bootloader_defconfig index db7c5b02..9a36f948 100644 --- a/target/configs/d21x_demo88-nand_baremetal_bootloader_defconfig +++ b/target/configs/d21x_demo88-nand_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -230,11 +232,6 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set @@ -313,9 +310,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 # @@ -344,6 +340,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -367,7 +364,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NAND=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # # Debug @@ -421,6 +417,7 @@ CONFIG_AIC_BOOTLOADER_CMD_PART=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/d21x_demo88-nor_baremetal_bootloader_defconfig b/target/configs/d21x_demo88-nor_baremetal_bootloader_defconfig index c01d5e4a..d923e742 100644 --- a/target/configs/d21x_demo88-nor_baremetal_bootloader_defconfig +++ b/target/configs/d21x_demo88-nor_baremetal_bootloader_defconfig @@ -26,6 +26,8 @@ CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/d21x_bootloader CONFIG_AIC_CHIP_D21X=y CONFIG_CACHE_LINE_SIZE=64 CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_DRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x00100000 CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V10=y CONFIG_AIC_CMU_DRV_VER="10" @@ -229,11 +231,6 @@ CONFIG_AIC_WIRELESS_LAN=y # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_I2S1 is not set # CONFIG_AIC_USING_AUDIO is not set @@ -312,9 +309,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x43E00100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x7FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x43000000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x280000 # @@ -343,6 +339,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set # CONFIG_AICUPG_UART_ENABLE is not set CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -365,7 +362,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NOR=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # # Debug @@ -419,6 +415,7 @@ CONFIG_AIC_BOOTLOADER_CMD_PART=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/g73x_demo100-nor_baremetal_bootloader_defconfig b/target/configs/g73x_demo100-nor_baremetal_bootloader_defconfig index 4c4fd935..709d0d7f 100644 --- a/target/configs/g73x_demo100-nor_baremetal_bootloader_defconfig +++ b/target/configs/g73x_demo100-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_G73X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -97,7 +99,7 @@ CONFIG_AIC_SID_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -180,7 +182,7 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -220,29 +222,24 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # # CONFIG_AIC_USING_DE is not set # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y CONFIG_AIC_USING_WRI=y @@ -321,7 +318,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -363,9 +360,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x30100100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x300d0000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x2F000 # @@ -394,6 +390,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -414,7 +411,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NOR=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # CONFIG_AIC_BOOTLOADER_CMD_PSRAM_TEST is not set # @@ -470,6 +466,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set diff --git a/target/configs/g73x_demo100-nor_rt-thread_helloworld_defconfig b/target/configs/g73x_demo100-nor_rt-thread_helloworld_defconfig index e0f9add8..080e8f20 100644 --- a/target/configs/g73x_demo100-nor_rt-thread_helloworld_defconfig +++ b/target/configs/g73x_demo100-nor_rt-thread_helloworld_defconfig @@ -45,6 +45,8 @@ CONFIG_AIC_CHIP_G73X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -134,7 +136,7 @@ CONFIG_AIC_AUDIO_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -240,7 +242,7 @@ CONFIG_AIC_DEV_GMAC0_USE_CHIPID=y CONFIG_AIC_DEV_GMAC0_PHYADDR=1 # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -280,7 +282,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # CONFIG_AIC_USING_TSEN=y @@ -315,17 +317,12 @@ CONFIG_AIC_GPAI7_PERIOD_TIME=1 CONFIG_AIC_GPAI7_ADC_ACQ=0x2f # -# MutiMedia Related: +# MutiMedia Related: # # CONFIG_AIC_USING_DE is not set # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -344,10 +341,10 @@ CONFIG_AIC_AUDIO_DMIC=y # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -430,7 +427,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1334,7 +1331,6 @@ CONFIG_LPKG_CHERRYUSB_HOST_MSC_TEMPLATE=y # CONFIG_LPKG_USING_ADBD is not set # CONFIG_LPKG_USING_AWTK is not set # CONFIG_LPKG_USING_LWIP is not set -# CONFIG_LPKG_USING_LWIP213 is not set # CONFIG_LPKG_USING_DFS_UFFS is not set CONFIG_LPKG_USING_LITTLEFS=y CONFIG_LPKG_LITTLEFS_PATH="/packages/third-party/littlefs" @@ -1376,6 +1372,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1388,6 +1385,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1419,6 +1417,7 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support diff --git a/target/configs/g73x_demo68-nor_baremetal_bootloader_defconfig b/target/configs/g73x_demo68-nor_baremetal_bootloader_defconfig index 30066c45..4704b081 100644 --- a/target/configs/g73x_demo68-nor_baremetal_bootloader_defconfig +++ b/target/configs/g73x_demo68-nor_baremetal_bootloader_defconfig @@ -27,6 +27,8 @@ CONFIG_AIC_CHIP_G73X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -97,7 +99,7 @@ CONFIG_AIC_SID_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -180,7 +182,7 @@ CONFIG_AIC_DEV_UART0_RX_MODE=0 # CONFIG_AIC_USING_GMAC0 is not set # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -220,32 +222,27 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # # CONFIG_AIC_USING_TSEN is not set # CONFIG_AIC_USING_GPAI is not set # -# MutiMedia Related: +# MutiMedia Related: # # CONFIG_AIC_USING_DE is not set # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set # CONFIG_AIC_USING_AUDIO is not set # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -327,7 +324,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -369,9 +366,8 @@ CONFIG_AIC_BOOTLOADER=y # # Memory # -CONFIG_AIC_BOOTLOADER_TEXT_BASE=0x30100100 +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 -CONFIG_AIC_BOOTLOADER_HEAP_BASE=0x300e0000 CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x1F000 # @@ -400,6 +396,7 @@ CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y # Upgrading # # CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set CONFIG_AICUPG_UART_ENABLE=y CONFIG_AICUPG_USB_ENABLE=y # CONFIG_AICUPG_USB_DMA_ENABLE is not set @@ -420,7 +417,6 @@ CONFIG_AIC_BOOTLOADER_CMD_SPI_NOR=y CONFIG_AIC_BOOTLOADER_CMD_MTD=y CONFIG_AIC_BOOTLOADER_CMD_MEM=y CONFIG_AIC_BOOTLOADER_CMD_PART=y -# CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR is not set # CONFIG_AIC_BOOTLOADER_CMD_PSRAM_TEST is not set # @@ -463,6 +459,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -475,6 +472,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -519,6 +517,7 @@ CONFIG_AIC_SPINOR_DRV=y CONFIG_LPKG_USING_SFUD=y CONFIG_BOOTLOADER_SFUD_USING_FLASH_INFO_TABLE=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support diff --git a/target/configs/g73x_demo68-nor_rt-thread_helloworld_defconfig b/target/configs/g73x_demo68-nor_rt-thread_helloworld_defconfig index a41c020e..95f7a96e 100644 --- a/target/configs/g73x_demo68-nor_rt-thread_helloworld_defconfig +++ b/target/configs/g73x_demo68-nor_rt-thread_helloworld_defconfig @@ -45,6 +45,8 @@ CONFIG_AIC_CHIP_G73X=y CONFIG_CACHE_LINE_SIZE=32 # CONFIG_CPU_DCACHE_PREFETCH_EN is not set CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 # CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set CONFIG_AIC_CMU_DRV=y CONFIG_AIC_CMU_DRV_V11=y @@ -134,7 +136,7 @@ CONFIG_AIC_AUDIO_DRV_VER="11" # # -# Interface Related: +# Interface Related: # CONFIG_AIC_USING_UART0=y # CONFIG_AIC_USING_UART1 is not set @@ -240,7 +242,7 @@ CONFIG_AIC_DEV_GMAC0_USE_CHIPID=y CONFIG_AIC_DEV_GMAC0_PHYADDR=1 # -# Storage Related: +# Storage Related: # CONFIG_AIC_USING_QSPI0=y @@ -280,7 +282,7 @@ CONFIG_AIC_SDMC1_CLK_FREQ=100000000 # CONFIG_AIC_WIRELESS_LAN is not set # -# Analog Related: +# Analog Related: # CONFIG_AIC_USING_TSEN=y @@ -315,17 +317,12 @@ CONFIG_AIC_GPAI7_PERIOD_TIME=1 CONFIG_AIC_GPAI7_ADC_ACQ=0x2f # -# MutiMedia Related: +# MutiMedia Related: # # CONFIG_AIC_USING_DE is not set # CONFIG_AIC_USING_GE is not set # CONFIG_AIC_USING_VE is not set # CONFIG_AIC_USING_DVP is not set - -# -# Camera Support -# -# CONFIG_AIC_USING_CAMERA is not set # CONFIG_AIC_USING_I2S0 is not set CONFIG_AIC_USING_AUDIO=y @@ -344,10 +341,10 @@ CONFIG_AIC_AUDIO_DMIC=y # CONFIG_AIC_USING_TOUCH is not set # -# System Related: +# System Related: # CONFIG_AIC_USING_DMA=y -# CONFIG_AIC_USING_WRI is not set +CONFIG_AIC_USING_WRI=y CONFIG_AIC_USING_RTC=y # @@ -429,7 +426,7 @@ CONFIG_AIC_CLK_APB0_FREQ=100000000 # CONFIG_AIC_USING_PM is not set # -# Security Related: +# Security Related: # # CONFIG_AIC_USING_SPIENC is not set CONFIG_AIC_USING_SID=y @@ -1413,6 +1410,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set # CONFIG_LPKG_USING_RPMSG_LITE is not set # CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set # CONFIG_LPKG_USING_FREETYPE is not set # CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set # CONFIG_LPKG_USING_NETUTILS is not set @@ -1425,6 +1423,7 @@ CONFIG_AIC_PRINT_FLOAT_CUSTOM=y # CONFIG_LPKG_USING_SQLITE is not set # CONFIG_LPKG_USING_DFS is not set # CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set CONFIG_LPKG_USING_FDTLIB=y # CONFIG_LPKG_USING_GIF is not set # CONFIG_LPKG_USING_MICROPYTHON is not set @@ -1456,6 +1455,7 @@ CONFIG_AIC_SPINOR_DRV=y # CONFIG_LPKG_USING_SPINAND is not set CONFIG_LPKG_USING_SFUD=y # CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set # # External Audio Codec Support diff --git a/target/configs/g73x_scan_baremetal_bootloader_defconfig b/target/configs/g73x_scan_baremetal_bootloader_defconfig new file mode 100644 index 00000000..8ad0c51b --- /dev/null +++ b/target/configs/g73x_scan_baremetal_bootloader_defconfig @@ -0,0 +1,652 @@ +# +# Automatically generated file; DO NOT EDIT. +# ArtInChip Luban-Lite SDK Configuration +# + +# +# Project options +# +CONFIG_PRJ_DEFCONFIG_FILENAME="g73x_scan_baremetal_bootloader_defconfig" + +# +# -- Important: If following options have been changed, you need save & rerun menuconfig before changing any other options. +# +CONFIG_PRJ_CHIP="g73x" +CONFIG_PRJ_BOARD="scan" +CONFIG_PRJ_KERNEL="baremetal" +CONFIG_PRJ_APP="bootloader" +CONFIG_PLATFORM_LUBANLITE=y + +# +# Chip options +# +CONFIG_SOC_THEAD_SMART=y +# CONFIG_QEMU_RUN is not set +CONFIG_PRJ_CUSTOM_LDS="application/baremetal/bootloader/ldscript/g73x_bootloader_gcc.ld" +CONFIG_AIC_CHIP_G73X=y +CONFIG_CACHE_LINE_SIZE=32 +# CONFIG_CPU_DCACHE_PREFETCH_EN is not set +CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 +# CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set +CONFIG_AIC_CMU_DRV=y +CONFIG_AIC_CMU_DRV_V11=y +CONFIG_AIC_CMU_DRV_VER="11" +CONFIG_AIC_GPIO_DRV=y +CONFIG_AIC_GPIO_DRV_V11=y +CONFIG_AIC_GPIO_DRV_VER="11" +CONFIG_AIC_SYSCFG_DRV=y +CONFIG_AIC_SYSCFG_DRV_V11=y +CONFIG_AIC_SYSCFG_DRV_VER="11" +CONFIG_AIC_DMA_DRV=y +CONFIG_AIC_DMA_DRV_V11=y +CONFIG_AIC_DMA_DRV_VER="11" +CONFIG_AIC_DMA_CH_NUM=8 +CONFIG_AIC_DMA_ALIGN_SIZE=8 +CONFIG_AIC_UART_DRV=y +CONFIG_AIC_UART_DRV_V11=y +CONFIG_AIC_UART_DEV_NUM=8 +# CONFIG_AIC_I2C_DRV is not set +CONFIG_AIC_QSPI_DRV=y +CONFIG_AIC_QSPI_DRV_V11=y +CONFIG_AIC_QSPI_DRV_VER="11" +CONFIG_AIC_XSPI_DRV=y +CONFIG_AIC_XSPI_DRV_V10=y +# CONFIG_AIC_AXICFG_DRV is not set +CONFIG_AIC_WRI_DRV=y +CONFIG_AIC_WRI_DRV_V11=y +CONFIG_AIC_WRI_DRV_VER="11" +CONFIG_AIC_RTC_DRV=y +CONFIG_AIC_RTC_DRV_V11=y +CONFIG_AIC_RTC_DRV_VER="11" +CONFIG_AIC_WDT_DRV=y +CONFIG_AIC_WDT_DRV_V10=y +CONFIG_AIC_WDT_DRV_VER="10" +# CONFIG_AIC_SPIENC_DRV is not set +CONFIG_AIC_SDMC_DRV=y +CONFIG_AIC_SDMC_DRV_V11=y +CONFIG_AIC_SDMC_DRV_VER="11" +CONFIG_AIC_DE_DRV=y +CONFIG_AIC_DE_DRV_V11=y +CONFIG_AIC_DE_DRV_VER="11" +# CONFIG_AIC_GE_DRV is not set +# CONFIG_AIC_VE_DRV is not set +# CONFIG_AIC_DVP_DRV is not set +# CONFIG_AIC_USB_DEVICE_DRV is not set +# CONFIG_AIC_USB_HOST_EHCI_DRV is not set +# CONFIG_AIC_GMAC_DRV is not set +# CONFIG_AIC_ADCIM_DRV is not set +# CONFIG_AIC_RTP_DRV is not set +# CONFIG_AIC_TSEN_DRV is not set +# CONFIG_AIC_GPAI_DRV is not set +# CONFIG_AIC_PWM_DRV is not set +# CONFIG_AIC_EPWM_DRV is not set +# CONFIG_AIC_HRTIMER_DRV is not set +# CONFIG_AIC_CAP_DRV is not set +CONFIG_AIC_SID_DRV=y +CONFIG_AIC_SID_DRV_V11=y +CONFIG_AIC_SID_DRV_VER="11" +# CONFIG_AIC_CE_DRV is not set +# CONFIG_AIC_MTOP_DRV is not set +# CONFIG_AIC_CAN_DRV is not set +# CONFIG_AIC_CIR_DRV is not set +# CONFIG_AIC_I2S_DRV is not set +# CONFIG_AIC_AUDIO_DRV is not set +# CONFIG_AIC_PM_DRV is not set +# CONFIG_AIC_PSADC_DRV is not set + +# +# Board options +# + +# +# Interface Related: +# +CONFIG_AIC_USING_UART0=y +# CONFIG_AIC_USING_UART1 is not set +# CONFIG_AIC_USING_UART2 is not set +# CONFIG_AIC_USING_UART3 is not set +# CONFIG_AIC_USING_UART4 is not set +# CONFIG_AIC_USING_UART5 is not set +# CONFIG_AIC_USING_UART6 is not set +# CONFIG_AIC_USING_UART7 is not set + +# +# UART0 Parameter +# +CONFIG_AIC_CLK_UART0_FREQ=48000000 +CONFIG_AIC_DEV_UART0_BAUDRATE=115200 +CONFIG_AIC_DEV_UART0_DATABITS=8 +CONFIG_AIC_DEV_UART0_STOPBITS=1 +CONFIG_AIC_DEV_UART0_PARITY=0 +CONFIG_AIC_DEV_UART0_RS232=y +# CONFIG_AIC_DEV_UART0_RS485 is not set +CONFIG_AIC_DEV_UART0_MODE_RS232=y +# CONFIG_AIC_DEV_UART0_MODE_RS232_AUTO_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL is not set +CONFIG_AIC_DEV_UART0_MODE=0 +# CONFIG_AIC_UART0_DMA_ENABLE_FLAG is not set +CONFIG_AIC_UART0_FLAG=259 +CONFIG_AIC_DEV_UART0_RX_MODE_POLL=y +# CONFIG_AIC_DEV_UART0_RX_MODE_INT is not set +CONFIG_AIC_DEV_UART0_RX_MODE=0 +# CONFIG_AIC_USING_SOFT_I2C is not set +# CONFIG_AIC_USING_I2C0 is not set +# CONFIG_AIC_USING_I2C1 is not set +# CONFIG_AIC_USING_I2C2 is not set +# CONFIG_AIC_USING_PWM0 is not set +# CONFIG_AIC_USING_PWM1 is not set +# CONFIG_AIC_USING_PWM2 is not set +# CONFIG_AIC_USING_PWM3 is not set + +# +# Using EPWM +# +# CONFIG_AIC_USING_EPWM0 is not set +# CONFIG_AIC_USING_EPWM1 is not set +# CONFIG_AIC_USING_EPWM2 is not set +# CONFIG_AIC_USING_EPWM3 is not set +# CONFIG_AIC_USING_EPWM4 is not set +# CONFIG_AIC_USING_EPWM5 is not set +# CONFIG_AIC_USING_EPWM6 is not set +# CONFIG_AIC_USING_EPWM7 is not set +# CONFIG_AIC_USING_EPWM8 is not set +# CONFIG_AIC_USING_EPWM9 is not set +# CONFIG_AIC_USING_EPWM10 is not set +# CONFIG_AIC_USING_EPWM11 is not set + +# +# Using HRTIMER +# +# CONFIG_AIC_USING_HRTIMER0 is not set +# CONFIG_AIC_USING_HRTIMER1 is not set +# CONFIG_AIC_USING_HRTIMER2 is not set +# CONFIG_AIC_USING_HRTIMER3 is not set +# CONFIG_AIC_USING_HRTIMER4 is not set +# CONFIG_AIC_USING_HRTIMER5 is not set + +# +# Using CAP +# +# CONFIG_AIC_USING_CAP0 is not set +# CONFIG_AIC_USING_CAP1 is not set +# CONFIG_AIC_USING_CAP2 is not set +# CONFIG_AIC_USING_CAP3 is not set +# CONFIG_AIC_USING_CAP4 is not set +# CONFIG_AIC_USING_CAP5 is not set +# CONFIG_AIC_USING_CAN0 is not set +# CONFIG_AIC_USING_CAN1 is not set +# CONFIG_AIC_USING_CIR is not set +# CONFIG_AIC_USB_OTG_DRV is not set +# CONFIG_AIC_USING_USB0 is not set +# CONFIG_AIC_USING_GMAC0 is not set + +# +# Storage Related: +# +CONFIG_AIC_USING_QSPI0=y + +# +# SPI0 Parameter +# +CONFIG_AIC_DEV_QSPI0_MAX_SRC_FREQ_HZ=100000000 +# CONFIG_AIC_QSPI0_BUS_WIDTH_1 is not set +CONFIG_AIC_QSPI0_BUS_WIDTH_4=y +CONFIG_AIC_QSPI0_BUS_WIDTH=4 +CONFIG_AIC_DEV_QSPI0_DELAY_MODE=2 +# CONFIG_AIC_USING_QSPI1 is not set +# CONFIG_AIC_USING_QSPI2 is not set +# CONFIG_AIC_USING_QSPI3 is not set +# CONFIG_AIC_SUPPORT_SPI_IN_BIT_MODE is not set +CONFIG_AIC_QSPI0_DEVICE_SPINOR=y +CONFIG_AIC_QSPI0_DEVICE_SPINOR_FREQ=100000000 +# CONFIG_AIC_QSPI0_DEVICE_SPINAND is not set +# CONFIG_AIC_USING_SDMC0 is not set +CONFIG_AIC_USING_SDMC1=y +# CONFIG_AIC_SDMC_IRQ_MODE is not set + +# +# SDMC1 Parameter +# +# CONFIG_AIC_SDMC1_BUSWIDTH1 is not set +CONFIG_AIC_SDMC1_BUSWIDTH4=y +# CONFIG_AIC_SD_USING_HOTPLUG is not set +# CONFIG_AIC_SDMC1_IS_SDIO is not set +CONFIG_AIC_SDMC1_DRV_PHASE=3 +CONFIG_AIC_SDMC1_SMP_PHASE=0 +CONFIG_AIC_SDMC1_CLK_FREQ=100000000 + +# +# WLAN Related: +# +# CONFIG_AIC_WIRELESS_LAN is not set + +# +# Analog Related: +# +# CONFIG_AIC_USING_TSEN is not set +# CONFIG_AIC_USING_GPAI is not set + +# +# MutiMedia Related: +# +CONFIG_AIC_USING_DE=y + +# +# Display Parameter +# +CONFIG_AIC_DISPLAY_DRV=y +# CONFIG_AIC_DISP_PQ_TOOL is not set +CONFIG_AIC_DISP_DE_DRV=y +# CONFIG_AIC_DISP_RGB_DRV is not set +CONFIG_AIC_DISP_LVDS_DRV=y +# CONFIG_AIC_DISP_MIPI_DSI_DRV is not set +# CONFIG_AIC_DISP_RGB is not set +CONFIG_AIC_DISP_LVDS=y +# CONFIG_AIC_DISP_MIPI_DSI is not set +# CONFIG_AIC_DISP_MIPI_DBI is not set +CONFIG_AIC_DI_TYPE=2 + +# +# LVDS interface options +# +CONFIG_AIC_LVDS_NS=y +# CONFIG_AIC_LVDS_JEIDA_24BIT is not set +# CONFIG_AIC_LVDS_JEIDA_18BIT is not set +CONFIG_AIC_LVDS_MODE=0 +CONFIG_AIC_LVDS_LINK_0=y +CONFIG_AIC_LVDS_LINK_MODE=0 +# CONFIG_AICFB_ARGB8888 is not set +# CONFIG_AICFB_ABGR8888 is not set +# CONFIG_AICFB_XRGB8888 is not set +# CONFIG_AICFB_RGB888 is not set +CONFIG_AICFB_RGB565=y +# CONFIG_AICFB_ARGB1555 is not set +CONFIG_AICFB_FORMAT=0x0e +# CONFIG_AIC_PAN_DISPLAY is not set +# CONFIG_AIC_DISP_COLOR_BLOCK is not set +CONFIG_AICFB_ROTATE_0=y +# CONFIG_AICFB_ROTATE_90 is not set +# CONFIG_AICFB_ROTATE_180 is not set +# CONFIG_AICFB_ROTATE_270 is not set +CONFIG_AIC_FB_ROTATE_DEGREE=0 + +# +# Display Panels +# +CONFIG_AIC_SIMPLE_PANEL=y +# CONFIG_AIC_PANEL_BRIDGE_LT8911 is not set + +# +# display timing of simple panel +# +CONFIG_PANEL_PIXELCLOCK=52 +CONFIG_PANEL_HACTIVE=1024 +CONFIG_PANEL_VACTIVE=600 +CONFIG_PANEL_HBP=160 +CONFIG_PANEL_HFP=160 +CONFIG_PANEL_HSW=20 +CONFIG_PANEL_VBP=12 +CONFIG_PANEL_VFP=20 +CONFIG_PANEL_VSW=2 +CONFIG_AIC_GPIO_BACKLIGHT=y +CONFIG_AIC_PANEL_ENABLE_GPIO="PE.13" +# CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set +# CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set +# CONFIG_AIC_USING_GE is not set +# CONFIG_AIC_USING_VE is not set +# CONFIG_AIC_USING_DVP is not set +# CONFIG_AIC_USING_I2S0 is not set +# CONFIG_AIC_USING_AUDIO is not set +# CONFIG_AIC_USING_TOUCH is not set + +# +# System Related: +# +CONFIG_AIC_USING_DMA=y +CONFIG_AIC_USING_WRI=y +CONFIG_AIC_USING_RTC=y + +# +# RTC Parameter +# +CONFIG_AIC_RTC_CLK_RATE=3276800 +# CONFIG_AIC_RTC_ALARM_IO_OUTPUT is not set +# CONFIG_AIC_RTC_32K_IO_OUTPUT is not set +CONFIG_AIC_USING_WDT=y + +# +# Mem Options +# + +# +# SRAM parameter +# +CONFIG_AIC_SRAM_TOTAL_SIZE=0x100000 +# CONFIG_AIC_TCM_EN is not set +CONFIG_AIC_ITCM_SIZE=0x0 +CONFIG_AIC_DTCM_SIZE=0x0 +CONFIG_AIC_SRAM_S1_SIZE_0K=y +# CONFIG_AIC_SRAM_S1_SIZE_128K is not set +# CONFIG_AIC_SRAM_S1_SIZE_256K is not set +# CONFIG_AIC_SRAM_S1_SIZE_384K is not set +# CONFIG_AIC_SRAM_S1_SIZE_512K is not set +# CONFIG_AIC_SRAM_S1_SIZE_640K is not set +# CONFIG_AIC_SRAM_S1_SIZE_768K is not set +CONFIG_AIC_SRAM_S1_SIZE=0 +CONFIG_AIC_SRAM_S1_REG_SIZE=0x00 +CONFIG_AIC_SRAM1_SW_SIZE=0x0 +CONFIG_AIC_BOOTLOADER_RESERVE_SIZE=0x40000 + +# +# PSRAM parameter +# +CONFIG_AIC_PSRAM_SIZE=0x400000 +CONFIG_AIC_PSRAM_CMA_EN=y +CONFIG_AIC_PSRAM_SW_SIZE=0x300000 +CONFIG_AIC_PSRAM_SW_EN=y +# CONFIG_AIC_XIP is not set + +# +# ELF Sections memory location +# +CONFIG_AIC_SEC_TEXT_SRAM_S0=y +# CONFIG_AIC_SEC_TEXT_PSRAM is not set +CONFIG_AIC_SEC_RODATA_SRAM_S0=y +# CONFIG_AIC_SEC_RODATA_PSRAM is not set +CONFIG_AIC_SEC_DATA_SRAM_S0=y +# CONFIG_AIC_SEC_DATA_PSRAM is not set +CONFIG_AIC_SEC_BSS_SRAM_S0=y +# CONFIG_AIC_SEC_BSS_PSRAM is not set +CONFIG_AIC_INTERRUPTSTACK_SIZE=4096 + +# +# Support another Flash +# +CONFIG_AIC_FLASH_NUM_ONE=y +# CONFIG_AIC_FLASH_NUM_TWO is not set + +# +# Clocks options +# +CONFIG_AIC_CLK_PLL_INT0_FREQ=480000000 +CONFIG_AIC_CLK_PLL_INT1_FREQ=1200000000 +CONFIG_AIC_CLK_PLL_FRA0_FREQ=0 +# CONFIG_AIC_CLK_PLL_FRA0_SSC_DIS is not set +CONFIG_AIC_CLK_PLL_FRA2_FREQ=0 +# CONFIG_AIC_CLK_PLL_FRA2_SSC_DIS is not set +CONFIG_AIC_CLK_CPU_FREQ=480000000 +CONFIG_AIC_CLK_AXI0_FREQ=200000000 +CONFIG_AIC_CLK_AHB0_FREQ=200000000 +CONFIG_AIC_CLK_APB0_FREQ=100000000 +# CONFIG_AIC_USING_CLK_OUT0 is not set +# CONFIG_AIC_USING_CLK_OUT1 is not set +# CONFIG_AIC_USING_CLK_OUT2 is not set +# CONFIG_AIC_USING_CLK_OUT3 is not set +# CONFIG_AIC_USING_PM is not set + +# +# Security Related: +# +# CONFIG_AIC_USING_SPIENC is not set +CONFIG_AIC_USING_SID=y + +# +# SID Parameter +# +CONFIG_EFUSE_MAX_WORD=64 +CONFIG_EFUSE_TIMING_VALUE=0x0402FFD8 +# CONFIG_AIC_USING_CE is not set +CONFIG_AIC_USING_SYSCFG=y + +# +# Syscfg Parameter +# +CONFIG_AIC_SYSCFG_SIP_FLASH_ENABLE=y +CONFIG_AIC_SIP_FLASH_ACCESS_QSPI_ID=0 +# CONFIG_AIC_SYSCFG_LDO1X_ENABLE is not set +# CONFIG_AIC_USING_MTOP is not set +# CONFIG_AIC_USING_PSADC is not set + +# +# Baremetal options +# +CONFIG_KERNEL_BAREMETAL=y +CONFIG_DRIVER_HAL_EN=y +CONFIG_DRIVER_BARE_DRV_EN=y +CONFIG_AIC_NORMALSTACK_SIZE=8092 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_RISCV_FPU=y +CONFIG_ARCH_RISCV_FPU_D=y +CONFIG_ARCH_RISCV32=y + +# +# Bootloader options +# +CONFIG_AIC_BOOTLOADER=y + +# +# Memory +# +CONFIG_AIC_BOOTLOADER_MEM_AUTO=y +CONFIG_AIC_BOOTLOADER_TEXT_SIZE=0x3FF00 +CONFIG_AIC_BOOTLOADER_HEAP_SIZE=0x300000 + +# +# Console +# +CONFIG_AIC_BOOTLOADER_CONSOLE_UART=0 + +# +# Drivers +# +CONFIG_AIC_BOOTLOADER_MMC_SUPPORT=y +CONFIG_AIC_BOOTLOADER_SPINOR_SUPPORT=y +# CONFIG_AIC_BOOTLOADER_SPINAND_SUPPORT is not set +CONFIG_AIC_BOOTLOADER_PSRAM_EN=y + +# +# PSRAM Parameter +# +CONFIG_AIC_XSPI_PSRAM_CS0_PINS=0x0 +CONFIG_AIC_XSPI_PSRAM_CS1_PINS=0x0 +CONFIG_AIC_XSPI_PSRAM_CLK=198000000 +# CONFIG_AIC_BOOTLOADER_AXICFG_SUPPORT is not set +CONFIG_AIC_BOOT_USB_DRV=y +CONFIG_AIC_BOOT_USBH_DRV=y +CONFIG_AIC_BOOTLOADER_UDISK_SUPPORT=y + +# +# Components +# +CONFIG_AIC_BOOTLOADER_FATFS_SUPPORT=y + +# +# Upgrading +# +# CONFIG_AICUPG_SINGLE_TRANS_BURN_CRC32_VERIFY is not set +# CONFIG_AICUPG_FORCE_UPGRADE_SUPPORT is not set +CONFIG_AICUPG_UART_ENABLE=y +CONFIG_AICUPG_USB_ENABLE=y +# CONFIG_AICUPG_USB_DMA_ENABLE is not set +CONFIG_AICUPG_SDCARD_ENABLE=y +CONFIG_AICUPG_SDCARD_CONTROLLER_ID=1 +CONFIG_AICUPG_UDISK_ENABLE=y +CONFIG_AICUPG_UDISK_CHECK_TIMEOUT=1000 +CONFIG_AICUPG_USB_CONTROLLER_MAX_NUM=1 +CONFIG_AICUPG_MMC_ARTINCHIP=y +CONFIG_AICUPG_NOR_ARTINCHIP=y +CONFIG_AICUPG_LOG_BUFFER_SUPPORT=y +CONFIG_AICUPG_LOG_BUFFER_ADDR=0x30040000 +CONFIG_AICUPG_LOG_BUFFER_SIZE=0x3000 + +# +# Commands +# +CONFIG_AIC_BOOTLOADER_CMD_NOR_BOOT=y +# CONFIG_AIC_BOOTLOADER_CMD_XIP_BOOT is not set +# CONFIG_AIC_BOOTLOADER_CMD_MMC_BOOT is not set +CONFIG_AIC_BOOTLOADER_CMD_SPI_NOR=y +CONFIG_AIC_BOOTLOADER_CMD_MTD=y +CONFIG_AIC_BOOTLOADER_CMD_MEM=y +CONFIG_AIC_BOOTLOADER_CMD_PART=y +CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR=y +CONFIG_AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE=0 +CONFIG_AIC_BOOTLOADER_CMD_FB_CONSOLE=y +# CONFIG_AIC_BOOTLOADER_CMD_ONLY_FB_CONSOLE is not set +# CONFIG_AIC_BOOTLOADER_CMD_PSRAM_TEST is not set + +# +# Debug +# +# CONFIG_AICUPG_DEBUG is not set +# CONFIG_AICUPG_UART_DEBUG is not set +# CONFIG_AIC_SHOW_BOOT_TIME is not set + +# +# Local packages options +# + +# +# Third-party packages options +# +# CONFIG_LPKG_USING_CPU_USAGE is not set +# CONFIG_LPKG_USING_RAMDISK is not set +# CONFIG_LPKG_USING_CHERRYUSB is not set +# CONFIG_LPKG_USING_ADBD is not set +# CONFIG_LPKG_USING_AWTK is not set +# CONFIG_LPKG_USING_LWIP is not set +# CONFIG_LPKG_USING_DFS_UFFS is not set +# CONFIG_LPKG_USING_LITTLEFS is not set + +# +# BenchMark Tests +# +CONFIG_AIC_PRINT_FLOAT_CUSTOM=y +# CONFIG_LPKG_USING_COREMARK is not set +# CONFIG_LPKG_USING_DHRYSTONE is not set +# CONFIG_LPKG_USING_STREAM is not set +# CONFIG_LPKG_USING_WHETSTONE is not set +# CONFIG_LPKG_USING_LINPACK is not set +# CONFIG_LPKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_LPKG_USING_I2C_TOOLS is not set +# CONFIG_LPKG_USING_BEEP is not set +# CONFIG_LPKG_USING_MEMLEAK_CHECK is not set +# CONFIG_LPKG_USING_WEBCLIENT is not set +# CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set +# CONFIG_LPKG_USING_FREETYPE is not set +# CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set +# CONFIG_LPKG_USING_NETUTILS is not set +# CONFIG_LPKG_USING_LIBMODBUS is not set +# CONFIG_LPKG_USING_PTPD is not set +# CONFIG_LPKG_USING_CJSON is not set +# CONFIG_LPKG_USING_MBEDTLS is not set +# CONFIG_LPKG_USING_AT24CXX is not set +# CONFIG_LPKG_USING_ZLIB is not set +# CONFIG_LPKG_USING_SQLITE is not set +# CONFIG_LPKG_USING_DFS is not set +# CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set +CONFIG_LPKG_USING_FDTLIB=y +# CONFIG_LPKG_USING_GIF is not set +# CONFIG_LPKG_USING_MICROPYTHON is not set + +# +# ArtInChip packages options +# +# CONFIG_LPKG_MPP is not set +# CONFIG_LPKG_USING_ENV is not set +# CONFIG_LPKG_USING_USERID is not set +# CONFIG_LPKG_USING_PINMUX_CHECHK is not set +# CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_BURN_IN is not set +# CONFIG_AIC_USING_IPMANAGER is not set +# CONFIG_AIC_USING_BARCODE_DEMO is not set + +# +# Drivers options +# + +# +# AIC Bare Driver +# +CONFIG_AIC_MTD_BARE_DRV=y +CONFIG_AIC_CONSOLE_BARE_DRV=y +CONFIG_AIC_CONSOLE_SYSNAME="tinySPL" +CONFIG_AIC_PRINTF_BARE_DRV=y +# CONFIG_AIC_USING_TLSF_HEAP is not set +CONFIG_AIC_USING_UMM_HEAP=y +CONFIG_AIC_UMM_HEAP_BARE_DRV=y +# CONFIG_TLSF_MEM_HEAP is not set +# CONFIG_AIC_GPIO_IRQ_DRV_EN is not set +# CONFIG_AIC_I2C_INTERRUPT_MODE is not set +CONFIG_AIC_SPINOR_DRV=y +# CONFIG_AIC_SPINAND_DRV is not set +# CONFIG_AIC_SPINAND_CONT_READ is not set + +# +# Peripheral +# +# CONFIG_LPKG_USING_SPINAND is not set +CONFIG_LPKG_USING_SFUD=y +CONFIG_BOOTLOADER_SFUD_USING_FLASH_INFO_TABLE=y +# CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set + +# +# External Audio Codec Support +# +# CONFIG_AIC_I2S_CODEC_SELECT is not set + +# +# Drivers debug +# +# CONFIG_AIC_LOG_LEVEL_NONE is not set +# CONFIG_AIC_LOG_LEVEL_ERR is not set +CONFIG_AIC_LOG_LEVEL_WARN=y +# CONFIG_AIC_LOG_LEVEL_INFO is not set +# CONFIG_AIC_LOG_LEVEL_DEBUG is not set +CONFIG_AIC_LOG_LEVEL=4 +# CONFIG_AIC_CMU_DRV_DEBUG is not set +# CONFIG_AIC_GPIO_DRV_DEBUG is not set +# CONFIG_AIC_DMA_DRV_DEBUG is not set +# CONFIG_AIC_UART_DRV_DEBUG is not set +# CONFIG_AIC_RTC_DRV_DEBUG is not set +# CONFIG_AIC_QSPI_DRV_DEBUG is not set +# CONFIG_AIC_SPINOR_SFUD_DEBUG is not set +CONFIG_AIC_SPINOR_SFUD_WP_DEBUG=y +# CONFIG_AIC_FB_DRV_DEBUG is not set +# CONFIG_AIC_CACHE_LINE_DEBUG is not set + +# +# Drivers examples +# +# CONFIG_AIC_CMU_DRV_TEST is not set +# CONFIG_AIC_GPIO_DRV_TEST is not set +# CONFIG_AIC_GPIO_TWINKLE_TEST is not set +# CONFIG_AIC_GPIO_KEY_TEST is not set +# CONFIG_AIC_DMA_DRV_TEST is not set +# CONFIG_AIC_UART_DRV_TEST is not set +# CONFIG_AIC_RTC_DRV_TEST is not set +# CONFIG_AIC_QSPI_DRV_TEST is not set +CONFIG_AIC_SPINOR_DRV_TEST=y +CONFIG_AIC_SDMC_DRV_TEST=y +# CONFIG_AIC_MMC_BARE_TEST is not set +CONFIG_AIC_MTD_BARE_TEST=y +# CONFIG_AIC_FILE_CRC32_TEST is not set +# CONFIG_AIC_MTD_LOAD_FILE_TEST is not set +# CONFIG_AIC_DISPLAY_TEST is not set +# CONFIG_AIC_WDT_DRV_TEST is not set +# CONFIG_AIC_MONKEY_TEST is not set +# CONFIG_AIC_SOFT_AES_TEST is not set +# CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set +# CONFIG_AIC_MEM_API_TEST is not set +# CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/configs/g73x_scan_rt-thread_helloworld_defconfig b/target/configs/g73x_scan_rt-thread_helloworld_defconfig new file mode 100644 index 00000000..5c0ccc6a --- /dev/null +++ b/target/configs/g73x_scan_rt-thread_helloworld_defconfig @@ -0,0 +1,1512 @@ +# +# Automatically generated file; DO NOT EDIT. +# ArtInChip Luban-Lite SDK Configuration +# + +# +# Project options +# +CONFIG_PRJ_DEFCONFIG_FILENAME="g73x_scan_rt-thread_helloworld_defconfig" + +# +# -- Important: If following options have been changed, you need save & rerun menuconfig before changing any other options. +# +CONFIG_PRJ_CHIP="g73x" +CONFIG_PRJ_BOARD="scan" +CONFIG_PRJ_KERNEL="rt-thread" +CONFIG_PRJ_APP="helloworld" +CONFIG_PLATFORM_LUBANLITE=y + +# +# Application options +# + +# +# Filesystem related +# +# CONFIG_AIC_USING_FS_IMAGE_0 is not set +# CONFIG_AIC_USING_FS_IMAGE_1 is not set +# CONFIG_GENERATE_BURNER_IMAGE is not set + +# +# LVGL demo select related +# +# CONFIG_LPKG_USING_LVGL is not set +# CONFIG_AIC_LVGL_DEMO is not set +CONFIG_LVGL_STORAGE_PATH="/rodata/lvgl_data" + +# +# Chip options +# +CONFIG_SOC_THEAD_SMART=y +# CONFIG_QEMU_RUN is not set +CONFIG_PRJ_CUSTOM_LDS="" +CONFIG_AIC_CHIP_G73X=y +CONFIG_CACHE_LINE_SIZE=32 +# CONFIG_CPU_DCACHE_PREFETCH_EN is not set +CONFIG_CPU_BASE=0x20000000 +CONFIG_CPU_PSRAM_BASE=0x40000000 +CONFIG_CPU_SRAM_BASE=0x30040000 +# CONFIG_GLOBAL_INT_SW_THRESHOLD_EN is not set +CONFIG_AIC_CMU_DRV=y +CONFIG_AIC_CMU_DRV_V11=y +CONFIG_AIC_CMU_DRV_VER="11" +CONFIG_AIC_GPIO_DRV=y +CONFIG_AIC_GPIO_DRV_V11=y +CONFIG_AIC_GPIO_DRV_VER="11" +CONFIG_AIC_SYSCFG_DRV=y +CONFIG_AIC_SYSCFG_DRV_V11=y +CONFIG_AIC_SYSCFG_DRV_VER="11" +CONFIG_AIC_DMA_DRV=y +CONFIG_AIC_DMA_DRV_V11=y +CONFIG_AIC_DMA_DRV_VER="11" +CONFIG_AIC_DMA_CH_NUM=8 +CONFIG_AIC_DMA_ALIGN_SIZE=8 +CONFIG_AIC_UART_DRV=y +CONFIG_AIC_UART_DRV_V11=y +CONFIG_AIC_UART_DEV_NUM=8 +CONFIG_AIC_I2C_DRV=y +CONFIG_AIC_I2C_DRV_V10=y +CONFIG_AIC_I2C_DRV_VER="10" +CONFIG_AIC_I2C_CH_NUM=3 +CONFIG_AIC_QSPI_DRV=y +CONFIG_AIC_QSPI_DRV_V11=y +CONFIG_AIC_QSPI_DRV_VER="11" +CONFIG_AIC_XSPI_DRV=y +CONFIG_AIC_XSPI_DRV_V10=y +# CONFIG_AIC_AXICFG_DRV is not set +CONFIG_AIC_WRI_DRV=y +CONFIG_AIC_WRI_DRV_V11=y +CONFIG_AIC_WRI_DRV_VER="11" +CONFIG_AIC_RTC_DRV=y +CONFIG_AIC_RTC_DRV_V11=y +CONFIG_AIC_RTC_DRV_VER="11" +CONFIG_AIC_WDT_DRV=y +CONFIG_AIC_WDT_DRV_V10=y +CONFIG_AIC_WDT_DRV_VER="10" +# CONFIG_AIC_SPIENC_DRV is not set +CONFIG_AIC_SDMC_DRV=y +CONFIG_AIC_SDMC_DRV_V11=y +CONFIG_AIC_SDMC_DRV_VER="11" +CONFIG_AIC_DE_DRV=y +CONFIG_AIC_DE_DRV_V11=y +CONFIG_AIC_DE_DRV_VER="11" +CONFIG_AIC_DISP_RGB_DRV_V11=y +CONFIG_AIC_GE_DRV=y +CONFIG_AIC_GE_DRV_V11=y +CONFIG_AIC_GE_DRV_VER="11" +CONFIG_AIC_VE_DRV=y +CONFIG_AIC_VE_DRV_V30=y +CONFIG_AIC_VE_DRV_VER="30" +CONFIG_AIC_DVP_DRV=y +CONFIG_AIC_DVP_DRV_V11=y +CONFIG_AIC_DVP_DRV_VER="11" +# CONFIG_AIC_USB_DEVICE_DRV is not set +# CONFIG_AIC_USB_HOST_EHCI_DRV is not set +# CONFIG_AIC_GMAC_DRV is not set +# CONFIG_AIC_ADCIM_DRV is not set +# CONFIG_AIC_RTP_DRV is not set +# CONFIG_AIC_TSEN_DRV is not set +# CONFIG_AIC_GPAI_DRV is not set +# CONFIG_AIC_PWM_DRV is not set +# CONFIG_AIC_EPWM_DRV is not set +# CONFIG_AIC_HRTIMER_DRV is not set +# CONFIG_AIC_CAP_DRV is not set +CONFIG_AIC_SID_DRV=y +CONFIG_AIC_SID_DRV_V11=y +CONFIG_AIC_SID_DRV_VER="11" +# CONFIG_AIC_CE_DRV is not set +# CONFIG_AIC_MTOP_DRV is not set +# CONFIG_AIC_CAN_DRV is not set +# CONFIG_AIC_CIR_DRV is not set +# CONFIG_AIC_I2S_DRV is not set +# CONFIG_AIC_AUDIO_DRV is not set +# CONFIG_AIC_PM_DRV is not set +# CONFIG_AIC_PSADC_DRV is not set + +# +# Board options +# + +# +# Interface Related: +# +CONFIG_AIC_USING_UART0=y +# CONFIG_AIC_USING_UART1 is not set +# CONFIG_AIC_USING_UART2 is not set +# CONFIG_AIC_USING_UART3 is not set +# CONFIG_AIC_USING_UART4 is not set +# CONFIG_AIC_USING_UART5 is not set +# CONFIG_AIC_USING_UART6 is not set +# CONFIG_AIC_USING_UART7 is not set + +# +# UART0 Parameter +# +CONFIG_AIC_CLK_UART0_FREQ=48000000 +CONFIG_AIC_DEV_UART0_BAUDRATE=115200 +CONFIG_AIC_DEV_UART0_DATABITS=8 +CONFIG_AIC_DEV_UART0_STOPBITS=1 +CONFIG_AIC_DEV_UART0_PARITY=0 +CONFIG_AIC_DEV_UART0_RS232=y +# CONFIG_AIC_DEV_UART0_RS485 is not set +CONFIG_AIC_DEV_UART0_MODE_RS232=y +# CONFIG_AIC_DEV_UART0_MODE_RS232_AUTO_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_UNAUTO_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_SW_FLOW_CTRL is not set +# CONFIG_AIC_DEV_UART0_MODE_RS232_SW_HW_FLOW_CTRL is not set +CONFIG_AIC_DEV_UART0_MODE=0 +# CONFIG_AIC_UART0_DMA_ENABLE_FLAG is not set +CONFIG_AIC_UART0_FLAG=259 +# CONFIG_AIC_USING_SOFT_I2C is not set +# CONFIG_AIC_USING_I2C0 is not set +# CONFIG_AIC_USING_I2C1 is not set +CONFIG_AIC_USING_I2C2=y + +# +# I2C2 Parameter +# +# CONFIG_AIC_DEV_I2C2_ADDR_BIT is not set +CONFIG_AIC_DEV_I2C2_10BIT=0 +CONFIG_AIC_DEV_I2C2_SPEED=400000 +# CONFIG_AIC_DEV_I2C2_BUS_MODE is not set +CONFIG_AIC_DEV_I2C2_SLAVE_MODE=0 +# CONFIG_AIC_USING_PWM0 is not set +# CONFIG_AIC_USING_PWM1 is not set +# CONFIG_AIC_USING_PWM2 is not set +# CONFIG_AIC_USING_PWM3 is not set + +# +# Using EPWM +# +# CONFIG_AIC_USING_EPWM0 is not set +# CONFIG_AIC_USING_EPWM1 is not set +# CONFIG_AIC_USING_EPWM2 is not set +# CONFIG_AIC_USING_EPWM3 is not set +# CONFIG_AIC_USING_EPWM4 is not set +# CONFIG_AIC_USING_EPWM5 is not set +# CONFIG_AIC_USING_EPWM6 is not set +# CONFIG_AIC_USING_EPWM7 is not set +# CONFIG_AIC_USING_EPWM8 is not set +# CONFIG_AIC_USING_EPWM9 is not set +# CONFIG_AIC_USING_EPWM10 is not set +# CONFIG_AIC_USING_EPWM11 is not set + +# +# Using HRTIMER +# +# CONFIG_AIC_USING_HRTIMER0 is not set +# CONFIG_AIC_USING_HRTIMER1 is not set +# CONFIG_AIC_USING_HRTIMER2 is not set +# CONFIG_AIC_USING_HRTIMER3 is not set +# CONFIG_AIC_USING_HRTIMER4 is not set +# CONFIG_AIC_USING_HRTIMER5 is not set + +# +# Using CAP +# +# CONFIG_AIC_USING_CAP0 is not set +# CONFIG_AIC_USING_CAP1 is not set +# CONFIG_AIC_USING_CAP2 is not set +# CONFIG_AIC_USING_CAP3 is not set +# CONFIG_AIC_USING_CAP4 is not set +# CONFIG_AIC_USING_CAP5 is not set +# CONFIG_AIC_USING_CAN0 is not set +# CONFIG_AIC_USING_CAN1 is not set +# CONFIG_AIC_USING_CIR is not set +# CONFIG_AIC_USB_OTG_DRV is not set +# CONFIG_AIC_USING_USB0 is not set +# CONFIG_AIC_USING_GMAC0 is not set + +# +# Storage Related: +# +CONFIG_AIC_USING_QSPI0=y + +# +# SPI0 Parameter +# +CONFIG_AIC_DEV_QSPI0_MAX_SRC_FREQ_HZ=100000000 +# CONFIG_AIC_QSPI0_BUS_WIDTH_1 is not set +CONFIG_AIC_QSPI0_BUS_WIDTH_4=y +CONFIG_AIC_QSPI0_BUS_WIDTH=4 +CONFIG_AIC_DEV_QSPI0_DELAY_MODE=2 +# CONFIG_AIC_USING_QSPI1 is not set +# CONFIG_AIC_USING_QSPI2 is not set +# CONFIG_AIC_USING_QSPI3 is not set +# CONFIG_AIC_SUPPORT_SPI_IN_BIT_MODE is not set +CONFIG_AIC_QSPI0_DEVICE_SPINOR=y +CONFIG_AIC_QSPI0_DEVICE_SPINOR_FREQ=100000000 +# CONFIG_AIC_QSPI0_DEVICE_SPINAND is not set +# CONFIG_AIC_USING_SDMC0 is not set +CONFIG_AIC_USING_SDMC1=y +# CONFIG_AIC_SDMC_IRQ_MODE is not set + +# +# SDMC1 Parameter +# +# CONFIG_AIC_SDMC1_BUSWIDTH1 is not set +CONFIG_AIC_SDMC1_BUSWIDTH4=y +# CONFIG_AIC_SD_USING_HOTPLUG is not set +# CONFIG_AIC_SDMC1_IS_SDIO is not set +CONFIG_AIC_SDMC1_DRV_PHASE=3 +CONFIG_AIC_SDMC1_SMP_PHASE=0 +CONFIG_AIC_SDMC1_CLK_FREQ=100000000 + +# +# WLAN Related: +# +# CONFIG_AIC_WIRELESS_LAN is not set + +# +# Analog Related: +# +# CONFIG_AIC_USING_TSEN is not set +# CONFIG_AIC_USING_GPAI is not set + +# +# MutiMedia Related: +# +CONFIG_AIC_USING_DE=y + +# +# Display Parameter +# +CONFIG_AIC_DISPLAY_DRV=y +# CONFIG_AIC_DISP_PQ_TOOL is not set +CONFIG_AIC_DISP_DE_DRV=y +CONFIG_AIC_DISP_RGB_DRV=y +# CONFIG_AIC_DISP_LVDS_DRV is not set +# CONFIG_AIC_DISP_MIPI_DSI_DRV is not set +CONFIG_AIC_DISP_RGB=y +# CONFIG_AIC_DISP_LVDS is not set +# CONFIG_AIC_DISP_MIPI_DSI is not set +# CONFIG_AIC_DISP_MIPI_DBI is not set +CONFIG_AIC_DI_TYPE=1 + +# +# RGB interface options +# +CONFIG_PRGB_MODE=y +# CONFIG_SRGB_MODE is not set +CONFIG_AIC_RGB_MODE=0 +# CONFIG_AIC_PRGB_24BIT is not set +# CONFIG_AIC_PRGB_18BIT_LD is not set +# CONFIG_AIC_PRGB_18BIT_HD is not set +CONFIG_AIC_PRGB_16BIT_LD=y +# CONFIG_AIC_PRGB_16BIT_HD is not set +# CONFIG_AIC_SRGB_8BIT is not set +# CONFIG_AIC_SRGB_6BIT is not set +CONFIG_AIC_RGB_FORMAT=3 +# CONFIG_DATA_ORDER_RGB is not set +# CONFIG_DATA_ORDER_RBG is not set +CONFIG_DATA_ORDER_BGR=y +# CONFIG_DATA_ORDER_BRG is not set +# CONFIG_DATA_ORDER_GRB is not set +# CONFIG_DATA_ORDER_GBR is not set +CONFIG_AIC_RGB_DATA_ORDER=0x00120012 +# CONFIG_AIC_DEGREE_0 is not set +CONFIG_AIC_DEGREE_90=y +# CONFIG_AIC_DEGREE_180 is not set +# CONFIG_AIC_DEGREE_270 is not set +CONFIG_AIC_RGB_CLK_CTL=1 +# CONFIG_RGB_DATA_MIRROT is not set +CONFIG_AIC_RGB_DATA_MIRROR=0 +# CONFIG_AICFB_ARGB8888 is not set +# CONFIG_AICFB_ABGR8888 is not set +# CONFIG_AICFB_XRGB8888 is not set +# CONFIG_AICFB_RGB888 is not set +CONFIG_AICFB_RGB565=y +# CONFIG_AICFB_ARGB1555 is not set +CONFIG_AICFB_FORMAT=0x0e +# CONFIG_AIC_PAN_DISPLAY is not set +# CONFIG_AIC_DISP_COLOR_BLOCK is not set +CONFIG_AICFB_ROTATE_0=y +# CONFIG_AICFB_ROTATE_90 is not set +# CONFIG_AICFB_ROTATE_180 is not set +# CONFIG_AICFB_ROTATE_270 is not set +CONFIG_AIC_FB_ROTATE_DEGREE=0 + +# +# Display Panels +# +CONFIG_AIC_SIMPLE_PANEL=y +# CONFIG_AIC_PANEL_RGB_ST7701S is not set +# CONFIG_AIC_PANEL_RGB_GC9A01A is not set +# CONFIG_AIC_PANEL_RGB_NT35560 is not set +# CONFIG_AIC_PANEL_RGB_ST77922 is not set +# CONFIG_AIC_PANEL_SRGB_HX8238 is not set +# CONFIG_AIC_PANEL_LCOS_HX7033 is not set + +# +# display timing of simple panel +# +CONFIG_PANEL_PIXELCLOCK=10 +CONFIG_PANEL_HACTIVE=480 +CONFIG_PANEL_VACTIVE=272 +CONFIG_PANEL_HBP=43 +CONFIG_PANEL_HFP=8 +CONFIG_PANEL_HSW=1 +CONFIG_PANEL_VBP=12 +CONFIG_PANEL_VFP=4 +CONFIG_PANEL_VSW=10 +CONFIG_AIC_GPIO_BACKLIGHT=y +CONFIG_AIC_PANEL_ENABLE_GPIO="PB.7" +# CONFIG_AIC_PANEL_ENABLE_GPIO_LOW is not set +# CONFIG_AIC_PANEL_SPI_EMULATION is not set +# CONFIG_AIC_SCREEN_CROP is not set +CONFIG_AIC_USING_GE=y + +# +# Graphics Engine Parameter +# +CONFIG_AIC_GE_CMDQ=y +# CONFIG_AIC_GE_NORMAL is not set +CONFIG_AIC_GE_DITHER=y +CONFIG_AIC_GE_CMDQ_BUF_LENGTH=2048 +# CONFIG_CTRL_GE_CLK_IN_FRAME is not set +CONFIG_AIC_USING_VE=y +CONFIG_AIC_USING_DVP=y +# CONFIG_AIC_USING_I2S0 is not set +# CONFIG_AIC_USING_AUDIO is not set +# CONFIG_AIC_USING_TOUCH is not set + +# +# System Related: +# +CONFIG_AIC_USING_DMA=y +CONFIG_AIC_USING_WRI=y +CONFIG_AIC_USING_RTC=y + +# +# RTC Parameter +# +CONFIG_AIC_RTC_CLK_RATE=3276800 +# CONFIG_AIC_RTC_ALARM_IO_OUTPUT is not set +# CONFIG_AIC_RTC_32K_IO_OUTPUT is not set +CONFIG_AIC_USING_WDT=y + +# +# Mem Options +# + +# +# SRAM parameter +# +CONFIG_AIC_SRAM_TOTAL_SIZE=0x100000 +# CONFIG_AIC_TCM_EN is not set +CONFIG_AIC_ITCM_SIZE=0x0 +CONFIG_AIC_DTCM_SIZE=0x0 +CONFIG_AIC_SRAM_S1_SIZE_0K=y +# CONFIG_AIC_SRAM_S1_SIZE_128K is not set +# CONFIG_AIC_SRAM_S1_SIZE_256K is not set +# CONFIG_AIC_SRAM_S1_SIZE_384K is not set +# CONFIG_AIC_SRAM_S1_SIZE_512K is not set +# CONFIG_AIC_SRAM_S1_SIZE_640K is not set +# CONFIG_AIC_SRAM_S1_SIZE_768K is not set +CONFIG_AIC_SRAM_S1_SIZE=0 +CONFIG_AIC_SRAM_S1_REG_SIZE=0x00 +CONFIG_AIC_SRAM1_SW_SIZE=0x0 +CONFIG_AIC_BOOTLOADER_RESERVE_SIZE=0x40000 + +# +# PSRAM parameter +# +CONFIG_AIC_PSRAM_SIZE=0x400000 +CONFIG_AIC_PSRAM_CMA_EN=y +CONFIG_AIC_PSRAM_SW_SIZE=0x0 +# CONFIG_AIC_XIP is not set + +# +# ELF Sections memory location +# +CONFIG_AIC_SEC_TEXT_SRAM_S0=y +# CONFIG_AIC_SEC_TEXT_PSRAM is not set +# CONFIG_AIC_SEC_RODATA_SRAM_S0 is not set +CONFIG_AIC_SEC_RODATA_PSRAM=y +# CONFIG_AIC_SEC_DATA_SRAM_S0 is not set +CONFIG_AIC_SEC_DATA_PSRAM=y +# CONFIG_AIC_SEC_BSS_SRAM_S0 is not set +CONFIG_AIC_SEC_BSS_PSRAM=y +CONFIG_AIC_INTERRUPTSTACK_SIZE=4096 + +# +# Support another Flash +# +CONFIG_AIC_FLASH_NUM_ONE=y +# CONFIG_AIC_FLASH_NUM_TWO is not set + +# +# Clocks options +# +CONFIG_AIC_CLK_PLL_INT0_FREQ=480000000 +CONFIG_AIC_CLK_PLL_INT1_FREQ=1200000000 +CONFIG_AIC_CLK_PLL_FRA0_FREQ=792000000 +# CONFIG_AIC_CLK_PLL_FRA0_SSC_DIS is not set +CONFIG_AIC_CLK_PLL_FRA2_FREQ=1188000000 +# CONFIG_AIC_CLK_PLL_FRA2_SSC_DIS is not set +CONFIG_AIC_CLK_CPU_FREQ=480000000 +CONFIG_AIC_CLK_AXI0_FREQ=200000000 +CONFIG_AIC_CLK_AHB0_FREQ=200000000 +CONFIG_AIC_CLK_APB0_FREQ=100000000 +# CONFIG_AIC_USING_CLK_OUT0 is not set +CONFIG_AIC_USING_CLK_OUT1=y +CONFIG_AIC_CLK_OUT1_FREQ=24000000 +# CONFIG_AIC_USING_CLK_OUT2 is not set +# CONFIG_AIC_USING_CLK_OUT3 is not set +# CONFIG_AIC_USING_PM is not set + +# +# Security Related: +# +# CONFIG_AIC_USING_SPIENC is not set +CONFIG_AIC_USING_SID=y + +# +# SID Parameter +# +CONFIG_EFUSE_MAX_WORD=64 +CONFIG_EFUSE_TIMING_VALUE=0x0402FFD8 +# CONFIG_AIC_USING_CE is not set +CONFIG_AIC_USING_SYSCFG=y + +# +# Syscfg Parameter +# +CONFIG_AIC_SYSCFG_SIP_FLASH_ENABLE=y +CONFIG_AIC_SIP_FLASH_ACCESS_QSPI_ID=0 +# CONFIG_AIC_SYSCFG_LDO1X_ENABLE is not set +# CONFIG_AIC_USING_MTOP is not set +# CONFIG_AIC_USING_PSADC is not set + +# +# Rt-Thread options +# +CONFIG_KERNEL_RTTHREAD=y +CONFIG_DRIVER_HAL_EN=y +CONFIG_DRIVER_DRV_EN=y + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=16 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_ALIGN_SIZE=4 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=1000 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_HOOK_USING_FUNC_PTR=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=1024 +CONFIG_RT_USING_TIMER_SOFT=y +CONFIG_RT_TIMER_THREAD_PRIO=4 +CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 + +# +# kservice optimization +# +# CONFIG_RT_KSERVICE_USING_STDLIB is not set +# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set +# CONFIG_RT_USING_TINY_FFS is not set +# CONFIG_RT_KPRINTF_USING_LONGLONG is not set +# CONFIG_RT_DEBUG is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +# CONFIG_RT_USING_SMALL_MEM is not set +# CONFIG_RT_USING_SLAB is not set +CONFIG_RT_USING_MEMHEAP=y +CONFIG_RT_MEMHEAP_FAST_MODE=y +# CONFIG_RT_MEMHEAP_BSET_MODE is not set +# CONFIG_RT_USING_SMALL_MEM_AS_HEAP is not set +CONFIG_RT_USING_MEMHEAP_AS_HEAP=y +# CONFIG_RT_USING_MEMHEAP_AUTO_BINDING is not set +# CONFIG_RT_USING_SLAB_AS_HEAP is not set +# CONFIG_RT_USING_USERHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +CONFIG_RT_USING_MEMTRACE=y +# CONFIG_RT_USING_HEAP_ISR is not set +CONFIG_RT_USING_HEAP=y + +# +# Kernel Device Object +# +CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set +# CONFIG_RT_USING_INTERRUPT_INFO is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" +CONFIG_RT_VER_NUM=0x40101 +# CONFIG_RT_USING_CPU_FFS is not set +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_RISCV_FPU=y +CONFIG_ARCH_RISCV_FPU_D=y +CONFIG_ARCH_RISCV32=y +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 +CONFIG_RT_USING_LEGACY=y +CONFIG_RT_USING_MSH=y +CONFIG_RT_USING_FINSH=y +CONFIG_FINSH_USING_MSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_PROMPT_NAME="aic" +# CONFIG_FINSH_POLL_MODE is not set +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=4096 +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=1 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_CMD_SIZE=80 +CONFIG_MSH_USING_BUILT_IN_COMMANDS=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_ARG_MAX=10 +CONFIG_RT_USING_DFS=y +CONFIG_DFS_USING_POSIX=y +CONFIG_DFS_USING_WORKDIR=y +CONFIG_DFS_FILESYSTEMS_MAX=8 +CONFIG_DFS_FILESYSTEM_TYPES_MAX=4 +CONFIG_DFS_FD_MAX=16 +CONFIG_RT_USING_DFS_MNTTABLE=y +CONFIG_RT_USING_DFS_ELMFAT=y + +# +# elm-chan's FatFs, Generic FAT Filesystem Module +# +CONFIG_RT_DFS_ELM_CODE_PAGE=437 +CONFIG_RT_DFS_ELM_WORD_ACCESS=y +# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set +# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set +# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set +CONFIG_RT_DFS_ELM_USE_LFN_3=y +CONFIG_RT_DFS_ELM_USE_LFN=3 +CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y +# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set +# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set +# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set +CONFIG_RT_DFS_ELM_LFN_UNICODE=0 +CONFIG_RT_DFS_ELM_USE_EXFAT=y +CONFIG_RT_DFS_ELM_MAX_LFN=255 +CONFIG_RT_DFS_ELM_DRIVES=2 +CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096 +# CONFIG_RT_DFS_ELM_USE_ERASE is not set +CONFIG_RT_DFS_ELM_REENTRANT=y +CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 +# CONFIG_RT_USING_DFS_DEVFS is not set +CONFIG_RT_USING_DFS_ROMFS=y +# CONFIG_RT_USING_DFS_RAMFS is not set +CONFIG_RT_USING_FAL=y +# CONFIG_FAL_DEBUG_CONFIG is not set +CONFIG_FAL_DEBUG=0 +CONFIG_FAL_PART_HAS_TABLE_CFG=y +CONFIG_FAL_USING_SFUD_PORT=y +CONFIG_FAL_USING_NOR_FLASH_DEV_NAME="norflash0" +# CONFIG_FAL_BLK_DEVICE_RDONLY is not set + +# +# Device Drivers +# +CONFIG_RT_USING_DEVICE_IPC=y +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_USING_SERIAL_V1=y +# CONFIG_RT_USING_SERIAL_V2 is not set +CONFIG_RT_SERIAL_USING_DMA=y +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_HWTIMER is not set +# CONFIG_RT_USING_CPUTIME is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG is not set +# CONFIG_RT_USING_PHY is not set +CONFIG_RT_USING_PIN=y +CONFIG_RT_USING_ADC=y +# CONFIG_RT_USING_DAC is not set +CONFIG_RT_USING_PWM=y +CONFIG_RT_USING_MTD_NOR=y +# CONFIG_RT_USING_MTD_NAND is not set +CONFIG_RT_USING_PM=y +CONFIG_PM_TICKLESS_THRESHOLD_TIME=2 +CONFIG_PM_USING_CUSTOM_CONFIG=y +# CONFIG_PM_ENABLE_DEBUG is not set +CONFIG_PM_ENABLE_SUSPEND_SLEEP_MODE=y +CONFIG_PM_ENABLE_THRESHOLD_SLEEP_MODE=y +CONFIG_PM_LIGHT_THRESHOLD_TIME=5 +CONFIG_PM_DEEP_THRESHOLD_TIME=20 +CONFIG_PM_STANDBY_THRESHOLD_TIME=100 +CONFIG_RT_USING_RTC=y +CONFIG_RT_USING_ALARM=y +# CONFIG_RT_USING_SOFT_RTC is not set +CONFIG_RT_USING_SDIO=y +CONFIG_RT_SDIO_STACK_SIZE=512 +CONFIG_RT_SDIO_THREAD_PRIORITY=15 +CONFIG_RT_MMCSD_STACK_SIZE=8192 +CONFIG_RT_MMCSD_THREAD_PREORITY=22 +CONFIG_RT_MMCSD_MAX_PARTITION=16 +# CONFIG_RT_SDIO_DEBUG is not set +CONFIG_RT_USING_SPI=y +# CONFIG_RT_USING_SPI_BITOPS is not set +CONFIG_RT_USING_QSPI=y +# CONFIG_RT_USING_SPI_MSD is not set +CONFIG_RT_USING_SFUD=y +CONFIG_RT_SFUD_USING_SFDP=y +CONFIG_RT_SFUD_USING_FLASH_INFO_TABLE=y +CONFIG_RT_SFUD_USING_QSPI=y +CONFIG_RT_SFUD_SPI_MAX_HZ=50000000 +# CONFIG_RT_DEBUG_SFUD is not set +# CONFIG_RT_USING_ENC28J60 is not set +# CONFIG_RT_USING_SPI_WIFI is not set +CONFIG_RT_USING_WDT=y +CONFIG_RT_USING_AUDIO=y +CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_SIZE=2048 +CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_COUNT=2 +CONFIG_RT_AUDIO_RECORD_PIPE_SIZE=2048 +CONFIG_RT_USING_SENSOR=y +CONFIG_RT_USING_SENSOR_CMD=y +CONFIG_RT_USING_TOUCH=y +CONFIG_RT_TOUCH_PIN_IRQ=y +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set +# CONFIG_RT_USING_WIFI is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB is not set +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# C/C++ and POSIX layer +# +CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 + +# +# POSIX (Portable Operating System Interface) layer +# +# CONFIG_RT_USING_POSIX_FS is not set +CONFIG_RT_USING_POSIX_DELAY=y +CONFIG_RT_USING_POSIX_CLOCK=y +# CONFIG_RT_USING_POSIX_TIMER is not set +# CONFIG_RT_USING_PTHREADS is not set +# CONFIG_RT_USING_MODULE is not set + +# +# Interprocess Communication (IPC) +# +# CONFIG_RT_USING_POSIX_PIPE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_QUEUE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE is not set + +# +# Socket is in the 'Network' category +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Network +# +# CONFIG_RT_USING_SAL is not set +# CONFIG_RT_USING_NETDEV is not set +# CONFIG_RT_USING_LWIP is not set +# CONFIG_RT_USING_AT is not set + +# +# Utilities +# +# CONFIG_RT_USING_RYM is not set +CONFIG_RT_USING_ULOG=y +# CONFIG_ULOG_OUTPUT_LVL_A is not set +# CONFIG_ULOG_OUTPUT_LVL_E is not set +# CONFIG_ULOG_OUTPUT_LVL_W is not set +CONFIG_ULOG_OUTPUT_LVL_I=y +# CONFIG_ULOG_OUTPUT_LVL_D is not set +CONFIG_ULOG_OUTPUT_LVL=6 +# CONFIG_ULOG_USING_ISR_LOG is not set +CONFIG_ULOG_ASSERT_ENABLE=y +CONFIG_ULOG_LINE_BUF_SIZE=128 +# CONFIG_ULOG_USING_ASYNC_OUTPUT is not set + +# +# log format +# +# CONFIG_ULOG_OUTPUT_FLOAT is not set +CONFIG_ULOG_USING_COLOR=y +CONFIG_ULOG_OUTPUT_TIME=y +CONFIG_ULOG_TIME_USING_TIMESTAMP=y +CONFIG_ULOG_OUTPUT_LEVEL=y +CONFIG_ULOG_OUTPUT_TAG=y +# CONFIG_ULOG_OUTPUT_THREAD_NAME is not set +CONFIG_ULOG_BACKEND_USING_CONSOLE=y +# CONFIG_ULOG_BACKEND_USING_FILE is not set +CONFIG_ULOG_USING_FILTER=y +# CONFIG_ULOG_USING_SYSLOG is not set +# CONFIG_RT_USING_UTEST is not set +# CONFIG_RT_USING_VAR_EXPORT is not set +# CONFIG_RT_USING_RT_LINK is not set +# CONFIG_RT_USING_VBUS is not set + +# +# RT-Thread Utestcases +# +# CONFIG_RT_USING_UTESTCASES is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_LWIP is not set +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_LIBMODBUS is not set +# CONFIG_PKG_USING_FREEMODBUS is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set +# CONFIG_PKG_USING_WIZNET is not set +# CONFIG_PKG_USING_ZB_COORDINATOR is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_EZ_IOT_OS is not set +# CONFIG_PKG_USING_IOTSHARP_SDK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set +# CONFIG_PKG_USING_PDULIB is not set +# CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set +# CONFIG_PKG_USING_MAVLINK is not set +# CONFIG_PKG_USING_BSAL is not set +# CONFIG_PKG_USING_AGILE_MODBUS is not set +# CONFIG_PKG_USING_AGILE_FTP is not set +# CONFIG_PKG_USING_EMBEDDEDPROTO is not set +# CONFIG_PKG_USING_RT_LINK_HW is not set +# CONFIG_PKG_USING_LORA_PKT_FWD is not set +# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set +# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set +# CONFIG_PKG_USING_HM is not set +# CONFIG_PKG_USING_SMALL_MODBUS is not set +# CONFIG_PKG_USING_NET_SERVER is not set +# CONFIG_PKG_USING_ZFTP is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_LIBSODIUM is not set +# CONFIG_PKG_USING_LIBHYDROGEN is not set +# CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set + +# +# language packages +# + +# +# JSON: JavaScript Object Notation, a lightweight data-interchange format +# +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_RAPIDJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_AGILE_JSMN is not set +# CONFIG_PKG_USING_PARSON is not set + +# +# XML: Extensible Markup Language +# +# CONFIG_PKG_USING_SIMPLE_XML is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_LUATOS_SOC is not set +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set +# CONFIG_PKG_USING_PIKASCRIPT is not set +# CONFIG_PKG_USING_RTT_RUST is not set + +# +# multimedia packages +# + +# +# u8g2: a monochrome graphic library +# +# CONFIG_PKG_USING_U8G2_OFFICIAL is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set +# CONFIG_PKG_USING_PDFGEN is not set +# CONFIG_PKG_USING_HELIX is not set +# CONFIG_PKG_USING_AZUREGUIX is not set +# CONFIG_PKG_USING_TOUCHGFX2RTT is not set +# CONFIG_PKG_USING_NUEMWIN is not set +# CONFIG_PKG_USING_MP3PLAYER is not set +# CONFIG_PKG_USING_TINYJPEG is not set +# CONFIG_PKG_USING_UGUI is not set + +# +# PainterEngine: A cross-platform graphics application framework written in C language +# +# CONFIG_PKG_USING_PAINTERENGINE is not set +# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set +# CONFIG_PKG_USING_MCURSES is not set +# CONFIG_PKG_USING_TERMBOX is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_GUIENGINE is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_SEGGER_RTT is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_ULOG_FILE is not set +# CONFIG_PKG_USING_LOGMGR is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_MEMORYPERF is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set +# CONFIG_PKG_USING_UMCN is not set +# CONFIG_PKG_USING_LWRB2RTT is not set +# CONFIG_PKG_USING_CPU_USAGE is not set +# CONFIG_PKG_USING_GBK2UTF8 is not set +# CONFIG_PKG_USING_VCONSOLE is not set +# CONFIG_PKG_USING_KDB is not set +# CONFIG_PKG_USING_WAMR is not set +# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set +# CONFIG_PKG_USING_LWLOG is not set +# CONFIG_PKG_USING_ANV_TRACE is not set +# CONFIG_PKG_USING_ANV_MEMLEAK is not set +# CONFIG_PKG_USING_ANV_TESTSUIT is not set +# CONFIG_PKG_USING_ANV_BENCH is not set +# CONFIG_PKG_USING_DEVMEM is not set +# CONFIG_PKG_USING_REGEX is not set +# CONFIG_PKG_USING_MEM_SANDBOX is not set +# CONFIG_PKG_USING_SOLAR_TERMS is not set +# CONFIG_PKG_USING_GAN_ZHI is not set +# CONFIG_PKG_USING_FDT is not set +# CONFIG_PKG_USING_CBOX is not set +# CONFIG_PKG_USING_SNOWFLAKE is not set +# CONFIG_PKG_USING_HASH_MATCH is not set +# CONFIG_PKG_USING_FIRE_PID_CURVE is not set +# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set +# CONFIG_PKG_USING_VOFA_PLUS is not set + +# +# system packages +# + +# +# enhanced kernel services +# +# CONFIG_PKG_USING_RT_MEMCPY_CM is not set +# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set +# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set + +# +# acceleration: Assembly language or algorithmic acceleration packages +# +# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set +# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set +# CONFIG_PKG_USING_QFPLIB_M3 is not set + +# +# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard +# +# CONFIG_PKG_USING_CMSIS_5 is not set +# CONFIG_PKG_USING_CMSIS_RTOS1 is not set +# CONFIG_PKG_USING_CMSIS_RTOS2 is not set + +# +# Micrium: Micrium software products porting for RT-Thread +# +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set +# CONFIG_PKG_USING_UCOSII_WRAPPER is not set +# CONFIG_PKG_USING_UC_CRC is not set +# CONFIG_PKG_USING_UC_CLK is not set +# CONFIG_PKG_USING_UC_COMMON is not set +# CONFIG_PKG_USING_UC_MODBUS is not set +# CONFIG_PKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_PERF_COUNTER is not set +# CONFIG_PKG_USING_FLASHDB is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_DFS_JFFS2 is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_PPOOL is not set +# CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_LPM is not set +# CONFIG_PKG_USING_TLSF is not set +# CONFIG_PKG_USING_EVENT_RECORDER is not set +# CONFIG_PKG_USING_ARM_2D is not set +# CONFIG_PKG_USING_MCUBOOT is not set +# CONFIG_PKG_USING_TINYUSB is not set +# CONFIG_PKG_USING_CHERRYUSB is not set +# CONFIG_PKG_USING_KMULTI_RTIMER is not set +# CONFIG_PKG_USING_TFDB is not set +# CONFIG_PKG_USING_QPC is not set +# CONFIG_PKG_USING_AGILE_UPGRADE is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_SENSORS_DRIVERS is not set +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_ADT74XX is not set +# CONFIG_PKG_USING_AS7341 is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ESP_IDF is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_WM_LIBRARIES is not set + +# +# Kendryte SDK +# +# CONFIG_PKG_USING_K210_SDK is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_MULTI_INFRARED is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_TOUCH_DRIVERS is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_NUCLEI_SDK is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set +# CONFIG_PKG_USING_WK2124 is not set +# CONFIG_PKG_USING_LY68L6400 is not set +# CONFIG_PKG_USING_DM9051 is not set +# CONFIG_PKG_USING_SSD1306 is not set +# CONFIG_PKG_USING_QKEY is not set +# CONFIG_PKG_USING_RS485 is not set +# CONFIG_PKG_USING_RS232 is not set +# CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set +# CONFIG_PKG_USING_SGM706 is not set +# CONFIG_PKG_USING_STM32WB55_SDK is not set +# CONFIG_PKG_USING_RDA58XX is not set +# CONFIG_PKG_USING_LIBNFC is not set +# CONFIG_PKG_USING_MFOC is not set +# CONFIG_PKG_USING_TMC51XX is not set +# CONFIG_PKG_USING_TCA9534 is not set +# CONFIG_PKG_USING_KOBUKI is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_MICRO_ROS is not set +# CONFIG_PKG_USING_MCP23008 is not set +# CONFIG_PKG_USING_BLUETRUM_SDK is not set +# CONFIG_PKG_USING_MISAKA_AT24CXX is not set +# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set +# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set +# CONFIG_PKG_USING_BL_MCU_SDK is not set +# CONFIG_PKG_USING_SOFT_SERIAL is not set +# CONFIG_PKG_USING_MB85RS16 is not set +# CONFIG_PKG_USING_CW2015 is not set +# CONFIG_PKG_USING_RFM300 is not set +# CONFIG_PKG_USING_IO_INPUT_FILTER is not set +# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set + +# +# AI packages +# +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_QUEST is not set +# CONFIG_PKG_USING_NAXOS is not set + +# +# miscellaneous packages +# + +# +# project laboratory +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# entertainment: terminal games and other interesting software packages +# +# CONFIG_PKG_USING_CMATRIX is not set +# CONFIG_PKG_USING_SL is not set +# CONFIG_PKG_USING_CAL is not set +# CONFIG_PKG_USING_ACLOCK is not set +# CONFIG_PKG_USING_THREES is not set +# CONFIG_PKG_USING_2048 is not set +# CONFIG_PKG_USING_SNAKE is not set +# CONFIG_PKG_USING_TETRIS is not set +# CONFIG_PKG_USING_DONUT is not set +# CONFIG_PKG_USING_COWSAY is not set +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_MINIZIP is not set +# CONFIG_PKG_USING_HEATSHRINK is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set +# CONFIG_PKG_USING_HELLO is not set +# CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_KI is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_CRCLIB is not set +# CONFIG_PKG_USING_LWGPS is not set +# CONFIG_PKG_USING_STATE_MACHINE is not set +# CONFIG_PKG_USING_DESIGN_PATTERN is not set +# CONFIG_PKG_USING_CONTROLLER is not set +# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set +# CONFIG_PKG_USING_MFBD is not set +# CONFIG_PKG_USING_SLCAN2RTT is not set +# CONFIG_PKG_USING_SOEM is not set +# CONFIG_PKG_USING_QPARAM is not set + +# +# Arduino libraries +# +# CONFIG_PKG_USING_RTDUINO is not set + +# +# Projects +# +# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set +# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set + +# +# Sensors +# +# CONFIG_PKG_USING_ARDUINO_SEEED_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_DHT is not set +# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSOR is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS1 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AHTX0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADT7410 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME680 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA219 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DHT is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM6DS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO055 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX1704X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMC56X3 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90393 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90395 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ICM20X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DPS310 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTS221 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT4X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT31 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL343 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AS726X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AMG88XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2320 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2315 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LTR329_LTR303 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP3XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MS8607 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90640 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMA8451 is not set +# CONFIG_PKG_USING_ADAFRUIT_MSA301 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPL115A2 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X_RVC is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS2MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM303DLH_MAG is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LC709203F is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CAP1188 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CCS811 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_NAU7802 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3DH is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8591 is not set + +# +# Display +# +# CONFIG_PKG_USING_ARDUINO_U8G2 is not set + +# +# Timing +# +# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set + +# +# Data Processing +# +# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set +# CONFIG_PKG_USING_ARDUINO_ARDUINOJSON is not set + +# +# Data Storage +# + +# +# Communication +# + +# +# Device Control +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8574 is not set + +# +# Other +# + +# +# Signal IO +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BUSIO is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCA8418 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP23017 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADS1X15 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AW9523 is not set + +# +# Uncategorized +# + +# +# Local packages options +# + +# +# Third-party packages options +# +# CONFIG_LPKG_USING_BONNIE is not set +CONFIG_LPKG_USING_CPU_USAGE=y +# CONFIG_LPKG_USING_RAMDISK is not set +# CONFIG_LPKG_USING_CHERRYUSB is not set +# CONFIG_LPKG_USING_ADBD is not set +# CONFIG_LPKG_USING_AWTK is not set +# CONFIG_LPKG_USING_LWIP is not set +# CONFIG_LPKG_USING_DFS_UFFS is not set +CONFIG_LPKG_USING_LITTLEFS=y +CONFIG_LPKG_LITTLEFS_PATH="/packages/third-party/littlefs" +# CONFIG_LPKG_USING_LITTLEFS_V090 is not set +# CONFIG_LPKG_USING_LITTLEFS_V170 is not set +# CONFIG_LPKG_USING_LITTLEFS_V172 is not set +# CONFIG_LPKG_USING_LITTLEFS_V201 is not set +# CONFIG_LPKG_USING_LITTLEFS_V205 is not set +# CONFIG_LPKG_USING_LITTLEFS_V214 is not set +# CONFIG_LPKG_USING_LITTLEFS_V220 is not set +# CONFIG_LPKG_USING_LITTLEFS_V221 is not set +# CONFIG_LPKG_USING_LITTLEFS_V230 is not set +# CONFIG_LPKG_USING_LITTLEFS_V250 is not set +CONFIG_LPKG_USING_LITTLEFS_LATEST_VERSION=y +CONFIG_LFS_READ_SIZE=256 +CONFIG_LFS_PROG_SIZE=256 +CONFIG_LFS_BLOCK_SIZE=4096 +CONFIG_LFS_CACHE_SIZE=256 +CONFIG_LFS_BLOCK_CYCLES=-1 +# CONFIG_DFS_LFS_READONLY is not set +CONFIG_LFS_THREADSAFE=y +CONFIG_LFS_LOOKAHEAD_MAX=128 +CONFIG_LPKG_LITTLEFS_VER="latest" + +# +# BenchMark Tests +# +CONFIG_AIC_PRINT_FLOAT_CUSTOM=y +# CONFIG_LPKG_USING_COREMARK is not set +# CONFIG_LPKG_USING_DHRYSTONE is not set +# CONFIG_LPKG_USING_STREAM is not set +# CONFIG_LPKG_USING_WHETSTONE is not set +# CONFIG_LPKG_USING_LINPACK is not set +# CONFIG_LPKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_LPKG_USING_I2C_TOOLS is not set +# CONFIG_LPKG_USING_BEEP is not set +# CONFIG_LPKG_USING_MEMLEAK_CHECK is not set +# CONFIG_LPKG_USING_WEBCLIENT is not set +# CONFIG_LPKG_USING_HTTP_OTA_DOWNLOADER is not set +# CONFIG_LPKG_USING_RPMSG_LITE is not set +# CONFIG_LPKG_RPMSG_LITE_CUSTOM_CONFIG is not set +# CONFIG_LPKG_USING_PROTOBUF_C is not set +# CONFIG_LPKG_USING_FREETYPE is not set +# CONFIG_LPKG_USING_RTT_AUTO_EXE_CMD is not set +# CONFIG_LPKG_USING_NETUTILS is not set +# CONFIG_LPKG_USING_LIBMODBUS is not set +# CONFIG_LPKG_USING_PTPD is not set +# CONFIG_LPKG_USING_CJSON is not set +# CONFIG_LPKG_USING_MBEDTLS is not set +# CONFIG_LPKG_USING_AT24CXX is not set +# CONFIG_LPKG_USING_ZLIB is not set +# CONFIG_LPKG_USING_SQLITE is not set +# CONFIG_LPKG_USING_DFS is not set +# CONFIG_LPKG_USING_MAD is not set +# CONFIG_LPKG_USING_LIBFLAC is not set +# CONFIG_LPKG_USING_FDTLIB is not set +# CONFIG_LPKG_USING_GIF is not set +# CONFIG_LPKG_USING_MICROPYTHON is not set + +# +# ArtInChip packages options +# +CONFIG_LPKG_MPP=y +# CONFIG_AIC_MPP_PLAYER_INTERFACE is not set +# CONFIG_AIC_MPP_RECORDER_INTERFACE is not set +CONFIG_AIC_MPP_VIN=y +CONFIG_AIC_MPP_VIN_BUF_SIZE=1843264 +# CONFIG_AIC_MPP_FB_TEST is not set +# CONFIG_AIC_STARTUP_UI_SHOW is not set +# CONFIG_AIC_MPP_AICP_DEC_ENABLE is not set +# CONFIG_LPKG_USING_ENV is not set +# CONFIG_LPKG_USING_USERID is not set +# CONFIG_LPKG_USING_PINMUX_CHECHK is not set +# CONFIG_LPKG_USING_OTA_DOWNLOADER is not set +# CONFIG_LPKG_BURN_IN is not set +# CONFIG_AIC_USING_IPMANAGER is not set +CONFIG_AIC_USING_BARCODE_DEMO=y + +# +# Drivers options +# +CONFIG_AIC_GPIO_IRQ_DRV_EN=y +# CONFIG_AIC_I2C_INTERRUPT_MODE is not set +CONFIG_AIC_SPINOR_DRV=y +# CONFIG_AIC_SPINAND_DRV is not set +# CONFIG_AIC_SPINAND_CONT_READ is not set + +# +# Peripheral +# +# CONFIG_LPKG_USING_SPINAND is not set +CONFIG_LPKG_USING_SFUD=y +# CONFIG_AIC_NFTL_SUPPORT is not set +# CONFIG_AIC_BT_BT8858A is not set +CONFIG_AIC_USING_CAMERA=y +# CONFIG_AIC_USING_CAMERA_OV7670 is not set +# CONFIG_AIC_USING_CAMERA_OV5640 is not set +# CONFIG_AIC_USING_CAMERA_OV2659 is not set +# CONFIG_AIC_USING_CAMERA_OV2640 is not set +CONFIG_AIC_USING_CAMERA_GC0308=y +# CONFIG_AIC_USING_CAMERA_GC032A is not set +# CONFIG_AIC_USING_CAMERA_GM7150 is not set +# CONFIG_AIC_USING_CAMERA_SC030IOT is not set +# CONFIG_AIC_USING_CAMERA_TP2825 is not set +CONFIG_AIC_CAMERA_I2C_CHAN=2 +CONFIG_AIC_CAMERA_RST_PIN="PD.9" +CONFIG_AIC_CAMERA_PWDN_PIN="PD.10" + +# +# External Audio Codec Support +# +# CONFIG_AIC_I2S_CODEC_SELECT is not set + +# +# Drivers debug +# +# CONFIG_AIC_CMU_DRV_DEBUG is not set +# CONFIG_AIC_GPIO_DRV_DEBUG is not set +# CONFIG_AIC_DMA_DRV_DEBUG is not set +# CONFIG_AIC_UART_DRV_DEBUG is not set +# CONFIG_AIC_I2C_DRV_DEBUG is not set +# CONFIG_AIC_RTC_DRV_DEBUG is not set +# CONFIG_AIC_QSPI_DRV_DEBUG is not set +# CONFIG_AIC_SPINOR_SFUD_DEBUG is not set +CONFIG_AIC_SPINOR_SFUD_WP_DEBUG=y +# CONFIG_AIC_FB_DRV_DEBUG is not set +# CONFIG_AIC_CACHE_LINE_DEBUG is not set + +# +# Drivers examples +# +# CONFIG_AIC_CMU_DRV_TEST is not set +# CONFIG_AIC_GPIO_DRV_TEST is not set +# CONFIG_AIC_GPIO_TWINKLE_TEST is not set +# CONFIG_AIC_GPIO_KEY_TEST is not set +# CONFIG_AIC_DMA_DRV_TEST is not set +# CONFIG_AIC_UART_DRV_TEST is not set +# CONFIG_AIC_RTC_DRV_TEST is not set +# CONFIG_AIC_QSPI_DRV_TEST is not set +# CONFIG_AIC_SPINOR_DRV_TEST is not set +# CONFIG_AIC_SDMC_DRV_TEST is not set +# CONFIG_AIC_MMC_TEST is not set +# CONFIG_AIC_FILE_CRC32_TEST is not set +# CONFIG_AIC_MTD_LOAD_FILE_TEST is not set +# CONFIG_AIC_DISPLAY_TEST is not set +# CONFIG_AIC_GE_TEST is not set +# CONFIG_AIC_VE_TEST is not set +# CONFIG_AIC_I2C_DRV_TEST is not set +# CONFIG_AIC_CAMERA_DRV_TEST is not set +# CONFIG_AIC_DVP_TEST is not set +# CONFIG_AIC_WDT_DRV_TEST is not set +# CONFIG_AIC_ZLIB_TEST is not set +# CONFIG_AIC_MONKEY_TEST is not set +# CONFIG_AIC_SOFT_AES_TEST is not set +# CONFIG_AIC_SID_BARE_TEST is not set +# CONFIG_AIC_IOPMP_TEST is not set +# CONFIG_AIC_MEM_API_TEST is not set +# CONFIG_AIC_FILE_SYSTEM_TEST is not set diff --git a/target/d12x/common/Kconfig.board b/target/d12x/common/Kconfig.board index 5ed19afe..5fddd385 100644 --- a/target/d12x/common/Kconfig.board +++ b/target/d12x/common/Kconfig.board @@ -51,6 +51,12 @@ source "bsp/artinchip/drv/uart/Kconfig.dev" # i2c device global option #--------------------------- +config AIC_USING_SOFT_I2C + bool "Using SOFT_I2C" + default n + select RT_USING_I2C_BITOPS + select AIC_I2C_DRV + config AIC_USING_I2C0 bool "Using I2C0" default n @@ -202,6 +208,12 @@ menu "SPI1 Parameter" bool "Dynamic DMA channel SPI1" default n + config AIC_QSPI1_BUS_SPI + bool "Work in SPI BUS Mode" + default n + select AIC_QSPI_DRV + depends on AIC_QSPI1_BUS_WIDTH_1 + endmenu source "bsp/artinchip/drv/qspi/Kconfig.dev" diff --git a/target/d12x/demo68-nand/pack/bootloader.bin b/target/d12x/demo68-nand/pack/bootloader.bin index 1399b10a..68d6f941 100755 Binary files a/target/d12x/demo68-nand/pack/bootloader.bin and b/target/d12x/demo68-nand/pack/bootloader.bin differ diff --git a/target/d12x/demo68-nand/pack/image_cfg.json b/target/d12x/demo68-nand/pack/image_cfg.json index 81a20db3..8c430d59 100644 --- a/target/d12x/demo68-nand/pack/image_cfg.json +++ b/target/d12x/demo68-nand/pack/image_cfg.json @@ -100,8 +100,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d12x/demo68-nor/pack/bootloader.bin b/target/d12x/demo68-nor/pack/bootloader.bin index 5bcdb83a..21db8dd6 100755 Binary files a/target/d12x/demo68-nor/pack/bootloader.bin and b/target/d12x/demo68-nor/pack/bootloader.bin differ diff --git a/target/d12x/demo68-nor/pack/image_cfg.json b/target/d12x/demo68-nor/pack/image_cfg.json index 7f8ee2b8..18c4aaf3 100644 --- a/target/d12x/demo68-nor/pack/image_cfg.json +++ b/target/d12x/demo68-nor/pack/image_cfg.json @@ -83,8 +83,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d12x/hmi-nor/pack/bootloader.bin b/target/d12x/hmi-nor/pack/bootloader.bin index 86821744..3c7db337 100755 Binary files a/target/d12x/hmi-nor/pack/bootloader.bin and b/target/d12x/hmi-nor/pack/bootloader.bin differ diff --git a/target/d12x/hmi-nor/pack/image_cfg.json b/target/d12x/hmi-nor/pack/image_cfg.json index ce12905a..73a7b96f 100644 --- a/target/d12x/hmi-nor/pack/image_cfg.json +++ b/target/d12x/hmi-nor/pack/image_cfg.json @@ -83,8 +83,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d13x/common/Kconfig.board b/target/d13x/common/Kconfig.board index 8a8a8561..9f912695 100644 --- a/target/d13x/common/Kconfig.board +++ b/target/d13x/common/Kconfig.board @@ -14,7 +14,7 @@ source "bsp/artinchip/drv/gpio/Kconfig.dev" # Interface Class #================================================ -comment "Interface Related: " +comment "Interface Related:" #--------------------------- # uart device global option @@ -66,6 +66,12 @@ source "bsp/artinchip/drv/uart/Kconfig.dev" # i2c device global option #--------------------------- +config AIC_USING_SOFT_I2C + bool "Using SOFT_I2C" + default n + select RT_USING_I2C_BITOPS + select AIC_I2C_DRV + config AIC_USING_I2C0 bool "Using I2C0" default n @@ -331,7 +337,7 @@ source "packages/third-party/lwip/contrib/ports/drv/aic/Kconfig.dev" # Storage Class #================================================ -comment "Storage Related: " +comment "Storage Related:" #-------------------------------------------- # qspi device global option @@ -406,6 +412,12 @@ menu "SPI1 Parameter" bool "Dynamic DMA channel SPI1" default n + config AIC_QSPI1_BUS_SPI + bool "Work in SPI BUS Mode" + default n + select AIC_QSPI_DRV + depends on AIC_QSPI1_BUS_WIDTH_1 + endmenu config AIC_USING_QSPI2 @@ -441,6 +453,11 @@ menu "SPI2 Parameter" bool "Dynamic DMA channel SPI2" default n + config AIC_QSPI2_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu config AIC_USING_QSPI3 @@ -476,6 +493,11 @@ menu "SPI3 Parameter" bool "Dynamic DMA channel SPI3" default n + config AIC_QSPI3_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu source "bsp/artinchip/drv/qspi/Kconfig.dev" @@ -511,7 +533,7 @@ source "bsp/peripheral/wireless/Kconfig" # Analog Class #================================================ -comment "Analog Related: " +comment "Analog Related:" #--------------------------- # TSEN device global option @@ -599,7 +621,7 @@ endmenu # MutiMedia Class #================================================ -comment "MutiMedia Related: " +comment "MutiMedia Related:" #-------------------------------------------- # DE device global option @@ -688,7 +710,7 @@ endif # System Class #================================================ -comment "System Related: " +comment "System Related:" #--------------------------- # DMA device global option @@ -1084,7 +1106,7 @@ source "bsp/artinchip/drv/pm/Kconfig" # Security Class #================================================ -comment "Security Related: " +comment "Security Related:" #-------------------------------------------- # spienc device global option diff --git a/target/d13x/demo68-nor/pack/bootloader.bin b/target/d13x/demo68-nor/pack/bootloader.bin index 8fdcd581..74120c33 100755 Binary files a/target/d13x/demo68-nor/pack/bootloader.bin and b/target/d13x/demo68-nor/pack/bootloader.bin differ diff --git a/target/d13x/demo68-nor/pack/image_cfg.json b/target/d13x/demo68-nor/pack/image_cfg.json index 0b10bce9..8e1bf1c1 100644 --- a/target/d13x/demo68-nor/pack/image_cfg.json +++ b/target/d13x/demo68-nor/pack/image_cfg.json @@ -82,8 +82,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d13x/demo88-nand/pack/bootloader.bin b/target/d13x/demo88-nand/pack/bootloader.bin index baaac110..a4febf59 100755 Binary files a/target/d13x/demo88-nand/pack/bootloader.bin and b/target/d13x/demo88-nand/pack/bootloader.bin differ diff --git a/target/d13x/demo88-nand/pack/image_cfg.json b/target/d13x/demo88-nand/pack/image_cfg.json index f028ac30..933f3caf 100644 --- a/target/d13x/demo88-nand/pack/image_cfg.json +++ b/target/d13x/demo88-nand/pack/image_cfg.json @@ -99,8 +99,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d13x/demo88-nor/pack/bootloader.bin b/target/d13x/demo88-nor/pack/bootloader.bin index 906ea65c..03c65800 100755 Binary files a/target/d13x/demo88-nor/pack/bootloader.bin and b/target/d13x/demo88-nor/pack/bootloader.bin differ diff --git a/target/d13x/demo88-nor/pack/image_cfg.json b/target/d13x/demo88-nor/pack/image_cfg.json index 1b1b8ac6..830cebce 100644 --- a/target/d13x/demo88-nor/pack/image_cfg.json +++ b/target/d13x/demo88-nor/pack/image_cfg.json @@ -82,8 +82,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d13x/kunlunpi88-nor/pack/bootloader.bin b/target/d13x/kunlunpi88-nor/pack/bootloader.bin index 241e7891..1a64c984 100755 Binary files a/target/d13x/kunlunpi88-nor/pack/bootloader.bin and b/target/d13x/kunlunpi88-nor/pack/bootloader.bin differ diff --git a/target/d13x/kunlunpi88-nor/pack/image_cfg.json b/target/d13x/kunlunpi88-nor/pack/image_cfg.json index 643cd6cf..30b4e02e 100644 --- a/target/d13x/kunlunpi88-nor/pack/image_cfg.json +++ b/target/d13x/kunlunpi88-nor/pack/image_cfg.json @@ -82,8 +82,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x40300000", - "entry point": "0x40300100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/d21x/common/Kconfig.board b/target/d21x/common/Kconfig.board index 1c70ea88..f9d565b9 100644 --- a/target/d21x/common/Kconfig.board +++ b/target/d21x/common/Kconfig.board @@ -66,6 +66,12 @@ source "bsp/artinchip/drv/uart/Kconfig.dev" # i2c device global option #--------------------------- +config AIC_USING_SOFT_I2C + bool "Using SOFT_I2C" + default n + select RT_USING_I2C_BITOPS + select AIC_I2C_DRV + config AIC_USING_I2C0 bool "Using I2C0" default n @@ -387,6 +393,12 @@ menu "SPI1 Parameter" bool "Dynamic DMA channel SPI1" default n + config AIC_QSPI1_BUS_SPI + bool "Work in SPI BUS Mode" + default n + select AIC_QSPI_DRV + depends on AIC_QSPI1_BUS_WIDTH_1 + endmenu config AIC_USING_QSPI2 @@ -422,6 +434,11 @@ menu "SPI2 Parameter" bool "Dynamic DMA channel SPI2" default n + config AIC_QSPI2_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu config AIC_USING_QSPI3 @@ -457,6 +474,11 @@ menu "SPI3 Parameter" bool "Dynamic DMA channel SPI3" default n + config AIC_QSPI3_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu source "bsp/artinchip/drv/qspi/Kconfig.dev" diff --git a/target/d21x/d215-demo88-nand/pack/bootloader.bin b/target/d21x/d215-demo88-nand/pack/bootloader.bin index 90851f79..8f3ad0fb 100755 Binary files a/target/d21x/d215-demo88-nand/pack/bootloader.bin and b/target/d21x/d215-demo88-nand/pack/bootloader.bin differ diff --git a/target/d21x/d215-demo88-nand/pack/image_cfg.json b/target/d21x/d215-demo88-nand/pack/image_cfg.json index 3d0510cd..5caf1b68 100644 --- a/target/d21x/d215-demo88-nand/pack/image_cfg.json +++ b/target/d21x/d215-demo88-nand/pack/image_cfg.json @@ -99,8 +99,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/d21x/d215-demo88-nor/pack/bootloader.bin b/target/d21x/d215-demo88-nor/pack/bootloader.bin index 1dba7a39..4a3d6a90 100755 Binary files a/target/d21x/d215-demo88-nor/pack/bootloader.bin and b/target/d21x/d215-demo88-nor/pack/bootloader.bin differ diff --git a/target/d21x/d215-demo88-nor/pack/image_cfg.json b/target/d21x/d215-demo88-nor/pack/image_cfg.json index b2014186..dd03e447 100644 --- a/target/d21x/d215-demo88-nor/pack/image_cfg.json +++ b/target/d21x/d215-demo88-nor/pack/image_cfg.json @@ -85,8 +85,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/d21x/demo100-nor/pack/bootloader.bin b/target/d21x/demo100-nor/pack/bootloader.bin index 69d5b301..94d60cb3 100755 Binary files a/target/d21x/demo100-nor/pack/bootloader.bin and b/target/d21x/demo100-nor/pack/bootloader.bin differ diff --git a/target/d21x/demo100-nor/pack/image_cfg.json b/target/d21x/demo100-nor/pack/image_cfg.json index 452b32e5..80b95fce 100644 --- a/target/d21x/demo100-nor/pack/image_cfg.json +++ b/target/d21x/demo100-nor/pack/image_cfg.json @@ -75,8 +75,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/d21x/demo100-nor/pinmux.c b/target/d21x/demo100-nor/pinmux.c index 6e3eb89d..821b7f95 100644 --- a/target/d21x/demo100-nor/pinmux.c +++ b/target/d21x/demo100-nor/pinmux.c @@ -296,6 +296,16 @@ struct aic_pinmux aic_pinmux_config[] = { #ifdef AIC_USING_GPAI7 {2, PIN_PULL_DIS, 3, "PA.7"}, #endif +#ifdef AIC_USING_AUDIO +#ifdef AIC_AUDIO_PLAYBACK + {4, PIN_PULL_DIS, 3, "PE.11"}, + {1, PIN_PULL_DIS, 3, AIC_AUDIO_PA_ENABLE_GPIO}, +#endif +#ifdef AIC_AUDIO_DMIC + {4, PIN_PULL_DIS, 3, "PF.14"}, + {4, PIN_PULL_DIS, 3, "PF.15"}, +#endif +#endif #ifdef AIC_USING_RTP {2, PIN_PULL_DIS, 3, "PA.8"}, {2, PIN_PULL_DIS, 3, "PA.9"}, diff --git a/target/d21x/demo128-nand/pack/bootloader.bin b/target/d21x/demo128-nand/pack/bootloader.bin index 05241063..c584d171 100755 Binary files a/target/d21x/demo128-nand/pack/bootloader.bin and b/target/d21x/demo128-nand/pack/bootloader.bin differ diff --git a/target/d21x/demo128-nand/pack/image_cfg.json b/target/d21x/demo128-nand/pack/image_cfg.json index b4e5f563..64eafd82 100644 --- a/target/d21x/demo128-nand/pack/image_cfg.json +++ b/target/d21x/demo128-nand/pack/image_cfg.json @@ -99,8 +99,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/d21x/demo88-nand/pack/bootloader.bin b/target/d21x/demo88-nand/pack/bootloader.bin index 3341d1d9..c1e419f0 100755 Binary files a/target/d21x/demo88-nand/pack/bootloader.bin and b/target/d21x/demo88-nand/pack/bootloader.bin differ diff --git a/target/d21x/demo88-nand/pack/image_cfg.json b/target/d21x/demo88-nand/pack/image_cfg.json index 3d0510cd..5caf1b68 100644 --- a/target/d21x/demo88-nand/pack/image_cfg.json +++ b/target/d21x/demo88-nand/pack/image_cfg.json @@ -99,8 +99,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/d21x/demo88-nor/pack/bootloader.bin b/target/d21x/demo88-nor/pack/bootloader.bin index 82dde962..2657828c 100755 Binary files a/target/d21x/demo88-nor/pack/bootloader.bin and b/target/d21x/demo88-nor/pack/bootloader.bin differ diff --git a/target/d21x/demo88-nor/pack/image_cfg.json b/target/d21x/demo88-nor/pack/image_cfg.json index 0a8d5ab8..97d4eb39 100644 --- a/target/d21x/demo88-nor/pack/image_cfg.json +++ b/target/d21x/demo88-nor/pack/image_cfg.json @@ -84,8 +84,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x43E00000", - "entry point": "0x43E00100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "ddr_init.bin", diff --git a/target/g73x/common/Kconfig.board b/target/g73x/common/Kconfig.board index 1f897107..e4c0114b 100644 --- a/target/g73x/common/Kconfig.board +++ b/target/g73x/common/Kconfig.board @@ -14,7 +14,7 @@ source "bsp/artinchip/drv/gpio/Kconfig.dev" # Interface Class #================================================ -comment "Interface Related: " +comment "Interface Related:" #--------------------------- # uart device global option @@ -66,6 +66,12 @@ source "bsp/artinchip/drv/uart/Kconfig.dev" # i2c device global option #--------------------------- +config AIC_USING_SOFT_I2C + bool "Using SOFT_I2C" + default n + select RT_USING_I2C_BITOPS + select AIC_I2C_DRV + config AIC_USING_I2C0 bool "Using I2C0" default n @@ -331,7 +337,7 @@ source "packages/third-party/lwip/contrib/ports/drv/aic/Kconfig.dev" # Storage Class #================================================ -comment "Storage Related: " +comment "Storage Related:" #-------------------------------------------- # qspi device global option @@ -406,6 +412,12 @@ menu "SPI1 Parameter" bool "Dynamic DMA channel SPI1" default n + config AIC_QSPI1_BUS_SPI + bool "Work in SPI BUS Mode" + default n + select AIC_QSPI_DRV + depends on AIC_QSPI1_BUS_WIDTH_1 + endmenu config AIC_USING_QSPI2 @@ -441,6 +453,11 @@ menu "SPI2 Parameter" bool "Dynamic DMA channel SPI2" default n + config AIC_QSPI2_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu config AIC_USING_QSPI3 @@ -476,6 +493,11 @@ menu "SPI3 Parameter" bool "Dynamic DMA channel SPI3" default n + config AIC_QSPI3_BUS_SPI + bool "Work in SPI BUS Mode" + default y + select AIC_QSPI_DRV + endmenu source "bsp/artinchip/drv/qspi/Kconfig.dev" @@ -511,7 +533,7 @@ source "bsp/peripheral/wireless/Kconfig" # Analog Class #================================================ -comment "Analog Related: " +comment "Analog Related:" #--------------------------- # TSEN device global option @@ -599,7 +621,7 @@ endmenu # MutiMedia Class #================================================ -comment "MutiMedia Related: " +comment "MutiMedia Related:" #-------------------------------------------- # DE device global option @@ -688,7 +710,7 @@ endif # System Class #================================================ -comment "System Related: " +comment "System Related:" #--------------------------- # DMA device global option @@ -1085,7 +1107,7 @@ source "bsp/artinchip/drv/pm/Kconfig" # Security Class #================================================ -comment "Security Related: " +comment "Security Related:" #-------------------------------------------- # spienc device global option diff --git a/target/g73x/demo100-nor/pack/bootloader.bin b/target/g73x/demo100-nor/pack/bootloader.bin index c6e4463c..b8a988ea 100755 Binary files a/target/g73x/demo100-nor/pack/bootloader.bin and b/target/g73x/demo100-nor/pack/bootloader.bin differ diff --git a/target/g73x/demo100-nor/pack/image_cfg.json b/target/g73x/demo100-nor/pack/image_cfg.json index 2e0bb8e4..d6fdbd31 100644 --- a/target/g73x/demo100-nor/pack/image_cfg.json +++ b/target/g73x/demo100-nor/pack/image_cfg.json @@ -60,8 +60,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x30100000", - "entry point": "0x30100100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/g73x/demo68-nor/pack/bootloader.bin b/target/g73x/demo68-nor/pack/bootloader.bin index 7bdf4318..498bb7e2 100755 Binary files a/target/g73x/demo68-nor/pack/bootloader.bin and b/target/g73x/demo68-nor/pack/bootloader.bin differ diff --git a/target/g73x/demo68-nor/pack/image_cfg.json b/target/g73x/demo68-nor/pack/image_cfg.json index 500066d5..3857ea96 100644 --- a/target/g73x/demo68-nor/pack/image_cfg.json +++ b/target/g73x/demo68-nor/pack/image_cfg.json @@ -60,8 +60,8 @@ "head_ver": "0x00010001", "loader": { "file": "bootloader.bin", - "load address": "0x30100000", - "entry point": "0x30100100", // 256 byte aic header + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header }, "resource": { "private": "pbp_cfg.bin", diff --git a/target/g73x/scan/SConscript b/target/g73x/scan/SConscript new file mode 100755 index 00000000..59034ff9 --- /dev/null +++ b/target/g73x/scan/SConscript @@ -0,0 +1,14 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = GetCurrentDir() + +# add the board drivers. +src = Glob("*.c") + Glob("*.cpp") + Glob("*.S") + +LOCAL_CPPPATH = [cwd] +CPPPATH = [cwd + '/include'] +group = DefineGroup('Board', src, depend = [''], LOCAL_CPPPATH = LOCAL_CPPPATH, CPPPATH = CPPPATH) + +Return('group') diff --git a/target/g73x/scan/board.c b/target/g73x/scan/board.c new file mode 100644 index 00000000..79e1a352 --- /dev/null +++ b/target/g73x/scan/board.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: weilin.peng@artinchip.com + */ +#include +#include +#include "board.h" + +extern void aic_board_pinmux_init(void); +extern void aic_board_sysclk_init(void); + +#if defined(KERNEL_RTTHREAD) +#include +#include +#include + +extern size_t __heap_start; +extern size_t __heap_end; + +#ifdef RT_USING_MEMHEAP +extern size_t __sram_cma_heap_start; +extern size_t __sram_cma_heap_end; + +struct aic_memheap +{ + aic_mem_region_t type; + char * name; + void * begin_addr; + void * end_addr; + struct rt_memheap heap; + struct rt_mutex lock; +}; + +struct aic_memheap aic_memheaps[] = { +#if defined(AIC_PSRAM_CMA_EN) || defined(AIC_SRAM1_CMA_EN) + {MEM_CMA, "heap_cma", (void *)&__cma_heap_start, (void *)&__cma_heap_end}, +#endif +}; + +void aic_memheap_init(void) +{ + rt_ubase_t begin_align; + rt_ubase_t end_align; + int i = 0; + + for (i=0; i begin_align); + + rt_memheap_init(&aic_memheaps[i].heap, aic_memheaps[i].name, + (void *)begin_align, end_align - begin_align); + rt_mutex_init(&aic_memheaps[i].lock, aic_memheaps[i].name, RT_IPC_FLAG_PRIO); + } +} + +void *aic_memheap_malloc(int type, size_t size) +{ + void *ptr; + int i = 0; + + for (i=0; i= sizeof(aic_memheaps)/sizeof(struct aic_memheap)) + return NULL; + + /* Enter critical zone */ + rt_mutex_take(&aic_memheaps[i].lock, RT_WAITING_FOREVER); + /* allocate memory block from system heap */ + ptr = rt_memheap_alloc(&aic_memheaps[i].heap, size); + /* Exit critical zone */ + rt_mutex_release(&aic_memheaps[i].lock); + + return ptr; +} + +void aic_memheap_free(int type, void *rmem) +{ + int i = 0; + + if (rmem == RT_NULL) + return; + + for (i=0; i= sizeof(aic_memheaps)/sizeof(struct aic_memheap)) + return; + + /* Enter critical zone */ + rt_mutex_take(&aic_memheaps[i].lock, RT_WAITING_FOREVER); + rt_memheap_free(rmem); + /* Exit critical zone */ + rt_mutex_release(&aic_memheaps[i].lock); +} +#endif + +/** + * This function will initial smart-evb board. + */ +void rt_hw_board_init(void) +{ + aic_board_sysclk_init(); + aic_board_pinmux_init(); + +#ifdef RT_USING_HEAP + rt_system_heap_init((void *)&__heap_start, (void *)&__heap_end); +#if (!defined(QEMU_RUN) && defined(RT_USING_MEMHEAP)) + aic_memheap_init(); +#endif +#endif + +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif + +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#endif +} + +#elif defined(KERNEL_FREERTOS) +#elif defined(KERNEL_BAREMETAL) +#include + +void aic_hw_board_init(void) +{ +#ifdef TLSF_MEM_HEAP + aic_tlsf_heap_init(); +#endif + aic_board_sysclk_init(); + aic_board_pinmux_init(); +} +#endif + +#ifdef RT_USING_DFS_MNTTABLE +#include +/*@}*/ +#ifdef RT_USING_DFS_ROMFS +#include "dfs_romfs.h" +static const struct romfs_dirent _mountpoint_root[] = +{ + {ROMFS_DIRENT_DIR, "ram", RT_NULL, 0}, + {ROMFS_DIRENT_DIR, "data", RT_NULL, 0}, + {ROMFS_DIRENT_DIR, "rodata", RT_NULL, 0}, + {ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0}, + {ROMFS_DIRENT_DIR, "udisk", RT_NULL, 0}, +}; +const struct romfs_dirent romfs_root = +{ + ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_mountpoint_root, ARRAY_SIZE(_mountpoint_root) +}; +#endif +const struct dfs_mount_tbl mount_table[] = { +#ifdef RT_USING_DFS_ROMFS + {RT_NULL, "/", "rom", 0, &romfs_root, 0}, +#endif +#ifdef LPKG_RAMDISK_TYPE_INITDATA + {"ramdisk0", "/ram", "elm", 0, 0, 0}, +#endif +#ifndef AIC_AB_SYSTEM_INTERFACE +#if (defined(AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_0) || defined(AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_1)) + {"blk_rodata", "/rodata", "elm", 0, 0, 0}, +#endif +#endif +#ifdef LPKG_USING_LITTLEFS + {"data", "/data", "lfs", 0, 0, 0}, +#endif +#ifdef LPKG_USING_DFS_UFFS + {"data", "/data", "uffs", 0, 0, 1}, +#endif +#ifdef AIC_USING_SDMC1 + {"sd0p0", "/sdcard", "elm", 0, 0, 0}, + {"sd0", "/sdcard", "elm", 0, 0, 0}, +#endif +#if (defined(AIC_USING_USB0_HOST) || defined(AIC_USING_USB0_OTG) || defined(AIC_USING_USB1_HOST)) + {"udisk", "/udisk", "elm", 0, 0, 0xFF}, +#endif + {0} +}; +#endif diff --git a/target/g73x/scan/include/board.h b/target/g73x/scan/include/board.h new file mode 100644 index 00000000..6648b064 --- /dev/null +++ b/target/g73x/scan/include/board.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: weilin.peng@artinchip.com + */ + +#ifndef __AIC_BOARD_H__ +#define __AIC_BOARD_H__ + +#include + +#if defined(KERNEL_RTTHREAD) +#elif defined(KERNEL_FREERTOS) +#elif defined(KERNEL_BAREMETAL) +void aic_hw_board_init(void); +#endif + +#endif /* __AIC_BOARD_H__ */ diff --git a/target/g73x/scan/pack/env.txt b/target/g73x/scan/pack/env.txt new file mode 100644 index 00000000..7846c5b8 --- /dev/null +++ b/target/g73x/scan/pack/env.txt @@ -0,0 +1,13 @@ +osAB_next=A +osAB_now=A +rodataAB_next=A +rodataAB_now=A +dataAB_next=A +dataAB_now=A +upgrade_available=0 +bootlimit=5 +bootcount=0 +rodata_partname=blk_rodata +rodata_partname_r=blk_rodata_r +data_partname=blk_data +data_partname_r=blk_data_r diff --git a/target/g73x/scan/pack/image_cfg.json b/target/g73x/scan/pack/image_cfg.json new file mode 100644 index 00000000..37e680ce --- /dev/null +++ b/target/g73x/scan/pack/image_cfg.json @@ -0,0 +1,85 @@ +{ + "spi-nor": { // Device, The name should be the same with string in image:info:media:type + "size": "2m", // Size of SPI NOR + "partitions": { + "spl": { "size": "256k" }, + "env": { "size": "128k" }, + "os": { "size": "1m" }, + + }, + }, + "image": { + "info": { // Header information about image + "platform": "g73x", + "product": "scan", + "version": "1.0.0", + "media": { + "type": "spi-nor", + "device_id": 0, + } + }, + "updater": { // Image writer which is downloaded to RAM by USB + "spl": { + "file": "bootloader.aic", + "attr": ["required", "run"], + "ram": "0x30100000" + }, + }, + "target": { // Image components which will be burn to device's partitions + "spl": { + "file": "bootloader.aic", + "attr": ["mtd", "required"], + "part": ["spl"] + }, + "env": { + "file": "env.bin", + "attr": ["mtd", "optional"], + "part": ["env"] + }, + "os": { + "file": "g73x_os.itb", + "attr": ["mtd", "required"], + "part": ["os"] + }, + }, + }, + "pre-process": { // Pre-proccess to generate image components from raw data + "aicimage": { // Create aic boot image + "pbp_ext.aic": { + "head_ver": "0x00010001", + "resource": { + "pbp": "g73x.pbp", + "private": "pbp_cfg.bin", + }, + // combine to use with loader.aic + "with_ext": "true", + }, + "loader.aic": { + "head_ver": "0x00010001", + "loader": { + "file": "bootloader.bin", + "load address": "CONFIG_AIC_BOOTLOADER_LOAD_BASE", + "entry point": "CONFIG_AIC_BOOTLOADER_TEXT_BASE", // 256 byte aic header + }, + "resource": { + "private": "pbp_cfg.bin", + }, + }, + }, + "concatenate": { // cat files in order + "bootloader.aic": ["pbp_ext.aic", "loader.aic"], + }, + "itb": { // Create itb image from its + "g73x_os.itb": { + "its": "g73x_os.its" + }, + }, + "uboot_env": { // Create env data from txt + "env.bin": { + "file": "env.txt", + "size": "4096", + "redundant": "enable", + }, + }, + }, +} diff --git a/target/g73x/scan/pack/ota-subimgs.cfg b/target/g73x/scan/pack/ota-subimgs.cfg new file mode 100644 index 00000000..13f8e71e --- /dev/null +++ b/target/g73x/scan/pack/ota-subimgs.cfg @@ -0,0 +1,7 @@ +[image] +size = ""; +version = "1.0.0"; + +[file] +ota_info.bin:file; +g73x_os.itb:os; diff --git a/target/g73x/scan/pack/pbp_cfg.json b/target/g73x/scan/pack/pbp_cfg.json new file mode 100644 index 00000000..36949671 --- /dev/null +++ b/target/g73x/scan/pack/pbp_cfg.json @@ -0,0 +1,249 @@ +{ + "psram": { + + "cfg0": { //OPI APS3208K 8M PSRAM + "common": { + "clock": "198000000", + "cs0_pins": "0x0", + "cs1_pins": "0x0", + "xspi_ctl": "0x116d", + "xspi_tcr": "0x280011", + "xspi_cfg": "0x01020001", + "xspi_ldo": "0x17", //1.92V + "psram_cfg0": "0x03030303", + "psram_cfg1": "0x00400001", + "xspi_cs0_iocfg1": "0x06060606", + "xspi_cs0_iocfg2": "0x06060606", + "xspi_cs0_iocfg3": "0x36062636", + "xspi_cs0_iocfg4": "0x26", + "xspi_cs1_iocfg1": "0x06060606", + "xspi_cs1_iocfg2": "0x06060606", + "xspi_cs1_iocfg3": "0x36062636", + "xspi_cs1_iocfg4": "0x26", + }, + "reset": { + "proto": "0xff000001", + "buf": "0x00ffffff", + }, + "getid": { + "proto": "0x40030204", + "id": "0x80c980c9", + "buf": "0xffffffff", + }, + "init": { + "proto0": "0xc0000002", //cmd: byte[0]=0xc0; dummy: byte[1]=0x00; addr: byte[2]=0x00; len: byte[3]=0x02; + "buf0": "0x19000000", + "proto1": "0xc0000402", + "buf1": "0x80000000", + "proto2": "0xffffffff", + "buf2": "0xffffffff", + "proto3": "0xffffffff", + "buf3": "0xffffffff", + }, + "xip_cfg": { + "wr_proto": "0x80020002", + "wr_buf": "0xffffffff", + "rd_proto": "0x00060003", + "rd_buf": "0xffffffff", + }, + "backup": { + "buf0": "0xAA55AA55", // training_value1 + "buf1": "0x55AA55AA", // training_value2 + "buf2": "0x02080100", //byte0:read_hold (0x02); byte1:write_hold (0x08); byte3:axi_read_first(0x01); byte4: bit mode + "buf3": "0xFFFFFF04", + "buf4": "0xFFFFFF05", + "buf5": "0xFFFFFF06", + "buf6": "0xFFFFFF07", + "buf7": "0xFFFFFF08", + "buf8": "0xFFFFFF09", + "buf9": "0xFFFFFF00", + }, + }, + + "cfg1": { // XCCELA AP12816 16M PSRAM + "common": { + "clock": "198000000", + "cs0_pins": "0x0", + "cs1_pins": "0x0", + "xspi_ctl": "0x116d", + "xspi_tcr": "0x280011", + "xspi_cfg": "0x03000001", + "xspi_ldo": "0x17", //1.92V + "psram_cfg0": "0x03030304", //cmd_lines, addr_lines, data_lines, addr_width + "psram_cfg1": "0x02000001", + "xspi_cs0_iocfg1": "0x06060606", + "xspi_cs0_iocfg2": "0x06060606", + "xspi_cs0_iocfg3": "0x36062636", + "xspi_cs0_iocfg4": "0x26", + "xspi_cs1_iocfg1": "0x06060606", + "xspi_cs1_iocfg2": "0x06060606", + "xspi_cs1_iocfg3": "0x36062636", + "xspi_cs1_iocfg4": "0x26", + }, + "reset": { + "proto": "0xff000001", + "buf": "0x00ffffff", + }, + "getid": { + + "proto": "0x40040104", + "id": "0xdd8ddd8d", + "buf": "0xffffffff", + }, + "init": { + "proto0": "0xc0000001", //cmd: byte[0]=0xc0; dummy: byte[1]=0x00; addr: byte[2]=0x00; len: byte[3]=0x02; + "buf0": "0x11000000", + "proto1": "0xc0000401", + "buf1": "0x20000000", + "proto2": "0xc0000801", + "buf2": "0x4c000000", + "proto3": "0xffffffff", + "buf3": "0xffffffff", + }, + "xip_cfg": { + "wr_proto": "0x80070002", //cmd: byte[0]=0x80; dummy: byte[1]=0x07; addr: byte[2]=0x08; len: byte[3]=0x02; + "wr_buf": "0xffffffff", + "rd_proto": "0x00070003", + "rd_buf": "0xffffffff", + }, + "backup": { + "buf0": "0x5555aaaa", + "buf1": "0xaaaa5555", + "buf2": "0x05050101", //byte0:read_hold; byte1:write_hold; byte3:axi_read_first; byte4:bit mode + "buf3": "0xFFFFFF04", + "buf4": "0xFFFFFF05", + "buf5": "0xFFFFFF06", + "buf6": "0xFFFFFF07", + "buf7": "0xFFFFFF08", + "buf8": "0xFFFFFF09", + "buf9": "0xFFFFFF00", + }, + }, + + "cfg2": { // XCCELA UnilC SCKW18X12816 16M PSRAM + "common": { + "clock": "198000000", + "cs0_pins": "0x0", + "cs1_pins": "0x0", + "xspi_ctl": "0x116d", + "xspi_tcr": "0x280011", + "xspi_cfg": "0x03000001", + "xspi_ldo": "0x17", //1.92V + "psram_cfg0": "0x03030304", //cmd_lines, addr_lines, data_lines, addr_width + "psram_cfg1": "0x02000001", + "xspi_cs0_iocfg1": "0x06060606", + "xspi_cs0_iocfg2": "0x06060606", + "xspi_cs0_iocfg3": "0x36062636", + "xspi_cs0_iocfg4": "0x26", + "xspi_cs1_iocfg1": "0x06060606", + "xspi_cs1_iocfg2": "0x06060606", + "xspi_cs1_iocfg3": "0x36062636", + "xspi_cs1_iocfg4": "0x26", + }, + "reset": { + "proto": "0xff000001", + "buf": "0x00ffffff", + }, + "getid": { + + "proto": "0x40040104", + "id": "0xc59ac59a", + "buf": "0xffffffff", + }, + "init": { + "proto0": "0xc0000001", //cmd: byte[0]=0xc0; dummy: byte[1]=0x00; addr: byte[2]=0x00; len: byte[3]=0x02; + "buf0": "0x10000000", + "proto1": "0xc0000401", + "buf1": "0x20000000", + "proto2": "0xc0000801", + "buf2": "0x4c000000", + "proto3": "0xffffffff", + "buf3": "0xffffffff", + }, + "xip_cfg": { + "wr_proto": "0x80070002", //cmd: byte[0]=0x80; dummy: byte[1]=0x07; addr: byte[2]=0x08; len: byte[3]=0x02; + "wr_buf": "0xffffffff", + "rd_proto": "0x00070003", + "rd_buf": "0xffffffff", + }, + "backup": { + "buf0": "0x5555aaaa", + "buf1": "0xaaaa5555", + "buf2": "0x05050101", //byte0:read_hold; byte1:write_hold; byte3:axi_read_first; byte4:bit mode + "buf3": "0xFFFFFF04", + "buf4": "0xFFFFFF05", + "buf5": "0xFFFFFF06", + "buf6": "0xFFFFFF07", + "buf7": "0xFFFFFF08", + "buf8": "0xFFFFFF09", + "buf9": "0xFFFFFF00", + }, + }, + }, + + "system": { + "upgmode": { // Set PIN to enter BROM's upgrading mode + // If set upgmode_pin_cfg_reg to "0", disable bootpin detect in PBP + "upgmode_pin_cfg_reg": "0x18700080", // PINMUX REG, PA0 + "upgmode_pin_cfg_val": "0x10321", // PINMUX VAL + "upgmode_pin_input_reg": "0x18700000", // INPUT VAL REG + "upgmode_pin_input_msk": "0x1", // Bit MSK + "upgmode_pin_input_val": "0x0", // Bit VAL + "upgmode_pin_pullup_dly": "500", // us + }, + "uart": { // PBP's uart setting + "main": { + "uart_id": "0", // UART0 for log output + "uart_tx_pin_cfg_reg": "0x18700080", // PA0 + "uart_tx_pin_cfg_val": "0x035", + "uart_rx_pin_cfg_reg": "0x18700084", // PA1 + "uart_rx_pin_cfg_val": "0x035", + + // "uart_id": "0", // UART0 for log output + // "uart_tx_pin_cfg_reg": "0x18700E88", // PN2 + // "uart_tx_pin_cfg_val": "0x324", + // "uart_rx_pin_cfg_reg": "0x18700E8C", // PN3 + // "uart_rx_pin_cfg_val": "0x324", + + // "uart_id": "1", // UART1 for log output + // "uart_tx_pin_cfg_reg": "0x18700090", // PA4 + // "uart_tx_pin_cfg_val": "0x325", + // "uart_rx_pin_cfg_reg": "0x18700094", // PA5 + // "uart_rx_pin_cfg_val": "0x325", + + // "uart_id": "3", // UART3 for log output + // "uart_tx_pin_cfg_reg": "0x187004B8", // PE14 + // "uart_tx_pin_cfg_val": "0x325", + // "uart_rx_pin_cfg_reg": "0x187004BC", // PE15 + // "uart_rx_pin_cfg_val": "0x325", + + // "uart_id": "4", // UART4 for log output + // "uart_tx_pin_cfg_reg": "0x18700198", // PB6 + // "uart_tx_pin_cfg_val": "0x325", + // "uart_rx_pin_cfg_reg": "0x1870019C", // PB7 + // "uart_rx_pin_cfg_val": "0x325", + + // "uart_id": "5", // UART5 for log output + // "uart_tx_pin_cfg_reg": "0x18700490", // PE4 + // "uart_tx_pin_cfg_val": "0x325", + // "uart_rx_pin_cfg_reg": "0x18700494", // PE5 + // "uart_rx_pin_cfg_val": "0x325", + }, + }, + "jtag": { + "jtag_only": "0", // 1: Boot code stop in PBP after DDR init and jtag init + "main": { + "jtag_id": "0", + "jtag_ms_pin_cfg_reg": "0x187000A8", // PA10 + "jtag_ms_pin_cfg_val": "0x338", + "jtag_ck_pin_cfg_reg": "0x187000AC", // PA11 + "jtag_ck_pin_cfg_val": "0x338", + + // "jtag_ms_pin_cfg_reg": "0x18700280", // PC0 + // "jtag_ms_pin_cfg_val": "0x338", + // "jtag_ck_pin_cfg_reg": "0x18700294", // PC5 + // "jtag_ck_pin_cfg_val": "0x338", + }, + }, + }, +} diff --git a/target/g73x/scan/pinmux.c b/target/g73x/scan/pinmux.c new file mode 100644 index 00000000..4517c608 --- /dev/null +++ b/target/g73x/scan/pinmux.c @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd + * + * SPDX-License-Identifier: Apache-2.0 + * + * Authors: weilin.peng@artinchip.com + */ + +#include +#include +#include "board.h" + +struct aic_pinmux +{ + unsigned char func; + unsigned char bias; + unsigned char drive; + char * name; +}; + +struct aic_pinmux aic_pinmux_config[] = { +#ifdef AIC_USING_UART0 + /* uart0 */ + {5, PIN_PULL_DIS, 3, "PA.0"}, + {5, PIN_PULL_UP, 3, "PA.1"}, +#ifdef AIC_DEV_UART0_MODE_RS485 + {1, PIN_PULL_DIS, 3, AIC_UART0_PA_RS485_CTL_NAME}, +#endif +#endif +#ifdef AIC_USING_UART1 + /* uart1 */ + {5, PIN_PULL_DIS, 3, "PD.2"}, + {5, PIN_PULL_UP, 3, "PD.3"}, +#ifdef AIC_DEV_UART1_MODE_RS485 + {1, PIN_PULL_DIS, 3, AIC_UART1_PA_RS485_CTL_NAME}, +#endif +#endif +#ifdef AIC_USING_UART2 + /* uart2 */ +#ifdef AIC_DEV_UART2_MODE_RS485 + {5, PIN_PULL_DIS, 3, "PD.4"}, // BT_UART2_TX + {5, PIN_PULL_UP, 3, "PD.5"}, // BT_UART2_RX + {1, PIN_PULL_DIS, 3, AIC_UART2_PA_RS485_CTL_NAME}, +#else + {8, PIN_PULL_DIS, 3, "PA.2"}, // BT_UART2_CTS + {8, PIN_PULL_DIS, 3, "PA.3"}, // BT_UART2_RTS + {5, PIN_PULL_DIS, 3, "PD.4"}, // BT_UART2_TX + {5, PIN_PULL_UP, 3, "PD.5"}, // BT_UART2_RX + {1, PIN_PULL_DIS, 3, "PD.6"}, // BT_PWR_ON +#endif +#endif +#ifdef AIC_USING_CAN0 + /* can0 */ + {4, PIN_PULL_DIS, 3, "PA.4"}, + {4, PIN_PULL_DIS, 3, "PA.5"}, +#endif +#ifdef AIC_USING_AUDIO +#ifdef AIC_AUDIO_DMIC + {4, PIN_PULL_DIS, 3, "PD.16"}, + {4, PIN_PULL_DIS, 3, "PD.17"}, +#endif +#ifdef AIC_AUDIO_PLAYBACK + {5, PIN_PULL_DIS, 3, "PE.12"}, + {1, PIN_PULL_DIS, 3, AIC_AUDIO_PA_ENABLE_GPIO}, +#endif +#endif +#ifdef AIC_USING_I2S0 + {4, PIN_PULL_DIS, 3, "PD.11"}, + {4, PIN_PULL_DIS, 3, "PD.12"}, + {4, PIN_PULL_DIS, 3, "PD.13"}, + {4, PIN_PULL_DIS, 3, "PD.14"}, + {4, PIN_PULL_DIS, 3, "PD.15"}, +#endif +#ifdef AIC_USING_RTP + {2, PIN_PULL_DIS, 3, "PA.8"}, + {2, PIN_PULL_DIS, 3, "PA.9"}, + {2, PIN_PULL_DIS, 3, "PA.10"}, + {2, PIN_PULL_DIS, 3, "PA.11"}, +#endif +#ifdef AIC_USING_I2C2 + {4, PIN_PULL_DIS, 3, "PA.8"}, // SCK + {4, PIN_PULL_DIS, 3, "PA.9"}, // SDA +#endif +#if defined(AIC_USING_QSPI0) && !defined(AIC_SYSCFG_SIP_FLASH_ENABLE) + /* qspi0 */ + {2, PIN_PULL_DIS, 3, "PB.0"}, + {2, PIN_PULL_DIS, 3, "PB.1"}, + {2, PIN_PULL_DIS, 3, "PB.2"}, + {2, PIN_PULL_DIS, 3, "PB.3"}, + {2, PIN_PULL_DIS, 3, "PB.4"}, + {2, PIN_PULL_DIS, 3, "PB.5"}, +#endif +#ifdef AIC_USING_QSPI1 + /* qspi1 */ + {3, PIN_PULL_DIS, 3, "PD.4"}, + {3, PIN_PULL_DIS, 3, "PD.5"}, + {3, PIN_PULL_DIS, 3, "PD.6"}, + {3, PIN_PULL_DIS, 3, "PD.7"}, + {3, PIN_PULL_DIS, 3, "PD.8"}, + {3, PIN_PULL_DIS, 3, "PD.9"}, +#endif +#ifdef AIC_USING_QSPI2 + /* qspi2 */ + {2, PIN_PULL_DIS, 3, "PE.12"}, + {2, PIN_PULL_DIS, 3, "PE.13"}, + {2, PIN_PULL_DIS, 3, "PE.14"}, + {2, PIN_PULL_DIS, 3, "PE.15"}, + {2, PIN_PULL_DIS, 3, "PE.16"}, + {2, PIN_PULL_DIS, 3, "PE.17"}, +#endif +#ifdef AIC_USING_QSPI3 + /* qspi3 */ + {2, PIN_PULL_DIS, 3, "PC.8"}, + {2, PIN_PULL_DIS, 3, "PC.9"}, + {2, PIN_PULL_DIS, 3, "PC.10"}, + {2, PIN_PULL_DIS, 3, "PC.11"}, +#endif +#ifdef AIC_USING_SDMC0 + {2, PIN_PULL_UP, 7, "PB.6"}, + {2, PIN_PULL_UP, 7, "PB.7"}, + {2, PIN_PULL_UP, 7, "PB.8"}, + {2, PIN_PULL_UP, 7, "PB.9"}, + {2, PIN_PULL_UP, 7, "PB.10"}, + {2, PIN_PULL_UP, 7, "PB.11"}, +#endif +#ifdef AIC_USING_SDMC1 + {2, PIN_PULL_UP, 3, "PC.0"}, + {2, PIN_PULL_UP, 3, "PC.1"}, + {2, PIN_PULL_UP, 3, "PC.2"}, + {2, PIN_PULL_UP, 3, "PC.3"}, + {2, PIN_PULL_UP, 3, "PC.4"}, + {2, PIN_PULL_UP, 3, "PC.5"}, + {2, PIN_PULL_UP, 3, "PC.6"}, +#endif +#ifdef AIC_USING_CAP0 + {3, PIN_PULL_UP, 3, "PC.6"}, +#endif +#ifdef AIC_USING_CAP1 + {3, PIN_PULL_UP, 3, "PC.7"}, +#endif +#ifdef AIC_USING_CAP2 + {3, PIN_PULL_UP, 3, "PC.8"}, +#endif +#ifdef AIC_USING_CAP3 + {3, PIN_PULL_UP, 3, "PC.9"}, +#endif +#ifdef AIC_USING_CAP4 + {3, PIN_PULL_UP, 3, "PC.10"}, +#endif +#ifdef AIC_USING_CAP5 + {3, PIN_PULL_UP, 3, "PC.11"}, +#endif +#ifdef AIC_WIRELESS_LAN + {1, PIN_PULL_DIS, 3, "PD.7"}, // WIFI_PWR_ON +#endif +#ifdef AIC_USING_I2C0 + {4, PIN_PULL_DIS, 3, "PD.0"}, // SCK + {4, PIN_PULL_DIS, 3, "PD.1"}, // SDA +#endif +#ifdef AIC_PANEL_ENABLE_GPIO + {1, PIN_PULL_DIS, 3, AIC_PANEL_ENABLE_GPIO}, +#endif +#ifdef AIC_PRGB_16BIT_LD + {2, PIN_PULL_DIS, 3, "PD.8"}, + {2, PIN_PULL_DIS, 3, "PD.9"}, + {2, PIN_PULL_DIS, 3, "PD.10"}, + {2, PIN_PULL_DIS, 3, "PD.11"}, + {2, PIN_PULL_DIS, 3, "PD.12"}, + {2, PIN_PULL_DIS, 3, "PD.13"}, + {2, PIN_PULL_DIS, 3, "PD.14"}, + {2, PIN_PULL_DIS, 3, "PD.15"}, + {2, PIN_PULL_DIS, 3, "PD.16"}, + {2, PIN_PULL_DIS, 3, "PD.17"}, + {2, PIN_PULL_DIS, 3, "PD.18"}, + {2, PIN_PULL_DIS, 3, "PD.19"}, + {2, PIN_PULL_DIS, 3, "PD.20"}, + {2, PIN_PULL_DIS, 3, "PD.21"}, + {2, PIN_PULL_DIS, 3, "PD.22"}, + {2, PIN_PULL_DIS, 3, "PD.23"}, + {2, PIN_PULL_DIS, 3, "PD.24"}, + {2, PIN_PULL_DIS, 3, "PD.25"}, + {2, PIN_PULL_DIS, 3, "PD.26"}, + {2, PIN_PULL_DIS, 3, "PD.27"}, +#endif +#ifdef AIC_USING_DVP + {3, PIN_PULL_DIS, 3, "PE.0"}, + {3, PIN_PULL_DIS, 3, "PE.1"}, + {3, PIN_PULL_DIS, 3, "PE.2"}, + {3, PIN_PULL_DIS, 3, "PE.3"}, + {3, PIN_PULL_DIS, 3, "PE.4"}, + {3, PIN_PULL_DIS, 3, "PE.5"}, + {3, PIN_PULL_DIS, 3, "PE.6"}, + {3, PIN_PULL_DIS, 3, "PE.7"}, + {3, PIN_PULL_DIS, 3, "PE.8"}, + {3, PIN_PULL_DIS, 3, "PE.9"}, + {3, PIN_PULL_DIS, 3, "PE.10"}, +#endif +#ifdef AIC_LVDS_LINK_0 + {3, PIN_PULL_DIS, 3, "PD.18"}, + {3, PIN_PULL_DIS, 3, "PD.19"}, + {3, PIN_PULL_DIS, 3, "PD.20"}, + {3, PIN_PULL_DIS, 3, "PD.21"}, + {3, PIN_PULL_DIS, 3, "PD.22"}, + {3, PIN_PULL_DIS, 3, "PD.23"}, + {3, PIN_PULL_DIS, 3, "PD.24"}, + {3, PIN_PULL_DIS, 3, "PD.25"}, + {3, PIN_PULL_DIS, 3, "PD.26"}, + {3, PIN_PULL_DIS, 3, "PD.27"}, +#endif +#ifdef AIC_DISP_MIPI_DSI + {4, PIN_PULL_DIS, 3, "PD.18"}, + {4, PIN_PULL_DIS, 3, "PD.19"}, + {4, PIN_PULL_DIS, 3, "PD.20"}, + {4, PIN_PULL_DIS, 3, "PD.21"}, + {4, PIN_PULL_DIS, 3, "PD.22"}, + {4, PIN_PULL_DIS, 3, "PD.23"}, + {4, PIN_PULL_DIS, 3, "PD.24"}, + {4, PIN_PULL_DIS, 3, "PD.25"}, + {4, PIN_PULL_DIS, 3, "PD.26"}, + {4, PIN_PULL_DIS, 3, "PD.27"}, +#endif +#ifdef AIC_USING_GMAC0 + /* gmac0 */ + {2, PIN_PULL_DIS, 3, "PE.0"}, + {2, PIN_PULL_DIS, 3, "PE.1"}, + {2, PIN_PULL_DIS, 3, "PE.2"}, + {2, PIN_PULL_DIS, 3, "PE.3"}, + {2, PIN_PULL_DIS, 3, "PE.4"}, + {2, PIN_PULL_DIS, 3, "PE.5"}, + {2, PIN_PULL_DIS, 3, "PE.7"}, + {2, PIN_PULL_DIS, 3, "PE.8"}, + {2, PIN_PULL_DIS, 3, "PE.9"}, + /* phy0 reset gpio */ + {1, PIN_PULL_DIS, 3, "PE.6"}, +#endif +#ifdef AIC_USING_CLK_OUT0 + {6, PIN_PULL_DIS, 3, "PD.13"}, +#endif +#ifdef AIC_USING_CLK_OUT1 + {2, PIN_PULL_DIS, 3, "PE.11"}, +#endif +#ifdef AIC_USING_CLK_OUT2 + {2, PIN_PULL_DIS, 3, "PE.10"}, +#endif +#ifdef AIC_USING_CLK_OUT3 + {7, PIN_PULL_DIS, 3, "PC.6"}, +#endif +#ifdef AIC_USING_PWM0 + {4, PIN_PULL_DIS, 3, "PE.0"}, + //{4, PIN_PULL_DIS, 3, "PE.1"}, +#endif +#ifdef AIC_USING_PWM1 + {3, PIN_PULL_DIS, 3, "PE.11"}, + //{3, PIN_PULL_DIS, 3, "PE.12"}, +#endif +#ifdef AIC_USING_PWM2 + {3, PIN_PULL_DIS, 3, "PE.13"}, + //{3, PIN_PULL_DIS, 3, "PE.15"}, +#endif +#ifdef AIC_USING_PWM3 + {3, PIN_PULL_DIS, 3, "PE.16"}, + //{3, PIN_PULL_DIS, 3, "PE.15"}, +#endif +#ifdef AIC_USING_EPWM0 + {7, PIN_PULL_DIS, 3, "PD.26"}, + {7, PIN_PULL_DIS, 3, "PD.27"}, +#endif +#ifdef AIC_USING_EPWM1 + {7, PIN_PULL_DIS, 3, "PD.24"}, + {7, PIN_PULL_DIS, 3, "PD.25"}, +#endif +#ifdef AIC_USING_EPWM2 + {7, PIN_PULL_DIS, 3, "PD.22"}, + {7, PIN_PULL_DIS, 3, "PD.23"}, +#endif +#ifdef AIC_USING_EPWM3 + {7, PIN_PULL_DIS, 3, "PD.20"}, + {7, PIN_PULL_DIS, 3, "PD.21"}, +#endif +#ifdef AIC_USING_EPWM4 + {7, PIN_PULL_DIS, 3, "PD.18"}, + {7, PIN_PULL_DIS, 3, "PD.19"}, +#endif +#ifdef AIC_USING_EPWM5 + {7, PIN_PULL_DIS, 3, "PD.16"}, + {7, PIN_PULL_DIS, 3, "PD.17"}, +#endif +#ifdef AIC_USING_EPWM6 + {7, PIN_PULL_DIS, 3, "PD.14"}, + {7, PIN_PULL_DIS, 3, "PD.15"}, +#endif +#ifdef AIC_USING_EPWM7 + {7, PIN_PULL_DIS, 3, "PD.12"}, + {7, PIN_PULL_DIS, 3, "PD.13"}, +#endif +#ifdef AIC_USING_EPWM8 + {7, PIN_PULL_DIS, 3, "PD.10"}, + {7, PIN_PULL_DIS, 3, "PD.11"}, +#endif +#ifdef AIC_USING_EPWM9 + {7, PIN_PULL_DIS, 3, "PD.8"}, + {7, PIN_PULL_DIS, 3, "PD.9"}, +#endif +#ifdef AIC_USING_EPWM10 + {7, PIN_PULL_DIS, 3, "PD.2"}, + {7, PIN_PULL_DIS, 3, "PD.3"}, +#endif +#ifdef AIC_USING_EPWM11 + {7, PIN_PULL_DIS, 3, "PD.0"}, + {7, PIN_PULL_DIS, 3, "PD.1"}, +#endif +#if (defined(AIC_USING_USB0_DEVICE) || defined(AIC_USING_USB0_HOST)) + /* usb0 */ + {2, PIN_PULL_DIS, 3, "PO.0"}, // USB-DM + {2, PIN_PULL_DIS, 3, "PO.1"}, // USB-DP + {1, PIN_PULL_DIS, 3, "PD.8"}, // USB-ID +#endif +#ifdef AIC_USING_PSADC0 + {7, PIN_PULL_DIS, 3, "PA.0"}, +#endif +#ifdef AIC_USING_PSADC1 + {7, PIN_PULL_DIS, 3, "PA.1"}, +#endif +#ifdef AIC_USING_PSADC2 + {7, PIN_PULL_DIS, 3, "PA.2"}, +#endif +#ifdef AIC_USING_PSADC3 + {7, PIN_PULL_DIS, 3, "PA.3"}, +#endif +#ifdef AIC_USING_PSADC4 + {7, PIN_PULL_DIS, 3, "PA.4"}, +#endif +#ifdef AIC_USING_PSADC5 + {7, PIN_PULL_DIS, 3, "PA.5"}, +#endif +#ifdef AIC_USING_PSADC6 + {7, PIN_PULL_DIS, 3, "PA.6"}, +#endif +#ifdef AIC_USING_PSADC7 + {7, PIN_PULL_DIS, 3, "PA.7"}, +#endif +#ifdef AIC_USING_PSADC8 + {7, PIN_PULL_DIS, 3, "PA.8"}, +#endif +#ifdef AIC_USING_PSADC9 + {7, PIN_PULL_DIS, 3, "PA.9"}, +#endif +#ifdef AIC_USING_PSADC10 + {7, PIN_PULL_DIS, 3, "PA.10"}, +#endif +#ifdef AIC_USING_PSADC11 + {7, PIN_PULL_DIS, 3, "PA.11"}, +#endif +#ifdef AIC_USING_PSADC12 + {7, PIN_PULL_DIS, 3, "PA.12"}, +#endif +#ifdef AIC_USING_PSADC13 + {7, PIN_PULL_DIS, 3, "PA.13"}, +#endif +#ifdef AIC_USING_PSADC14 + {7, PIN_PULL_DIS, 3, "PA.14"}, +#endif +#ifdef AIC_USING_PSADC15 + {7, PIN_PULL_DIS, 3, "PA.15"}, +#endif +#ifdef AIC_USING_CTP + {1, PIN_PULL_DIS, 3, AIC_TOUCH_PANEL_RST_PIN}, + {1, PIN_PULL_DIS, 3, AIC_TOUCH_PANEL_INT_PIN}, +#endif +}; + +void aic_board_pinmux_init(void) +{ + uint32_t i = 0; + long pin = 0; + unsigned int g; + unsigned int p; + + for (i=0; i +#include +#include "board.h" + +struct aic_sysclk +{ + unsigned long freq; + unsigned int clk_id; + unsigned int parent_clk_id; +}; + +struct aic_sysclk aic_sysclk_config[] = { + {AIC_CLK_PLL_INT0_FREQ, CLK_PLL_INT0, 0}, /* 480000000 */ + {AIC_CLK_PLL_INT1_FREQ, CLK_PLL_INT1, 0}, /* 1200000000 */ + {AIC_CLK_PLL_FRA0_FREQ, CLK_PLL_FRA0, 0}, /* 792000000 */ + {AIC_CLK_PLL_FRA2_FREQ, CLK_PLL_FRA2, 0}, /* 1188000000 */ + {AIC_CLK_CPU_FREQ, CLK_CPU, CLK_CPU_SRC1}, /* 480000000 */ + {AIC_CLK_AXI0_FREQ, CLK_AXI0, CLK_AXI_AHB_SRC1}, /* 200000000 */ + {AIC_CLK_AHB0_FREQ, CLK_AHB0, CLK_AXI_AHB_SRC1}, /* 200000000 */ + {AIC_CLK_APB0_FREQ, CLK_APB0, CLK_APB0_SRC1}, /* 100000000 */ +// {24000000, CLK_APB1, 0}, +#ifdef AIC_USING_CLK_OUT0 + {AIC_CLK_OUT0_FREQ, CLK_OUT0, 0}, +#endif /* AIC_USING_CLK_OUT0 */ +#ifdef AIC_USING_CLK_OUT1 + {AIC_CLK_OUT1_FREQ, CLK_OUT1, 0}, +#endif /* AIC_USING_CLK_OUT1 */ +#ifdef AIC_USING_CLK_OUT2 + {AIC_CLK_OUT2_FREQ, CLK_OUT2, 0}, +#endif /* AIC_USING_CLK_OUT2 */ +#ifdef AIC_USING_CLK_OUT3 + {AIC_CLK_OUT3_FREQ, CLK_OUT3, 0}, +#endif /* AIC_USING_CLK_OUT3 */ +}; + +/* + * Some Chips may enable USB0 EHCI in Boot ROM, + * it is better to disable USB0 EHCI during boot to avoid some side effect. + */ +static void usb_ehci_disable(void) +{ + hal_clk_disable_assertrst(CLK_USBH0); + hal_clk_disable(CLK_USBH0); +} + +void aic_board_sysclk_init(void) +{ + uint32_t i = 0; + + usb_ehci_disable(); + + for (i=0; i +# +# Tool to calculate bootloader linked addr from .config file +# + +import os +from menuconfig import get_config_val, get_text_base + + +def calc_link_addr(infile, config, outfile): + mem_auto_enable = 'CONFIG_AIC_BOOTLOADER_MEM_AUTO' + text_base_config = 'CONFIG_AIC_BOOTLOADER_TEXT_BASE' + text_load_config = 'CONFIG_AIC_BOOTLOADER_LOAD_BASE' + + if get_config_val(config, mem_auto_enable) == 'y': + text_base = hex(get_text_base(config)) + load_base = hex(int(text_base, 16) - 0x100) + else: + text_base = get_config_val(config, text_base_config) + load_base = hex(int(text_base, 16) - 0x100) + with open(infile, 'r') as f: + cfg = f.read() + + cfg = cfg.replace(text_base_config, text_base) + cfg = cfg.replace(text_load_config, load_base) + + with open(outfile, 'w') as f: + f.write(cfg) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Tool to calculate bootloader linked addr from .config file') + parser.add_argument('-i', '--infile', type=str, help='input image_cfg.json file') + parser.add_argument('-c', '--config', type=str, help='bootloader defconfig file') + parser.add_argument('-o', '--outfile', type=str, help='output image_cfg.jaon file') + args = parser.parse_args() + if args.infile is None: + print('Error, option --infile is required.') + sys.exit(1) + if args.config is None: + print('Error, option --config is required.') + sys.exit(1) + if args.outfile is None: + outname = '.' + os.path.basename(img) + '.tmp' + args.outfile = os.path.dirname(img) + '/' + outname + sys.exit(1) + + calc_link_addr(args.infile, args.config, args.outfile) diff --git a/tools/scripts/makefatfs.py b/tools/scripts/makefatfs.py index 189e420d..0cae2958 100644 --- a/tools/scripts/makefatfs.py +++ b/tools/scripts/makefatfs.py @@ -11,6 +11,8 @@ import sys import platform import argparse import subprocess +import json +from collections import OrderedDict def mkimage_get_resource_size(srcdir, cluster_siz): @@ -45,6 +47,48 @@ def mkimage_get_part_size(outfile): return size +def parse_image_cfg(cfgfile): + """ Load image configuration file + Args: + cfgfile: Configuration file name + """ + with open(cfgfile, "r") as f: + lines = f.readlines() + jsonstr = "" + for line in lines: + sline = line.strip() + if sline.startswith("//"): + continue + slash_start = sline.find("//") + if slash_start > 0: + jsonstr += sline[0:slash_start].strip() + else: + jsonstr += sline + # Use OrderedDict is important, we need to iterate FWC in order. + jsonstr = jsonstr.replace(",}", "}").replace(",]", "]") + cfg = json.loads(jsonstr, object_pairs_hook=OrderedDict) + return cfg + + +def check_is_nftl_part(outfile): + imgname = os.path.basename(outfile) + partjson = os.path.join(os.path.dirname(outfile), 'partition.json') + if not os.path.exists(partjson): + return False + + cfg = parse_image_cfg(partjson) + nftl_value = cfg["partitions"].get("nftl") + if nftl_value is None: + return False + + imgname = os.path.basename(outfile) + parts = imgname.split('.') + nftl_part = parts[0] + ':' + if nftl_part in nftl_value: + return True + return False + + def run_cmd(cmdstr): # print(cmdstr) cmd = cmdstr.split(' ') @@ -192,6 +236,15 @@ if __name__ == "__main__": imgsiz = rsvd_siz + 2 * fat_siz + root_ent_cnt + data_region_sz # Round to cluster alignment imgsiz = cluster_siz * int(((imgsiz + cluster_siz - 1) / cluster_siz)) + if check_is_nftl_part(args.outfile): + # Space reserved for bad block management in NFTL + NFTL_RESERVED = 51 * 64 * 2048 + imgsiz = part_size - NFTL_RESERVED + if imgsiz < 0: + print('Error, partition size: {} is less than NFTL reserved: {}.'.format(part_size, NFTL_RESERVED)) + sys.exit(1) + # Round to cluster alignment + imgsiz = cluster_siz * int(((imgsiz + cluster_siz - 1) / cluster_siz)) elif args.fullpart: imgsiz = part_size else: