diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.mdd b/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.mdd index fcd0637a..dba60d7f 100755 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.mdd +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.mdd @@ -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; diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.tcl b/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.tcl index 9b4a23d9..881d8bf7 100755 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.tcl +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/data/ycrcb2rgb.tcl @@ -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" } diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/example.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/example.c deleted file mode 100755 index 3ddfe6d3..00000000 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/example.c +++ /dev/null @@ -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. - * - *
- * MODIFICATION HISTORY:
- *
- * Ver   Who  Date     Changes
- * ----- ---- -------- -------------------------------------------------------
- * 5.00a tb   02/28/12 Updates for the v5.00.a release
- * 
- * - * *************************************************************************** - */ - -#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; -} - - diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/index.html b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/index.html index 128d8184..c4232d9e 100755 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/index.html +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/index.html @@ -1,17 +1,22 @@ - - - - - -Driver example applications - - - -

Example Applications for the driver ycrcb2rgb_v6_0

-
- -

Copyright � 1995-2014 Xilinx, Inc. All rights reserved.

- - \ No newline at end of file + + + + + +Driver example applications + + + +

Example Applications for the driver ycrcb2rgb_v7_0

+
+ + +

Copyright ? 1995-2014 Xilinx, Inc. All rights reserved.

+ + + + diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_example.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_example.c new file mode 100755 index 00000000..16e6d515 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_example.c @@ -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. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who  Date     Changes
+* ----- ---- -------- -------------------------------------------------------
+* 7.00 adk   07/14/14 First release.
+* 
+* +******************************************************************************/ + +#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; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_selftest_example.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_selftest_example.c new file mode 100755 index 00000000..d6ef7646 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/examples/ycrcb2rgb_selftest_example.c @@ -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. +* +*
+* MODIFICATION HISTORY:
+
+* Ver   Who    Date     Changes
+* ----- ------ -------- ------------------------------------------------------
+* 7.0   adk    02/10/14 First Release.
+* 
+* +******************************************************************************/ + +/***************************** 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; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/Makefile b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/Makefile index 7dbc6d92..69a9a6d3 100755 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/Makefile +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/Makefile @@ -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} + diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.c new file mode 100755 index 00000000..fe351b0b --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.c @@ -0,0 +1,1285 @@ +/****************************************************************************** +* +* 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.c +* +* This file contains the implementation of the interface functions for +* YCRCB2RGB core. Refer to the header file xycrcb2rgb.h for more detailed +* information. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ----   -------- ----------------------------------------------------
+* 5.00a tb     02/28/12 Updated for YCRCB2RGB v5.00.a.
+* 7.0   adk    01/31/14 Changed the file name from "ycrcb2rgb.c" to
+*                       "xycrcb2rgb.c".
+*
+*                       Implemented following functions:
+*                       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.
+* 
+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xycrcb2rgb.h" + +/************************** Constant Definitions *****************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/**************************** Type Definitions *******************************/ + + +/************************** Function Prototypes ******************************/ + +/** +* Each of the callback functions to be called on different types of interrupts. +* These stub functions are set during XYCrCb2Rgb_CfgInitialize as default +* callback functions. If application is not registered any of the callback +* function, these functions will be called for doing nothing. +*/ +static void StubCallBack(void *CallBackRef); +static void StubErrCallBack(void *CallBackRef, u32 ErrorMask); + +static double XYCrCb2Rgb_Pow2(u32 Num); + +/************************** Variable Definitions *****************************/ + + +/************************** Function Definitions *****************************/ + +/*****************************************************************************/ +/** +* +* This function initializes the YCrCb2Rgb core. This function must be called +* prior to using the YCrCb2Rgb core. Initialization of the YCrCb2Rgb includes +* setting up the instance data and ensuring the hardware is in a quiescent +* state. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param CfgPtr is a reference to a structure containing information +* about a specific XYCrCb2Rgb driver. +* @param EffectiveAddr is the core base address in the virtual memory +* address space. The caller is responsible for keeping the +* address mapping from EffectiveAddr to the core physical base +* address unchanged once this function is invoked. Unexpected +* errors may occur if the address mapping changes after this +* function is called. If address translation is not used, pass +* in the physical address instead. +* +* @return - XST_SUCCESS if initialization was successful. +* +* @note None. +* +******************************************************************************/ +int XYCrCb2Rgb_CfgInitialize(XYCrCb2Rgb *InstancePtr, + XYCrCb2Rgb_Config *CfgPtr, u32 EffectiveAddr) +{ + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(CfgPtr != NULL); + Xil_AssertNonvoid(EffectiveAddr != (u32)0x0); + + /* Setup the instance */ + (void)memset((void *)InstancePtr, 0, sizeof(XYCrCb2Rgb)); + (void)memcpy((void *)(&(InstancePtr->Config)), (const void *)CfgPtr, + sizeof(XYCrCb2Rgb_Config)); + + InstancePtr->Config.BaseAddress = EffectiveAddr; + + /* Set all handlers to stub values, let user configure this + * data later + */ + InstancePtr->ProcStartCallBack = + (XYCrCb2Rgb_CallBack)((void *)StubCallBack); + InstancePtr->FrameDoneCallBack = + (XYCrCb2Rgb_CallBack)((void *)StubCallBack); + InstancePtr->ErrCallBack = + (XYCrCb2Rgb_ErrorCallBack)((void *)StubErrCallBack); + + /* Reset the hardware and set the flag to indicate the driver is + * ready + */ + XYCrCb2Rgb_Reset(InstancePtr); + InstancePtr->IsReady = (u32)(XIL_COMPONENT_IS_READY); + + return (XST_SUCCESS); +} + +/*****************************************************************************/ +/** +* +* This function sets the bypass bit of control register to switch the core to +* bypass mode if debug is enabled in the IP. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_EnableDbgByPass(XYCrCb2Rgb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET), + XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET)) | (XYCC_CTL_BPE_MASK)); +} + +/*****************************************************************************/ +/** +* +* This function returns the current bypass mode of the core. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return +* - TRUE if Bypass mode is enabled. +* - FALSE if Bypass mode is not enabled. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +int XYCrCb2Rgb_IsDbgByPassEnabled(XYCrCb2Rgb *InstancePtr) +{ + u32 DbgByPass; + int Status; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + DbgByPass = (XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET))) & (XYCC_CTL_BPE_MASK); + + if (DbgByPass == (XYCC_CTL_BPE_MASK)) { + Status = (TRUE); + } + else { + Status = (FALSE); + } + + return Status; +} + +/*****************************************************************************/ +/** +* +* This function disables Bypass mode of the core. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_DisableDbgBypass(XYCrCb2Rgb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET), + ((XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET))) & (~(XYCC_CTL_BPE_MASK)))); +} + +/*****************************************************************************/ +/** +* +* This function switches the core to test-pattern generator mode if debug +* feature is enabled. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_EnableDbgTestPattern(XYCrCb2Rgb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET), + XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET)) | (XYCC_CTL_TPE_MASK)); +} + +/*****************************************************************************/ +/** +* +* This function returns the test-pattern generator mode (enabled or not), if +* debug feature is enabled. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return +* - TRUE if Test-pattern mode is enabled. +* - FALSE if Test-pattern mode is not enabled. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +int XYCrCb2Rgb_IsDbgTestPatternEnabled(XYCrCb2Rgb *InstancePtr) +{ + u32 DbgTestPattern; + int Status; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + DbgTestPattern = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET)) & (XYCC_CTL_TPE_MASK); + + if (DbgTestPattern == (XYCC_CTL_TPE_MASK)) { + Status = (TRUE); + } + else { + Status = (FALSE); + } + + return Status; +} + +/*****************************************************************************/ +/** +* +* This function disables debug test pattern mode. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_DisableDbgTestPattern(XYCrCb2Rgb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET), + ((XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CONTROL_OFFSET))) & (~(XYCC_CTL_TPE_MASK)))); +} + +/*****************************************************************************/ +/** +* +* This function facilitates software identification of exact version of the +* YCrCb2rGB hardware (h/w). +* +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return Version, contents of a Version register. +* +* @note None. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetVersion(XYCrCb2Rgb *InstancePtr) +{ + u32 Version; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + /* Read Version register */ + Version = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_VERSION_OFFSET)); + + return Version; +} + +/*****************************************************************************/ +/** +* +* This function returns the frame count, the number of frames processed since +* power-up. This is available only if the debugging feature is enabled. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return DbgFrameCount, number of frames processed since power-up. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetDbgFrameCount(XYCrCb2Rgb *InstancePtr) +{ + u32 DbgFrameCount; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Frame Throughput monitor */ + DbgFrameCount = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_SYSDEBUG0_OFFSET)); + + return DbgFrameCount; +} + +/*****************************************************************************/ +/** +* +* This function returns Line count, the number of lines processed since +* power-up. This is available only if the debugging feature is enabled. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return DbgLineCount, number of lines processed since power-up. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetDbgLineCount(XYCrCb2Rgb *InstancePtr) +{ + u32 DbgLineCount; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Line Throughput monitor */ + DbgLineCount = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_SYSDEBUG1_OFFSET)); + + return DbgLineCount; +} + +/*****************************************************************************/ +/** +* +* This function returns the pixel count, the number of pixels processed since +* power up. This is available only if the debugging feature is enabled. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return DbgPixelCount, number of pixels processed since power-up. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetDbgPixelCount(XYCrCb2Rgb *InstancePtr) +{ + u32 DbgPixelCount; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Pixel Throughput monitor */ + DbgPixelCount = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_SYSDEBUG2_OFFSET)); + + return DbgPixelCount; +} + +/*****************************************************************************/ +/** +* +* This function sets up double buffered active size register and enables the +* register update. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_Setup(XYCrCb2Rgb *InstancePtr) +{ + u32 ActiveSize; + + /* Verify argument. */ + Xil_AssertVoid(InstancePtr != NULL); + + XYCrCb2Rgb_RegUpdateDisable(InstancePtr); + + /* Write into active size register */ + ActiveSize = ((((u32)InstancePtr->VSize) & + (u32)(XYCC_ACTSIZE_NUM_PIXEL_MASK)) << + (XYCC_ACTSIZE_NUM_LINE_SHIFT)) | + ((InstancePtr->HSize) & + (u32)(XYCC_ACTSIZE_NUM_PIXEL_MASK)); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_ACTIVE_SIZE_OFFSET), ActiveSize); + XYCrCb2Rgb_RegUpdateEnable(InstancePtr); +} + +/*****************************************************************************/ +/** +* +* This function sets active H/V sizes in the active frame size register. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param HSize specifies the number of Active Pixels per scanline that +* needs to be set within the range [32, 8192]. +* @param VSize specifies the number of Active Lines per frame that needs +* to be set within the range [32, 8192]. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_SetActiveSize(XYCrCb2Rgb *InstancePtr, u16 HSize, u16 VSize) +{ + u32 Size; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid((VSize >= (u16)(XYCC_ACT_SIZE_FIRST)) && + (VSize <= (u16)(XYCC_ACT_SIZE_LAST))); + Xil_AssertVoid((HSize >= (u16)(XYCC_ACT_SIZE_FIRST)) && + (HSize <= (u16)(XYCC_ACT_SIZE_LAST))); + + Size = (((u32)VSize) << ((u32)(XYCC_ACTSIZE_NUM_LINE_SHIFT))) | + (HSize); + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_ACTIVE_SIZE_OFFSET), Size); +} + +/*****************************************************************************/ +/** +* +* This function gets the active H/V sizes of the YCrCb2Rgb core from +* active size register. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param HSize is a pointer to 16-bit variable in which the number of +* Active Pixels per scanline is returned within the range +* [32, 8192]. +* @param VSize is a pointer to 16-bit variable in which the number of +* Active Lines per frame is returned within the range +* [32, 8192]. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_GetActiveSize(XYCrCb2Rgb *InstancePtr, u16 *HSize, u16 *VSize) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(HSize != NULL); + Xil_AssertVoid(VSize != NULL); + + /* Reads Number of Active Pixels per scan line */ + *VSize = (u16)(XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_ACTIVE_SIZE_OFFSET)) & + (XYCC_ACTSIZE_NUM_LINE_MASK)) >> + (XYCC_ACTSIZE_NUM_LINE_SHIFT); + + /* Reads number of active lines per frame */ + *HSize = (u16)(XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_ACTIVE_SIZE_OFFSET)) & + (XYCC_ACTSIZE_NUM_PIXEL_MASK)); +} + +/*****************************************************************************/ +/** +* +* This function sets the RGB maximum value on YCrCb2Rgb channels of the output. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param RGBMax is the maximum value within the range [0, 255] on the +* RGB channels of the output. +* +* @return None. +* +* @note Clipping functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_SetRGBMax(XYCrCb2Rgb *InstancePtr, u32 RGBMax) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(RGBMax <= (u32)XYCC_RGBMAX_MIN_LAST); + Xil_AssertVoid(InstancePtr->Config.HasClip != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_RGBMAX_OFFSET), RGBMax); +} + +/*****************************************************************************/ +/** +* +* This function gets the maximum value on RGB channels of the output. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return RGBMax is the maximum value within the range [0, 255] from RGB +* channels of the output. +* +* @note Clipping functionality should be enabled. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetRGBMax(XYCrCb2Rgb *InstancePtr) +{ + u32 RGBMax; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasClip != (u16)0x0); + + RGBMax = (XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_RGBMAX_OFFSET)) & XYCC_16_BIT_MASK); + + return RGBMax; +} + +/*****************************************************************************/ +/** +* +* This function sets minimum value on RGB channels of the output. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param RGBMin is the minimum value within the range [0, 255] on RGB +* channels of the output. +* +* @return None. +* +* @note Clamping functionality should be enabled. +* +******************************************************************************/ +void XYCrCb2Rgb_SetRGBMin(XYCrCb2Rgb *InstancePtr, u32 RGBMin) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(RGBMin <= (u32)XYCC_RGBMAX_MIN_LAST); + Xil_AssertVoid(InstancePtr->Config.HasClamp != (u16)0x0); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_RGBMIN_OFFSET), RGBMin); +} + +/*****************************************************************************/ +/** +* +* This function gets the minimum value on RGB channels of the output. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return RGBMin is the minimum value within the range [0, 255] from RGB +* channels of the output. +* +* @note Clamping functionality should be enabled. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetRGBMin(XYCrCb2Rgb *InstancePtr) +{ + u32 RGBMin; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasClamp != (u16)0x0); + + RGBMin = (XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_RGBMIN_OFFSET)) & XYCC_16_BIT_MASK); + + return RGBMin; +} + +/*****************************************************************************/ +/** +* +* This function sets offset compensation value on the Red channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param ROffset is compensation value within the range [0, 255] to be +* set on the Red channel. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_SetROffset(XYCrCb2Rgb *InstancePtr, u32 ROffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(ROffset <= (u32)(XYCC_RGBOFFSET_LAST)); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_ROFFSET_OFFSET), ROffset); +} + +/*****************************************************************************/ +/** +* +* This function gets offset compensation value from the Red channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return ROffset is a compensation value within the range [0, 255] from +* the Red channel. +* +* @note None. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetROffset(XYCrCb2Rgb *InstancePtr) +{ + u32 ROffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + ROffset = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_ROFFSET_OFFSET)); + + return ROffset; +} + +/*****************************************************************************/ +/** +* +* This function sets offset compensation value on the Green channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param GOffset is a compensation value within the range [0, 255] to be +* set on the Green channel. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_SetGOffset(XYCrCb2Rgb *InstancePtr, u32 GOffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(GOffset <= (u32)(XYCC_RGBOFFSET_LAST)); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_GOFFSET_OFFSET), GOffset); +} + +/*****************************************************************************/ +/** +* +* This function gets offset compensation value from the Green channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return GOffset is a compensation value within the range [0, 255] from +* the Green channel. +* +* @note None. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetGOffset(XYCrCb2Rgb *InstancePtr) +{ + u32 GOffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + GOffset = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_GOFFSET_OFFSET)); + + return GOffset; +} + +/*****************************************************************************/ +/** +* +* This function sets offset compensation value on the Blue channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param BOffset is a compensation value within the range [0, 255] to be +* set on the Blue channel. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XYCrCb2Rgb_SetBOffset(XYCrCb2Rgb *InstancePtr, u32 BOffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(BOffset <= (u32)(XYCC_RGBOFFSET_LAST)); + + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_BOFFSET_OFFSET),BOffset); +} + +/*****************************************************************************/ +/** +* +* This function gets offset compensation value from the Blue channel. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* +* @return BOffset is a compensation value within the range [0, 255] from +* the Blue channel. +* +* @note None. +* +******************************************************************************/ +u32 XYCrCb2Rgb_GetBOffset(XYCrCb2Rgb *InstancePtr) +{ + u32 BOffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + BOffset = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_BOFFSET_OFFSET)); + + return BOffset; +} + +/*****************************************************************************/ +/** +* +* This function sets A, B, C and D coefficients. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param Coef specifies a pointer to XYCrCb2Rgb_Coefficients structure +* in which ACoef, BCoef, CCoef, DCoef members value within the +* range [0.0, 1.0] that needs to be set. +* +* @return None. +* +* @note Floating point coefficients are represented in 17-bit fixed +* point format where 17 bits indicates integer portion (Mantissa) +* of the number exclusive of sign bit. +* +******************************************************************************/ +void XYCrCb2Rgb_SetCoefs(XYCrCb2Rgb *InstancePtr, + struct XYCrCb2Rgb_Coefficients *Coef) +{ + u32 CoefVal; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(Coef != NULL); + + CoefVal = (u32)((Coef->ACoef) * (1 << (XYCC_16_BIT_COEF_SHIFT))); + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_ACOEF_OFFSET), CoefVal); + + CoefVal = (u32)((Coef->BCoef) * (1 << (XYCC_16_BIT_COEF_SHIFT))); + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_BCOEF_OFFSET), CoefVal); + + CoefVal = (u32)((Coef->CCoef) * (1 << (XYCC_16_BIT_COEF_SHIFT))); + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_CCOEF_OFFSET), CoefVal); + + CoefVal = (u32)((Coef->DCoef) * (1 << (XYCC_16_BIT_COEF_SHIFT))); + XYCrCb2Rgb_WriteReg(InstancePtr->Config.BaseAddress, + (XYCC_DCOEF_OFFSET), CoefVal); +} + +/*****************************************************************************/ +/** +* +* This function returns A, B, C and D coefficients. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgbb instance. +* @param Coef specifies a pointer to XYCrCb2Rgb_Coefficients structure +* in which ACoef, BCoef, CCoef, DCoef members value will be +* updated within the range [0.0, 1.0]. +* +* @return None. +* +* @note Floating point coefficients are represented in 17-bit fixed +* point format where 17 bits indicates integer portion (Mantissa) +* of the number exclusive of sign bit. +* +******************************************************************************/ +void XYCrCb2Rgb_GetCoefs(XYCrCb2Rgb *InstancePtr, + struct XYCrCb2Rgb_Coefficients *Coef) +{ + u32 CoefVal; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(Coef != NULL); + + CoefVal = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_ACOEF_OFFSET)); + Coef->ACoef = (double)CoefVal / + (double)(1 << (XYCC_16_BIT_COEF_SHIFT)); + + CoefVal = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_BCOEF_OFFSET)); + Coef->BCoef = (double)CoefVal / + (double)(1 << (XYCC_16_BIT_COEF_SHIFT)); + + CoefVal = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_CCOEF_OFFSET)); + Coef->CCoef = (double)CoefVal / + (double)(1 << (XYCC_16_BIT_COEF_SHIFT)); + + CoefVal = XYCrCb2Rgb_ReadReg(InstancePtr->Config.BaseAddress, + (XYCC_DCOEF_OFFSET)); + Coef->DCoef = (double)CoefVal / + (double)(1 << (XYCC_16_BIT_COEF_SHIFT)); +} + +/*****************************************************************************/ +/** +* +* This function populates an XYCrCb2Rgb_Coef_Inputs structure with the values +* from the selected video standard. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgbb instance. +* @param StandardSel needs to be set from enum Standards value as : +* 0 = XYCC_STANDARD_ITU_601_SD +* 1 = XYCC_STANDARD_ITU_709_NTSC +* 2 = XYCC_STANDARD_ITU_709_PAL +* 3 = XYCC_STANDARD_YUV. +* @param InputRange needs to be set from enum OutputRanges value as: +* 0 = XYCC_TV_16_TO_240, +* 1 = XYCC_STUDIO_16_TO_235, +* 2 = XYCC_GRAPHICS_0_TO_255. +* @param DataWidth specifies the valid range of [8,10,12,16] that needs +* to be set. +* @param CoefIn specifies a pointer to a XYCrCb2Rgb_Coef_Inputs +* structure which is populated with the values from selected +* video standard. +* +* @return None. +* +* @note Floating point coefficients are represented in 17-bit fixed +* point format where 17 bits indicates integer portion (Mantissa) +* of the number exclusive of sign bit. +* +******************************************************************************/ +void XYCrCb2Rgb_Select_Standard(XYCrCb2Rgb *InstancePtr, + enum Standards StandardSel, + enum OutputRanges InputRange, u32 DataWidth, + struct XYCrCb2Rgb_Coef_Inputs *CoefIn) +{ + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CoefIn != NULL); + Xil_AssertVoid( (DataWidth == (u32)(XYCC_DATA_WIDTH_8)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_10)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_12)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_16))); + Xil_AssertVoid(StandardSel <(u32)(XYCC_STANDARD_CUSTOM)); + Xil_AssertVoid(InputRange <= (u32)(XYCC_GRAPHICS_0_TO_255)); + + 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 = (u32)((u32)1 << (DataWidth - 4)); + u32 COffset = (u32)((u32)1 << (DataWidth - 1)); + + u32 Max[3] = { (240 * (1 << (DataWidth -8))), + (235 * (1 << (DataWidth - 8))), + ((1 << DataWidth) - 1) + }; + + u32 Min[3] = { + (16 * (1 << (DataWidth - 8))), + (16 * (1 << (DataWidth - 8))), + 0 + }; + + CoefIn->ACoef = ACoef[StandardSel][InputRange]; + CoefIn->BCoef = BCoef[StandardSel][InputRange]; + CoefIn->CCoef = CCoef[StandardSel][InputRange]; + CoefIn->DCoef = DCoef[StandardSel][InputRange]; + + CoefIn->YOffset = YOffset; + CoefIn->CbOffset = COffset; + CoefIn->CrOffset = COffset; + + CoefIn->RgbMax = Max[InputRange]; + CoefIn->RgbMin = Min[InputRange]; +} + +/*****************************************************************************/ +/** +* +* This function translates the XYCrCb2Rgb_Coef_Inputs structure into the +* XYCrCb2Rgb_Coef_Outputs structure that can be used to program the core's +* registers. The XYCrCb2Rgb_Coef_Inputs structure uses the same values as the +* core's GUIs. The XYCrCb2Rgb_Coef_Outputs structure uses the values that can +* be programmed into the core's registers. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgbb instance. +* @param CoefIn specifies a pointer to a XYCrCb2Rgb_Coef_Inputs +* structure to be translated. +* @param CoefOut specifies a pointer to a XYCrCb2Rgb_Coef_Outputs +* structure with translated values. +* @param DataWidth specifies a valid range of [8,10,12,16] that needs +* to be set. +* @param MWidth specifies a valid range from min(32, DataWidth + 17) +* +* @return RetVal, returns value with following bit information: +* - 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^DataWidth, (2^DataWidth)-1]. +* - bit(3) = Cb Offset outside data width range: +* [-2^DataWidth, (2^DataWidth)-1]. +* - bit(4) = Cr Offset outside data width range: +* [-2^DataWidth, (2^DataWidth)-1]. +* - bit(5) = RGB Max outside data width range: +* [0, (2^DataWidth)-1]. +* - bit(6) = RGB Min outside data width range: +* [0, (2^DataWidth)-1]. +* +* @note Floating point coefficients are represented in 17-bit fixed +* point format where 17 bits indicates integer portion (Mantissa) +* of the number exclusive of sign bit. +* +******************************************************************************/ +u32 XYCrCb2Rgb_Coefficient_Translation(XYCrCb2Rgb *InstancePtr, + struct XYCrCb2Rgb_Coef_Inputs *CoefIn, + struct XYCrCb2Rgb_Coef_Outputs *CoefOut, + u32 DataWidth, u32 MWidth) +{ + u32 RetVal = 0; + u32 ScaleCoeffs; + double ScaleIc2m; + u32 CoefRange; + + double ACoef; + double BCoef; + double CCoef; + double DCoef; + + u32 YOffset; + u32 CbOffset; + u32 CrOffset; + + u32 RgbMax; + u32 RgbMin; + + /* Converted coefficients */ + double AConvCoef; + double BConvCoef; + double CConvCoef; + double DConvCoef; + + /* Quantized coefficients */ + u32 AQuntCoef; + u32 BQuntCoef; + u32 CQuntCoef; + u32 DQuntCoef; + + /* Input Width */ + u32 IWidth; + + /* Output Width */ + u32 OWidth; + + /* Common Width */ + u32 CWidth; + + double RoundingConst; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(CoefIn != NULL); + Xil_AssertNonvoid(CoefOut != NULL); + Xil_AssertNonvoid((DataWidth == (u32)(XYCC_DATA_WIDTH_8)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_10)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_12)) || + (DataWidth == (u32)(XYCC_DATA_WIDTH_16))); + Xil_AssertNonvoid(((MWidth) == (u32)(((u32)XYCC_DATA_WIDTH_8) + + ((u32)17))) || + (MWidth == (u32)((u32)XYCC_DATA_WIDTH_10 + + (u32)17)) || (MWidth == + (u32)((u32)XYCC_DATA_WIDTH_12 + (u32)17)) || + (MWidth == (u32)(((u32)XYCC_DATA_WIDTH_16 + + (u32)17) - ((u32)1)))); + + IWidth = DataWidth; + OWidth = DataWidth; + CoefRange = 2; + CWidth = 17; + + /* Store values from XYCrCb2Rgb_Coef_Inputs structure into local + * variables. + */ + ACoef = CoefIn->ACoef; + BCoef = CoefIn->BCoef; + CCoef = CoefIn->CCoef; + DCoef = CoefIn->DCoef; + YOffset = CoefIn->YOffset; + CbOffset = CoefIn->CbOffset; + CrOffset = CoefIn->CrOffset; + RgbMax = CoefIn->RgbMax; + RgbMin = CoefIn->RgbMin; + + if ((ACoef + BCoef) > 1.0) { + RetVal = (RetVal) | (u32)(0x1); + } + if (((int)YOffset < (-((int)(1 << (u32)IWidth)))) || + ((int)YOffset > (int)((1 << (u32)IWidth) - 1))) { + RetVal = (RetVal) | (u32)(0x2); + } + if (((int)CbOffset < (-((int)(1 << (u32)IWidth)))) || + ((int)CbOffset > (int)((1 << (u32)IWidth) - 1))) { + RetVal = (RetVal) | (u32)(0x4); + } + if (((int)CrOffset < (-((int)(1 << (u32)IWidth)))) || + ((int)CrOffset > (int)((1 << (u32)IWidth) - 1))) { + RetVal = (RetVal) | (u32)(0x8); + } + if ((int)RgbMax > (int)((1 << (u32)IWidth) - 1)) { + RetVal = (RetVal) | (u32)(0x10); + } + if ((int)RgbMin > (int)((1 << (u32)IWidth) - 1)) { + RetVal = (RetVal) | (u32)(0x20); + } + + AConvCoef = 1 / CCoef; + BConvCoef = -(ACoef / CCoef / (1 - ACoef - BCoef)); + CConvCoef = -(BCoef / DCoef / (1 - ACoef - BCoef)); + DConvCoef = 1 / DCoef; + + ScaleCoeffs = XYCrCb2Rgb_Max(1, (1 << (CWidth - CoefRange - 1))); + + /* +0.5 turns truncation to biased rounding */ + RoundingConst = XYCrCb2Rgb_Pow2(MWidth - OWidth - CoefRange -2); + ScaleIc2m = XYCrCb2Rgb_Pow2(((u32)1 + MWidth) - IWidth - CWidth); + + /* Quantize coefficients */ + AQuntCoef = (u32)(AConvCoef * ScaleCoeffs); + BQuntCoef = (u32)(BConvCoef * ScaleCoeffs); + CQuntCoef = (u32)(CConvCoef * ScaleCoeffs); + DQuntCoef = (u32)(DConvCoef * ScaleCoeffs); + + CoefOut->ACoef = AQuntCoef; + CoefOut->BCoef = BQuntCoef; + CoefOut->CCoef = CQuntCoef; + CoefOut->DCoef = DQuntCoef; + + /* Assuming signals are OWIDTH + 1 bits wide after the offset + * compensating rounder's / adders. + */ + CoefOut->ROffset = (u32)((RoundingConst - (((AQuntCoef * CrOffset) + + (YOffset * ScaleCoeffs)))) * ScaleIc2m); + CoefOut->GOffset = (u32)((RoundingConst - (((BQuntCoef * CrOffset) + + (CQuntCoef * CbOffset)) + (YOffset * ScaleCoeffs))) * + ScaleIc2m); + CoefOut->BOffset = (u32)((RoundingConst - ((DQuntCoef * CbOffset) + + (YOffset * ScaleCoeffs))) * ScaleIc2m); + + CoefOut->RgbMax = RgbMax; + CoefOut->RgbMin = RgbMin; + + return RetVal; +} + +/*****************************************************************************/ +/** +* +* This function governs the range of outputs R, G and B by affecting the +* conversion coefficients as well as the clipping and clamping values. +* +* @param InstancePtr is a pointer to the XYCrCb2Rgb instance. +* @param Range needs to be set from the enum OutputRanges values as: +* 0 = XYCC_TV_16_TO_240, +* 1 = XYCC_STUDIO_16_TO_235, +* 2 = XYCC_GRAPHICS_0_TO_255. +* +* @return None. +* +* @note None. +* +*****************************************************************************/ +void XYCrCb2Rgb_Select_OutputRange(XYCrCb2Rgb *InstancePtr, + enum OutputRanges Range) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(Range <= (u32)(XYCC_GRAPHICS_0_TO_255)); + + /* Sets output range. */ + switch(Range) { + case XYCC_TV_16_TO_240: + InstancePtr->OutputRange = (u32)XYCC_TV_16_TO_240; + break; + + case XYCC_STUDIO_16_TO_235: + InstancePtr->OutputRange = (u32)XYCC_STUDIO_16_TO_235; + break; + + case XYCC_GRAPHICS_0_TO_255: + InstancePtr->OutputRange = (u32)XYCC_GRAPHICS_0_TO_255; + break; + default : + ; + break; + } +} + +/*****************************************************************************/ +/** +* +* This routine is a stub for the asynchronous callbacks. The stub is here in +* case the upper layer forgot to set the handlers. On initialization, All +* handlers except error handler are set to this callback. It is considered an +* error for this handler to be invoked. +* +* @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. +* +******************************************************************************/ +static void StubCallBack(void *CallBackRef) +{ + (void)CallBackRef; +} + +/*****************************************************************************/ +/** +* +* This routine is a stub for the asynchronous error interrupt callback. The +* stub is here in case the upper layer forgot to set the handler. On +* initialization, Error interrupt handler is set to this callback. It is +* considered an error for this handler to be invoked. +* +* @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. +* +******************************************************************************/ +static void StubErrCallBack(void *CallBackRef, u32 ErrorMask) +{ + (void)CallBackRef; + (void)ErrorMask; +} + +/*****************************************************************************/ +/** +* +* This function converts a given number into pow(2, Num) +* +* @param Num is a number used as a power for base 2. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +static double XYCrCb2Rgb_Pow2(u32 Num) +{ + double Power ; + + if ((Num > (u32)0x0)) { + Power = (1 << Num); + } + else { + Power = (double)(1.000)/(1 << (-Num)); + } + + return Power; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h new file mode 100755 index 00000000..5982b18d --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h @@ -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. +* +* Initialization & Configuration +* +* 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. +* +* Interrupts +* +* 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. +* +* Virtual Memory +* +* This driver supports Virtual Memory. The RTOS is responsible for calculating +* the correct device base address in Virtual Memory space. +* +* Threads +* +* This driver is not thread safe. Any needs for threads or thread mutual +* exclusion must be satisfied by the layer above this driver. +* +* Asserts +* +* 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. +* +* Building the driver +* +* 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. +* +*
+* 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.
+*
+* +******************************************************************************/ + +#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 */ diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_g.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_g.c new file mode 100755 index 00000000..86915b8e --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_g.c @@ -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 + + */ +}; diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_hw.h b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_hw.h new file mode 100755 index 00000000..0ba509bf --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_hw.h @@ -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. +* +*
+* 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.
+* 
+* +******************************************************************************/ + +#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 */ diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_intr.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_intr.c new file mode 100755 index 00000000..a90ff7a6 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_intr.c @@ -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. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- --------------------------------------------------
+* 7.0   adk    01/31/14 First Release.
+*                       Implemented the following functions:
+*                       XYCrCb2Rgb_IntrHandler
+*                       XYCrCb2Rgb_SetCallBack
+* 
+* +******************************************************************************/ + +/***************************** 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. +* +*
+* HandlerType              Callback Function Type
+* -----------------------  ---------------------------
+* XYCC_HANDLER_PROCSTART   ProcStartCallBack.
+* XYCC_HANDLER_FRAMEDONE   FrameDoneCallBack.
+* XYCC_HANDLER_ERROR       ErrCallBack.
+* 
+* +* @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; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_selftest.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_selftest.c new file mode 100755 index 00000000..addee311 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_selftest.c @@ -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. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ----   -------- -----------------------------------------------
+* 7.0   adk    02/03/14 First Release.
+*                       Implemented the following function:
+*                       XYCrCb2Rgb_SelfTest
+* 
+* +******************************************************************************/ + +/***************************** 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; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_sinit.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_sinit.c new file mode 100755 index 00000000..96e985ce --- /dev/null +++ b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb_sinit.c @@ -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. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- -----------------------------------------------
+* 7.0   adk    02/10/14 First release.
+*                       Implemented following function:
+*                       XYCrCb2Rgb_Config.
+* 
+* +******************************************************************************/ + +/***************************** 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, DeviceId. 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 DeviceId, 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; +} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.c b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.c deleted file mode 100755 index 4197235d..00000000 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.c +++ /dev/null @@ -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<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< (1< (1< (1< (1< (1<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); -} diff --git a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.h b/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.h deleted file mode 100755 index 49f35d9c..00000000 --- a/XilinxProcessorIPLib/drivers/ycrcb2rgb/src/ycrcb2rgb.h +++ /dev/null @@ -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 */