175 lines
4.3 KiB
C
Executable File
175 lines
4.3 KiB
C
Executable File
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/time.h>
|
|
#include <fcntl.h>
|
|
#include <pthread.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include "sample_comm.h"
|
|
#include "fh_system_mpi.h"
|
|
#include "vmm_api.h"
|
|
#include "fh_vb_mpi.h"
|
|
#include "pre_rolling.h"
|
|
#include <camif/fh_camif_mpi.h>
|
|
#include <fh_venc_mpipara.h>
|
|
#include <dsp/fh_jpege_mpi.h>
|
|
#include <dsp/fh_jpege_mpipara.h>
|
|
#include <isp_sensor_if.h>
|
|
#include <isp_enum.h>
|
|
#include "prg_config.h"
|
|
|
|
|
|
#include <sys/mman.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
struct prg_system_info prg_cfg = {
|
|
.pic_enc_mode = 4,
|
|
.main_sensor_preconfig = 0,
|
|
.pic_continue_out = 0,
|
|
.pic_abort = 0,
|
|
.sensor_power_mode = SENSOR_POWER_ALWAYS_ON,
|
|
.prg_power_mode = 0,
|
|
.stanby_time = 0,
|
|
};
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int ret = 0;
|
|
int mode = 1;
|
|
int pic_ready = 0;
|
|
char fileNameIn[128] = "./f23_dvp_day_attr.hex";
|
|
char path[128] = "./";
|
|
|
|
struct prg_image_info prg_image;
|
|
switch(atoi(argv[1])) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
pic_ready = 0;
|
|
prg_cfg.pic_enc_mode = atoi(argv[1]);
|
|
break;
|
|
case 9:
|
|
pic_ready = 1;
|
|
break;
|
|
default:
|
|
printf("---------invalid input-------\n");
|
|
printf("---------please input--------\n");
|
|
printf("./main [path mode] [hex path] (ae enable) (awb enable)\n");
|
|
printf("-----------------------------\n");
|
|
printf("---------path mode-----------\n");
|
|
printf("---------1 init RAWEC--------\n");
|
|
printf("---------2 init Y ONLY-------\n");
|
|
printf("---------3 init JPEG---------\n");
|
|
printf("---------4 init H264---------\n");
|
|
printf("---------9 (dump path)-------\n");
|
|
printf("-----------------------------\n");
|
|
printf("---------hex path------------\n");
|
|
printf("-----------------------------\n");
|
|
printf("---------ae enable-----------\n");
|
|
printf("---------1/0 enable/disable--\n");
|
|
printf("-----------------------------\n");
|
|
printf("---------awb enable----------\n");
|
|
printf("---------1/0 enable/disable--\n");
|
|
goto exit_0;
|
|
}
|
|
|
|
if (0 == pic_ready) {
|
|
/* parse arguments.
|
|
* 1: indicate to handle picture.
|
|
*/
|
|
/*hex file path*/
|
|
if(argc<3){
|
|
printf("Parameter err!\n");
|
|
printf("./main [path mode] [hex path] (ae enable) (awb enable)\n");
|
|
goto exit_0;
|
|
}
|
|
strcpy(fileNameIn, argv[2]);
|
|
|
|
ret = pre_rolling_init(mode, &prg_cfg);
|
|
if (ret) {
|
|
printf("pre-rolling system config failed%d.\n", ret);
|
|
}
|
|
pre_rolling_get_image_info(&prg_image);
|
|
printf("image:phy:0x%x,size:0x%x\n",prg_image.phy_base,prg_image.size);
|
|
prg_load(prg_image.phy_base, prg_image.size,prg_cfg.pic_enc_mode);
|
|
if (mode) {
|
|
/* normal mode */
|
|
/* 1. camif init/config. */
|
|
int pic_bypass = 0;
|
|
if(prg_cfg.pic_enc_mode != 1)
|
|
pic_bypass = 1;
|
|
if(argv[3] != NULL && argv[4] != NULL) {
|
|
ret = prg_camif_cfg_init(CAMIF_PORT_TYPE_DVP, 0, atoi(argv[3]), atoi(argv[4]), 1, fileNameIn,pic_bypass);
|
|
if (ret) {
|
|
printf("pre-rolling prg_camif_cfg_init failed%d.\n", ret);
|
|
goto exit_0;
|
|
}
|
|
} else {
|
|
prg_camif_cfg_init(CAMIF_PORT_TYPE_DVP, 0, 0, 0, 0, fileNameIn,pic_bypass);
|
|
}
|
|
/* 2. venc/jpege init/config. */
|
|
if(prg_cfg.pic_enc_mode == 4){
|
|
prg_veu_cfg_init();
|
|
}else if(prg_cfg.pic_enc_mode == 3){
|
|
prg_JPEGE_cfg_init();
|
|
}
|
|
/* 3. sync pre-rolling system parameters from DDR to IRAM. */
|
|
//ret = pre_rolling_parameters_update();
|
|
pre_rolling_deinit(mode);
|
|
|
|
/* 4. close i2c 0 IRQ. */
|
|
//0x201100 + 12 [7] = 1 en
|
|
//0x201180 + 12 [7] = 1 dis
|
|
unsigned int val = 0;
|
|
FH_SYS_GetReg(0x20118C, &val);
|
|
val |= 0x80;
|
|
FH_SYS_SetReg(0x20118C, val);
|
|
|
|
|
|
pre_rolling_start();
|
|
switch(prg_cfg.pic_enc_mode) {
|
|
case 1:
|
|
system("echo prg1 > /proc/mc_sleep");
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
//close xbus irq
|
|
FH_SYS_SetReg(0x1900000C, 0x0);
|
|
system("echo prg2 > /proc/mc_sleep");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} else {
|
|
/* tuning mode. Nothing to do! */
|
|
}
|
|
|
|
} else {
|
|
/* get picture pre-rolling? */
|
|
//system("devmem 0x60010000 32 0xA6A6A6A6");
|
|
//system("devmem 0x201184 32 0xFFF");
|
|
//system("echo 12 > /sys/class/gpio/export");
|
|
//system("echo out > /sys/class/gpio/gpio12/direction");
|
|
|
|
/* handle pre-store picture. */
|
|
if (argv[2] != NULL){
|
|
strcpy(path, argv[2]);
|
|
set_storage_path(path);
|
|
}
|
|
ret = prg_dump(0,0);
|
|
}
|
|
|
|
exit_0:
|
|
return ret;
|
|
}
|
|
|