📄 prpclass.cpp
字号:
(TEXT("%s: Requested viewfinding height %x greater than display height %x. Height will be set to the display height. \r\n"),
__WFUNCTION__, iVfOutputHeight, m_displayCharacteristics.height));
}
//-----------------------------------------------------------------
// Setup color space conversion
//-----------------------------------------------------------------
// Set up CSC for viewfinding
if (configData->vfCSCEquation != prpCSCNoOp)
{
switch (configData->vfCSCEquation)
{
case prpCSCR2Y_A1:
case prpCSCR2Y_A0:
case prpCSCR2Y_B0:
case prpCSCR2Y_B1:
CSCCoeffs.C00 = rgb2yuv_tbl[configData->vfCSCEquation][0];
CSCCoeffs.C01 = rgb2yuv_tbl[configData->vfCSCEquation][1];
CSCCoeffs.C02 = rgb2yuv_tbl[configData->vfCSCEquation][2];
CSCCoeffs.C10 = rgb2yuv_tbl[configData->vfCSCEquation][3];
CSCCoeffs.C11 = rgb2yuv_tbl[configData->vfCSCEquation][4];
CSCCoeffs.C12 = rgb2yuv_tbl[configData->vfCSCEquation][5];
CSCCoeffs.C20 = rgb2yuv_tbl[configData->vfCSCEquation][6];
CSCCoeffs.C21 = rgb2yuv_tbl[configData->vfCSCEquation][7];
CSCCoeffs.C22 = rgb2yuv_tbl[configData->vfCSCEquation][8];
CSCCoeffs.A0 = rgb2yuv_tbl[configData->vfCSCEquation][9];
CSCCoeffs.A1 = rgb2yuv_tbl[configData->vfCSCEquation][10];
CSCCoeffs.A2 = rgb2yuv_tbl[configData->vfCSCEquation][11];
CSCCoeffs.Scale = rgb2yuv_tbl[configData->vfCSCEquation][12];
break;
case prpCSCY2R_A1:
case prpCSCY2R_A0:
case prpCSCY2R_B0:
case prpCSCY2R_B1:
CSCCoeffs.C00 = yuv2rgb_tbl[configData->vfCSCEquation - 4][0];
CSCCoeffs.C01 = yuv2rgb_tbl[configData->vfCSCEquation - 4][1];
CSCCoeffs.C02 = yuv2rgb_tbl[configData->vfCSCEquation - 4][2];
CSCCoeffs.C10 = yuv2rgb_tbl[configData->vfCSCEquation - 4][3];
CSCCoeffs.C11 = yuv2rgb_tbl[configData->vfCSCEquation - 4][4];
CSCCoeffs.C12 = yuv2rgb_tbl[configData->vfCSCEquation - 4][5];
CSCCoeffs.C20 = yuv2rgb_tbl[configData->vfCSCEquation - 4][6];
CSCCoeffs.C21 = yuv2rgb_tbl[configData->vfCSCEquation - 4][7];
CSCCoeffs.C22 = yuv2rgb_tbl[configData->vfCSCEquation - 4][8];
CSCCoeffs.A0 = yuv2rgb_tbl[configData->vfCSCEquation - 4][9];
CSCCoeffs.A1 = yuv2rgb_tbl[configData->vfCSCEquation - 4][10];
CSCCoeffs.A2 = yuv2rgb_tbl[configData->vfCSCEquation - 4][11];
CSCCoeffs.Scale = yuv2rgb_tbl[configData->vfCSCEquation - 4][12];
break;
case prpCSCCustom:
CSCCoeffs.C00 = configData->vfCSCCoeffs.C00;
CSCCoeffs.C01 = configData->vfCSCCoeffs.C01;
CSCCoeffs.C02 = configData->vfCSCCoeffs.C02;
CSCCoeffs.C10 = configData->vfCSCCoeffs.C10;
CSCCoeffs.C11 = configData->vfCSCCoeffs.C11;
CSCCoeffs.C12 = configData->vfCSCCoeffs.C12;
CSCCoeffs.C20 = configData->vfCSCCoeffs.C20;
CSCCoeffs.C21 = configData->vfCSCCoeffs.C21;
CSCCoeffs.C22 = configData->vfCSCCoeffs.C22;
CSCCoeffs.A0 = configData->vfCSCCoeffs.A0;
CSCCoeffs.A1 = configData->vfCSCCoeffs.A1;
CSCCoeffs.A2 = configData->vfCSCCoeffs.A2;
CSCCoeffs.Scale = configData->vfCSCCoeffs.Scale;
break;
default:
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Invalid viewfinding CSC equation. \r\n"), __WFUNCTION__));
}
// Set up the task parameter memory
PrpTaskParamConfig(prpCSCVfMatrix1, &CSCCoeffs);
// Now enable CSC in IC configuration register
INSREG32BF(&P_IPU_REGS->IC_CONF, IPU_IC_CONF_PRPVF_CSC1,
IPU_IC_CONF_PRPVF_CSC1_ENABLE);
}
else
{
// Disable CSC in IC configuration register
INSREG32BF(&P_IPU_REGS->IC_CONF, IPU_IC_CONF_PRPVF_CSC1,
IPU_IC_CONF_PRPVF_CSC1_DISABLE);
}
//-----------------------------------------------------------------
// Set up resizing.
//-----------------------------------------------------------------
// Viewfinding path
if (configData->vfFormat != prpVfOutputFormat_Disabled)
{
// Vertical resizing
// Get coefficients and then set registers
if (!PrpGetResizeCoeffs(configData->inputSize.height,
configData->vfSize.height, &resizeCoeffs))
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Viewfinding vertical resizing failed. \r\n"), __WFUNCTION__));
result = FALSE;
goto _vfDone;
}
// Set downsizing field
INSREG32BF(&P_IPU_REGS->IC_PRP_VF_RSC, IPU_IC_PRP_VF_RSC_PRPVF_DS_R_V,
resizeCoeffs.downsizeCoeff);
// Set resizing field
INSREG32BF(&P_IPU_REGS->IC_PRP_VF_RSC, IPU_IC_PRP_VF_RSC_PRPVF_RS_R_V,
resizeCoeffs.resizeCoeff);
// Horizontal resizing
// Get coefficients and then set registers
if (!PrpGetResizeCoeffs(configData->inputSize.width,
configData->vfSize.width, &resizeCoeffs))
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Viewfinding horizontal resizing failed. \r\n"), __WFUNCTION__));
result = FALSE;
goto _vfDone;
}
// Set downsizing field
INSREG32BF(&P_IPU_REGS->IC_PRP_VF_RSC, IPU_IC_PRP_VF_RSC_PRPVF_DS_R_H,
resizeCoeffs.downsizeCoeff);
// Set resizing field
INSREG32BF(&P_IPU_REGS->IC_PRP_VF_RSC, IPU_IC_PRP_VF_RSC_PRPVF_RS_R_H,
resizeCoeffs.resizeCoeff);
}
//-----------------------------------------------------------------
// Setup output format
//-----------------------------------------------------------------
switch(iVfFormat)
{
case prpVfOutputFormat_RGB:
if (m_displayCharacteristics.bpp == 24)
{
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 8;
channelParams.pixelFormat.component2_offset = 16;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
// 24 bits per pixel
channelParams.iLineStride = iVfOutputWidth * 3;
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_24;
channelParams.iPixelBurstCode = IDMAC_PIXEL_BURST_CODE_16;
}
else if (m_displayCharacteristics.bpp == 16)
{
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 5;
channelParams.pixelFormat.component2_offset = 11;
channelParams.pixelFormat.component0_width = 4;
channelParams.pixelFormat.component1_width = 5;
channelParams.pixelFormat.component2_width = 4;
// 16 bits per pixel
channelParams.iLineStride = iVfOutputWidth * 2;
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16;
channelParams.iPixelBurstCode = IDMAC_PIXEL_BURST_CODE_16;
}
break;
case prpVfOutputFormat_RGBA:
// TODO: Add support for RGBA, and find out data path and use cases for RGBA
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 8;
channelParams.pixelFormat.component2_offset = 16;
channelParams.pixelFormat.component3_offset = 24;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
channelParams.pixelFormat.component3_width = 7;
// 32 bits per pixel for RGB data
channelParams.iLineStride = iVfOutputWidth << 2;
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_32;
channelParams.iPixelBurstCode = IDMAC_PIXEL_BURST_CODE_16;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Invalid viewfinding output format, %d !! \r\n"), __WFUNCTION__, configData->vfFormat));
result = FALSE;
goto _vfDone;
}
//-----------------------------------------------------------------
// Image size validity check
// Setup viewfinding channel output image size
//-----------------------------------------------------------------
if((iVfOutputWidth < PRP_MIN_OUTPUT_WIDTH) ||
(iVfOutputHeight < PRP_MIN_OUTPUT_HEIGHT) ||
(iVfOutputWidth > PRP_MAX_OUTPUT_WIDTH) ||
(iVfOutputHeight > PRP_MAX_OUTPUT_HEIGHT) ||
(configData->inputSize.width > (iVfOutputWidth << 3)) ||
(configData->inputSize.height > (iVfOutputHeight << 3)))
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Error viewfinding channel size: \r\n"), __WFUNCTION__));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Input Size: width (%d), height (%d)\r\n"),
configData->inputSize.width, configData->inputSize.height));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Viewfinding Channel Size: width (%d), height (%d)\r\n"),
iVfOutputWidth, iVfOutputHeight));
result = FALSE;
goto _vfDone;
}
channelParams.iHeight = iVfOutputHeight;
channelParams.iWidth = iVfOutputWidth;
// Set member variable for whether we will be
// displaying viewfinder data directly to display or not.
m_bVfDirectDisplay = configData->directDisplay;
// The following are our scenarios for using
// the viewfinding channel:
// 1) Direct Display + SDC:
// - Set up frame sync for task chaining to SDC BG
// - Configure display for viewfinding
// 2) Direct Display + ADC:
// - Set up frame sync for task chaining to ADC direct
// - Configure display for viewfinding
// 3) No direct display:
// - Set up frame sync to write to memory
// - No configuration of display for viewfinding,
// as we will not be displaying viewfinding image
dumpIpuRegisters(P_IPU_REGS);
if (m_bVfDirectDisplay)
{
// Direct display mode enabled
// Set up display structure to configure
// display for viewfinding mode.
displayConfig.verticalFlip = FALSE;
displayConfig.alpha = 0xFF;
displayConfig.colorKey = 0;
displayConfig.plane = IPU_SDC_COM_CONF_GWSEL_FG;
if (configData->vfFlipRot.rotate90)
{
displayConfig.width = iVfOutputHeight;
displayConfig.height = iVfOutputWidth;
}
else
{
displayConfig.width = iVfOutputWidth;
displayConfig.height = iVfOutputHeight;
}
// Configure display for viewfinding mode
if (ExtEscape(m_hDisplay, VF_SET_OFFSET, sizeof(POINT),
(LPCSTR) &configData->vfOffset, 0, NULL) <= 0)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error initialize VF display mode. \r\n"), __WFUNCTION__));
return FALSE;
}
// Configure display for viewfinding mode
if (ExtEscape(m_hDisplay, VF_CONFIG, sizeof(DISPLAY_SDC_FG_CONFIG_DATA),
(LPCSTR) &displayConfig, 0, NULL) <= 0)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error initialize VF display mode. \r\n"), __WFUNCTION__));
return FALSE;
}
switch (m_displayCharacteristics.eType)
{
case eIPU_SDC:
m_bADCDirect = FALSE;
// Compute bitmask and shifted bit value for IPU_FS_PROC_FLOW register
iMask = CSP_BITFMASK(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL);
iBitval = CSP_BITFVAL(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL,
IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL_ARM);
// If display type is a dumb display, we configure
// frame synchronization to write data to SDC
// Foreground/Background plane.
do
{
oldVal = INREG32(&P_IPU_REGS->IPU_FS_PROC_FLOW);
newVal = (oldVal & (~iMask)) | iBitval;
} while (InterlockedTestExchange((LPLONG)&P_IPU_REGS->IPU_FS_PROC_FLOW,
oldVal, newVal) != oldVal);
break;
case eIPU_ADC:
m_bADCDirect = TRUE;
// Compute bitmask and shifted bit value for IPU_FS_PROC_FLOW register
iMask = CSP_BITFMASK(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL);
iBitval = CSP_BITFVAL(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL,
IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL_ADC_DIRECT);
// If display type is a smart display, we configure
// frame synchronization to write data to ADC
// Direct Viewfinding Channel
do
{
oldVal = INREG32(&P_IPU_REGS->IPU_FS_PROC_FLOW);
newVal = (oldVal & (~iMask)) | iBitval;
} while (InterlockedTestExchange((LPLONG)&P_IPU_REGS->IPU_FS_PROC_FLOW,
oldVal, newVal) != oldVal);
break;
default:
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error. Display type is neither SDC or ADC!\r\n"),
__WFUNCTION__));
return FALSE;
}
}
else
{
m_bADCDirect = FALSE;
// Compute bitmask and shifted bit value for IPU_FS_PROC_FLOW register
iMask = CSP_BITFMASK(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL);
iBitval = CSP_BITFVAL(IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL,
IPU_IPU_FS_PROC_FLOW_PRPVF_DEST_SEL_ARM);
// Direct display mo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -