ycrcb2rgb: Added new implementation in ycrcb2rgb_v7_0
Added new APIs for offset compensation, clippling, clampling, coefficients, throughput monitor and get version Added examples Signed-off-by: Shadul Shaikh <shaduls@xilinx.com> Acked-by: Srikanth Vemula <svemula@xilinx.com>
This commit is contained in:
parent
89ae17e5b3
commit
1ecae8852c
16 changed files with 3352 additions and 918 deletions
|
@ -1,9 +1,9 @@
|
|||
###############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# of this software and associated documentation files (the "Software"),to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
|
@ -27,7 +27,6 @@
|
|||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
OPTION psf_version = 2.1;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
###############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# of this software and associated documentation files (the "Software"),to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
|
@ -27,12 +27,12 @@
|
|||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
proc generate {drv_handle} {
|
||||
xdefine_include_file $drv_handle "xparameters.h" "YCRCB2RGB" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_MWIDTH" "C_COEF_RANGE" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_ROFFSET" "C_GOFFSET" "C_BOFFSET" "C_HAS_CLIP" "C_HAS_CLAMP" "C_RGBMAX" "C_RGBMIN"
|
||||
xdefine_include_file $drv_handle "xparameters.h" "YCRCB2RGB" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_MWIDTH" "C_COEF_RANGE" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_ROFFSET" "C_GOFFSET" "C_BOFFSET" "C_HAS_CLIP" "C_HAS_CLAMP" "C_RGBMAX" "C_RGBMIN" "C_S_AXIS_VIDEO_FORMAT" "C_M_AXIS_VIDEO_FORMAT" "C_HAS_DEBUG" "C_HAS_INTC_IF" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE"
|
||||
xdefine_config_file $drv_handle "xycrcb2rgb_g.c" "XYCrCr2Rgb" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_FORMAT" "C_M_AXIS_VIDEO_FORMAT" "C_HAS_DEBUG" "C_HAS_INTC_IF" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_MWIDTH" "C_COEF_RANGE" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_ROFFSET" "C_GOFFSET" "C_BOFFSET" "C_HAS_CLIP" "C_HAS_CLAMP" "C_RGBMAX" "C_RGBMIN" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE"
|
||||
|
||||
|
||||
xdefine_canonical_xpars $drv_handle "xparameters.h" "YCRCB2RGB" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_MWIDTH" "C_COEF_RANGE" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_ROFFSET" "C_GOFFSET" "C_BOFFSET" "C_HAS_CLIP" "C_HAS_CLAMP" "C_RGBMAX" "C_RGBMIN"
|
||||
xdefine_canonical_xpars $drv_handle "xparameters.h" "YCRCB2RGB" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_MWIDTH" "C_COEF_RANGE" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_ROFFSET" "C_GOFFSET" "C_BOFFSET" "C_HAS_CLIP" "C_HAS_CLAMP" "C_RGBMAX" "C_RGBMIN" "C_S_AXIS_VIDEO_FORMAT" "C_M_AXIS_VIDEO_FORMAT" "C_HAS_DEBUG" "C_HAS_INTC_IF" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE"
|
||||
}
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file example.c
|
||||
*
|
||||
* This file demonstrates how to use Xilinx YCrCb to RGB Color Space Converter
|
||||
* (YCRCB2RGB) driver on Xilinx YCrCb to RGB Color Space Converter (YCRCB2RGB)
|
||||
* core. This code does not cover the Xilinx TimeBase setup and any other
|
||||
* configuration which might be required to get the YCRCB2RGB device working properly.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 5.00a tb 02/28/12 Updates for the v5.00.a release
|
||||
* </pre>
|
||||
*
|
||||
* ***************************************************************************
|
||||
*/
|
||||
|
||||
#include "ycrcb2rgb.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/***************************************************************************/
|
||||
// YCrCb to RGB Color Space Converter Register Reading Example
|
||||
// This function provides an example of how to read the current configuration
|
||||
// settings of the YCRCB2RGB core.
|
||||
/***************************************************************************/
|
||||
void report_ycc_settings(u32 BaseAddress) {
|
||||
xil_printf("YCrCb to RGB Color Space Converter Core Configuration:\r\n");
|
||||
xil_printf(" Version: 0x%08x\r\n", YCC_ReadReg(BaseAddress, YCC_VERSION));
|
||||
xil_printf(" Enable Bit: %1d\r\n", YCC_ReadReg(BaseAddress, YCC_CONTROL) & YCC_CTL_EN_MASK);
|
||||
|
||||
xil_printf(" Register Update Bit: %1d\r\n", (YCC_ReadReg(BaseAddress, YCC_CONTROL) & YCC_CTL_RUE_MASK) >> 1);
|
||||
|
||||
xil_printf(" Reset Bit: %1d\r\n", (YCC_ReadReg(BaseAddress, YCC_CONTROL) & YCC_RST_RESET) >> 31);
|
||||
|
||||
xil_printf(" AutoReset Bit: %1d\r\n", (YCC_ReadReg(BaseAddress, YCC_CONTROL) & YCC_RST_AUTORESET) >> 30);
|
||||
|
||||
xil_printf(" Columns=0x%08x, Rows=0x%08x\r\n",
|
||||
(YCC_ReadReg(BaseAddress, YCC_ACTIVE_SIZE)>>16),
|
||||
(YCC_ReadReg(BaseAddress, YCC_ACTIVE_SIZE)&0xFFFF));
|
||||
|
||||
xil_printf(" Acoef=0x%08x, Bcoef=0x%08x, Ccoef=0x%08x, Dcoef=0x%08x\r\n",
|
||||
YCC_ReadReg(BaseAddress, YCC_ACOEF),
|
||||
YCC_ReadReg(BaseAddress, YCC_BCOEF),
|
||||
YCC_ReadReg(BaseAddress, YCC_CCOEF),
|
||||
YCC_ReadReg(BaseAddress, YCC_DCOEF));
|
||||
|
||||
xil_printf(" R Offset=0x%08x, G Offset=0x%08x, B Offset=0x%08x\r\n",
|
||||
YCC_ReadReg(BaseAddress, YCC_ROFFSET),
|
||||
YCC_ReadReg(BaseAddress, YCC_GOFFSET),
|
||||
YCC_ReadReg(BaseAddress, YCC_BOFFSET));
|
||||
|
||||
xil_printf(" RGB Max=0x%08x, RGB Min=0x%08x\r\n",
|
||||
YCC_ReadReg(BaseAddress, YCC_RGBMAX),
|
||||
YCC_ReadReg(BaseAddress, YCC_RGBMIN));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
// RGB to YCrCb Color Space Converter Register Update Example
|
||||
// This function provides an example of the process used to update
|
||||
// the coefficient and offset registers in the YCrCb2RGB core.
|
||||
// In most video systems, it is expected that this process would be executed
|
||||
// in response to an interrupt connected to the SOF timing signal
|
||||
// or a timeout signal associated with a watchdog timer.
|
||||
/***************************************************************************/
|
||||
void YCC_Update_Example() {
|
||||
//Enable the YCRCB2RGB software enable
|
||||
YCC_Enable(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
//Disable register updates.
|
||||
//This is the default operating mode for the CCM core, and allows
|
||||
//registers to be updated without effecting the core's behavior.
|
||||
YCC_RegUpdateDisable(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
//Set the Active Columns and Rows
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_ACTIVE_SIZE, (1280<<16)+720); //1280x720
|
||||
|
||||
//Set the coefficients
|
||||
// These values are floating point values in the range: [0.0, 1.0)
|
||||
// These are represented as integers by multiplying by 2^16,
|
||||
// resulting in an integer value in the range from [0, 65535]
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_ACOEF, 22978);
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_BCOEF, -11704);
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_CCOEF, -5641);
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_DCOEF, 29049);
|
||||
|
||||
//Set the offsets
|
||||
// For Valid range = [-2147483648, 2147483647]
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_ROFFSET, -6390272); //ROFFSET = 16
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_GOFFSET, 3932416); //GOFFSET = 128
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_BOFFSET, -7944448); //BOFFSET = 128
|
||||
|
||||
//Set the Clip/Clamp
|
||||
// For 8-bit color: Valid range = [0, 255]
|
||||
// For 10-bit color: Valid range = [0, 1023]
|
||||
// For 12-bit color: Valid range = [0, 4095]
|
||||
// For 16-bit color: Valid range = [0, 65535]
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_RGBMAX, 240); //RGBMAX = 240
|
||||
YCC_WriteReg(XPAR_YCRCB2RGB_0_BASEADDR, YCC_RGBMIN, 16); //RGBMIN = 16
|
||||
|
||||
//Enable register updates.
|
||||
//This mode will cause the coefficient and offset registers internally
|
||||
//to the CCM core to automatically be updated on the next SOF.
|
||||
YCC_RegUpdateEnable(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
//
|
||||
// This is the main function for the YCrCb2RGB example.
|
||||
//
|
||||
/*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
struct ycc_coef_inputs coef_in;
|
||||
struct ycc_coef_outputs coef_out;
|
||||
|
||||
// Print the current settings for the YCrCb2RGB core
|
||||
report_ycc_settings(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
// Call the YCrCb2RGB example, specify the Device ID generated in xparameters.h
|
||||
YCC_Update_Example(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
// Read the current YCrCb2RGB core coefficients
|
||||
YCC_get_coefficients(XPAR_YCRCB2RGB_0_BASEADDR, &coef_out);
|
||||
|
||||
// Setup coef_in for SD_ITU_601, 16_to_235_for_Studio_Equipment
|
||||
// and data width of 8-bits
|
||||
YCC_select_standard(0, 1, XPAR_YCRCB2RGB_0_S_AXIS_VIDEO_DATA_WIDTH, &coef_in);
|
||||
|
||||
// Translate into YCrCb2RGB core coefficients
|
||||
YCC_coefficient_translation(&coef_in, &coef_out, XPAR_YCRCB2RGB_0_S_AXIS_VIDEO_DATA_WIDTH, XPAR_YCRCB2RGB_0_MWIDTH);
|
||||
|
||||
// Program the new YCrCb2RGB core coefficients
|
||||
YCC_set_coefficients(XPAR_YCRCB2RGB_0_BASEADDR, &coef_out);
|
||||
|
||||
// Print the current settings for the YCrCb2RGB core
|
||||
report_ycc_settings(XPAR_YCRCB2RGB_0_BASEADDR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +1,22 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver ycrcb2rgb_v6_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>example.c <a href="example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright <20> 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver ycrcb2rgb_v7_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>ycrcb2rgb_selftest_example.c <a href="ycrcb2rgb_selftest_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>ycrcb2rgb_example.c <a href="ycrcb2rgb_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright ? 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
|
220
XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_example.c
Executable file
220
XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_example.c
Executable file
|
@ -0,0 +1,220 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file ycrcb2rgb_example.c
|
||||
*
|
||||
* This file demonstrates how to use Xilinx YCrCb to RGB Color Space Converter
|
||||
* (YCrCb2RGB) driver on Xilinx YCrCb to RGB Color Space Converter (YCrCb2RGB)
|
||||
* core.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 7.00 adk 07/14/14 First release.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "xycrcb2rgb.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define XYCC_DEVICE_ID XPAR_XYCC_0_DEVICE_ID
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int YCrCb2Rgb_Update_Example(u16 DeviceId);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XYCrCb2Rgb XYccInstance; /**< Instance of the YCRCB2RGB core */
|
||||
|
||||
/************************** Function Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the YCrCb2RGB example.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful,
|
||||
* - XST_FAILURE if it is unsuccessful
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
|
||||
/* Call the YCrCb2RGB update example, specify the parameters generated
|
||||
* in xparameters.h
|
||||
*/
|
||||
Status = YCrCb2Rgb_Update_Example(XYCC_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("YCrCb2RGB driver example failed.\n\r");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran YCrCb2RGB driver example.\n\r");
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* YCrCb to RGB Color Space Converter Register Update Example.
|
||||
* This function provides an example of the process used to update the
|
||||
* coefficient and offset registers in the YCRCB2RGB core.
|
||||
*
|
||||
* @param DeviceId is the unique device id of the YCRCB2RGB core.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful,
|
||||
* - XST_FAILURE if it is un-successful
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
****************************************************************************/
|
||||
int YCrCb2Rgb_Update_Example(u16 DeviceId)
|
||||
{
|
||||
|
||||
struct XYCrCb2Rgb_Coef_Inputs CoefIn;
|
||||
struct XYCrCb2Rgb_Coef_Outputs CoefOut;
|
||||
struct XYCrCb2Rgb_Coefficients Coef;
|
||||
XYCrCb2Rgb_Config *Config;
|
||||
int Status;
|
||||
|
||||
/* Initialize the CrCb2RGB driver so that it's ready to use look up
|
||||
* the configuration in the config table then initialize it.
|
||||
*/
|
||||
Config = XYCrCb2Rgb_LookupConfig(DeviceId);
|
||||
if(NULL == Config){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XYCrCb2Rgb_CfgInitialize(&XYccInstance, Config,
|
||||
Config->BaseAddress);
|
||||
if(Status != XST_SUCCESS){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Enable the YCRCB2RGB core */
|
||||
XYCrCb2Rgb_Enable(&XYccInstance);
|
||||
|
||||
/* Disable register updates. This is the default operating mode for
|
||||
* the YCRCB2RGB core and allows registers to be updated without
|
||||
* effecting the core's behavior.
|
||||
*/
|
||||
XYCrCb2Rgb_RegUpdateDisable(&XYccInstance);
|
||||
|
||||
/* Setup CoefIn for XYCC_STANDARD_ITU_601_SD, 16_to_240_for_TV
|
||||
* and data width of 8-bits.
|
||||
* enum Standards are:
|
||||
* 0 = XYCC_STANDARD_ITU_601_SD
|
||||
* 1 = XYCC_STANDARD_ITU_709_NTSC
|
||||
* 2 = XYCC_STANDARD_ITU_709_PAL
|
||||
* 3 = XYCC_STANDARD_YUV.
|
||||
*/
|
||||
XYCrCb2Rgb_Select_Standard(&XYccInstance, XYCC_STANDARD_ITU_601_SD,
|
||||
XYCC_TV_16_TO_240, (u32)XYCC_DATA_WIDTH_8,
|
||||
&CoefIn);
|
||||
|
||||
/* Translate into YCRCB2RGB core coefficients */
|
||||
XYCrCb2Rgb_Coefficient_Translation(&XYccInstance,
|
||||
&CoefIn, &CoefOut,(u32)XYCC_DATA_WIDTH_8,
|
||||
(u32)XYCC_DATA_WIDTH_8);
|
||||
|
||||
/* Store coefficient values */
|
||||
Coef.ACoef = CoefIn.ACoef;
|
||||
Coef.ACoef = CoefIn.ACoef;
|
||||
Coef.ACoef = CoefIn.ACoef;
|
||||
Coef.ACoef = CoefIn.ACoef;
|
||||
|
||||
/* Program the new YCRCB2RGB core coefficients */
|
||||
XYCrCb2Rgb_SetCoefs(&XYccInstance, &Coef);
|
||||
|
||||
/* Set output range */
|
||||
XYCrCb2Rgb_Select_OutputRange(&XYccInstance, XYCC_TV_16_TO_240);
|
||||
|
||||
/* Set the Active Columns and Rows */
|
||||
XYCrCb2Rgb_SetActiveSize(&XYccInstance, 720, 1280);
|
||||
|
||||
/* Set the offsets
|
||||
* For 8-bit color: Valid range = [0, 255]
|
||||
* For 10-bit color: Valid range = [0, 1023]
|
||||
* For 12-bit color: Valid range = [0, 4095]
|
||||
* For 16-bit color: Valid range = [0, 65535]
|
||||
*/
|
||||
XYCrCb2Rgb_SetROffset(&XYccInstance, 16);
|
||||
XYCrCb2Rgb_SetGOffset(&XYccInstance, 128);
|
||||
XYCrCb2Rgb_SetBOffset(&XYccInstance, 128);
|
||||
|
||||
/* Set the Clip/Clamp
|
||||
* For 8-bit color: Valid range = [0, 255]
|
||||
* For 10-bit color: Valid range = [0, 1023]
|
||||
* For 12-bit color: Valid range = [0, 4095]
|
||||
* For 16-bit color: Valid range = [0, 65535]
|
||||
*/
|
||||
XYCrCb2Rgb_SetRGBMax(&XYccInstance, 240);
|
||||
XYCrCb2Rgb_SetRGBMin(&XYccInstance, 16);
|
||||
|
||||
/* Enable register updates. This mode will cause the coefficient and
|
||||
* offset registers internally to the YCRCB2RGB core to automatically
|
||||
* be updated on the next start-of-frame (SOF).
|
||||
*/
|
||||
XYCrCb2Rgb_RegUpdateEnable(&XYccInstance);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
149
XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_selftest_example.c
Executable file
149
XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_selftest_example.c
Executable file
|
@ -0,0 +1,149 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file ycrcb2rgb_selftest_example.c
|
||||
*
|
||||
* This file contains an example using the XYCrCb2RGB driver to do self test
|
||||
* on the device.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 7.0 adk 02/10/14 First Release.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xycrcb2rgb.h"
|
||||
#include "xparameters.h"
|
||||
#include "xil_printf.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define XYCC_DEVICE_ID XPAR_XYCC_0_DEVICE_ID
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XYCrCb2RgbSelfTestExample(u16 DeviceId);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XYCrCb2Rgb YccInst; /**< Instance of the YCrCb2RGB Device */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main/Entry function for self test example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if it is unsuccessful.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run selftest example */
|
||||
Status = XYCrCb2RgbSelfTestExample(XYCC_DEVICE_ID);
|
||||
if(Status != XST_SUCCESS) {
|
||||
xil_printf("YCrCb2RGB Selftest Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran YCrCb2RGB driver Selftest example\r\n");
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a minimal test on the YCrCb2RGB driver.
|
||||
*
|
||||
* @param DeviceId is an ID of the YCrCb2RGB core or device.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if it is unsuccessful.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XYCrCb2RgbSelfTestExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XYCrCb2Rgb_Config *Config;
|
||||
|
||||
/* Initialize the YCrCb2RGB driver so that it's ready to use look up
|
||||
* the configuration in the config table, then initialize it.
|
||||
*/
|
||||
Config = XYCrCb2Rgb_LookupConfig(DeviceId);
|
||||
if(NULL == Config){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XYCrCb2Rgb_CfgInitialize(&YccInst, Config,
|
||||
Config->BaseAddress);
|
||||
if(Status != XST_SUCCESS){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Perform a self-test to check hardware build. */
|
||||
Status = XYCrCb2Rgb_SelfTest(&YccInst);
|
||||
if(Status != XST_SUCCESS){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -1,29 +1,29 @@
|
|||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
LEVEL=0
|
||||
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
INCLUDES=-I./. -I${INCLUDEDIR}
|
||||
|
||||
INCLUDEFILES=*.h
|
||||
LIBSOURCES=*.c
|
||||
|
||||
OUTS = *.o
|
||||
|
||||
libs:
|
||||
echo "Compiling ycrcb2rgb"
|
||||
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
|
||||
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
|
||||
make clean
|
||||
|
||||
include:
|
||||
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
|
||||
|
||||
clean:
|
||||
rm -rf ${OUTS}
|
||||
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
LEVEL=0
|
||||
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
INCLUDES=-I./. -I${INCLUDEDIR}
|
||||
|
||||
INCLUDEFILES=*.h
|
||||
LIBSOURCES=*.c
|
||||
|
||||
OUTS = *.o
|
||||
|
||||
libs:
|
||||
echo "Compiling ycrcb2rgb"
|
||||
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
|
||||
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
|
||||
make clean
|
||||
|
||||
include:
|
||||
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
|
||||
|
||||
clean:
|
||||
rm -rf ${OUTS}
|
||||
|
||||
|
|
1285
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.c
Executable file
1285
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.c
Executable file
File diff suppressed because it is too large
Load diff
792
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h
Executable file
792
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h
Executable file
|
@ -0,0 +1,792 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xycrcb2rgb.h
|
||||
*
|
||||
* This header file contains identifiers and register-level driver functions
|
||||
* (or macros), range macros, structure typedefs that can be used to access the
|
||||
* Xilinx YCRCB2RGB core.
|
||||
*
|
||||
* The YCrCb to RGB Color-Space Convertor core is a simplified 3x3 matrix
|
||||
* multiplier converts three input color samples to three output samples in a
|
||||
* single clock cycle. The core supports four common format conversions as well
|
||||
* as a custom mode that allows for a user-defined transform. The core is
|
||||
* capable of a maximum resolution of 7680 columns by 7680 rows with 8, 10, 12,
|
||||
* or 16 bits per pixel.
|
||||
*
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate to the YCRCB2RGB core.
|
||||
*
|
||||
* XYCrCb2Rgb_CfgInitialize() API is used to initialize the YCRCB2RGB core.
|
||||
* The user needs to first call the XYCrCb2Rgb_LookupConfig() API which returns
|
||||
* the Configuration structure pointer which is passed as a parameter to the
|
||||
* XYCrCb2Rgb_CfgInitialize() API.
|
||||
*
|
||||
* <b> Interrupts </b>
|
||||
*
|
||||
* The driver provides an interrupt handler XYCrCb2Rgb_IntrHandler for handling
|
||||
* the interrupt from the YCRCB2RGB core. The users of this driver have to
|
||||
* register this handler with the interrupt system and provide the callback
|
||||
* functions by using XYCrCb2Rgb_SetCallBack API.
|
||||
*
|
||||
* <b> Virtual Memory </b>
|
||||
*
|
||||
* This driver supports Virtual Memory. The RTOS is responsible for calculating
|
||||
* the correct device base address in Virtual Memory space.
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The XYCrCb2Rgb driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
*
|
||||
*<pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -------------------------------------------------------
|
||||
* 5.00a tb 02/28/12 Updated for YCRCB2RGB V5.00.a
|
||||
* 5.01a bao 12/28/12 Converted from xio.h to xil_io.h, translating basic
|
||||
* types, MB cache functions, exceptions and assertions
|
||||
* to xil_io format.
|
||||
* 6.0 adk 19/12/13 Updated as per the New Tcl API's
|
||||
* 7.0 adk 01/31/14 Changed the file name from "ycrcb2rgb.h" to
|
||||
* "xycrcb2rgb.h".
|
||||
*
|
||||
* Moved register offsets and bit definitions from
|
||||
* ycrcb2rgb.h file to xycrcb2rgb_hw.h file.
|
||||
*
|
||||
* Removed YCC_TIMING_STATUS register offset because this
|
||||
* register is not present in latest product guide.
|
||||
*
|
||||
* Removed following function macros:
|
||||
* YCC_Enable, YCC_Disable, YCC_RegUpdateEnable,
|
||||
* YCC_RegUpdateDisable, YCC_Reset, YCC_ClearReset,
|
||||
* YCC_AutoSyncReset, ycc_max..
|
||||
*
|
||||
* Removed following functions:
|
||||
* YCC_select_standard, YCC_coefficient_translation,
|
||||
* YCC_set_coefficients, YCC_get_coefficients.
|
||||
*
|
||||
* Added following handler types as enum:
|
||||
* XYCC_HANDLER_PROCSTART, XYCC_HANDLER_FRAMEDONE,
|
||||
* XYCC_HANDLER_ERROR.
|
||||
*
|
||||
* Added following standard types as enum:
|
||||
* XYCC_STANDARD_ITU_601_SD, XYCC_STANDARD_ITU_709_NTSC,
|
||||
* XYCC_STANDARD_ITU_709_PAL, XYCC_STANDARD_YUV,
|
||||
* XYCC_STANDARD_CUSTOM.
|
||||
*
|
||||
* Added following output ranges as enum:
|
||||
* XYCC_TV_16_TO_240, XYCC_STUDIO_16_TO_235,
|
||||
* XYCC_GRAPHICS_0_TO_255.
|
||||
*
|
||||
* Added range macros for ActiveSize, RGBMAX, RGBMIN,
|
||||
* ROFFSET, GOFFSET, BOFFSET registers.
|
||||
*
|
||||
* Added following function macros:
|
||||
* XYCrCb2Rgb_IntrEnable, XYCrCb2Rgb_IntrDisable,
|
||||
* XYCrCb2Rgb_StatusGetPending, XYCrCb2Rgb_IntrGetPending,
|
||||
* XYCrCb2Rgb_IntrClear, XYCrCb2Rgb_Reset,
|
||||
* XYCrCb2Rgb_Enable, XYCrCb2Rgb_Disable,
|
||||
* XYCrCb2Rgb_Start, XYCrCb2Rgb_Stop,
|
||||
* XYCrCb2Rgb_RegUpdateEnable,
|
||||
* XYCrCb2Rgb_RegUpdateDisable,
|
||||
* XYCrCb2Rgb_SyncReset, XYCrCb2Rgb_Max
|
||||
*
|
||||
* Added core, configuration and coefficient structure.
|
||||
* Renamed ycc_coef_inputs -> XYCrCb2Rgb_Coef_Inputs and
|
||||
* ycc_coef_outputs - > XYCrCb2Rgb_Coef_Outputs.
|
||||
*
|
||||
* Added callback functions typedef.
|
||||
*
|
||||
* Implemented XYCrCb2Rgb_LookupConfig in
|
||||
* xycrcb2rgb_sinit.c
|
||||
* Implemented XYCrCb2Rgb_SelfTest in
|
||||
* xycrcb2rgb_selftest.c
|
||||
* Implemented XYCrCb2Rgb_IntrHandler,
|
||||
* XYCrCb2Rgb_SetCallBack in xycrcb2rgb_intr.c.
|
||||
*
|
||||
* Implemented following functions in xycrcb2rgb.c:
|
||||
* XYCrCb2Rgb_CfgInitialize, XYCrCb2Rgb_EnableDbgByPass,
|
||||
* XYCrCb2Rgb_IsDbgByPassEnabled,
|
||||
* XYCrCb2Rgb_DisableDbgBypass,
|
||||
* XYCrCb2Rgb_EnableDbgTestPattern,
|
||||
* XYCrCb2Rgb_IsDbgTestPatternEnabled,
|
||||
* XYCrCb2Rgb_DisableDbgTestPattern,
|
||||
* XYCrCb2Rgb_GetVersion, XYCrCb2Rgb_GetDbgFrameCount,
|
||||
* XYCrCb2Rgb_GetDbgLineCount,
|
||||
* XYCrCb2Rgb_GetDbgPixelCount, XYCrCb2Rgb_Setup,
|
||||
* XYCrCb2Rgb_SetActiveSize, XYCrCb2Rgb_GetActiveSize,
|
||||
* XYCrCb2Rgb_SetRGBMax, XYCrCb2Rgb_GetRGBMax,
|
||||
* XYCrCb2Rgb_SetRGBMin, XYCrCb2Rgb_GetRGBMin,
|
||||
* XYCrCb2Rgb_SetROffset, XYCrCb2Rgb_GetROffset,
|
||||
* XYCrCb2Rgb_SetGOffset, XYCrCb2Rgb_GetGOffset,
|
||||
* XYCrCb2Rgb_SetBOffset, XYCrCb2Rgb_GetBOffset,
|
||||
* XYCrCb2Rgb_SetCoefs, XYCrCb2Rgb_GetCoefs,
|
||||
* XYCrCb2Rgb_Select_Standard,
|
||||
* XYCrCb2Rgb_Coefficient_Translation,
|
||||
* XYCrCb2Rgb_Select_OutputRange.
|
||||
*</pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XYCRCB2RGB_H_
|
||||
#define XYCRCB2RGB_H_ /**< Prevent circular inclusions by using protection
|
||||
* macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xycrcb2rgb_hw.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Handler Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* These constants specify different types of handler and used to differentiate
|
||||
* interrupt requests from core.
|
||||
*/
|
||||
enum {
|
||||
XYCC_HANDLER_PROCSTART = 1, /**< A processing start event interrupt
|
||||
* type */
|
||||
XYCC_HANDLER_FRAMEDONE, /**< A frame done event interrupt
|
||||
* type */
|
||||
XYCC_HANDLER_ERROR /**< An error condition interrupt
|
||||
* type */
|
||||
} ;
|
||||
/*@}*/
|
||||
|
||||
/** @name Standard Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* These constants specify different types of standards used to represent
|
||||
* standard color encoding.
|
||||
*/
|
||||
enum Standards {
|
||||
XYCC_STANDARD_ITU_601_SD = 0, /**< Standard ITU 601 SD. */
|
||||
XYCC_STANDARD_ITU_709_NTSC, /**< Standard ITU 709 NTSC. */
|
||||
XYCC_STANDARD_ITU_709_PAL, /**< Standard ITU 709 PAL. */
|
||||
XYCC_STANDARD_YUV, /**< Standard YUV. */
|
||||
XYCC_STANDARD_CUSTOM /**< Standard Custom. */
|
||||
} ;
|
||||
/*@}*/
|
||||
|
||||
/** @name Output Ranges
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* These constants specify different ranges used for studio equipment,
|
||||
* television and computer graphics respectively.
|
||||
*/
|
||||
enum OutputRanges {
|
||||
XYCC_TV_16_TO_240 = 0, /**< 16 to 240, for Television. */
|
||||
XYCC_STUDIO_16_TO_235, /**< 16 to 235, for Studio Equipment. */
|
||||
XYCC_GRAPHICS_0_TO_255 /**< 0 to 255, for Computer Graphics. */
|
||||
} ;
|
||||
/*@}*/
|
||||
|
||||
/** Active Size (VxH) range macros
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ACT_SIZE_FIRST 32 /**< Starting value for H/V */
|
||||
#define XYCC_ACT_SIZE_LAST 8192 /**< Ending value for H/V */
|
||||
/*@}*/
|
||||
|
||||
/** RGBMAX, RGBMIN range macros
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_RGBMAX_MIN_FIRST 0 /**< Starting value for
|
||||
* RGBMAX/RGBMIN */
|
||||
#define XYCC_RGBMAX_MIN_LAST 255 /**< Ending value for RGBMAX/RGBMIN */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** ROFFSET, GOFFSET, BOFFSET range macros
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_RGBOFFSET_FIRST 0 /**< Starting value for ROFFSET/
|
||||
* GOFFSET/BOFFSET */
|
||||
#define XYCC_RGBOFFSET_LAST 255 /**< Ending value for ROFFSET/
|
||||
* GOFFSET/BOFFSET */
|
||||
/*@}*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro enables the YCrCb2Rgb core.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_Enable(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Enable(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), \
|
||||
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET)) | (XYCC_CTL_SW_EN_MASK))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro disables the YCrCb2Rgb core.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_Disable(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Disable(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), \
|
||||
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET)) & (~(XYCC_CTL_SW_EN_MASK))))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro starts the YCrCb2Rgb core.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_Start(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Start XYCrCb2Rgb_Enable
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro stops the YCrCb2Rgb core.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_Stop(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Stop XYCrCb2Rgb_Disable
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro enables copying from updated processor register values to
|
||||
* the active set at the end of each AXI-Stream frame.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_RegUpdateEnable(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_RegUpdateEnable(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), \
|
||||
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET)) | (XYCC_CTL_RUE_MASK)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro disables copying from updated processor register values to
|
||||
* the active set at the end of each AXI-Stream frame.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_RegUpdateDisable(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_RegUpdateDisable(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), \
|
||||
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET)) & (~(XYCC_CTL_RUE_MASK))))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro resets a the YCrCb2Rgb core, but differs from XYCrCb2Rgb_Reset()
|
||||
* in that it automatically synchronizes to the VBlank_in input of the core to
|
||||
* prevent tearing.
|
||||
*
|
||||
* On the next rising-edge of VBlank_in following a call to
|
||||
* XYCrCb2Rgb_SyncReset(), all of the core's configuration registers and
|
||||
* outputs will be reset, then the reset flag will be immediately released,
|
||||
* allowing the core to immediately resume default operation.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_SyncReset(*XYCrCb2Rgb InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_SyncReset(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), (XYCC_CTL_AUTORESET_MASK))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro resets the YCrCb2Rgb core.. This reset effects the core
|
||||
* immediately and may cause image tearing.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_Reset(XYCrCb2Rgb *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Reset(InstancePtr) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_CONTROL_OFFSET), (XYCC_CTL_RESET_MASK))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro enables individual interrupts of the YCRCB2RGB core by
|
||||
* updating the IRQ_ENABLE register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
|
||||
* to be worked on.
|
||||
* @param IntrType is the bit-mask of the interrupts to be enabled.
|
||||
* Bit positions of 1 will be enabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XYCC_IXR_*_MASK bits defined in xycrcb2rgb_hw.h.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_IntrEnable(XYCrCb2Rgb *InstancePtr,
|
||||
* u32 IntrType)
|
||||
*
|
||||
* The existing enabled interrupt(s) will remain enabled.
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_IntrEnable(InstancePtr, IntrType) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_IRQ_EN_OFFSET), (((IntrType) & \
|
||||
(XYCC_IXR_ALLINTR_MASK)) | \
|
||||
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_IRQ_EN_OFFSET)))))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro disables individual interrupts of the YCRCB2RGB core by
|
||||
* updating the IRQ_ENABLE register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
|
||||
* to be worked on.
|
||||
* @param IntrType is the bit-mask of the interrupts to be disabled.
|
||||
* Bit positions of 1 will be disabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XYCC_IXR_*_MASK bits defined in xycrcb2rgb_hw.h.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_IntrDisable(XYCrCb2Rgb *InstancePtr,
|
||||
* u32 IntrType)
|
||||
*
|
||||
* Any other interrupt not covered by parameter IntrType, if
|
||||
* enabled before this macro is called, will remain enabled.
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_IntrDisable(InstancePtr, IntrType) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_IRQ_EN_OFFSET),\
|
||||
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_IRQ_EN_OFFSET)) & \
|
||||
((~(IntrType)) & (XYCC_IXR_ALLINTR_MASK)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro returns the pending interrupt status of the YCRCB2RGB
|
||||
* core read from the Status register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
|
||||
* to be worked on.
|
||||
*
|
||||
* @return The status of pending interrupts of the YCRCB2RGB core.
|
||||
* Use XYCC_IXR_*_MASK constants defined in xycrcb2rgb_hw.h to
|
||||
* interpret this value.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* XYCrCb2Rgb_StatusGePending(XYCC *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_StatusGetPending(InstancePtr) \
|
||||
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_STATUS_OFFSET)) & (XYCC_IXR_ALLINTR_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro returns the pending interrupts of the YCRCB2RGB core for
|
||||
* the interrupts that have been enabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
|
||||
* to be worked on.
|
||||
*
|
||||
* @return The pending interrupts of the YCRCB2RGB core. Use
|
||||
* XYCC_IXR_*_MASK constants defined in xycrcb2rgb_hw.h to
|
||||
* interpret this value. The returned value is a logical AND of
|
||||
* the contents of the STATUS register and the IRQ_ENABLE
|
||||
* register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XYCC_IntrGetPending(XYCC *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_IntrGetPending(InstancePtr) \
|
||||
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_IRQ_EN_OFFSET)) & \
|
||||
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_STATUS_OFFSET)) & \
|
||||
((u32)(XYCC_IXR_ALLINTR_MASK)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro clears/acknowledges pending interrupts of the YCRCB2RGB
|
||||
* core in the Status register. Bit positions of 1 will be cleared.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the YCRCB2RGB core instance
|
||||
* to be worked on.
|
||||
*
|
||||
* @param IntrType is the pending interrupts to clear/acknowledge.
|
||||
* Use OR'ing of XYCC_IXR_*_MASK constants defined in
|
||||
* xycrcb2rgb_hw.h to create this parameter value.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_IntrClear(XYCC *InstancePtr, u32 IntrType)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_IntrClear(InstancePtr, IntrType) \
|
||||
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
(XYCC_STATUS_OFFSET), \
|
||||
(IntrType) & (XYCC_IXR_ALLINTR_MASK))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro identifies maximum number from given numbers.
|
||||
*
|
||||
* @param Num1 is a a u32 number.
|
||||
* @param Num2 is a a u32 number.
|
||||
*
|
||||
* @return Maximum number from given two numbers.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XYCrCb2Rgb_Max(u32 Num1, u32 Num2)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_Max(Num1, Num2) (((Num1) > (Num2)) ? (Num1) : (Num2))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for a YCrCb2Rgb core.
|
||||
* Each YCrCb2Rgb core should have a configuration structure associated.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< DeviceId is the unique ID
|
||||
* of the YCRCB2RGB core */
|
||||
u32 BaseAddress; /**< BaseAddress is the physical base
|
||||
* address of the YCRCB2RGB core
|
||||
* registers */
|
||||
u32 SlaveAxisVideoFormat; /**< Slave Axis Video Format */
|
||||
u32 MasterAxisVideoFormat; /**< Master Axis Video Format */
|
||||
u16 HasDebug; /**< Debugging support */
|
||||
u16 HasIntcIf; /**< Interrupt controller support */
|
||||
u32 MaxCols; /**< Maximum number of columns */
|
||||
u32 ActiveCols; /**< Active number of columns */
|
||||
u32 ActiveRows; /**< Active number of rows */
|
||||
u32 MWidth; /**< MWidht */
|
||||
u32 CoefRange; /**< Coefficient range */
|
||||
u32 ACoef; /**< A Coefficient */
|
||||
u32 BCoef; /**< B Coefficient */
|
||||
u32 CCoef; /**< C Coefficient */
|
||||
u32 DCoef; /**< D Coefficient */
|
||||
u16 ROffset; /**< R Offset */
|
||||
u16 GOffset; /**< G Offset */
|
||||
u16 BOffset; /**< B Offset */
|
||||
u16 HasClip; /**< Clipping support */
|
||||
u16 HasClamp; /**< Clamping support */
|
||||
u16 RgbMax; /**< RGB Max value */
|
||||
u16 RgbMin; /**< RGB Min value */
|
||||
u32 SlaveAxiClkFreqHz; /**< Slave Axis Clock frequency
|
||||
* in Hz */
|
||||
u32 StandardSelection; /**< Standard Selection */
|
||||
u32 OutputRange; /**< Output Range */
|
||||
} XYCrCb2Rgb_Config;
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Callback type for all interrupts except error interrupt.
|
||||
*
|
||||
* @param CallBackRef is a callback reference passed in by the upper
|
||||
* layer when setting the callback functions, and passed back to
|
||||
* the upper layer when the callback is invoked.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
typedef void (*XYCrCb2Rgb_CallBack)(void *CallBackRef);
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Callback type for error interrupt.
|
||||
*
|
||||
* @param CallBackRef is a callback reference passed in by the upper
|
||||
* layer when setting the callback functions, and passed back to
|
||||
* the upper layer when the callback is invoked.
|
||||
* @param ErrorMask is a bit mask indicating the cause of the error. Its
|
||||
* value equals 'OR'ing one or more XYCC_IXR_*_MASK values defined
|
||||
* in xycrcb2rgb_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
typedef void (*XYCrCb2Rgb_ErrorCallBack)(void *CallBackRef, u32 ErrorMask);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* The XYCrCb2Rgb driver instance data structure. A pointer to an instance data
|
||||
* structure is passed around by functions to refer to a specific driver
|
||||
* instance.
|
||||
*/
|
||||
typedef struct {
|
||||
XYCrCb2Rgb_Config Config; /**< Hardware configuration */
|
||||
u32 IsReady; /**< Device and the driver instance are initialized */
|
||||
u16 HSize; /**< Active Video Horizontal Size */
|
||||
u16 VSize; /**< Active Video Vertical Size */
|
||||
|
||||
/* IRQ Callbacks Here */
|
||||
XYCrCb2Rgb_CallBack ProcStartCallBack; /**< Callback for Processing
|
||||
* start interrupt */
|
||||
void *ProcStartRef; /**< To be passed to Process start interrupt
|
||||
* callback */
|
||||
XYCrCb2Rgb_CallBack FrameDoneCallBack; /**< Callback for Frame Done
|
||||
* interrupt */
|
||||
void *FrameDoneRef; /**< To be passed to the Frame Done interrupt
|
||||
* callback */
|
||||
XYCrCb2Rgb_ErrorCallBack ErrCallBack; /**< Callback for Error
|
||||
* interrupt */
|
||||
void *ErrRef; /**< To be passed to the Error interrupt callback */
|
||||
u32 StandardSelection; /**< Standard Selection */
|
||||
u32 OutputRange; /**< Output Range */
|
||||
} XYCrCb2Rgb;
|
||||
|
||||
/**
|
||||
*
|
||||
* YCrCb2Rgb input coefficient
|
||||
*/
|
||||
struct XYCrCb2Rgb_Coef_Inputs {
|
||||
/* Pre-translated coefficient/offset data */
|
||||
double ACoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
|
||||
double BCoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
|
||||
double CCoef; /**< [ 0.0 - 1.0 ] */
|
||||
double DCoef; /**< [ 0.0 - 1.0 ] */
|
||||
u32 YOffset; /**< Offset for the Luminance Channel */
|
||||
u32 CbOffset; /**< Offset for the Chrominance Channels */
|
||||
u32 CrOffset; /**< Offset for the Chrominance Channels */
|
||||
u32 RgbMax; /**< RGB Clipping */
|
||||
u32 RgbMin; /**< RGB Clamping */
|
||||
} ;
|
||||
|
||||
/**
|
||||
*
|
||||
* YCrCb2Rgb output coefficient
|
||||
*/
|
||||
struct XYCrCb2Rgb_Coef_Outputs {
|
||||
/* Translated coefficient/offset data */
|
||||
u32 ACoef; /**< Translated ACoef */
|
||||
u32 BCoef; /**< Translated BCoef */
|
||||
u32 CCoef; /**< Translated CCoef */
|
||||
u32 DCoef; /**< Translated DCoef */
|
||||
u32 ROffset; /**< Translated Offset for the R Channel */
|
||||
u32 GOffset; /**< Translated Offset for the G Channel */
|
||||
u32 BOffset; /**< Translated Offset for the B Channel */
|
||||
u32 RgbMax; /**< Translated RGB Clipping */
|
||||
u32 RgbMin; /**< Translated RGB Clamping */
|
||||
} ;
|
||||
|
||||
/**
|
||||
*
|
||||
* YCrCb2Rgb coefficients
|
||||
*/
|
||||
struct XYCrCb2Rgb_Coefficients {
|
||||
double ACoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
|
||||
double BCoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
|
||||
double CCoef; /**< [ 0.0 - 1.0 ] */
|
||||
double DCoef; /**< [ 0.0 - 1.0 ] */
|
||||
} ;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Initialization function implemented in xycrcb2rgb_sinit.c
|
||||
*/
|
||||
XYCrCb2Rgb_Config *XYCrCb2Rgb_LookupConfig(u16 DeviceId);
|
||||
|
||||
/* Following functions implemented in xycrcb2rgb.c */
|
||||
int XYCrCb2Rgb_CfgInitialize(XYCrCb2Rgb *InstancePtr,
|
||||
XYCrCb2Rgb_Config *CfgPtr, u32 EffectiveAddr);
|
||||
|
||||
void XYCrCb2Rgb_EnableDbgByPass(XYCrCb2Rgb *InstancePtr);
|
||||
int XYCrCb2Rgb_IsDbgByPassEnabled(XYCrCb2Rgb *InstancePtr);
|
||||
void XYCrCb2Rgb_DisableDbgBypass(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_EnableDbgTestPattern(XYCrCb2Rgb *InstancePtr);
|
||||
int XYCrCb2Rgb_IsDbgTestPatternEnabled(XYCrCb2Rgb *InstancePtr);
|
||||
void XYCrCb2Rgb_DisableDbgTestPattern(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
u32 XYCrCb2Rgb_GetVersion(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
u32 XYCrCb2Rgb_GetDbgFrameCount(XYCrCb2Rgb *InstancePtr);
|
||||
u32 XYCrCb2Rgb_GetDbgLineCount(XYCrCb2Rgb *InstancePtr);
|
||||
u32 XYCrCb2Rgb_GetDbgPixelCount(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_Setup(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetActiveSize(XYCrCb2Rgb *InstancePtr, u16 HSize, u16 VSize);
|
||||
void XYCrCb2Rgb_GetActiveSize(XYCrCb2Rgb *InstancePtr, u16 *HSize, u16 *VSize);
|
||||
|
||||
void XYCrCb2Rgb_SetRGBMax(XYCrCb2Rgb *InstancePtr, u32 RGBMax);
|
||||
u32 XYCrCb2Rgb_GetRGBMax(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetRGBMin(XYCrCb2Rgb *InstancePtr, u32 RGBMin);
|
||||
u32 XYCrCb2Rgb_GetRGBMin(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetROffset(XYCrCb2Rgb *InstancePtr, u32 ROffset);
|
||||
u32 XYCrCb2Rgb_GetROffset(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetGOffset(XYCrCb2Rgb *InstancePtr, u32 GOffset);
|
||||
u32 XYCrCb2Rgb_GetGOffset(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetBOffset(XYCrCb2Rgb *InstancePtr, u32 BOffset);
|
||||
u32 XYCrCb2Rgb_GetBOffset(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
void XYCrCb2Rgb_SetCoefs(XYCrCb2Rgb *InstancePtr,
|
||||
struct XYCrCb2Rgb_Coefficients *Coef);
|
||||
void XYCrCb2Rgb_GetCoefs(XYCrCb2Rgb *InstancePtr,
|
||||
struct XYCrCb2Rgb_Coefficients *Coef);
|
||||
|
||||
void XYCrCb2Rgb_Select_Standard(XYCrCb2Rgb *InstancePtr,
|
||||
enum Standards StandardSel,
|
||||
enum OutputRanges InputRange, u32 DataWidth,
|
||||
struct XYCrCb2Rgb_Coef_Inputs *CoefIn);
|
||||
|
||||
u32 XYCrCb2Rgb_Coefficient_Translation(XYCrCb2Rgb *InstancePtr,
|
||||
struct XYCrCb2Rgb_Coef_Inputs *CoefIn,
|
||||
struct XYCrCb2Rgb_Coef_Outputs *CoefOut,
|
||||
u32 DataWidth, u32 MWidth);
|
||||
|
||||
void XYCrCb2Rgb_Select_OutputRange(XYCrCb2Rgb *InstancePtr,
|
||||
enum OutputRanges Range);
|
||||
|
||||
/* Self-test function implemented in xycrcb2rgb_selftest.c */
|
||||
int XYCrCb2Rgb_SelfTest(XYCrCb2Rgb *InstancePtr);
|
||||
|
||||
/* Interrupt related functions implemented in xycrcb2rgb_intr.c */
|
||||
void XYCrCb2Rgb_IntrHandler(void *InstancePtr);
|
||||
int XYCrCb2Rgb_SetCallBack(XYCrCb2Rgb *InstancePtr, u32 HandlerType,
|
||||
void *CallBackFunc, void *CallBackRef);
|
||||
|
||||
/************************** Variable Declarations ****************************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of protection macro */
|
97
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_g.c
Executable file
97
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_g.c
Executable file
|
@ -0,0 +1,97 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xycrcb2rgb.h"
|
||||
|
||||
/*
|
||||
* The configuration table for devices
|
||||
*/
|
||||
|
||||
XYCrCb2Rgb_Config XYCrCb2Rgb_ConfigTable[] =
|
||||
{
|
||||
/*
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_DEVICE_ID,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_BASEADDR,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_S_AXIS_VIDEO_FORMAT,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_M_AXIS_VIDEO_FORMAT,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_HAS_DEBUG,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_HAS_INTC_IF,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_MAX_COLS,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_ACTIVE_COLS,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_ACTIVE_ROWS,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_MWIDTH,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_COEF_RANGE,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_ACOEF,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_BCOEF,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_CCOEF,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_DCOEF,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_ROFFSET,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_GOFFSET,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_BOFFSET,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_HAS_CLIP,
|
||||
XPAR_FMC_SENSOR_INPUT_YCRCB2RGB_1_HAS_CLAMP,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_RGBMAX,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_RGBMIN,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_S_AXI_CLK_FREQ_HZ,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_STANDARD_SEL,
|
||||
XPAR_FMC_SENSOR_INPUT_V_YCRCB2RGB_1_OUTPUT_RANGE
|
||||
,*/
|
||||
/*
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_DEVICE_ID,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_BASEADDR,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_S_AXIS_VIDEO_FORMAT,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_M_AXIS_VIDEO_FORMAT,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_HAS_DEBUG,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_HAS_INTC_IF,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_MAX_COLS,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_ACTIVE_COLS,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_ACTIVE_ROWS,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_MWIDTH,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_COEF_RANGE,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_ACOEF,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_BCOEF,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_CCOEF,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_DCOEF,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_ROFFSET,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_GOFFSET,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_BOFFSET,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_HAS_CLIP,
|
||||
XPAR_HDMI_OUTPUT_YCRCB2RGB_1_HAS_CLAMP,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_RGBMAX,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_RGBMIN,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_S_AXI_CLK_FREQ_HZ,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_STANDARD_SEL,
|
||||
XPAR_HDMI_OUTPUT_V_YCRCB2RGB_1_OUTPUT_RANGE
|
||||
|
||||
*/
|
||||
};
|
330
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_hw.h
Executable file
330
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_hw.h
Executable file
|
@ -0,0 +1,330 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xycrcb2rgb_hw.h
|
||||
*
|
||||
* This header file contains identifiers and register-level driver functions (or
|
||||
* macros) that can be used to access the Xilinx YCrCb to RGB Color Space
|
||||
* Converter (YCRCB2RGB) core.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -------------------------------------------------------
|
||||
* 7.0 adk 01/31/14 First release.
|
||||
* Added the register offsets and bit masks for the
|
||||
* registers.
|
||||
* Added backward compatibility macros.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XYCRCB2RGB_HW_H_
|
||||
#define XYCRCB2RGB_HW_H_ /**< Prevent circular inclusions by using
|
||||
* protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_io.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Control Registers
|
||||
*
|
||||
* Control Registers offset for YCRCB2RGB core.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_CONTROL_OFFSET 0x000 /**< Control offset */
|
||||
#define XYCC_STATUS_OFFSET 0x004 /**< Status offset */
|
||||
#define XYCC_ERROR_OFFSET 0x008 /**< Error offset */
|
||||
#define XYCC_IRQ_EN_OFFSET 0x00C /**< IRQ Enable offset */
|
||||
#define XYCC_VERSION_OFFSET 0x010 /**< Version offset */
|
||||
#define XYCC_SYSDEBUG0_OFFSET 0x014 /**< System Debug 0 offset */
|
||||
#define XYCC_SYSDEBUG1_OFFSET 0x018 /**< System Debug 1 offset */
|
||||
#define XYCC_SYSDEBUG2_OFFSET 0x01C /**< System Debug 2 offset */
|
||||
/*@}*/
|
||||
|
||||
/** @name Timing Control Registers
|
||||
*
|
||||
* Timing control registers offset for YCRCB2RGB core.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ACTIVE_SIZE_OFFSET 0x020 /**< Active Size (V x H)
|
||||
* offset */
|
||||
/*@}*/
|
||||
|
||||
/** @name Core Specific Registers
|
||||
*
|
||||
* Core specific registers offset
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_RGBMAX_OFFSET 0x100 /**< RGB Clipping offset */
|
||||
#define XYCC_RGBMIN_OFFSET 0x104 /**< RGB Clamping offset */
|
||||
#define XYCC_ROFFSET_OFFSET 0x108 /**< R Offset offset */
|
||||
#define XYCC_GOFFSET_OFFSET 0x10C /**< G Offset offset */
|
||||
#define XYCC_BOFFSET_OFFSET 0x110 /**< B Offset offset */
|
||||
#define XYCC_ACOEF_OFFSET 0x114 /**< A Coefficient offset */
|
||||
#define XYCC_BCOEF_OFFSET 0x118 /**< B Coefficient offset */
|
||||
#define XYCC_CCOEF_OFFSET 0x11C /**< C Coefficient offset */
|
||||
#define XYCC_DCOEF_OFFSET 0x120 /**< D Coefficient offset */
|
||||
/*@}*/
|
||||
|
||||
/** @name Control Register Bit Masks
|
||||
*
|
||||
* Control Register bit definition for YCRCB2RGB core.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_CTL_SW_EN_MASK 0x00000001 /**< Software Enable Mask */
|
||||
#define XYCC_CTL_RUE_MASK 0x00000002 /**< Register Update
|
||||
* Enable Mask */
|
||||
#define XYCC_CTL_BPE_MASK 0x00000010 /**< Bypass Mask */
|
||||
#define XYCC_CTL_TPE_MASK 0x00000020 /**< Test Pattern Mask */
|
||||
#define XYCC_CTL_AUTORESET_MASK 0x40000000 /**< Software Reset -
|
||||
* Auto-synchronize
|
||||
* to SOF Mask */
|
||||
#define XYCC_CTL_RESET_MASK 0x80000000 /**< Software Reset -
|
||||
* Instantaneous Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name Slave Error Bit Masks
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ERR_EOL_EARLY_MASK 0x000000001 /**< Error: End of line
|
||||
* Early Mask */
|
||||
#define XYCC_ERR_EOL_LATE_MASK 0x000000002 /**< Error: End of line
|
||||
* Late Mask */
|
||||
#define XYCC_ERR_SOF_EARLY_MASK 0x000000004 /**< Error: Start of frame
|
||||
* Early Mask */
|
||||
#define XYCC_ERR_SOF_LATE_MASK 0x000000008 /**< Error: Start of frame
|
||||
* Late Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name Interrupt Register Bit Masks
|
||||
*
|
||||
* Interrupt Register bit definition for YCRCB2RGB core. It is applicable for
|
||||
* STATUS and IRQ_ENABLE Registers.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_IXR_PROCS_MASK 0x00000001 /**< Process Started Mask */
|
||||
#define XYCC_IXR_EOF_MASK 0x00000002 /**< End-Of-Frame Mask */
|
||||
#define XYCC_IXR_SE_MASK 0x00010000 /**< Slave Error Mask */
|
||||
#define XYCC_IXR_ALLINTR_MASK 0x00010003 /**< Interrupt All
|
||||
* Error Mask (ORing
|
||||
* (of All Interrupt
|
||||
* Mask) */
|
||||
/*@}*/
|
||||
|
||||
/** @name Version Register Bit Masks and Shifts
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_VER_REV_NUM_MASK 0x000000FF /**< Revision Number Mask */
|
||||
#define XYCC_VER_PID_MASK 0x00000F00 /**< Patch ID Mask */
|
||||
#define XYCC_VER_REV_MASK 0x0000F000 /**< Revision Mask */
|
||||
#define XYCC_VER_MINOR_MASK 0x00FF0000 /**< Minor Mask */
|
||||
#define XYCC_VER_MAJOR_MASK 0xFF000000 /**< Major Mask */
|
||||
#define XYCC_VER_MAJOR_SHIFT 24 /**< Major Shift */
|
||||
#define XYCC_VER_MINOR_SHIFT 16 /**< Minor Shift */
|
||||
#define XYCC_VER_REV_SHIFT 12 /**< Revision Shift */
|
||||
#define XYCC_VER_INTERNAL_SHIFT 8 /**< Internal Shift */
|
||||
/*@}*/
|
||||
|
||||
/** @name Active Size Register Bit Masks and Shifts
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ACTSIZE_NUM_PIXEL_MASK 0x00001FFF /**< The number of pixels
|
||||
* in source image */
|
||||
#define XYCC_ACTSIZE_NUM_LINE_MASK 0x1FFF0000 /**< The number of lines in
|
||||
* source image */
|
||||
#define XYCC_ACTSIZE_NUM_LINE_SHIFT 16 /**< Shift for number
|
||||
* of lines */
|
||||
/*@}*/
|
||||
|
||||
/** @name RGBMAX Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_RGBMAX_MASK 0x0000FFFF /**< Clipping Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name RGBMIN Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_RGBMIN_MASK 0x0000FFFF /**< Clamping Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name ROFFSET Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ROFFSET_MASK 0xFFFFFFFF /**< Red offset compensation
|
||||
* Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name GOFFSET Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_GOFFSET_MASK 0xFFFFFFFF /**< Green offset compensation
|
||||
* Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name BOFFSET Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_BOFFSET_MASK 0xFFFFFFFF /**< Blue offset compensation
|
||||
* Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name A ,B, C , D Coefficient Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_COEF_MASK 0x0003FFFF /**< Coefficients Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name General purpose Bit Mask and Shifts
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_8_BIT_MASK 0x000000FF /**< 8-bit Mask */
|
||||
#define XYCC_16_BIT_MASK 0x0000FFFF /**< 16-Bit Mask */
|
||||
#define XYCC_16_BIT_COEF_SHIFT 16 /**< 16-Bit Coefficient
|
||||
* Shift */
|
||||
/*@}*/
|
||||
|
||||
/** @name Data widths in bits per color.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_DATA_WIDTH_8 8 /**< 8-bit Data Width. */
|
||||
#define XYCC_DATA_WIDTH_10 10 /**< 10-bit Data Width. */
|
||||
#define XYCC_DATA_WIDTH_12 12 /**< 12-bit Data Width. */
|
||||
#define XYCC_DATA_WIDTH_16 16 /**< 16-bit Data Width. */
|
||||
/*@}*/
|
||||
|
||||
/** @name Backward Compatibility Macros
|
||||
*
|
||||
* To support backward compatibility, following macros definition are
|
||||
* re-defined.
|
||||
* @{
|
||||
*/
|
||||
#define YCC_CONTROL XYCC_CONTROL_OFFSET
|
||||
#define YCC_STATUS XYCC_STATUS_OFFSET
|
||||
#define YCC_ERROR XYCC_ERROR_OFFSET
|
||||
#define YCC_IRQ_EN XYCC_IRQ_EN_OFFSET
|
||||
#define YCC_VERSION XYCC_VERSION_OFFSET
|
||||
#define YCC_SYSDEBUG0 XYCC_SYSDEBUG0_OFFSET
|
||||
#define YCC_SYSDEBUG1 XYCC_SYSDEBUG1_OFFSET
|
||||
#define YCC_SYSDEBUG2 XYCC_SYSDEBUG2_OFFSET
|
||||
#define YCC_ACTIVE_SIZE XYCC_ACTIVE_SIZE_OFFSET
|
||||
#define YCC_CTL_EN_MASK XYCC_CTL_EN_MASK
|
||||
#define YCC_CTL_RUE_MASK XYCC_CTL_RUE_MASK
|
||||
#define YCC_CTL_CS_MASK XYCC_CTL_CS_MASK
|
||||
#define YCC_RST_RESET XYCC_CTL_RESET_MASK
|
||||
#define YCC_RST_AUTORESET XYCC_CTL_AUTORESET_MASK
|
||||
|
||||
#define YCC_In32 XYCrCb2Rgb_In32
|
||||
#define YCC_Out32 XYCrCb2Rgb_Out32
|
||||
|
||||
#define XYCC_ReadReg XYCrCb2Rgb_ReadReg
|
||||
#define XYCC_WriteReg XYCrCb2Rgb_WriteReg
|
||||
/*@}*/
|
||||
|
||||
/** @name Interrupt Registers
|
||||
*
|
||||
* Interrupt status register generates a interrupt if the corresponding bits
|
||||
* of interrupt enable register bits are set.
|
||||
* @{
|
||||
*/
|
||||
#define XYCC_ISR_OFFSET XYCC_STATUS_OFFSET /**< Interrupt Status
|
||||
* Offset */
|
||||
#define XYCC_IER_OFFSET XYCC_IRQ_EN_OFFSET /**< Interrupt Enable
|
||||
* Offset */
|
||||
/*@}*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
#define XYCrCb2Rgb_In32 Xil_In32 /**< Input operation */
|
||||
#define XYCrCb2Rgb_Out32 Xil_Out32 /**< Output operation */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro reads the given register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the YCRCB2RGB core.
|
||||
* @param RegOffset is the register offset of the register defined at
|
||||
* top of this file.
|
||||
*
|
||||
* @return 32-bit value of the register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XYCrCb2Rgb_ReadReg(u32 BaseAddress, u32 RegOffset).
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_ReadReg(BaseAddress, RegOffset) \
|
||||
XYCrCb2Rgb_In32((BaseAddress) + (u32)(RegOffset))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro writes the given register.
|
||||
*
|
||||
* @param BaseAddress is base address of the YCRCB2RGB core.
|
||||
* @param RegOffset is the register offset of the register (defined at
|
||||
* top of this file).
|
||||
* @param Data is the 32-bit value to write to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XYCrCb2Rgb_WriteReg(u32 BaseAddress, u32 RegOffset,
|
||||
* u32 Data)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XYCrCb2Rgb_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
XYCrCb2Rgb_Out32((BaseAddress) + (u32)(RegOffset), (Data))
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Declarations ****************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of protection macro */
|
204
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_intr.c
Executable file
204
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_intr.c
Executable file
|
@ -0,0 +1,204 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xycrcb2rgb_intr.c
|
||||
*
|
||||
* This file contains interrupt related functions for the YCRCB2RGB core.
|
||||
* Please see xycrcb2rgb.h for more details of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- --------------------------------------------------
|
||||
* 7.0 adk 01/31/14 First Release.
|
||||
* Implemented the following functions:
|
||||
* XYCrCb2Rgb_IntrHandler
|
||||
* XYCrCb2Rgb_SetCallBack
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xycrcb2rgb.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the interrupt handler for the YCRCB2RGB core.
|
||||
*
|
||||
* This handler reads the pending interrupt from the IER(IRQ_ENABLE register)
|
||||
* or ISR (STATUS register), determines the source of the interrupts,
|
||||
* calls according callbacks, and finally clears the interrupts.
|
||||
*
|
||||
* The application is responsible for connecting this function to the interrupt
|
||||
* system. Application beyond this driver is also responsible for providing
|
||||
* callbacks to handle interrupts and installing the callbacks using
|
||||
* XYCrCb2Rgb_SetCallBack() during initialization phase.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance that just
|
||||
* interrupted.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note Interrupt interface (HasIntcIf) should be enabled.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XYCrCb2Rgb_IntrHandler(void *InstancePtr)
|
||||
{
|
||||
u32 PendingIntr;
|
||||
u32 ErrorStatus;
|
||||
|
||||
XYCrCb2Rgb *XYCrCb2RgbPtr = (XYCrCb2Rgb *)((void *)InstancePtr);
|
||||
|
||||
/* Verify arguments. */
|
||||
Xil_AssertVoid(XYCrCb2RgbPtr != NULL);
|
||||
Xil_AssertVoid(XYCrCb2RgbPtr->IsReady ==
|
||||
(u32)(XIL_COMPONENT_IS_READY));
|
||||
Xil_AssertVoid(XYCrCb2RgbPtr->Config.HasIntcIf != (u16)0x0);
|
||||
|
||||
/* Get pending interrupts */
|
||||
PendingIntr = (u32)XYCrCb2Rgb_IntrGetPending(XYCrCb2RgbPtr);
|
||||
|
||||
/* Slave error interrupt has occurred */
|
||||
if ((PendingIntr & (XYCC_IXR_SE_MASK)) == (XYCC_IXR_SE_MASK)) {
|
||||
ErrorStatus = PendingIntr & (XYCC_IXR_SE_MASK);
|
||||
XYCrCb2RgbPtr->ErrCallBack(XYCrCb2RgbPtr->ErrRef, ErrorStatus);
|
||||
}
|
||||
|
||||
/* A Processing Start has occurred */
|
||||
if ((PendingIntr & (XYCC_IXR_PROCS_MASK)) == (XYCC_IXR_PROCS_MASK)) {
|
||||
XYCrCb2RgbPtr->ProcStartCallBack( XYCrCb2RgbPtr->ProcStartRef);
|
||||
}
|
||||
|
||||
/* A Frame Done interrupt has occurred */
|
||||
if ((PendingIntr & (XYCC_IXR_EOF_MASK)) == (XYCC_IXR_EOF_MASK)) {
|
||||
XYCrCb2RgbPtr->FrameDoneCallBack(XYCrCb2RgbPtr->FrameDoneRef);
|
||||
}
|
||||
|
||||
/* Clear pending interrupt(s) */
|
||||
XYCrCb2Rgb_IntrClear(XYCrCb2RgbPtr, PendingIntr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This routine installs an asynchronous callback function for the given
|
||||
* HandlerTypes.
|
||||
*
|
||||
* <pre>
|
||||
* HandlerType Callback Function Type
|
||||
* ----------------------- ---------------------------
|
||||
* XYCC_HANDLER_PROCSTART ProcStartCallBack.
|
||||
* XYCC_HANDLER_FRAMEDONE FrameDoneCallBack.
|
||||
* XYCC_HANDLER_ERROR ErrCallBack.
|
||||
* </pre>
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance to be
|
||||
* worked on.
|
||||
* @param HandlerType specifies which callback is to be attached.
|
||||
* @param CallBackFunc is the address of the callback function.
|
||||
* @param CallBackRef is a user data item that will be passed to the
|
||||
* callback function when it is invoked.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS when handler is installed.
|
||||
* - XST_INVALID_PARAM when HandlerType is invalid.
|
||||
*
|
||||
* @note Invoking this function for a handler that already has been
|
||||
* installed replaces it with the new handler.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XYCrCb2Rgb_SetCallBack(XYCrCb2Rgb *InstancePtr, u32 HandlerType,
|
||||
void *CallBackFunc, void *CallBackRef)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Verify arguments. */
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady ==
|
||||
(u32)(XIL_COMPONENT_IS_READY));
|
||||
Xil_AssertNonvoid(CallBackFunc != NULL);
|
||||
Xil_AssertNonvoid(CallBackRef != NULL);
|
||||
Xil_AssertNonvoid((HandlerType >= (u32)(XYCC_HANDLER_PROCSTART)) &&
|
||||
(HandlerType <= (u32)(XYCC_HANDLER_ERROR)));
|
||||
|
||||
/* Setting function and reference based on HandlerType */
|
||||
switch (HandlerType) {
|
||||
case XYCC_HANDLER_PROCSTART:
|
||||
InstancePtr->ProcStartCallBack =
|
||||
(XYCrCb2Rgb_CallBack)((void *)CallBackFunc);
|
||||
InstancePtr->ProcStartRef = CallBackRef;
|
||||
Status = (XST_SUCCESS);
|
||||
break;
|
||||
|
||||
case XYCC_HANDLER_FRAMEDONE:
|
||||
InstancePtr->FrameDoneCallBack =
|
||||
(XYCrCb2Rgb_CallBack)((void *)CallBackFunc);
|
||||
InstancePtr->FrameDoneRef = CallBackRef;
|
||||
Status = (XST_SUCCESS);
|
||||
break;
|
||||
|
||||
case XYCC_HANDLER_ERROR:
|
||||
InstancePtr->ErrCallBack =
|
||||
(XYCrCb2Rgb_ErrorCallBack)((void *)CallBackFunc);
|
||||
InstancePtr->ErrRef = CallBackRef;
|
||||
Status = (XST_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = (XST_INVALID_PARAM);
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
107
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_selftest.c
Executable file
107
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_selftest.c
Executable file
|
@ -0,0 +1,107 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xycrcb2rgb_selftest.c
|
||||
*
|
||||
* This file contains the self-test function for the YCRCB2RGB core.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 7.0 adk 02/03/14 First Release.
|
||||
* Implemented the following function:
|
||||
* XYCrCb2Rgb_SelfTest
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xycrcb2rgb.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function reads Version register of YCRCB2RGB core and compares with
|
||||
* zero as part of self test.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XCrCb2Rgb instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the Version register read test was successful.
|
||||
* - XST_FAILURE if the Version register read test failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XYCrCb2Rgb_SelfTest(XYCrCb2Rgb *InstancePtr)
|
||||
{
|
||||
u32 Version;
|
||||
int Status;
|
||||
|
||||
/* Verify argument. */
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
|
||||
Version = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
(XYCC_VERSION_OFFSET));
|
||||
|
||||
/* Compare Version with zero */
|
||||
if (Version != (u32)0x0) {
|
||||
Status = (XST_SUCCESS);
|
||||
}
|
||||
else {
|
||||
Status = (XST_FAILURE);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
110
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_sinit.c
Executable file
110
XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_sinit.c
Executable file
|
@ -0,0 +1,110 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xycrcb2rgb_sinit.c
|
||||
*
|
||||
* This file contains static initialization methods for Xilinx YCRCB2RGB core.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -----------------------------------------------
|
||||
* 7.0 adk 02/10/14 First release.
|
||||
* Implemented following function:
|
||||
* XYCrCb2Rgb_Config.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xycrcb2rgb.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns a reference to an XYCrCb2Rgb_Config structure
|
||||
* based on the unique core id, <i>DeviceId</i>. The return value will refer
|
||||
* to an entry in the core configuration table defined in the xycrcb2rgb_g.c
|
||||
* file.
|
||||
*
|
||||
* @param DeviceId is the unique core ID of the core for the lookup
|
||||
* operation.
|
||||
*
|
||||
* @return XYCrCb2Rgb_LookupConfig returns a reference to a config record
|
||||
* in the configuration table (in xycrcb2rgb_g.c) corresponding
|
||||
* to <i>DeviceId</i>, or NULL if no match is found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XYCrCb2Rgb_Config *XYCrCb2Rgb_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
u32 Index;
|
||||
extern XYCrCb2Rgb_Config
|
||||
XYCrCb2Rgb_ConfigTable[XPAR_XYCC_NUM_INSTANCES];
|
||||
XYCrCb2Rgb_Config *CfgPtr = NULL;
|
||||
|
||||
/* Get the reference pointer to XYCrCb2Rgb_Config structure */
|
||||
for (Index = (u32)0x0; Index < (u32)(XPAR_XYCC_NUM_INSTANCES);
|
||||
Index++) {
|
||||
|
||||
/* Compare device Id with configTable's device Id */
|
||||
if (XYCrCb2Rgb_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XYCrCb2Rgb_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XYCrCb2Rgb_Config *)CfgPtr;
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file rgb2ycrcb.c
|
||||
*
|
||||
* This is main code of Xilinx YCrCb to RGB Color Space Converter (YCRCB2RGB)
|
||||
* device driver. Please see ycrcb2rgb.h for more details of the driver.
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 5.00a tb 02/28/12 Updated for YCRCB2RGB v5.00.a
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "ycrcb2rgb.h"
|
||||
#include "xenv.h"
|
||||
#include "stdio.h"
|
||||
|
||||
double ycc_pow2(u32 a) { return( (a>0) ? (1 << a) : 1.0/(1 << (-a)) ); }
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
// Note: Most of the functions are currently implemented as high-performance
|
||||
// macros within ycrcb2rgb.h
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Select input coefficients for 4 supported Standards and 3 Input Ranges.
|
||||
*
|
||||
* @param standard_sel is the standards selection: 0 = SD_ITU_601
|
||||
* 1 = HD_ITU_709__1125_NTSC
|
||||
* 2 = HD_ITU_709__1250_PAL
|
||||
* 3 = YUV
|
||||
* @param input_range is the limit on the range of the data: 0 = 16_to_240_for_TV,
|
||||
* 1 = 16_to_235_for_Studio_Equipment,
|
||||
* 3 = 0_to_255_for_Computer_Graphics
|
||||
* @param data_width has a valid range of [8,10,12,16]
|
||||
* @param coef_in is a pointer to a ycc_coef_inputs data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_select_standard(u32 standard_sel, u32 input_range, u32 data_width, struct ycc_coef_inputs *coef_in)
|
||||
{
|
||||
double acoef[4][3] = {0.299, 0.299, 0.2568, 0.299, 0.299, 0.2568, 0.2126, 0.2126, 0.1819, 0.299, 0.299, 0.299};
|
||||
double bcoef[4][3] = {0.114, 0.114, 0.0979, 0.114, 0.114, 0.0979, 0.0722, 0.0722, 0.0618, 0.114, 0.114, 0.114};
|
||||
double ccoef[4][3] = {0.713, 0.7295, 0.5910, 0.713, 0.7295, 0.5910, 0.6350, 0.6495, 0.6495, 0.877283, 0.877283, 0.877283};
|
||||
double dcoef[4][3] = {0.564, 0.5772, 0.5772, 0.564, 0.5772, 0.5772, 0.5389, 0.5512, 0.5512, 0.492111, 0.492111, 0.492111};
|
||||
u32 yoffset = 1<<(data_width-4);
|
||||
u32 coffset = 1<<(data_width-1);
|
||||
u32 max[3] = {(240*(1<<(data_width-8))), (235*(1<<(data_width-8))), ((1<<data_width)-1)};
|
||||
u32 min[3] = { (16*(1<<(data_width-8))), (16*(1<<(data_width-8))), 0};
|
||||
|
||||
coef_in->acoef = acoef[standard_sel][input_range];
|
||||
coef_in->bcoef = bcoef[standard_sel][input_range];
|
||||
coef_in->ccoef = ccoef[standard_sel][input_range];
|
||||
coef_in->dcoef = dcoef[standard_sel][input_range];
|
||||
coef_in->yoffset = yoffset;
|
||||
coef_in->cboffset = coffset;
|
||||
coef_in->croffset = coffset;
|
||||
coef_in->rgbmax = max[input_range];
|
||||
coef_in->rgbmin = min[input_range];
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Translate input coefficients into coefficients that can be programmed into the
|
||||
* YCrCb2RGB core.
|
||||
*
|
||||
* @param coef_in is a pointer to a rgb_coef_inputs data structure.
|
||||
* @param coef_out is a pointer to a rgb_coef_output data structure.
|
||||
*
|
||||
* @return The 32-bit value: bit(0)= 1=data width outside range [8, 10, 12, 16]
|
||||
* bit(1)= Acoef + Bcoef > 1.0
|
||||
* bit(2)= Y Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(3)= Cb Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(4)= Cr Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(5)= RGB Max outside data width range [0, (2^data_width)-1]
|
||||
* bit(6)= RGB Min outside data width range [0, (2^data_width)-1]
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
u32 YCC_coefficient_translation(struct ycc_coef_inputs *coef_in, struct ycc_coef_outputs *coef_out, u32 data_width, u32 mwidth)
|
||||
{
|
||||
u32 ret_val = 0;
|
||||
u32 scale_coeffs;
|
||||
double scale_ic2m;
|
||||
u32 coef_range;
|
||||
double acoef, bcoef, ccoef, dcoef;
|
||||
double acr, bcr, ccr, dcr;
|
||||
u32 ac, bc, cc, dc;
|
||||
u32 yoffset, cboffset, croffset;
|
||||
u32 rgbmax, rgbmin;
|
||||
u32 iwidth, owidth, cwidth;
|
||||
double rounding_const;
|
||||
|
||||
iwidth = data_width;
|
||||
owidth = data_width;
|
||||
coef_range = 2;
|
||||
cwidth = 17;
|
||||
|
||||
acoef = coef_in->acoef;
|
||||
bcoef = coef_in->bcoef;
|
||||
ccoef = coef_in->ccoef;
|
||||
dcoef = coef_in->dcoef;
|
||||
yoffset = coef_in->yoffset;
|
||||
cboffset = coef_in->cboffset;
|
||||
croffset = coef_in->croffset;
|
||||
rgbmax = coef_in->rgbmax;
|
||||
rgbmin = coef_in->rgbmin;
|
||||
|
||||
if((acoef + bcoef) > 1.0) {
|
||||
printf("WARNING: Acoef (%lf) + Bcoef (%lf) can not be more then 1.0\r\n",acoef, bcoef);
|
||||
ret_val = ret_val | 0x1;
|
||||
}
|
||||
if(yoffset < -(1<<iwidth) || yoffset > (1<<iwidth)-1) {
|
||||
printf("WARNING: Y Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)yoffset, (unsigned int)-(1<<iwidth), (unsigned int)(1<<iwidth)-1);
|
||||
ret_val = ret_val | 0x2;
|
||||
}
|
||||
if(cboffset < -(1<<iwidth) || cboffset > (1<<iwidth)-1) {
|
||||
printf("WARNING: Cb Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)cboffset, (unsigned int)-(1<<iwidth), (unsigned int)(1<<iwidth)-1);
|
||||
ret_val = ret_val | 0x4;
|
||||
}
|
||||
if(croffset < -(1<<iwidth) || croffset > (1<<iwidth)-1) {
|
||||
printf("WARNING: Cr Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)croffset, (unsigned int)-(1<<iwidth), (unsigned int)(1<<iwidth)-1);
|
||||
ret_val = ret_val | 0x8;
|
||||
}
|
||||
if(rgbmax < 0 || rgbmax > (1<<iwidth)-1) {
|
||||
printf("WARNING: RGB Max (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)rgbmax, (unsigned int)(1<<iwidth)-1);
|
||||
ret_val = ret_val | 0x10;
|
||||
}
|
||||
if(rgbmin < 0 || rgbmin > (1<<iwidth)-1) {
|
||||
printf("WARNING: RGB Min (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)rgbmin, (unsigned int)(1<<iwidth)-1);
|
||||
ret_val = ret_val | 0x20;
|
||||
}
|
||||
|
||||
acr = 1/ccoef;
|
||||
bcr = -(acoef/ccoef/(1-acoef-bcoef));
|
||||
ccr = -(bcoef/dcoef/(1-acoef-bcoef));
|
||||
dcr = 1/dcoef;
|
||||
|
||||
scale_coeffs = ycc_max(1, (1 << (cwidth-coef_range-1)));
|
||||
rounding_const = ycc_pow2(mwidth - owidth - coef_range -2); // +0.5 turns truncation to biased rounding
|
||||
scale_ic2m = ycc_pow2(1+mwidth - iwidth - cwidth );
|
||||
|
||||
// Quantize coefficients:
|
||||
ac = (u32) (acr*scale_coeffs); // round, wrap
|
||||
bc = (u32) (bcr*scale_coeffs);
|
||||
cc = (u32) (ccr*scale_coeffs);
|
||||
dc = (u32) (dcr*scale_coeffs);
|
||||
|
||||
coef_out->acoef = ac;
|
||||
coef_out->bcoef = bc;
|
||||
coef_out->ccoef = cc;
|
||||
coef_out->dcoef = dc;
|
||||
|
||||
// Assuming signals are OWIDTH+1 bits wide after the offset compensating rounders / adders:
|
||||
coef_out->roffset = (u32) ((rounding_const - (ac*croffset + yoffset*scale_coeffs))*scale_ic2m);
|
||||
coef_out->goffset = (u32) ((rounding_const - (((bc*croffset)+(cc*cboffset)) + yoffset*scale_coeffs))*scale_ic2m);
|
||||
coef_out->boffset = (u32) ((rounding_const - (dc*cboffset + yoffset*scale_coeffs))*scale_ic2m);
|
||||
|
||||
coef_out->rgbmax = rgbmax;
|
||||
coef_out->rgbmin = rgbmin;
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Program the YCrCb2RGB coefficient/offset registers.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param coef_out is a pointer to a rgb_coef_output data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_set_coefficients(u32 BaseAddress, struct ycc_coef_outputs *coef_out)
|
||||
{
|
||||
YCC_WriteReg(BaseAddress, YCC_ACOEF, coef_out->acoef); //ACOEF
|
||||
YCC_WriteReg(BaseAddress, YCC_BCOEF, coef_out->bcoef); //BCOEF
|
||||
YCC_WriteReg(BaseAddress, YCC_CCOEF, coef_out->ccoef); //CCOEF
|
||||
YCC_WriteReg(BaseAddress, YCC_DCOEF, coef_out->dcoef); //DCOEF
|
||||
YCC_WriteReg(BaseAddress, YCC_ROFFSET, coef_out->roffset); //ROFFSET
|
||||
YCC_WriteReg(BaseAddress, YCC_GOFFSET, coef_out->goffset); //GOFFSET
|
||||
YCC_WriteReg(BaseAddress, YCC_BOFFSET, coef_out->boffset); //BOFFSET
|
||||
YCC_WriteReg(BaseAddress, YCC_RGBMAX, coef_out->rgbmax); //RGBMAX
|
||||
YCC_WriteReg(BaseAddress, YCC_RGBMIN, coef_out->rgbmin); //RGBMIN
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the YCrCb2RGB coefficient/offset registers.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param coef_out is a pointer to a rgb_coef_output data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_get_coefficients(u32 BaseAddress, struct ycc_coef_outputs *coef_out)
|
||||
{
|
||||
coef_out->acoef = YCC_ReadReg(BaseAddress, YCC_ACOEF);
|
||||
coef_out->bcoef = YCC_ReadReg(BaseAddress, YCC_BCOEF);
|
||||
coef_out->ccoef = YCC_ReadReg(BaseAddress, YCC_CCOEF);
|
||||
coef_out->dcoef = YCC_ReadReg(BaseAddress, YCC_DCOEF);
|
||||
coef_out->roffset = YCC_ReadReg(BaseAddress, YCC_ROFFSET);
|
||||
coef_out->goffset = YCC_ReadReg(BaseAddress, YCC_GOFFSET);
|
||||
coef_out->boffset = YCC_ReadReg(BaseAddress, YCC_BOFFSET);
|
||||
coef_out->rgbmax = YCC_ReadReg(BaseAddress, YCC_RGBMAX);
|
||||
coef_out->rgbmin = YCC_ReadReg(BaseAddress, YCC_RGBMIN);
|
||||
}
|
|
@ -1,417 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file rgb2ycrcb.h
|
||||
*
|
||||
* This header file contains identifiers and register-level driver functions (or
|
||||
* macros) that can be used to access the Xilinx YCrCb to RGB Color Space Converter
|
||||
* (RGB2YCRCB) device.
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 5.00a tb 02/28/12 Updated for YCRCB2RGB V5.00.a
|
||||
* 5.01a bao 12/28/12 Converted from xio.h to xil_io.h, translating basic types,
|
||||
* MB cache functions, exceptions and assertions to xil_io
|
||||
* format
|
||||
* 6.0 adk 19/12/13 Updated as per the New Tcl API's
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef YCRCB2RGB_DRIVER_H /* prevent circular inclusions */
|
||||
#define YCRCB2RGB_DRIVER_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_io.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**
|
||||
* Register Offsets
|
||||
*/
|
||||
/* General Control Registers */
|
||||
#define YCC_CONTROL 0x000 /**< Control */
|
||||
#define YCC_STATUS 0x004 /**< Status */
|
||||
#define YCC_ERROR 0x008 /**< Error */
|
||||
#define YCC_IRQ_EN 0x00C /**< IRQ Enable */
|
||||
#define YCC_VERSION 0x010 /**< Version */
|
||||
#define YCC_SYSDEBUG0 0x014 /**< System Debug 0 */
|
||||
#define YCC_SYSDEBUG1 0x018 /**< System Debug 1 */
|
||||
#define YCC_SYSDEBUG2 0x01C /**< System Debug 2 */
|
||||
/* Timing Control Registers */
|
||||
#define YCC_ACTIVE_SIZE 0x020 /**< Active Size (V x H) */
|
||||
#define YCC_TIMING_STATUS 0x024 /**< Timing Measurement Status */
|
||||
/* Core Specific Registers */
|
||||
#define YCC_RGBMAX 0x100 /**< RGB Clipping */
|
||||
#define YCC_RGBMIN 0x104 /**< RGB Clamping */
|
||||
#define YCC_ROFFSET 0x108 /**< R Offset */
|
||||
#define YCC_GOFFSET 0x10C /**< G Offset */
|
||||
#define YCC_BOFFSET 0x110 /**< B Offset */
|
||||
#define YCC_ACOEF 0x114 /**< Matrix Coversion Coefficient */
|
||||
#define YCC_BCOEF 0x118 /**< Matrix Coversion Coefficient */
|
||||
#define YCC_CCOEF 0x11C /**< Matrix Coversion Coefficient */
|
||||
#define YCC_DCOEF 0x120 /**< Matrix Coversion Coefficient */
|
||||
|
||||
/*
|
||||
* CCM Control Register bit definition
|
||||
*/
|
||||
#define YCC_CTL_EN_MASK 0x00000001 /**< CCM Enable */
|
||||
#define YCC_CTL_RUE_MASK 0x00000002 /**< CCM Register Update Enable */
|
||||
|
||||
/*
|
||||
* CCM Reset Register bit definition
|
||||
*/
|
||||
#define YCC_RST_RESET 0x80000000 /**< Software Reset - Instantaneous */
|
||||
#define YCC_RST_AUTORESET 0x40000000 /**< Software Reset - Auto-synchronize to SOF */
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
#define YCC_In32 Xil_In32
|
||||
#define YCC_Out32 Xil_Out32
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro enables a YCrCb2RGB device.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_Enable(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_Enable(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, \
|
||||
YCC_ReadReg(BaseAddress, YCC_CONTROL) | \
|
||||
YCC_CTL_EN_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro disables a YCrCb2RGB device.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_Disable(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_Disable(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, \
|
||||
YCC_ReadReg(BaseAddress, YCC_CONTROL) & \
|
||||
~YCC_CTL_EN_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro tells a YCrCb2RGB device to pick up all the register value changes
|
||||
* made so far by the software. The registers will be automatically updated
|
||||
* on the next SOF signal on the core.
|
||||
* It is up to the user to manually disable the register update after a sufficient
|
||||
* amount if time.
|
||||
*
|
||||
* This function only works when the YCrCb2RGB core is enabled.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_RegUpdateEnable(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_RegUpdateEnable(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, \
|
||||
YCC_ReadReg(BaseAddress, YCC_CONTROL) | \
|
||||
YCC_CTL_RUE_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro tells a YCrCb2RGB device not to update it's configuration registers made
|
||||
* so far by the software. When disabled, changes to other configuration registers
|
||||
* are stored, but do not effect the core's behavior.
|
||||
*
|
||||
* This function only works when the YCrCb2RGB core is enabled.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_RegUpdateDisable(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_RegUpdateDisable(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, \
|
||||
YCC_ReadReg(BaseAddress, YCC_CONTROL) & \
|
||||
~YCC_CTL_RUE_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro resets a YCrCb2RGB device. This reset effects the core immediately,
|
||||
* and may cause image tearing.
|
||||
*
|
||||
* This reset resets the YCrCb2RGB's configuration registers, and holds the core's outputs
|
||||
* in their reset state until YCC_ClearReset() is called.
|
||||
*
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_Reset(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_Reset(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, YCC_RST_RESET) \
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro clears the YCrCb2RGB's reset flag (which is set using YCC_Reset(), and
|
||||
* returns it to normal operation. This ClearReset effects the core immediately,
|
||||
* and may cause image tearing.
|
||||
*
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_ClearReset(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_ClearReset(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, 0) \
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro resets a YCrCb2RGB device, but differs from YCC_Reset() in that it
|
||||
* automatically synchronizes to the VBlank_in input of the core to prevent tearing.
|
||||
*
|
||||
* On the next rising-edge of VBlank_in following a call to YCC_AutoSyncReset(),
|
||||
* all of the core's configuration registers and outputs will be reset, then the
|
||||
* reset flag will be immediately released, allowing the core to immediately resume
|
||||
* default operation.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_Reset(u32 BaseAddress);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_AutoSyncReset(BaseAddress) \
|
||||
YCC_WriteReg(BaseAddress, YCC_CONTROL, YCC_RST_AUTORESET) \
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given register.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param RegOffset is the register offset of the register (defined at top of this file)
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 YCC_ReadReg(u32 BaseAddress, u32 RegOffset)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_ReadReg(BaseAddress, RegOffset) \
|
||||
YCC_In32((BaseAddress) + (RegOffset))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given register.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param RegOffset is the register offset of the register (defined at top of this file)
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void YCC_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define YCC_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
YCC_Out32((BaseAddress) + (RegOffset), (Data))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
struct ycc_coef_inputs
|
||||
{
|
||||
/* Pre-translated coefficient/offset data */
|
||||
double acoef; //@- [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0
|
||||
double bcoef; //@- [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0
|
||||
double ccoef; //@- [ 0.0 - 0.9 ]
|
||||
double dcoef; //@- [ 0.0 - 0.9 ]
|
||||
u32 yoffset; //@- Offset for the Luminance Channel
|
||||
u32 cboffset; //@- Offset for the Chrominance Channels
|
||||
u32 croffset; //@- Offset for the Chrominance Channels
|
||||
u32 rgbmax; //@- RGB Clipping
|
||||
u32 rgbmin; //@- RGB Clamping
|
||||
};
|
||||
|
||||
struct ycc_coef_outputs
|
||||
{
|
||||
/* Translated coefficient/offset data */
|
||||
u32 acoef; //@- Translated ACoef
|
||||
u32 bcoef; //@- Translated BCoef
|
||||
u32 ccoef; //@- Translated CCoef
|
||||
u32 dcoef; //@- Translated DCoef
|
||||
u32 roffset; //@- Translated Offset for the R Channel
|
||||
u32 goffset; //@- Translated Offset for the G Channel
|
||||
u32 boffset; //@- Translated Offset for the B Channel
|
||||
u32 rgbmax; //@- Translated RGB Clipping
|
||||
u32 rgbmin; //@- Translated RGB Clamping
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Select input coefficients for 4 supported Standards and 3 Input Ranges.
|
||||
*
|
||||
* @param standard_sel is the standards selection: 0 = SD_ITU_601
|
||||
* 1 = HD_ITU_709__1125_NTSC
|
||||
* 2 = HD_ITU_709__1250_PAL
|
||||
* 3 = YUV
|
||||
* @param input_range is the limit on the range of the data: 0 = 16_to_240_for_TV,
|
||||
* 1 = 16_to_235_for_Studio_Equipment,
|
||||
* 3 = 0_to_255_for_Computer_Graphics
|
||||
* @param data_width has a valid range of [8, 10,12,16]
|
||||
* @param coef_in is a pointer to a ycc_coef_inputs data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_select_standard(u32 standard_sel, u32 input_range, u32 data_width, struct ycc_coef_inputs *coef_in);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Translate input coefficients into coefficients that can be programmed into the
|
||||
* YCrCb2RGB core.
|
||||
*
|
||||
* @param coef_in is a pointer to a ycc_coef_inputs data structure.
|
||||
* @param coef_out is a pointer to a ycc_coef_output data structure.
|
||||
* @param data_width is the bit width of the data
|
||||
* @param mwidth is multiplicatio width value calculated by the core.
|
||||
*
|
||||
* @return The 32-bit value: bit(0)= 1=data width outside range [8, 10, 12, 16]
|
||||
* bit(1)= Acoef + Bcoef > 1.0
|
||||
* bit(2)= Y Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(3)= Cb Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(4)= Cr Offset outside data width range [-2^data_width, (2^data_width)-1]
|
||||
* bit(5)= RGB Max outside data width range [0, (2^data_width)-1]
|
||||
* bit(6)= RGB Min outside data width range [0, (2^data_width)-1]
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
u32 YCC_coefficient_translation(struct ycc_coef_inputs *coef_in, struct ycc_coef_outputs *coef_out, u32 data_width, u32 mwidth);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Program the YCrCb2RGB coefficient/offset registers.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param coef_out is a pointer to a ycc_coef_output data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_set_coefficients(u32 BaseAddress, struct ycc_coef_outputs *coef_out);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the YCrCb2RGB coefficient/offset registers.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx EDK base address of the YCrCb2RGB core (from xparameters.h)
|
||||
* @param coef_out is a pointer to a ycc_coef_output data structure.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
void YCC_get_coefficients(u32 BaseAddress, struct ycc_coef_outputs *coef_out);
|
||||
|
||||
|
||||
#define ycc_max(a,b) (((a)>(b)) ? (a) : (b))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
Loading…
Add table
Reference in a new issue