MC3302_SDK_V1.1.9_202507281.../media/sample/modules/npu/common.h
2025-11-11 12:08:31 +08:00

38 lines
1.7 KiB
C
Executable File

/**
* @file utils.h
*
* 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.
*/
#pragma once
#include <stdio.h>
#include "base.h"
#define DEBUG_LOG(fmt, ...) fprintf(stdout, "[DEBUG] " fmt "\n", ##__VA_ARGS__)
#define INFO_LOG(fmt, ...) fprintf(stdout, "[INFO] " fmt "\n", ##__VA_ARGS__)
#define IMPOTANT_LOG(fmt, ...) fprintf(stdout, "[IMPOT] " fmt "\n", ##__VA_ARGS__)
#define WARN_LOG(fmt, ...) fprintf(stdout, "[WARN] " fmt "\n", ##__VA_ARGS__)
#define ERROR_LOG(fmt, ...) fprintf(stdout, "[ERROR] " fmt "\n", ##__VA_ARGS__)
#define FATAL_LOG(fmt, ...) fprintf(stdout, "[FATAL] " fmt "\n", ##__VA_ARGS__)
void printMemSegments(T_TY_MemSegmentInfo *ptrMemInfo);
int32_t freeMem(uint64_t virAddr, uint64_t phyAddr, uint32_t size);
int32_t mallocMem(void **ppVirAddr, uint64_t *ptrPhyAddr, uint32_t size, uint32_t align, E_TY_MemAllocType type);
int32_t flushVmmMem(uint64_t virAddr, uint64_t phyAddr, uint32_t size);
int32_t flushCacheMemSeg(T_TY_MemSegmentInfo *ptrMemInfo);
int32_t freeMemSegments(T_TY_MemSegmentInfo *ptrMemInfo);
int32_t allocMemSegments(T_TY_MemSegmentInfo *ptrMemInfo);
int32_t readImage(T_TY_Image *img, char *imgPath);
int32_t readFile(T_TY_Mem *ptrMem, char *path);
int32_t writeFile(T_TY_Mem *ptrMem, char *path);
int32_t freeImageBuf(T_TY_Image *ptrImg);
int32_t CheckPathIsFile(char *filePath);
int32_t GetFileSize(char *path);
int32_t ReadBinFile(char *filePath, char **ppInputBuff, uint32_t *ptrFileSize);
void printBlob(T_TY_BlobDesc *blob);
uint32_t getBlobSize(T_TY_BlobDesc *blob);
int32_t getImageSize(uint32_t width, uint32_t height, E_TY_PixelFormat fmt);
#pragma once