2095
- 收藏
- 点赞
- 分享
- 举报
hi3559 VI through the BT656
I want to work with HI3559 chip through BT656 interface input (x2 AD TVP5150 <--> PAL camera).
Unfortunately in my SDK there are no examples of working with BT656 VI.
I used the examples from the SDK for the hi3518 chip (based on the HiMPP IPC V3.0 Media Processing Software document, i think working with BT656 is no different), but nothing worked.
Function HI_MPI_VI_SetDevAttr() returning 0xA0108003 code(HI_ERR_VI_INVALID_PARA).
Question 1: How the internal registers of the hi3559 chip should be configured?
Question 2: Is there any user manual about working in BT656 mode?
[img]static/image/hrline/5.gif[/img]
VI_DEV_ATTR_S DEV_ATTR_BT656D1_1MUX = {
VI_MODE_BT656, // Interface mode
VI_WORK_MODE_1Multiplex, // 1, 2, and 4 working modes
{0xFF000000, 0x00}, // r_mask g_mask b_mask
VI_SCAN_PROGRESSIVE, // Progressive or interlaced input
{-1, -1, -1, -1}, // AdChnId
VI_INPUT_DATA_YVYU, // enDataSeq, Only supports YUV format
// Synchronization information, corresponding to the following configuration of the reg manual, --bt1120 timing is invalid
// port_vsync port_vsync_neg port_hsync port_hsync_neg
{
VI_VSYNC_FIELD, VI_VSYNC_NEG_HIGH, VI_HSYNC_VALID_SINGNAL, VI_HSYNC_NEG_HIGH, VI_VSYNC_VALID_SINGAL, VI_VSYNC_VALID_NEG_HIGH,
// timing information, corresponding to the following configuration of the reg manual
{
// hsync_hfb hsync_act hsync_hhb
0, 0, 0,
// vsync0_vhb vsync0_act vsync0_hhb
0, 0, 0,
// vsync1_vhb vsync1_act vsync1_hhb
0, 0, 0
}
// ----------------------------------------------------------------------------------
},
// -----------------------------------------------------------------------------------------------------------------------
VI_PATH_BYPASS, // Use internal ISP
VI_DATA_TYPE_YUV // Input data type
};
HI_S32 VI_D1_BT656(void) {
#define SAMPLE_SYS_ALIGN_WIDTH 64
#define SAMPLE_PIXEL_FORMAT PIXEL_FORMAT_YUV_SEMIPLANAR_420
HI_U32 u32ViChnCnt = 1;
VI_CHN ViChn = 0;
HI_S32 s32Ret = HI_SUCCESS;
HI_U32 u32BlkSize;
// **********************************************************
// step 1: init global variables
// **********************************************************
VB_CONF_S stVbConf;
SIZE_S stSize;
memset(&stVbConf, 0, sizeof(VB_CONF_S));
stSize.u32Width = 720;
stSize.u32Height = 576;
// hi_math.h required for CEILING_2_POWER()
u32BlkSize = CEILING_2_POWER(stSize.u32Width, SAMPLE_SYS_ALIGN_WIDTH) * CEILING_2_POWER(stSize.u32Height, SAMPLE_SYS_ALIGN_WIDTH) * 1.5;
stVbConf.u32MaxPoolCnt = 128;
// ddr0 video buffer
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 8;
// ----------------------------------------------------------
// **********************************************************
// step 2: mpp system init
// **********************************************************
MPP_SYS_CONF_S stSysConf = { 0 };
stSysConf.u32AlignWidth = SAMPLE_SYS_ALIGN_WIDTH;
HI_MPI_SYS_Exit(); // Deinitializes the HiMPP system
HI_MPI_VB_Exit(); // Deinitializes the HiMPP VB pool
// Sets the attributes of the HiMPP VB pool
s32Ret = HI_MPI_VB_SetConf(&stVbConf);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
// Initializes a HiMPP VB pool
s32Ret = HI_MPI_VB_Init();
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
// Sets system control parameters
s32Ret = HI_MPI_SYS_SetConf(&stSysConf);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_SYS_SetConf failed\n");
return HI_FAILURE;
}
// Initializes the HiMPP system
s32Ret = HI_MPI_SYS_Init();
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_SYS_Init failed!\n");
return HI_FAILURE;
}
// ----------------------------------------------------------
// **********************************************************
// step 3: start vi dev & chn to capture
// **********************************************************
VI_DEV ViDev;
HI_S32 i;
/*** get parameter from Sample_Vi_Mode ***/
SAMPLE_VI_PARAM_S stViParam;
stViParam.s32ViDevCnt = 1;
stViParam.s32ViDevInterval = 1;
stViParam.s32ViChnCnt = 1;
stViParam.s32ViChnInterval = 1;
VI_DEV_ATTR_S stViDevAttr;
memset(&stViDevAttr, 0, sizeof(stViDevAttr));
memcpy(&stViDevAttr, &DEV_ATTR_BT656D1_1MUX, sizeof(stViDevAttr));
//stViDevAttr.stDevRect.s32X = 0;
//stViDevAttr.stDevRect.s32Y = 0;
//stViDevAttr.stDevRect.u32Width = 720;
//stViDevAttr.stDevRect.u32Height = 576;
/*** Start VI Dev ***/
for(i = 0; i < stViParam.s32ViDevCnt; i++) {
ViDev = i * stViParam.s32ViDevInterval;
s32Ret = HI_MPI_VI_SetDevAttr(ViDev, &stViDevAttr); // ERROR HERE
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VI_SetDevAttr failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableDev(ViDev);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VI_EnableDev failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
/*** Start VI Chn ***/
VI_CHN_ATTR_S stChnAttr;
for(i = 0; i < stViParam.s32ViChnCnt; i++) {
ViChn = i * stViParam.s32ViChnInterval;
stChnAttr.stCapRect.s32X = 0;
stChnAttr.stCapRect.s32Y = 0;
stChnAttr.stCapRect.u32Width = 720;
stChnAttr.stCapRect.u32Height = 576;
stChnAttr.enCapSel = VI_CAPSEL_BOTH;
stChnAttr.stDestSize.u32Width = 720;
stChnAttr.stDestSize.u32Height = 576;
stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;
stChnAttr.bMirror = 0;
stChnAttr.bFlip = 0;
//stChnAttr.bChromaResample = 0;
stChnAttr.s32SrcFrameRate = 25;
stChnAttr.s32DstFrameRate = 25;
s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr);
if (s32Ret != HI_SUCCESS) {
printf("failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableChn(ViChn);
if (s32Ret != HI_SUCCESS) {
printf("failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
// ----------------------------------------------------------
// TODO: HI_MPI_VI_GetFrame() just here
printf("---------------press any key to exit!---------------\n");
getchar();
return s32Ret;
}
[img]static/image/hrline/5.gif[/img]
#include "hi_init_config.h"
#include "asm/delay.h"
HI_CHAR *sensor_type0 = "";
HI_CHAR *sensor_type1 = "";
static HI_VOID vicap_pin_mux(void) {
ILOGD("vicap_pin_mux ...\n");
//VI BT656 input used
//#vi1 pinmux
himm(0x12040030, 0x1); // #VI1_CLK
himm(0x12040028, 0x1); // #VI1_HS
himm(0x1204002c, 0x1); // #VI1_VS
himm(0x12040034, 0x1); // #VI1_DATA0
himm(0x12040038, 0x1); // #VI1_DATA1
himm(0x1204003c, 0x1); // #VI1_DATA2
himm(0x12040040, 0x1); // #VI1_DATA3
himm(0x12040044, 0x1); // #VI1_DATA4
himm(0x12040048, 0x1); // #VI1_DATA5
//#vi1 drive capability
himm(0x12040830, 0x170); // #VI1_CLK
himm(0x12040828, 0x170); // #VI1_HS
himm(0x1204082c, 0x170); // #VI1_VS
himm(0x12040834, 0x170); // #VI1_DATA0
himm(0x12040838, 0x170); // #VI1_DATA1
himm(0x1204083c, 0x170); // #VI1_DATA2
himm(0x12040840, 0x170); // #VI1_DATA3
himm(0x12040844, 0x170); // #VI1_DATA4
himm(0x12040848, 0x170); // #VI1_DATA5
}
static HI_VOID clkcfg_hi3559v100(void) {
ILOGD("clkcfg_hi3559v100 ...\n");
// Advanced Peripheral Bus (APB) bridge module
// PERI_CRG57 is a clock soft reset control register for other APB modules
// UART clock 25MHz, Enable UART0, UART1, UART2, UART3, UART4 clocks
// (Synchronous Serial Port) SSP3, SSP2, SSP1, SSP0 clock enable
// Test clock enable, I2C clock 50MHz
himm (0x120100e4, 0x1ff70000);
// ------------------------------------------------------------------------
// PERI_CRG15 is a VI-MIPI clock reset configuration register
// VI1, VI0 clock enabled
// ISP1, ISP0 clock enabled [TODO: bypass IPS?]
himm (0x1201003c, 0x31000100);
// ------------------------------------------------------------------------
// Video encoding decoding unit (VEDU)
// PERI_CRG20 is a VEDU clock and soft reset control register
// VEDU clock enabled
himm (0x12010050, 0x02);
// ------------------------------------------------------------------------
// Video processing subsystem (VPSS)
// PERI_CRG22 is a VPSS clock and soft reset control register
// VPSS clock enabled
himm (0x12010058, 0x02);
// ------------------------------------------------------------------------
// Video graphics subsystem (VGS)
// PERI_CRG23 a VGS clock and soft reset control register
// VGS clock enabled
himm (0x1201005c, 0x02);
// ------------------------------------------------------------------------
// JPEG encoder (JPGE)
// PERI_CRG24 is a JPGE clock and soft reset control register
// JPGE clock enabled
himm (0x12010060, 0x02);
// ------------------------------------------------------------------------
// The two-dimensional engine (TDE) draws graphics using hardware
// PERI_CRG25 is a TDE clock and soft reset control register
// TDE clock enabled
himm (0x12010064, 0x02);
// ------------------------------------------------------------------------
// The geometric distortion correction (GDC) implements picture distortion correction
// PERI_CRG29 is a GDC clock and soft reset control register
// GDC clock enabled
himm (0x12010074, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG31 is a hash/LSADC/cipher clock and soft reset control register
// (Low-Speed ADC) LSADC clock enabled
himm (0x1201007C, 0x08);
// ------------------------------------------------------------------------
// The audio input/output (AIAO) interface
// PERI_CRG32 is an AIAO clock reset control register
// AIAO bus clock enabled
himm (0x12010080, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG33 is a GZIP clock and soft reset control register
// GZIP clock enabled
himm (0x12010084, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG56 is an RSA/TRNG/KLAD/DMA clock and soft reset control register
// DMA clock enabled, KLAD clock enabled
himm (0x120100e0, 0x0A);
// ------------------------------------------------------------------------
// PERI_CRG16 is a sensor clock configuration register
// Aplly Sensor0 soft reset
//himm (0x12010040, 0x60);
//himm (0x12010040, 0x00);
// ------------------------------------------------------------------------
// PERI_CRG19 is media CBB frequency configuration register 1
// VI0 clock 600 MHz, VPSS clock 300 MHz, VEDU clock 500 MHz
// VGS clock 500 MHz, GDC clock 475 MHz, IVE clock 396 MHz
// The intelligent video engine (IVE) module is used to accelerate hardware processing
himm (0x1201004c, 0x00094823);
// ------------------------------------------------------------------------
// PERI_CRG21 is media CBB frequency configuration register 2
// VI1 clock 600 MHz, ISP1 clock 300 MHz, ISP0 clock 600 MHz (as VI0 clock)
himm (0x12010054, 0x00020043);
// ------------------------------------------------------------------------
//lowpower config
himm(0x12030084, 0x500);
himm(0x12030084, 0x10500);
himm(0x12030084, 0x500);
himm(0x12030084, 0x00);
himm(0x12030084, 0x600);
himm(0x12030084, 0x10600);
himm(0x12030084, 0x600);
himm(0x12030084, 0x00);
himm(0x120100b0, 0x000001f0); // # pcie clk disable
himm(0x120100D0, 0x00); // # VDMA reset
himm(0x120100B8, 0x2001); // # USB3.0 reset
ILOGD("clock configure operation done!\n");
}
extern HI_U32 g_u32vi_vpss_online;
static HI_VOID sysctl_hi3559v100(void) {
ILOGD("sysctl_hi3559v100 ...\n");
// MISC_CTRL56 is an I2S channel selection control register
// The channel between the I2S interface of the chip and AIAO is enabled
// I2S interface of the chip connects to the I2S interface of the AIAO
himm(0x120300e0, 0x0E);
// ------------------------------------------------------------------------
if (g_u32vi_vpss_online) {
/*
ILOGE("==============vi_vpss_online==============");
// MISC_CTRL0 is a VICAP/VPSS/MIPI PHY control register
himm(0x12030000, 0x00000204);
//# write priority select
himm( 0x12030054, 0x55552356 ); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm( 0x12030058, 0x16554411 ); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm( 0x1203005c, 0x33466314); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm( 0x12030060, 0x46266666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
//# read priority select
himm( 0x12030064 , 0x55552356); //# each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm( 0x12030068 , 0x06554401); //# each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm( 0x1203006c , 0x33466304); //# each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm( 0x12030070 , 0x46266666); //# each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
himm( 0x120641f0 , 0x1); //# use pri_map
//# write timeout select
himm( 0x1206409c , 0x00000040); //#
himm( 0x120640a0 , 0x00000000); //#
//#read timeout select
himm( 0x120640ac, 0x00000040); //#
himm( 0x120640b0, 0x00000000); //#
//# timeout select
//himm (0x120641f0, 0x1); //# use pri_map
//himm (0x120640ac, 0x00000040) //#
//himm (0x120640b0, 0x00000000);
*/ }
else {
// allways work in offline mode
ILOGD("==============vi_vpss_offline==============\n");
// MISC_CTRL0 is a VICAP/VPSS/MIPI PHY control register
// VICAP1 input select CMOS1, VICAP0 input select CMOS0
himm(0x12030000, 0x0000000E);
// ------------------------------------------------------------------------
//# write priority select
himm(0x12030054, 0x55552366); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm(0x12030058, 0x16556611); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm(0x1203005c, 0x43466445); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm(0x12030060, 0x56466666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
//# read priority select
himm(0x12030064, 0x55552366); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm(0x12030068, 0x06556600); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm(0x1203006c, 0x43466435); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm(0x12030070, 0x56266666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
himm(0x120641f0, 0x00000001); // # use pri_map
//# write timeout select
himm(0x1206409c, 0x00000040); // #
himm(0x120640a0, 0x00000000); // #
//# read timeout select
himm(0x120640ac, 0x00000040); // #
himm(0x120640b0, 0x00000000); // #
}
// ive utili
//himm(0x11040000, 0x2); // Open utili statistic
//himm(0x11040080, 0x11E1A300); // Utili peri,default 0x11E1A300 cycle
}
static void vcap1_power_on() {
int count = 0;
int pwr_on = 0;
ILOGD("vcap1_power_on ...\n");
// PERI_CRG15 is a VI-MIPI clock reset configuration register
// VI0 clock gating enabled, VI0 soft reset, VI0 bus soft reset
// VI1 clock gating enabled, VI1 soft reset, VI1 bus soft reset
// ISP0 clock gating enabled, ISP0 core soft reset, ISP0 CFG soft reset
// ISP1 clock gating enabled, ISP1 core soft reset, ISP1 CFG soft reset
// TODO: ISP bypass?
himm (0x1201003c, 0x31330133);
// ------------------------------------------------------------------------
mdelay(1);
// PERI_PMC75 is a VICAP1 power-on/power-off control register
// VICAP1 powered-on mode
// VICAP1 signal isolation enabled
// The signal must be isolated before power-off, and the bus must be idle when isolation is started)
himm(0x120A012C, 0x03);
// ------------------------------------------------------------------------
while (count < 500) {
// Read VICAP1 power supply status
pwr_on = readl(0x120A012C) & 0x4;
if (pwr_on) {
break;
}
count++;
}
if(count == 500) {
ILOGD("vcap1_power_on ERROR...\n");
}
himm(0x120A012C, 0x2);
TIME_STAMP;
}
static void chip_cfg() {
TIME_STAMP;
vcap1_power_on();
vicap_pin_mux();
clkcfg_hi3559v100();
sysctl_hi3559v100();
}
HI_S32 HI_HAL_Board_PreInit(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
extern HI_S32 HI_RTC_Init();
s32Ret = HI_RTC_Init();
return s32Ret;
}
HI_S32 HI_HAL_Board_Init(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
chip_cfg();
TIME_STAMP;
return s32Ret;
}
HI_S32 HI_HAL_Board_PostInit(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
return s32Ret;
}
[img]static/image/hrline/5.gif[/img]
Unfortunately in my SDK there are no examples of working with BT656 VI.
I used the examples from the SDK for the hi3518 chip (based on the HiMPP IPC V3.0 Media Processing Software document, i think working with BT656 is no different), but nothing worked.
Function HI_MPI_VI_SetDevAttr() returning 0xA0108003 code(HI_ERR_VI_INVALID_PARA).
Question 1: How the internal registers of the hi3559 chip should be configured?
Question 2: Is there any user manual about working in BT656 mode?
[img]static/image/hrline/5.gif[/img]
VI_DEV_ATTR_S DEV_ATTR_BT656D1_1MUX = {
VI_MODE_BT656, // Interface mode
VI_WORK_MODE_1Multiplex, // 1, 2, and 4 working modes
{0xFF000000, 0x00}, // r_mask g_mask b_mask
VI_SCAN_PROGRESSIVE, // Progressive or interlaced input
{-1, -1, -1, -1}, // AdChnId
VI_INPUT_DATA_YVYU, // enDataSeq, Only supports YUV format
// Synchronization information, corresponding to the following configuration of the reg manual, --bt1120 timing is invalid
// port_vsync port_vsync_neg port_hsync port_hsync_neg
{
VI_VSYNC_FIELD, VI_VSYNC_NEG_HIGH, VI_HSYNC_VALID_SINGNAL, VI_HSYNC_NEG_HIGH, VI_VSYNC_VALID_SINGAL, VI_VSYNC_VALID_NEG_HIGH,
// timing information, corresponding to the following configuration of the reg manual
{
// hsync_hfb hsync_act hsync_hhb
0, 0, 0,
// vsync0_vhb vsync0_act vsync0_hhb
0, 0, 0,
// vsync1_vhb vsync1_act vsync1_hhb
0, 0, 0
}
// ----------------------------------------------------------------------------------
},
// -----------------------------------------------------------------------------------------------------------------------
VI_PATH_BYPASS, // Use internal ISP
VI_DATA_TYPE_YUV // Input data type
};
HI_S32 VI_D1_BT656(void) {
#define SAMPLE_SYS_ALIGN_WIDTH 64
#define SAMPLE_PIXEL_FORMAT PIXEL_FORMAT_YUV_SEMIPLANAR_420
HI_U32 u32ViChnCnt = 1;
VI_CHN ViChn = 0;
HI_S32 s32Ret = HI_SUCCESS;
HI_U32 u32BlkSize;
// **********************************************************
// step 1: init global variables
// **********************************************************
VB_CONF_S stVbConf;
SIZE_S stSize;
memset(&stVbConf, 0, sizeof(VB_CONF_S));
stSize.u32Width = 720;
stSize.u32Height = 576;
// hi_math.h required for CEILING_2_POWER()
u32BlkSize = CEILING_2_POWER(stSize.u32Width, SAMPLE_SYS_ALIGN_WIDTH) * CEILING_2_POWER(stSize.u32Height, SAMPLE_SYS_ALIGN_WIDTH) * 1.5;
stVbConf.u32MaxPoolCnt = 128;
// ddr0 video buffer
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 8;
// ----------------------------------------------------------
// **********************************************************
// step 2: mpp system init
// **********************************************************
MPP_SYS_CONF_S stSysConf = { 0 };
stSysConf.u32AlignWidth = SAMPLE_SYS_ALIGN_WIDTH;
HI_MPI_SYS_Exit(); // Deinitializes the HiMPP system
HI_MPI_VB_Exit(); // Deinitializes the HiMPP VB pool
// Sets the attributes of the HiMPP VB pool
s32Ret = HI_MPI_VB_SetConf(&stVbConf);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
// Initializes a HiMPP VB pool
s32Ret = HI_MPI_VB_Init();
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
// Sets system control parameters
s32Ret = HI_MPI_SYS_SetConf(&stSysConf);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_SYS_SetConf failed\n");
return HI_FAILURE;
}
// Initializes the HiMPP system
s32Ret = HI_MPI_SYS_Init();
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_SYS_Init failed!\n");
return HI_FAILURE;
}
// ----------------------------------------------------------
// **********************************************************
// step 3: start vi dev & chn to capture
// **********************************************************
VI_DEV ViDev;
HI_S32 i;
/*** get parameter from Sample_Vi_Mode ***/
SAMPLE_VI_PARAM_S stViParam;
stViParam.s32ViDevCnt = 1;
stViParam.s32ViDevInterval = 1;
stViParam.s32ViChnCnt = 1;
stViParam.s32ViChnInterval = 1;
VI_DEV_ATTR_S stViDevAttr;
memset(&stViDevAttr, 0, sizeof(stViDevAttr));
memcpy(&stViDevAttr, &DEV_ATTR_BT656D1_1MUX, sizeof(stViDevAttr));
//stViDevAttr.stDevRect.s32X = 0;
//stViDevAttr.stDevRect.s32Y = 0;
//stViDevAttr.stDevRect.u32Width = 720;
//stViDevAttr.stDevRect.u32Height = 576;
/*** Start VI Dev ***/
for(i = 0; i < stViParam.s32ViDevCnt; i++) {
ViDev = i * stViParam.s32ViDevInterval;
s32Ret = HI_MPI_VI_SetDevAttr(ViDev, &stViDevAttr); // ERROR HERE
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VI_SetDevAttr failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableDev(ViDev);
if (s32Ret != HI_SUCCESS) {
printf("HI_MPI_VI_EnableDev failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
/*** Start VI Chn ***/
VI_CHN_ATTR_S stChnAttr;
for(i = 0; i < stViParam.s32ViChnCnt; i++) {
ViChn = i * stViParam.s32ViChnInterval;
stChnAttr.stCapRect.s32X = 0;
stChnAttr.stCapRect.s32Y = 0;
stChnAttr.stCapRect.u32Width = 720;
stChnAttr.stCapRect.u32Height = 576;
stChnAttr.enCapSel = VI_CAPSEL_BOTH;
stChnAttr.stDestSize.u32Width = 720;
stChnAttr.stDestSize.u32Height = 576;
stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;
stChnAttr.bMirror = 0;
stChnAttr.bFlip = 0;
//stChnAttr.bChromaResample = 0;
stChnAttr.s32SrcFrameRate = 25;
stChnAttr.s32DstFrameRate = 25;
s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr);
if (s32Ret != HI_SUCCESS) {
printf("failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableChn(ViChn);
if (s32Ret != HI_SUCCESS) {
printf("failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
// ----------------------------------------------------------
// TODO: HI_MPI_VI_GetFrame() just here
printf("---------------press any key to exit!---------------\n");
getchar();
return s32Ret;
}
[img]static/image/hrline/5.gif[/img]
#include "hi_init_config.h"
#include "asm/delay.h"
HI_CHAR *sensor_type0 = "";
HI_CHAR *sensor_type1 = "";
static HI_VOID vicap_pin_mux(void) {
ILOGD("vicap_pin_mux ...\n");
//VI BT656 input used
//#vi1 pinmux
himm(0x12040030, 0x1); // #VI1_CLK
himm(0x12040028, 0x1); // #VI1_HS
himm(0x1204002c, 0x1); // #VI1_VS
himm(0x12040034, 0x1); // #VI1_DATA0
himm(0x12040038, 0x1); // #VI1_DATA1
himm(0x1204003c, 0x1); // #VI1_DATA2
himm(0x12040040, 0x1); // #VI1_DATA3
himm(0x12040044, 0x1); // #VI1_DATA4
himm(0x12040048, 0x1); // #VI1_DATA5
//#vi1 drive capability
himm(0x12040830, 0x170); // #VI1_CLK
himm(0x12040828, 0x170); // #VI1_HS
himm(0x1204082c, 0x170); // #VI1_VS
himm(0x12040834, 0x170); // #VI1_DATA0
himm(0x12040838, 0x170); // #VI1_DATA1
himm(0x1204083c, 0x170); // #VI1_DATA2
himm(0x12040840, 0x170); // #VI1_DATA3
himm(0x12040844, 0x170); // #VI1_DATA4
himm(0x12040848, 0x170); // #VI1_DATA5
}
static HI_VOID clkcfg_hi3559v100(void) {
ILOGD("clkcfg_hi3559v100 ...\n");
// Advanced Peripheral Bus (APB) bridge module
// PERI_CRG57 is a clock soft reset control register for other APB modules
// UART clock 25MHz, Enable UART0, UART1, UART2, UART3, UART4 clocks
// (Synchronous Serial Port) SSP3, SSP2, SSP1, SSP0 clock enable
// Test clock enable, I2C clock 50MHz
himm (0x120100e4, 0x1ff70000);
// ------------------------------------------------------------------------
// PERI_CRG15 is a VI-MIPI clock reset configuration register
// VI1, VI0 clock enabled
// ISP1, ISP0 clock enabled [TODO: bypass IPS?]
himm (0x1201003c, 0x31000100);
// ------------------------------------------------------------------------
// Video encoding decoding unit (VEDU)
// PERI_CRG20 is a VEDU clock and soft reset control register
// VEDU clock enabled
himm (0x12010050, 0x02);
// ------------------------------------------------------------------------
// Video processing subsystem (VPSS)
// PERI_CRG22 is a VPSS clock and soft reset control register
// VPSS clock enabled
himm (0x12010058, 0x02);
// ------------------------------------------------------------------------
// Video graphics subsystem (VGS)
// PERI_CRG23 a VGS clock and soft reset control register
// VGS clock enabled
himm (0x1201005c, 0x02);
// ------------------------------------------------------------------------
// JPEG encoder (JPGE)
// PERI_CRG24 is a JPGE clock and soft reset control register
// JPGE clock enabled
himm (0x12010060, 0x02);
// ------------------------------------------------------------------------
// The two-dimensional engine (TDE) draws graphics using hardware
// PERI_CRG25 is a TDE clock and soft reset control register
// TDE clock enabled
himm (0x12010064, 0x02);
// ------------------------------------------------------------------------
// The geometric distortion correction (GDC) implements picture distortion correction
// PERI_CRG29 is a GDC clock and soft reset control register
// GDC clock enabled
himm (0x12010074, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG31 is a hash/LSADC/cipher clock and soft reset control register
// (Low-Speed ADC) LSADC clock enabled
himm (0x1201007C, 0x08);
// ------------------------------------------------------------------------
// The audio input/output (AIAO) interface
// PERI_CRG32 is an AIAO clock reset control register
// AIAO bus clock enabled
himm (0x12010080, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG33 is a GZIP clock and soft reset control register
// GZIP clock enabled
himm (0x12010084, 0x02);
// ------------------------------------------------------------------------
// PERI_CRG56 is an RSA/TRNG/KLAD/DMA clock and soft reset control register
// DMA clock enabled, KLAD clock enabled
himm (0x120100e0, 0x0A);
// ------------------------------------------------------------------------
// PERI_CRG16 is a sensor clock configuration register
// Aplly Sensor0 soft reset
//himm (0x12010040, 0x60);
//himm (0x12010040, 0x00);
// ------------------------------------------------------------------------
// PERI_CRG19 is media CBB frequency configuration register 1
// VI0 clock 600 MHz, VPSS clock 300 MHz, VEDU clock 500 MHz
// VGS clock 500 MHz, GDC clock 475 MHz, IVE clock 396 MHz
// The intelligent video engine (IVE) module is used to accelerate hardware processing
himm (0x1201004c, 0x00094823);
// ------------------------------------------------------------------------
// PERI_CRG21 is media CBB frequency configuration register 2
// VI1 clock 600 MHz, ISP1 clock 300 MHz, ISP0 clock 600 MHz (as VI0 clock)
himm (0x12010054, 0x00020043);
// ------------------------------------------------------------------------
//lowpower config
himm(0x12030084, 0x500);
himm(0x12030084, 0x10500);
himm(0x12030084, 0x500);
himm(0x12030084, 0x00);
himm(0x12030084, 0x600);
himm(0x12030084, 0x10600);
himm(0x12030084, 0x600);
himm(0x12030084, 0x00);
himm(0x120100b0, 0x000001f0); // # pcie clk disable
himm(0x120100D0, 0x00); // # VDMA reset
himm(0x120100B8, 0x2001); // # USB3.0 reset
ILOGD("clock configure operation done!\n");
}
extern HI_U32 g_u32vi_vpss_online;
static HI_VOID sysctl_hi3559v100(void) {
ILOGD("sysctl_hi3559v100 ...\n");
// MISC_CTRL56 is an I2S channel selection control register
// The channel between the I2S interface of the chip and AIAO is enabled
// I2S interface of the chip connects to the I2S interface of the AIAO
himm(0x120300e0, 0x0E);
// ------------------------------------------------------------------------
if (g_u32vi_vpss_online) {
/*
ILOGE("==============vi_vpss_online==============");
// MISC_CTRL0 is a VICAP/VPSS/MIPI PHY control register
himm(0x12030000, 0x00000204);
//# write priority select
himm( 0x12030054, 0x55552356 ); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm( 0x12030058, 0x16554411 ); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm( 0x1203005c, 0x33466314); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm( 0x12030060, 0x46266666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
//# read priority select
himm( 0x12030064 , 0x55552356); //# each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm( 0x12030068 , 0x06554401); //# each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm( 0x1203006c , 0x33466304); //# each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm( 0x12030070 , 0x46266666); //# each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
himm( 0x120641f0 , 0x1); //# use pri_map
//# write timeout select
himm( 0x1206409c , 0x00000040); //#
himm( 0x120640a0 , 0x00000000); //#
//#read timeout select
himm( 0x120640ac, 0x00000040); //#
himm( 0x120640b0, 0x00000000); //#
//# timeout select
//himm (0x120641f0, 0x1); //# use pri_map
//himm (0x120640ac, 0x00000040) //#
//himm (0x120640b0, 0x00000000);
*/ }
else {
// allways work in offline mode
ILOGD("==============vi_vpss_offline==============\n");
// MISC_CTRL0 is a VICAP/VPSS/MIPI PHY control register
// VICAP1 input select CMOS1, VICAP0 input select CMOS0
himm(0x12030000, 0x0000000E);
// ------------------------------------------------------------------------
//# write priority select
himm(0x12030054, 0x55552366); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm(0x12030058, 0x16556611); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm(0x1203005c, 0x43466445); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm(0x12030060, 0x56466666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
//# read priority select
himm(0x12030064, 0x55552366); // # each module 4bit ---- ---- --- --- Fish gzip fd pcie
himm(0x12030068, 0x06556600); // # each module 4bit vicap1 hash ive aio jpge tde vicap vdp
himm(0x1203006c, 0x43466435); // # each module 4bit A17 vpss1 fmc sdio1 sdio0 A7 vpss0 vgs
himm(0x12030070, 0x56266666); // # each module 4bit gdc usb3 vedu usb2 cipher dma2 dma1 gsf
himm(0x120641f0, 0x00000001); // # use pri_map
//# write timeout select
himm(0x1206409c, 0x00000040); // #
himm(0x120640a0, 0x00000000); // #
//# read timeout select
himm(0x120640ac, 0x00000040); // #
himm(0x120640b0, 0x00000000); // #
}
// ive utili
//himm(0x11040000, 0x2); // Open utili statistic
//himm(0x11040080, 0x11E1A300); // Utili peri,default 0x11E1A300 cycle
}
static void vcap1_power_on() {
int count = 0;
int pwr_on = 0;
ILOGD("vcap1_power_on ...\n");
// PERI_CRG15 is a VI-MIPI clock reset configuration register
// VI0 clock gating enabled, VI0 soft reset, VI0 bus soft reset
// VI1 clock gating enabled, VI1 soft reset, VI1 bus soft reset
// ISP0 clock gating enabled, ISP0 core soft reset, ISP0 CFG soft reset
// ISP1 clock gating enabled, ISP1 core soft reset, ISP1 CFG soft reset
// TODO: ISP bypass?
himm (0x1201003c, 0x31330133);
// ------------------------------------------------------------------------
mdelay(1);
// PERI_PMC75 is a VICAP1 power-on/power-off control register
// VICAP1 powered-on mode
// VICAP1 signal isolation enabled
// The signal must be isolated before power-off, and the bus must be idle when isolation is started)
himm(0x120A012C, 0x03);
// ------------------------------------------------------------------------
while (count < 500) {
// Read VICAP1 power supply status
pwr_on = readl(0x120A012C) & 0x4;
if (pwr_on) {
break;
}
count++;
}
if(count == 500) {
ILOGD("vcap1_power_on ERROR...\n");
}
himm(0x120A012C, 0x2);
TIME_STAMP;
}
static void chip_cfg() {
TIME_STAMP;
vcap1_power_on();
vicap_pin_mux();
clkcfg_hi3559v100();
sysctl_hi3559v100();
}
HI_S32 HI_HAL_Board_PreInit(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
extern HI_S32 HI_RTC_Init();
s32Ret = HI_RTC_Init();
return s32Ret;
}
HI_S32 HI_HAL_Board_Init(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
chip_cfg();
TIME_STAMP;
return s32Ret;
}
HI_S32 HI_HAL_Board_PostInit(HI_VOID) {
HI_S32 s32Ret = HI_SUCCESS;
return s32Ret;
}
[img]static/image/hrline/5.gif[/img]
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2017-07-20 19:42:38
-
2019-10-09 22:44:44
-
2019-05-14 17:38:53
-
2020-06-27 01:26:19
-
2019-06-20 16:33:19
-
2022-11-29 17:21:33
-
32018-12-12 15:23:11
-
2019-06-05 16:16:50
-
2020-08-01 17:40:31
-
2017-07-22 12:52:57
-
2017-01-14 14:49:24
-
2019-12-23 20:27:52
-
2016-03-08 14:58:45
-
2019-10-15 17:26:35
-
2019-11-16 10:10:52
-
2019-07-29 16:46:53
-
2019-03-03 02:04:08
-
2019-05-16 11:44:42
-
2020-11-04 09:36:29
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认