mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 10:28:54 +00:00
V1.0.6
This commit is contained in:
21
packages/artinchip/burn-in/Kconfig
Normal file
21
packages/artinchip/burn-in/Kconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
# Kconfig file for package adbd
|
||||
menuconfig LPKG_BURN_IN
|
||||
bool "burn-in test"
|
||||
default n
|
||||
|
||||
if LPKG_BURN_IN
|
||||
config LPKG_BURN_IN_PLAYER_ENABLE
|
||||
bool "test player"
|
||||
default n
|
||||
depends on AIC_MPP_PLAYER_INTERFACE
|
||||
if LPKG_BURN_IN_PLAYER_ENABLE
|
||||
config LPKG_BURN_IN_PLAYER_LOOP
|
||||
int "set play file/dir loop num"
|
||||
default 10000000
|
||||
config LPKG_BURN_IN_PLAYER_LOG_TO_SERIAL
|
||||
bool "output log to serial interface"
|
||||
default y
|
||||
endif
|
||||
endif
|
||||
|
||||
13
packages/artinchip/burn-in/SConscript
Normal file
13
packages/artinchip/burn-in/SConscript
Normal file
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['burn_in.c']
|
||||
|
||||
if GetDepend('LPKG_BURN_IN_PLAYER_ENABLE'):
|
||||
src += ['burn_in_player.c']
|
||||
|
||||
group = DefineGroup('burn', src, depend = ['LPKG_BURN_IN'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
38
packages/artinchip/burn-in/burn_in.c
Normal file
38
packages/artinchip/burn-in/burn_in.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd
|
||||
*
|
||||
* author: <jun.ma@artinchip.com>
|
||||
* Desc: burn_in
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <shell.h>
|
||||
#include "msh.h"
|
||||
#include "aic_osal.h"
|
||||
#include "burn_in.h"
|
||||
|
||||
static void auto_burn_in_test(void *arg)
|
||||
{
|
||||
// wait some time for resource
|
||||
usleep(5*1000*1000);
|
||||
#ifdef LPKG_BURN_IN_PLAYER_ENABLE
|
||||
burn_in_player_test(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int auto_burn_in(void)
|
||||
{
|
||||
aicos_thread_t thid = NULL;
|
||||
thid = aicos_thread_create("auto_burn_in_test", 8192, 2, auto_burn_in_test, NULL);
|
||||
if (thid == NULL) {
|
||||
BURN_PRINT_ERR("Failed to create thread\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(auto_burn_in);
|
||||
25
packages/artinchip/burn-in/burn_in.h
Normal file
25
packages/artinchip/burn-in/burn_in.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd
|
||||
*
|
||||
* author: <jun.ma@artinchip.com>
|
||||
* Desc: burn_in
|
||||
*/
|
||||
|
||||
#ifndef _BURN_IN_H_
|
||||
#define _BURN_IN_H_
|
||||
|
||||
#define BURN_DEBUG
|
||||
|
||||
#ifdef BURN_DEBUG
|
||||
#define BURN_PRINT_DGB(fmt,args...) printf("\033[40;32m" "[%s:%s:%d]" fmt "\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__,##args)
|
||||
#define BURN_PRINT_ERR(fmt,args...) printf("\033[40;31m" "[%s:%s:%d]" fmt "\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__,##args)
|
||||
#else
|
||||
#define BURN_PRINT_DGB(...)
|
||||
#define BURN_PRINT_ERR(...)
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_BURN_IN_PLAYER_ENABLE
|
||||
int burn_in_player_test(void *arg);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
209
packages/artinchip/burn-in/burn_in_player.c
Normal file
209
packages/artinchip/burn-in/burn_in_player.c
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 ArtInChip Technology Co. Ltd
|
||||
*
|
||||
* author: <jun.ma@artinchip.com>
|
||||
* Desc: burn_in_player
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <shell.h>
|
||||
#include "msh.h"
|
||||
#include "burn_in.h"
|
||||
|
||||
#define BURN_PLAYER_FILE_MAX_NUM 128
|
||||
#define BURN_PLAYER_FILE_PATH_MAX_LEN 256
|
||||
|
||||
#define BURN_PLAYER_RODATA_DIR "/rodata/aic_test/video"
|
||||
#define BURN_PLAYER_DATA_DIR "/data/aic_test/video"
|
||||
#define BURN_PLAYER_SDCARD_DIR "/sdcard/aic_test/video"
|
||||
|
||||
#ifdef LPKG_BURN_IN_PLAYER_LOG_TO_SERIAL
|
||||
#define BURN_IN_PLAYER_LOG_TO_SERIAL 1
|
||||
#else
|
||||
#define BURN_IN_PLAYER_LOG_TO_SERIAL 0
|
||||
#endif
|
||||
|
||||
|
||||
struct file_list {
|
||||
char *file_path[BURN_PLAYER_FILE_MAX_NUM];
|
||||
int file_num;
|
||||
};
|
||||
|
||||
struct burn_in_player_ctx {
|
||||
char *dir;
|
||||
struct file_list files;
|
||||
FILE *log_file;
|
||||
};
|
||||
|
||||
static int8_t dir_is_exist(const char * dir)
|
||||
{
|
||||
DIR* d = opendir(dir);
|
||||
if (d) {
|
||||
closedir(d);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int8_t resource_is_exist(struct burn_in_player_ctx *ctx)
|
||||
{
|
||||
if(dir_is_exist(BURN_PLAYER_RODATA_DIR)) {
|
||||
ctx->dir = BURN_PLAYER_RODATA_DIR;
|
||||
return 1;
|
||||
} else if (dir_is_exist(BURN_PLAYER_DATA_DIR)) {
|
||||
ctx->dir = BURN_PLAYER_DATA_DIR;
|
||||
return 1;
|
||||
} else if (dir_is_exist(BURN_PLAYER_SDCARD_DIR)) {
|
||||
ctx->dir = BURN_PLAYER_SDCARD_DIR;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int8_t create_log_file(struct burn_in_player_ctx *ctx)
|
||||
{
|
||||
char log_file[128] = {0};
|
||||
time_t now;
|
||||
struct tm *local_time;
|
||||
now = time(RT_NULL);
|
||||
local_time = localtime(&now);
|
||||
snprintf(log_file,sizeof(log_file),"%s/%04d-%02d-%02d-%02d-%02d-%02d.log"
|
||||
,ctx->dir
|
||||
,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);
|
||||
|
||||
ctx->log_file = fopen(log_file, "wb");
|
||||
if (!ctx->log_file) {
|
||||
BURN_PRINT_ERR("fopen %s fail\n",log_file);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void output_log(struct burn_in_player_ctx *ctx,char *log,int res)
|
||||
{
|
||||
if (BURN_IN_PLAYER_LOG_TO_SERIAL) {
|
||||
BURN_PRINT_DGB("play %s %s\n",log,((res==0)?"ok":"fail"));
|
||||
} else {
|
||||
fprintf(ctx->log_file,"play %s %s\n",log,((res==0)?"ok":"fail"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int read_dir(char* path, struct file_list *files)
|
||||
{
|
||||
char* ptr = NULL;
|
||||
int file_path_len = 0;
|
||||
struct dirent* dir_file;
|
||||
DIR* dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
BURN_PRINT_ERR("read dir failed \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while((dir_file = readdir(dir))) {
|
||||
if (strcmp(dir_file->d_name, ".") == 0 || strcmp(dir_file->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
ptr = strrchr(dir_file->d_name, '.');
|
||||
if (ptr == NULL)
|
||||
continue;
|
||||
|
||||
if (strcmp(ptr, ".h264") && strcmp(ptr, ".264") && strcmp(ptr, ".mp4") && strcmp(ptr, ".mp3") && strcmp(ptr, ".avi"))
|
||||
continue;
|
||||
|
||||
file_path_len = 0;
|
||||
file_path_len += strlen(path);
|
||||
file_path_len += 1; // '/'
|
||||
file_path_len += strlen(dir_file->d_name);
|
||||
if (file_path_len > BURN_PLAYER_FILE_PATH_MAX_LEN-1) {
|
||||
BURN_PRINT_ERR("%s too long \n",dir_file->d_name);
|
||||
continue;
|
||||
}
|
||||
files->file_path[files->file_num] = (char *)malloc(file_path_len+1);
|
||||
files->file_path[files->file_num][file_path_len] = '\0';
|
||||
strcpy(files->file_path[files->file_num], path);
|
||||
strcat(files->file_path[files->file_num], "/");
|
||||
strcat(files->file_path[files->file_num], dir_file->d_name);
|
||||
BURN_PRINT_DGB("i: %d, filename: %s", files->file_num, files->file_path[files->file_num]);
|
||||
files->file_num ++;
|
||||
if (files->file_num >= BURN_PLAYER_FILE_MAX_NUM)
|
||||
break;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int burn_in_player_test(void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
char cmd[64] = {0};
|
||||
struct burn_in_player_ctx *ctx = malloc(sizeof(struct burn_in_player_ctx));
|
||||
|
||||
BURN_PRINT_DGB("!!!!!enter player test!!!!!");
|
||||
|
||||
if (!ctx) {
|
||||
BURN_PRINT_ERR("malloc error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(ctx,0x00,sizeof(struct burn_in_player_ctx));
|
||||
|
||||
if (!resource_is_exist(ctx)) {
|
||||
BURN_PRINT_ERR("!!!!resource is not exist!!!!!\n");
|
||||
ret = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (!BURN_IN_PLAYER_LOG_TO_SERIAL) {
|
||||
if (create_log_file(ctx)) {
|
||||
BURN_PRINT_ERR("create_log_file error\n");
|
||||
ret = -1;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
read_dir(ctx->dir,&ctx->files);
|
||||
|
||||
if (ctx->files.file_num == 0) {
|
||||
BURN_PRINT_ERR("no test video in %s\n",ctx->dir);
|
||||
ret = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for(i = 0;i < LPKG_BURN_IN_PLAYER_LOOP; i++) {
|
||||
for(j = 0;j < ctx->files.file_num;j++) {
|
||||
memset(cmd,0x00,sizeof(cmd));
|
||||
snprintf(cmd,sizeof(cmd),"player_demo -i %s",ctx->files.file_path[j]);
|
||||
ret = msh_exec(cmd, strlen(cmd));
|
||||
output_log(ctx,ctx->files.file_path[j],ret);
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (ctx->log_file) {
|
||||
fclose(ctx->log_file);
|
||||
}
|
||||
for(i = 0; i <ctx->files.file_num ;i++) {
|
||||
if (ctx->files.file_path[i]) {
|
||||
free(ctx->files.file_path[i]);
|
||||
ctx->files.file_path[i] = NULL;
|
||||
}
|
||||
}
|
||||
free(ctx);
|
||||
ctx = NULL;
|
||||
BURN_PRINT_DGB("!!!!!exit player test!!!!!");
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user