From b52598a34eb70530c94f42751704d1a1dcc9e05a Mon Sep 17 00:00:00 2001 From: Shadul Shaikh Date: Fri, 11 Jul 2014 12:42:36 +0530 Subject: [PATCH] rgb2ycrcb: Added files in rgb2ycrcb_v7_0 Added source files, integration files and examples. Added new functionality for coefficients, clipping and clamping features. Signed-off-by: Shadul Shaikh Acked-by: Srikanth Vemula --- .../drivers/rgb2ycrcb/data/rgb2ycrcb.mdd | 5 +- .../drivers/rgb2ycrcb/data/rgb2ycrcb.tcl | 18 +- .../drivers/rgb2ycrcb/examples/example.c | 195 --- .../drivers/rgb2ycrcb/examples/index.html | 38 +- .../rgb2ycrcb/examples/rgb2ycrcb_example.c | 217 +++ .../examples/rgb2ycrcb_selftest_example.c | 149 ++ .../drivers/rgb2ycrcb/src/rgb2ycrcb.c | 265 --- .../drivers/rgb2ycrcb/src/rgb2ycrcb.h | 427 ----- .../drivers/rgb2ycrcb/src/xrgb2ycrcb.c | 1436 +++++++++++++++++ .../drivers/rgb2ycrcb/src/xrgb2ycrcb.h | 840 ++++++++++ .../drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c | 87 + .../drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h | 371 +++++ .../drivers/rgb2ycrcb/src/xrgb2ycrcb_intr.c | 202 +++ .../rgb2ycrcb/src/xrgb2ycrcb_selftest.c | 108 ++ .../drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c | 110 ++ 15 files changed, 3550 insertions(+), 918 deletions(-) delete mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/example.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_selftest_example.c delete mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.c delete mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.h create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_intr.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c create mode 100755 XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.mdd b/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.mdd index bb722e9e..6dea9d86 100755 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.mdd +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.mdd @@ -1,9 +1,9 @@ -############################################################################### +############################################################################## # # Copyright (C) 2011 - 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/rgb2ycrcb/data/rgb2ycrcb.tcl b/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.tcl index 5c3d624e..e2382233 100755 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.tcl +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/data/rgb2ycrcb.tcl @@ -1,9 +1,9 @@ -############################################################################### +############################################################################## # # Copyright (C) 2011 - 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,16 +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. -# ############################################################################### -# -# MODIFICATION HISTORY: -# Ver Who Date Changes -# -------- ------ -------- ------------------------------------ -# 6.0 adk 12/10/13 Updated as per the New Tcl API's -################################################################## proc generate {drv_handle} { - xdefine_include_file $drv_handle "xparameters.h" "RGB2YCRCB" "NUM_INSTANCES" "C_BASEADDR" "C_HIGHADDR" "DEVICE_ID" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_S_AXIS_VIDEO_FORMAT" "C_S_AXIS_VIDEO_TDATA_WIDTH" "C_M_AXIS_VIDEO_DATA_WIDTH" "C_M_AXIS_VIDEO_FORMAT" "C_M_AXIS_VIDEO_TDATA_WIDTH" "C_HAS_AXI4_LITE" "C_HAS_DEBUG" "C_HAS_INTC_IF" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_HAS_CLIP" "C_HAS_CLAMP" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_YOFFSET" "C_CBOFFSET" "C_CROFFSET" "C_YMAX" "C_YMIN" "C_CBMAX" "C_CBMIN" "C_CRMAX" "C_CRMIN" - xdefine_canonical_xpars $drv_handle "xparameters.h" "RGB2YCRCB" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_S_AXIS_VIDEO_FORMAT" "C_S_AXIS_VIDEO_TDATA_WIDTH" "C_M_AXIS_VIDEO_DATA_WIDTH" "C_M_AXIS_VIDEO_FORMAT" "C_M_AXIS_VIDEO_TDATA_WIDTH" "C_HAS_AXI4_LITE" "C_HAS_DEBUG" "C_HAS_INTC_IF" "C_MAX_COLS" "C_ACTIVE_COLS" "C_ACTIVE_ROWS" "C_HAS_CLIP" "C_HAS_CLAMP" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_YOFFSET" "C_CBOFFSET" "C_CROFFSET" "C_YMAX" "C_YMIN" "C_CBMAX" "C_CBMIN" "C_CRMAX" "C_CRMIN" + xdefine_include_file $drv_handle "xparameters.h" "RGB2YCRCB" "NUM_INSTANCES" "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_HAS_CLIP" "C_HAS_CLAMP" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_YOFFSET" "C_CBOFFSET" "C_CROFFSET" "C_YMAX" "C_YMIN" "C_CBMAX" "C_CBMIN" "C_CRMAX" "C_CRMIN" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE" + + xdefine_config_file $drv_handle "xrgb2ycrcb_g.c" "XRgb2YCrCb" "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_HAS_CLIP" "C_HAS_CLAMP" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_YOFFSET" "C_CBOFFSET" "C_CROFFSET" "C_YMAX" "C_YMIN" "C_CBMAX" "C_CBMIN" "C_CRMAX" "C_CRMIN" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE" + + xdefine_canonical_xpars $drv_handle "xparameters.h" "RGB2YCRCB" "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_HAS_CLIP" "C_HAS_CLAMP" "C_ACOEF" "C_BCOEF" "C_CCOEF" "C_DCOEF" "C_YOFFSET" "C_CBOFFSET" "C_CROFFSET" "C_YMAX" "C_YMIN" "C_CBMAX" "C_CBMIN" "C_CRMAX" "C_CRMIN" "C_S_AXI_CLK_FREQ_HZ" "C_STANDARD_SEL" "C_OUTPUT_RANGE" } diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/example.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/example.c deleted file mode 100755 index cd8b9d26..00000000 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/example.c +++ /dev/null @@ -1,195 +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 RGB to YCrCb Color Space Converter - * (RGB2YCRCB) driver on Xilinx RGB to YCrCb Color Space Converter (RGB2YCRCB) - * 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/27/12 Updates for the v5.00.a release
- * 
- * - * *************************************************************************** - */ - -#include "rgb2ycrcb.h" -#include "xparameters.h" - -/***************************************************************************/ -// RGB to YCrCb Color Space Converter Register Reading Example -// This function provides an example of how to read the current configuration -// settings of the RGB2YCRCB core. -/***************************************************************************/ -void report_rgb_settings(u32 BaseAddress) { - xil_printf("RGB to YCrCb Color Space Converter Core Configuration:\r\n"); - xil_printf(" Version: 0x%08x\r\n", RGB_ReadReg(BaseAddress, RGB_VERSION)); - xil_printf(" Enable Bit: %1d\r\n", RGB_ReadReg(BaseAddress, RGB_CONTROL) & RGB_CTL_EN_MASK); - - xil_printf(" Register Update Bit: %1d\r\n", (RGB_ReadReg(BaseAddress, RGB_CONTROL) & RGB_CTL_RUE_MASK) >> 1); - - xil_printf(" Reset Bit: %1d\r\n", (RGB_ReadReg(BaseAddress, RGB_CONTROL) & RGB_RST_RESET) >> 31); - - xil_printf(" AutoReset Bit: %1d\r\n", (RGB_ReadReg(BaseAddress, RGB_CONTROL) & RGB_RST_AUTORESET) >> 30); - - xil_printf(" Columns=0x%8x, Rows=0x%8x\r\n", - (RGB_ReadReg(BaseAddress, RGB_ACTIVE_SIZE)>>16), - (RGB_ReadReg(BaseAddress, RGB_ACTIVE_SIZE)&0xFFFF)); - - xil_printf(" Acoef=0x%8x, Bcoef=0x%8x, Ccoef=0x%8x, Dcoef=0x%8x\r\n", - RGB_ReadReg(BaseAddress, RGB_ACOEF), - RGB_ReadReg(BaseAddress, RGB_BCOEF), - RGB_ReadReg(BaseAddress, RGB_CCOEF), - RGB_ReadReg(BaseAddress, RGB_DCOEF)); - - xil_printf(" Y Offset=0x%8x, Cb Offset=0x%8x, Cr Offset=0x%8x\r\n", - RGB_ReadReg(BaseAddress, RGB_YOFFSET), - RGB_ReadReg(BaseAddress, RGB_CBOFFSET), - RGB_ReadReg(BaseAddress, RGB_CROFFSET)); - - xil_printf(" Y Max=0x%8x, Y Min=0x%8x\r\n", - RGB_ReadReg(BaseAddress, RGB_YMAX), - RGB_ReadReg(BaseAddress, RGB_YMIN)); - - xil_printf(" Cb Max=0x%8x, Cb Min=0x%8x\r\n", - RGB_ReadReg(BaseAddress, RGB_CBMAX), - RGB_ReadReg(BaseAddress, RGB_CBMIN)); - - xil_printf(" Cr Max=0x%8x, Cr Min=0x%8x\r\n", - RGB_ReadReg(BaseAddress, RGB_CRMAX), - RGB_ReadReg(BaseAddress, RGB_CRMIN)); -} - - - -/***************************************************************************/ -// 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 RGB2YCrCb 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 RGB_Update_Example() { - //Enable the RGB2YCRCB software enable - RGB_Enable(XPAR_RGB2YCRCB_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. - RGB_RegUpdateDisable(XPAR_RGB2YCRCB_0_BASEADDR); - - //Set the Active Columns and Rows - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_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] - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_ACOEF, 19595); //ACOEF = 0.299 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_BCOEF, 7471); //BCOEF = 0.114 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CCOEF, 46727); //CCOEF = 0.713 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_DCOEF, 36962); //DCOEF = 0.564 - - //Set the offsets - // For 8-bit color: Valid range = [ -256, 255] - // For 10-bit color: Valid range = [ -1024, 1023] - // For 12-bit color: Valid range = [ -4096, 4095] - // For 16-bit color: Valid range = [-65536, 65535] - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_YOFFSET, 16); //YOFFSET = 16 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CBOFFSET, 128); //CBOFFSET = 128 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CROFFSET, 128); //CROFFSET = 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] - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_YMAX, 240); //YMAX = 240 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_YMIN, 16); //YMIN = 16 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CBMAX, 240); //CBMAX = 240 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CBMIN, 16); //CBMIN = 16 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CRMAX, 240); //CRMAX = 240 - RGB_WriteReg(XPAR_RGB2YCRCB_0_BASEADDR, RGB_CRMIN, 16); //CRMIN = 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. - RGB_RegUpdateEnable(XPAR_RGB2YCRCB_0_BASEADDR); - -} - - -/*****************************************************************************/ -// -// This is the main function for the RGB2YCrCb example. -// -/*****************************************************************************/ -int main(void) -{ - struct rgb_coef_inputs coef_in; - struct rgb_coef_outputs coef_out; - - // Print the current settings for the RGB2YCrCb core - report_rgb_settings(XPAR_RGB2YCRCB_0_BASEADDR); - - // Call the RGB2YCrCb example, specify the Device ID generated in xparameters.h - RGB_Update_Example(XPAR_RGB2YCRCB_0_BASEADDR); - - // Read the current RGB2YCrCb core coefficients - RGB_get_coefficients(XPAR_RGB2YCRCB_0_BASEADDR, &coef_out); - - // Setup coef_in for SD_ITU_601, 16_to_235_for_Studio_Equipment - // and data width of 8-bits - RGB_select_standard(0, 1, XPAR_RGB2YCRCB_0_M_AXIS_VIDEO_DATA_WIDTH, &coef_in); - - // Translate into RGB2YCrCb core coefficients - RGB_coefficient_translation(&coef_in, &coef_out,XPAR_RGB2YCRCB_0_M_AXIS_VIDEO_DATA_WIDTH); - - // Program the new RGB2YCrCb core coefficients - RGB_set_coefficients(XPAR_RGB2YCRCB_0_BASEADDR, &coef_out); - - // Print the current settings for the RGB2YCrCb core - report_rgb_settings(XPAR_RGB2YCRCB_0_BASEADDR); - - return 0; -} - - diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/index.html b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/index.html index 03af02aa..5993bf5a 100755 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/index.html +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/index.html @@ -1,17 +1,21 @@ - - - - - -Driver example applications - - - -

Example Applications for the driver rgb2ycrcb_v6_0

-
- -

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

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

Example Applications for the driver rgb2ycrcb_v7_0

+
+
    +
  • rgb2ycrcb_selftest_example.c (source)
  • +
+ +

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

+ + + diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c new file mode 100755 index 00000000..84923469 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c @@ -0,0 +1,217 @@ +/****************************************************************************** +* +* 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 rgb2ycrcb_example.c +* +* This file demonstrates how to use Xilinx RGB to YCrCb Color Space Converter +* (RGB2YCRCB) driver on Xilinx RGB to YCrCb Color Space Converter (RGB2YCRCB) +* core. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who  Date     Changes
+* ----- ---- -------- -------------------------------------------------------
+* 7.00 adk   07/07/14 First release.
+* 
+* +******************************************************************************/ + +#include "xrgb2ycrcb.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 XRGB_DEVICE_ID XPAR_RGB2YCRCB_0_DEVICE_ID + +/**************************** Type Definitions *******************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/************************** Function Prototypes ******************************/ + +int Rgb2YCrCb_Update_Example(u16 DeviceId); + +/************************** Variable Definitions *****************************/ + +XRgb2YCrCb XRgbInstance; /**< Instance of the RGB2YCRCB core */ + +/************************** Function Definitions *****************************/ + + +/*****************************************************************************/ +/** +* +* Main function to call the Rgb2YCrCb example. +* +* @param None. +* +* @return +* - XST_SUCCESS if successful, +* - XST_FAILURE if it is unsuccessful +* +* @note None. +* +******************************************************************************/ +int main(void) +{ + + int Status; + + /* Call the Rgb2YCrCb update example, specify the parameters generated + * in xparameters.h + */ + Status = Rgb2YCrCb_Update_Example(XRGB_DEVICE_ID); + if (Status != XST_SUCCESS) { + xil_printf("RGB2YCRCB driver example failed.\n\r"); + return XST_FAILURE; + } + + xil_printf("Successfully ran RGB2YCRCB driver example.\n\r"); + + return XST_SUCCESS; +} + +/*****************************************************************************/ +/** +* +* 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 RGB2YCrCb core. . +* +* @param DeviceId is the unique device id of the RGB2YCRCB core. +* +* @return +* - XST_SUCCESS if successful, +* - XST_FAILURE if it is un-successful +* +* @note None. +* +****************************************************************************/ +int Rgb2YCrCb_Update_Example(u16 DeviceId) +{ + + struct XRgb2YCrCb_Coef_Inputs CoefIn; + struct XRgb2YCrCb_Coef_Outputs CoefOut; + XRgb2YCrCb_Config *Config; + int Status; + + /* Initialize the RGB2YCrCb driver so that it's ready to use look up + * the configuration in the config table, then initialize it. + */ + Config = XRgb2YCrCb_LookupConfig(DeviceId); + if(NULL == Config){ + return XST_FAILURE; + } + + Status = XRgb2YCrCb_CfgInitialize(&XRgbInstance, Config, + Config->BaseAddress); + if(Status != XST_SUCCESS){ + return XST_FAILURE; + } + + /* Enable the RGB2YCRCB core */ + XRgb2YCrCb_Enable(&XRgbInstance); + + /* Disable register updates. This is the default operating mode for + * the RGB2YCRCB core and allows registers to be updated without + * effecting the core's behavior. + */ + XRgb2YCrCb_RegUpdateDisable(&XRgbInstance); + + /* Setup CoefIn for XRGB_STANDARD_ITU_601_SD, 16_to_240_for_TV + * and data width of 8-bits. + * enum Standards are: + * 0 = XRGB_STANDARD_ITU_601_SD + * 1 = XRGB_STANDARD_ITU_709_NTSC + * 2 = XRGB_STANDARD_ITU_709_PAL + * 3 = XRGB_STANDARD_YUV. + */ + XRgb2YCrCb_Select_Standard(&XRgbInstance, XRGB_STANDARD_ITU_601_SD, + XRGB_TV_16_TO_240, (u32)XRGB_DATA_WIDTH_8, + &CoefIn); + + /* Translate into RGB2YCrCb core coefficients */ + XRgb2YCrCb_Coefficient_Translation(&XRgbInstance, + &CoefIn, &CoefOut,(u32)XRGB_DATA_WIDTH_8); + + /* Program the new RGB2YCrCb core coefficients */ + XRgb2YCrCb_SetCoefs(&XRgbInstance, CoefIn.ACoef, CoefIn.BCoef, + CoefIn.CCoef, CoefIn.DCoef); + + /* Set output range */ + XRgb2YCrCb_Select_OutputRange(&XRgbInstance, XRGB_TV_16_TO_240); + + /* Set the Active Columns and Rows */ + XRgb2YCrCb_SetActiveSize(&XRgbInstance, 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] + */ + XRgb2YCrCb_SetYOffset(&XRgbInstance, 16); + XRgb2YCrCb_SetCbOffset(&XRgbInstance, 128); + XRgb2YCrCb_SetCrOffset(&XRgbInstance, 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] + */ + XRgb2YCrCb_SetYMax(&XRgbInstance, 240); + XRgb2YCrCb_SetYMin(&XRgbInstance, 16); + XRgb2YCrCb_SetCbMax(&XRgbInstance, 240); + XRgb2YCrCb_SetCbMin(&XRgbInstance, 16); + XRgb2YCrCb_SetCrMax(&XRgbInstance, 240); + XRgb2YCrCb_SetCrMin(&XRgbInstance, 16); + + /* Enable register updates. This mode will cause the coefficient and + * offset registers internally to the RGB2YCRCB core to automatically + * be updated on the next start-of-frame (SOF). + */ + XRgb2YCrCb_RegUpdateEnable(&XRgbInstance); + + return XST_SUCCESS; +} diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_selftest_example.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_selftest_example.c new file mode 100755 index 00000000..20d5e55a --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_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 rgb2ycrcb_selftest_example.c +* +* This file contains an example using the XRgb2YCrCb driver to do self test +* on the device. +* +* @note None. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- ------------------------------------------------------
+* 7.0   adk    01/20/14 First Release.
+* 
+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xparameters.h" +#include "xrgb2ycrcb.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 XRGB_DEVICE_ID XPAR_RGB2YCRCB_0_DEVICE_ID + +/**************************** Type Definitions *******************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/************************** Function Prototypes ******************************/ + +int XRgb2YCrCbSelfTestExample(u16 DeviceId); + +/************************** Variable Definitions *****************************/ + +XRgb2YCrCb Rgb2YCrCbInst; /**< Instance of the RGB2YCRCB core */ + +/*****************************************************************************/ +/** +* +* 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 = XRgb2YCrCbSelfTestExample(XRGB_DEVICE_ID); + if(Status != XST_SUCCESS) { + xil_printf("RGB Selftest Example Failed\r\n"); + return XST_FAILURE; + } + + xil_printf("Successfully ran RGB2YCrCb driver Selftest Example\r\n"); + + return XST_SUCCESS; +} + +/*****************************************************************************/ +/** +* +* This function does a minimal test on the RGB driver. +* +* @param DeviceId is an ID of RGB core or device. +* +* @return +* - XST_SUCCESS if successful. +* - XST_FAILURE if it is unsuccessful. +* +* @note None. +* +******************************************************************************/ +int XRgb2YCrCbSelfTestExample(u16 DeviceId) +{ + int Status; + XRgb2YCrCb_Config *Config; + + /* Initialize the RGB2YCrCb driver so that it's ready to use look up + * the configuration in the config table, then initialize it. + */ + Config = XRgb2YCrCb_LookupConfig(DeviceId); + if(NULL == Config){ + return XST_FAILURE; + } + + Status = XRgb2YCrCb_CfgInitialize(&Rgb2YCrCbInst, Config, + Config->BaseAddress); + if(Status != XST_SUCCESS){ + return XST_FAILURE; + } + + /* Perform a self-test to check hardware build. */ + Status = XRgb2YCrCb_SelfTest(&Rgb2YCrCbInst); + if(Status != XST_SUCCESS){ + return XST_FAILURE; + } + + return XST_SUCCESS; +} diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.c deleted file mode 100755 index 0ab47689..00000000 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.c +++ /dev/null @@ -1,265 +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 RGB to YCrCb Color Space Converter (RGB2YCRCB) -* device driver. Please see rgb2ycrcb.h for more details of the driver. -* -* MODIFICATION HISTORY: -* -* Ver Who Date Changes -* ----- ---- -------- ------------------------------------------------------- -* 5.00a tb 02/27/12 Updated for RGB2YCRCB v5.00.a -* -******************************************************************************/ - -/***************************** Include Files *********************************/ - -#include "rgb2ycrcb.h" -#include "xenv.h" -#include "stdio.h" - - -/*****************************************************************************/ -// Note: Most of the functions are currently implemented as high-performance -// macros within rgb2ycrcb.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 rgb_coef_inputs data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_select_standard(u32 standard_sel, u32 input_range, u32 data_width, struct rgb_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->ymax = max[input_range]; - coef_in->ymin = min[input_range]; - coef_in->cbmax = max[input_range]; - coef_in->cbmin = min[input_range]; - coef_in->crmax = max[input_range]; - coef_in->crmin = min[input_range]; -} - - -/*****************************************************************************/ -/** -* -* Translate input coefficients into coefficients that can be programmed into the -* RGB2YCrCb 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)= Acoef + Bcoef > 1.0 -* bit(1)= Y Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(2)= Cb Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(3)= Cr Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(4)= Y Max outside data width range [0, (2^data_width)-1] -* bit(5)= Y Min outside data width range [0, (2^data_width)-1] -* bit(6)= Cb Max outside data width range [0, (2^data_width)-1] -* bit(7)= Cb Min outside data width range [0, (2^data_width)-1] -* bit(8)= Cr Max outside data width range [0, (2^data_width)-1] -* bit(9)= Cr Min outside data width range [0, (2^data_width)-1] -* -* @note -* -******************************************************************************/ -u32 RGB_coefficient_translation(struct rgb_coef_inputs *coef_in, struct rgb_coef_outputs *coef_out, u32 data_width) -{ - u32 ret_val = 0; - - if((coef_in->acoef + coef_in->bcoef) > 1.0) { - printf("WARNING: Acoef (%1f) + Bcoef (%1f) can not be more then 1.0\r\n",coef_in->acoef, coef_in->bcoef); - ret_val = ret_val | 0x1; - } - if(coef_in->yoffset < -(1<yoffset > (1<yoffset, (unsigned int)-(1<cboffset < -(1<cboffset > (1<cboffset, (unsigned int)-(1<croffset < -(1<croffset > (1<croffset, (unsigned int)-(1<ymax < 0 || coef_in->ymax > (1<ymax, (unsigned int)(1<ymin < 0 || coef_in->ymin > (1<ymin, (unsigned int)(1<cbmax < 0 || coef_in->cbmax > (1<cbmax, (unsigned int)(1<cbmin < 0 || coef_in->cbmin > (1<cbmin, (unsigned int)(1<crmax < 0 || coef_in->crmax > (1<crmax, (unsigned int)(1<crmin < 0 || coef_in->crmin > (1<crmin, (unsigned int)(1<acoef = coef_in->acoef * (1<<16); - coef_out->bcoef = coef_in->bcoef * (1<<16); - coef_out->ccoef = coef_in->ccoef * (1<<16); - coef_out->dcoef = coef_in->dcoef * (1<<16); - coef_out->yoffset = coef_in->yoffset; - coef_out->cboffset = coef_in->cboffset; - coef_out->croffset = coef_in->croffset; - coef_out->ymax = coef_in->ymax; - coef_out->ymin = coef_in->ymin; - coef_out->cbmax = coef_in->cbmax; - coef_out->cbmin = coef_in->cbmin; - coef_out->crmax = coef_in->crmax; - coef_out->crmin = coef_in->crmin; - - return ret_val; -} - -/*****************************************************************************/ -/** -* -* Program the RGB2YCrCb coefficient/offset registers. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* @param coef_out is a pointer to a rgb_coef_output data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_set_coefficients(u32 BaseAddress, struct rgb_coef_outputs *coef_out) -{ - RGB_WriteReg(BaseAddress, RGB_ACOEF, coef_out->acoef); //ACOEF - RGB_WriteReg(BaseAddress, RGB_BCOEF, coef_out->bcoef); //BCOEF - RGB_WriteReg(BaseAddress, RGB_CCOEF, coef_out->ccoef); //CCOEF - RGB_WriteReg(BaseAddress, RGB_DCOEF, coef_out->dcoef); //DCOEF - RGB_WriteReg(BaseAddress, RGB_YOFFSET, coef_out->yoffset); //YOFFSET - RGB_WriteReg(BaseAddress, RGB_CBOFFSET, coef_out->cboffset); //CBOFFSET - RGB_WriteReg(BaseAddress, RGB_CROFFSET, coef_out->croffset); //CROFFSET - RGB_WriteReg(BaseAddress, RGB_YMAX, coef_out->ymax); //YMAX - RGB_WriteReg(BaseAddress, RGB_YMIN, coef_out->ymin); //YMIN - RGB_WriteReg(BaseAddress, RGB_CBMAX,coef_out->cbmax); //CBMAX - RGB_WriteReg(BaseAddress, RGB_CBMIN, coef_out->cbmin); //CBMIN - RGB_WriteReg(BaseAddress, RGB_CRMAX, coef_out->crmax); //CRMAX - RGB_WriteReg(BaseAddress, RGB_CRMIN, coef_out->crmin); //CRMIN - -} - -/*****************************************************************************/ -/** -* -* Read the RGB2YCrCb coefficient/offset registers. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* @param coef_out is a pointer to a rgb_coef_output data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_get_coefficients(u32 BaseAddress, struct rgb_coef_outputs *coef_out) -{ - coef_out->acoef = RGB_ReadReg(BaseAddress, RGB_ACOEF); - coef_out->bcoef = RGB_ReadReg(BaseAddress, RGB_BCOEF); - coef_out->ccoef = RGB_ReadReg(BaseAddress, RGB_CCOEF); - coef_out->dcoef = RGB_ReadReg(BaseAddress, RGB_DCOEF); - - coef_out->yoffset = RGB_ReadReg(BaseAddress, RGB_YOFFSET); - coef_out->cboffset = RGB_ReadReg(BaseAddress, RGB_CBOFFSET); - coef_out->croffset = RGB_ReadReg(BaseAddress, RGB_CROFFSET); - - coef_out->ymax = RGB_ReadReg(BaseAddress, RGB_YMAX); - coef_out->ymin = RGB_ReadReg(BaseAddress, RGB_YMIN); - - coef_out->cbmax = RGB_ReadReg(BaseAddress, RGB_CBMAX); - coef_out->cbmax = RGB_ReadReg(BaseAddress, RGB_CBMIN); - - coef_out->crmax = RGB_ReadReg(BaseAddress, RGB_CRMAX); - coef_out->crmax = RGB_ReadReg(BaseAddress, RGB_CRMIN); - -} diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.h b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.h deleted file mode 100755 index dce5da41..00000000 --- a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/rgb2ycrcb.h +++ /dev/null @@ -1,427 +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 RGB to YCrCb Color Space Converter -* (RGB2YCRCB) device. -* -* MODIFICATION HISTORY: -* -* Ver Who Date Changes -* ----- ---- -------- ------------------------------------------------------- -* 5.00a tb 02/27/12 Updated for RGB2YCRCB 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 RGB2YCRCB_DRIVER_H /* prevent circular inclusions */ -#define RGB2YCRCB_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 RGB_CONTROL 0x000 /**< Control */ -#define RGB_STATUS 0x004 /**< Status */ -#define RGB_ERROR 0x008 /**< Error */ -#define RGB_IRQ_EN 0x00C /**< IRQ Enable */ -#define RGB_VERSION 0x010 /**< Version */ -#define RGB_SYSDEBUG0 0x014 /**< System Debug 0 */ -#define RGB_SYSDEBUG1 0x018 /**< System Debug 1 */ -#define RGB_SYSDEBUG2 0x01C /**< System Debug 2 */ -/* Timing Control Registers */ -#define RGB_ACTIVE_SIZE 0x020 /**< Active Size (V x H) */ -#define RGB_TIMING_STATUS 0x024 /**< Timing Measurement Status */ -/* Core Specific Registers */ -#define RGB_YMAX 0x100 /**< Luma Clipping */ -#define RGB_YMIN 0x104 /**< Luma Clamping */ -#define RGB_CBMAX 0x108 /**< Cb Clipping */ -#define RGB_CBMIN 0x10C /**< Cb Clamping */ -#define RGB_CRMAX 0x110 /**< Cr Clipping */ -#define RGB_CRMIN 0x114 /**< Cr Clamping */ -#define RGB_YOFFSET 0x118 /**< Lumma Offset */ -#define RGB_CBOFFSET 0x11C /**< Cb Offset */ -#define RGB_CROFFSET 0x120 /**< Cr Offset */ -#define RGB_ACOEF 0x124 /**< Matrix Coversion Coefficient */ -#define RGB_BCOEF 0x128 /**< Matrix Coversion Coefficient */ -#define RGB_CCOEF 0x12C /**< Matrix Coversion Coefficient */ -#define RGB_DCOEF 0x130 /**< Matrix Coversion Coefficient */ - -/* - * CCM Control Register bit definition - */ -#define RGB_CTL_EN_MASK 0x00000001 /**< CCM Enable */ -#define RGB_CTL_RUE_MASK 0x00000002 /**< CCM Register Update Enable */ - -/* - * CCM Reset Register bit definition - */ -#define RGB_RST_RESET 0x80000000 /**< Software Reset - Instantaneous */ -#define RGB_RST_AUTORESET 0x40000000 /**< Software Reset - Auto-synchronize to SOF */ - - -/***************** Macros (Inline Functions) Definitions *********************/ - -#define RGB_In32 Xil_In32 -#define RGB_Out32 Xil_Out32 - - -/*****************************************************************************/ -/** -* -* This macro enables a RGB2YCrCb device. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_Enable(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_Enable(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, \ - RGB_ReadReg(BaseAddress, RGB_CONTROL) | \ - RGB_CTL_EN_MASK) - -/*****************************************************************************/ -/** -* -* This macro disables a RGB2YCrCb device. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_Disable(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_Disable(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, \ - RGB_ReadReg(BaseAddress, RGB_CONTROL) & \ - ~RGB_CTL_EN_MASK) - -/*****************************************************************************/ -/** -* -* This macro tells a RGB2YCrCb 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 RGB2YCrCb core is enabled. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_RegUpdateEnable(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_RegUpdateEnable(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, \ - RGB_ReadReg(BaseAddress, RGB_CONTROL) | \ - RGB_CTL_RUE_MASK) - -/*****************************************************************************/ -/** -* -* This macro tells a RGB2YCrCb 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 RGB2YCrCb core is enabled. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_RegUpdateDisable(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_RegUpdateDisable(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, \ - RGB_ReadReg(BaseAddress, RGB_CONTROL) & \ - ~RGB_CTL_RUE_MASK) - -/*****************************************************************************/ -/** -* -* This macro resets a RGB2YCrCb device. This reset effects the core immediately, -* and may cause image tearing. -* -* This reset resets the RGB2YCrCb's configuration registers, and holds the core's outputs -* in their reset state until RGB_ClearReset() is called. -* -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_Reset(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_Reset(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, RGB_RST_RESET) \ - -/*****************************************************************************/ -/** -* -* This macro clears the RGB2YCrCb's reset flag (which is set using RGB_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 RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_ClearReset(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_ClearReset(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, 0) \ - - -/*****************************************************************************/ -/** -* -* This macro resets a RGB2YCrCb device, but differs from RGB_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 RGB_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 RGB2YCrCb core (from xparameters.h) -* -* @return None. -* -* @note -* C-style signature: -* void RGB_Reset(u32 BaseAddress); -* -******************************************************************************/ -#define RGB_AutoSyncReset(BaseAddress) \ - RGB_WriteReg(BaseAddress, RGB_CONTROL, RGB_RST_AUTORESET) \ - -/*****************************************************************************/ -/** -* -* Read the given register. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb 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 RGB_ReadReg(u32 BaseAddress, u32 RegOffset) -* -******************************************************************************/ -#define RGB_ReadReg(BaseAddress, RegOffset) \ - RGB_In32((BaseAddress) + (RegOffset)) - -/*****************************************************************************/ -/** -* -* Write the given register. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb 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 RGB_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data) -* -******************************************************************************/ -#define RGB_WriteReg(BaseAddress, RegOffset, Data) \ - RGB_Out32((BaseAddress) + (RegOffset), (Data)) - -/************************** Function Prototypes ******************************/ - -struct rgb_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 ymax; //@- Y Clipping - u32 ymin; //@- Y Clamping - u32 cbmax; //@- Cb Clipping - u32 cbmin; //@- Cb Clamping - u32 crmax; //@- Cr Clipping - u32 crmin; //@- Cr Clamping -}; - -struct rgb_coef_outputs -{ - /* Translated coefficient/offset data */ - u32 acoef; //@- Translated ACoef - u32 bcoef; //@- Translated BCoef - u32 ccoef; //@- Translated CCoef - u32 dcoef; //@- Translated DCoef - u32 yoffset; //@- Translated Offset for the Luminance Channel - u32 cboffset; //@- Translated Offset for the Chrominance Channels - u32 croffset; //@- Translated Offset for the Chrominance Channels - u32 ymax; //@- Translated Y Clipping - u32 ymin; //@- Translated Y Clamping - u32 cbmax; //@- Translated Cb Clipping - u32 cbmin; //@- Translated Cb Clamping - u32 crmax; //@- Translated Cr Clipping - u32 crmin; //@- Translated Cr 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 rgb_coef_inputs data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_select_standard(u32 standard_sel, u32 input_range, u32 data_width, struct rgb_coef_inputs *coef_in); - - -/*****************************************************************************/ -/** -* -* Translate input coefficients into coefficients that can be programmed into the -* RGB2YCrCb 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)= Acoef + Bcoef > 1.0 -* bit(1)= Y Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(2)= Cb Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(3)= Cr Offset outside data width range [-2^data_width, (2^data_width)-1] -* bit(4)= Y Max outside data width range [0, (2^data_width)-1] -* bit(5)= Y Min outside data width range [0, (2^data_width)-1] -* bit(6)= Cb Max outside data width range [0, (2^data_width)-1] -* bit(7)= Cb Min outside data width range [0, (2^data_width)-1] -* bit(8)= Cr Max outside data width range [0, (2^data_width)-1] -* bit(9)= Cr Min outside data width range [0, (2^data_width)-1] -* -* @note -* -******************************************************************************/ -u32 RGB_coefficient_translation(struct rgb_coef_inputs *coef_in, struct rgb_coef_outputs *coef_out, u32 data_width); - - -/*****************************************************************************/ -/** -* -* Program the RGB2YCrCb coefficient/offset registers. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* @param coef_out is a pointer to a rgb_coef_output data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_set_coefficients(u32 BaseAddress, struct rgb_coef_outputs *coef_out); - - -/*****************************************************************************/ -/** -* -* Read the RGB2YCrCb coefficient/offset registers. -* -* @param BaseAddress is the Xilinx EDK base address of the RGB2YCrCb core (from xparameters.h) -* @param coef_out is a pointer to a rgb_coef_output data structure. -* -* @return None. -* -* @note -* -******************************************************************************/ -void RGB_get_coefficients(u32 BaseAddress, struct rgb_coef_outputs *coef_out); - - -#ifdef __cplusplus -} -#endif - -#endif /* end of protection macro */ diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c new file mode 100755 index 00000000..900f500b --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c @@ -0,0 +1,1436 @@ +/****************************************************************************** +* +* 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 xrgb2ycrcb.c +* +* This file contains the implementation of the interface functions for +* RGB2YCRCB driver. Refer to the header file xrgb2ycrcb.h for more detailed +* information. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- -------------------------------------------------------
+* 5.00a tb     02/27/12 Updated for RGB2YCRCB v5.00.a.
+* 7.0   adk    01/07/14 Changed the file name from "rgb2ycrcb.c" to
+*                       "xrgb2ycrcb.c".
+*
+*                       Implemented the following functions:
+*                       XRgb2YCrCb_CfgInitialize, XRgb2YCrCb_EnableDbgByPass,
+*                       XRgb2YCrCb_IsDbgByPassEnabled,
+*                       XRgb2YCrCb_DisableDbgBypass,
+*                       XRgb2YCrCb_EnableDbgTestPattern,
+*                       XRgb2YCrCb_IsDbgTestPatternEnabled,
+*                       XRgb2YCrCb_DisableDbgTestPattern,
+*                       XRgb2YCrCb_GetVersion, XRgb2YCrCb_GetDbgFrameCount,
+*                       XRgb2YCrCb_GetDbgLineCount,
+*                       XRgb2YCrCb_GetDbgPixelCount, XRgb2YCrCb_Setup,
+*                       XRgb2YCrCb_SetActiveSize, XRgb2YCrCb_GetActiveSize,
+*                       XRgb2YCrCb_SetYMax, XRgb2YCrCb_GetYMax,
+*                       XRgb2YCrCb_SetYMin, XRgb2YCrCb_GetYMin,
+*                       XRgb2YCrCb_SetCbMax, XRgb2YCrCb_GetCbMax,
+*                       XRgb2YCrCb_SetCbMin, XRgb2YCrCb_GetCbMin,
+*                       XRgb2YCrCb_SetCrMax, XRgb2YCrCb_GetCrMax,
+*                       XRgb2YCrCb_SetCrMin, XRgb2YCrCb_GetCrMin,
+*                       XRgb2YCrCb_SetYOffset, XRgb2YCrCb_GetYOffset,
+*                       XRgb2YCrCb_SetCbOffset, XRgb2YCrCb_GetCbOffset,
+*                       XRgb2YCrCb_SetCrOffset, XRgb2YCrCb_GetCrOffset,
+*                       XRgb2YCrCb_SetCoefs, XRgb2YCrCb_GetCoefs,
+*                       XRgb2YCrCb_Select_Standard,
+*                       XRgb2YCrCb_Coefficient_Translation,
+*                       XRgb2YCrCb_Select_OutputRange.
+* 
+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xrgb2ycrcb.h" + +/************************** Constant Definitions *****************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/**************************** Type Definitions *******************************/ + + +/************************** Function Prototypes ******************************/ + +/** +* Each of Callback functions to be called on different types of interrupts. +* These stub functions are set during XRgb2YCrCb_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); + +/************************** Variable Definitions *****************************/ + + +/************************** Function Definitions *****************************/ + +/*****************************************************************************/ +/** +* +* This function initializes the Rgb2YCrCb core. This function must be called +* prior to using the Rgb2YCrCb core. Initialization of the Rgb2YCrCb includes +* setting up the instance data and ensuring the hardware is in a quiescent +* state. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CfgPtr is a reference to a structure containing information +* about a specific XRgb2YCrCb 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 XRgb2YCrCb_CfgInitialize(XRgb2YCrCb *InstancePtr, + XRgb2YCrCb_Config *CfgPtr, u32 EffectiveAddr) +{ + /* Verify arguments. */ + Xil_AssertNonvoid(CfgPtr != NULL); + Xil_AssertNonvoid(EffectiveAddr != (u32)0x0); + + /* Setup the instance */ + (void)memset((void *)InstancePtr, 0, sizeof(XRgb2YCrCb)); + (void)memcpy((void *)&(InstancePtr->Config), (const void *)CfgPtr, + sizeof(XRgb2YCrCb_Config)); + + InstancePtr->Config.BaseAddress = EffectiveAddr; + + /* Set all handlers to stub values, let user configure this + * data later + */ + InstancePtr->ProcStartCallBack = + (XRgb2YCrCb_CallBack)((void *)StubCallBack); + InstancePtr->FrameDoneCallBack = + (XRgb2YCrCb_CallBack)((void *)StubCallBack); + InstancePtr->ErrCallBack = + (XRgb2YCrCb_ErrorCallBack)((void *)StubErrCallBack); + + /* Reset the hardware and set the flag to indicate the + * driver is ready + */ + XRgb2YCrCb_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 XRgb2YCrCb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XRgb2YCrCb_EnableDbgByPass(XRgb2YCrCb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET), + ((XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) | + (XRGB_CTL_BPE_MASK))); +} + +/*****************************************************************************/ +/** +* +* This function returns the current bypass mode of a core. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return +* - TRUE if ByPass mode is enabled. +* - FALSE if ByPpass mode is not enabled. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +int XRgb2YCrCb_IsDbgByPassEnabled(XRgb2YCrCb *InstancePtr) +{ + u32 DbgByPass; + int Status; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + DbgByPass = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) & (XRGB_CTL_BPE_MASK); + if (DbgByPass == (XRGB_CTL_BPE_MASK)) { + Status = (TRUE); + } + else { + Status = (FALSE); + } + + return Status; +} + +/*****************************************************************************/ +/** +* +* This function disables Bypass mode. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb core instance to be +* worked on. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XRgb2YCrCb_DisableDbgBypass(XRgb2YCrCb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid((InstancePtr)->Config.HasDebug != (u16)0x0); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET), + ((XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) & (~(XRGB_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 XRgb2YCrCb instance. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XRgb2YCrCb_EnableDbgTestPattern(XRgb2YCrCb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET), + ((XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) | (XRGB_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 XRgb2YCrCb instance. +* +* @return +* - TRUE if Test-pattern mode is enabled. +* - FALSE if Test-pattern mode is not enabled. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +int XRgb2YCrCb_IsDbgTestPatternEnabled(XRgb2YCrCb *InstancePtr) +{ + u32 DbgTestPattern; + int Status; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid((InstancePtr)->Config.HasDebug != (u16)0x0); + + DbgTestPattern = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) & (XRGB_CTL_TPE_MASK); + + if (DbgTestPattern == (XRGB_CTL_TPE_MASK)) { + Status = (TRUE); + } + else { + Status = (FALSE); + } + + return Status; +} + +/*****************************************************************************/ +/** +* +* This function disables debug test pattern mode. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb core instance to be +* worked on. +* +* @return None. +* +* @note Debug functionality should be enabled. +* +******************************************************************************/ +void XRgb2YCrCb_DisableDbgTestPattern(XRgb2YCrCb *InstancePtr) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->Config.HasDebug != (u16)0x0); + + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, + (XRGB_CONTROL_OFFSET), + ((XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CONTROL_OFFSET))) & (~(XRGB_CTL_TPE_MASK)))); +} + +/*****************************************************************************/ +/** +* +* This function facilitates software identification of exact version of the +* RGB2YCrCb hardware (h/w). +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return Version, contents of a Version register. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetVersion(XRgb2YCrCb *InstancePtr) +{ + u32 Version; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + /* Read version register */ + Version = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_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 XRgb2YCrCb instance. +* +* @return DbgFrameCount, number of frames processed since power-up. +* +* @note The SYSDEBUG0, or Frame Throughput Monitor register indicates +* the number of frames processed since power-up or the last time +* the core was reset. The SYSDEBUG registers can be useful to +* identify external memory / frame buffer/ throughput bottlenecks +* in a video system. +* Debug functionality should be enabled. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetDbgFrameCount(XRgb2YCrCb *InstancePtr) +{ + u32 DbgFrameCount; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Frame Throughput monitor */ + DbgFrameCount = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_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 XRgb2YCrCb instance. +* +* @return DbgLineCount, number of lines processed since power-up. +* +* @note The SYSDEBUG1 or Line Throughput Monitor register indicates +* the number of lines processed since power-up or the last time +* the core was reset. The SYSDEBUG registers can be useful to +* identify external memory / Frame buffer / throughput +* bottlenecks in a video system. +* Debug functionality should be enabled. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetDbgLineCount(XRgb2YCrCb *InstancePtr) +{ + u32 DbgLineCount; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Line Throughput monitor */ + DbgLineCount = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_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 XRgb2YCrCb instance. +* +* @return DbgPixelCount, number of pixels processed since power-up. +* +* @note The SYSDEBUG2, or Pixel Throughput Monitor register indicates +* the number of pixel processed since power-up or the last time +* the core was reset. The SYSDEBUG registers can be useful to +* identify external memory / Frame buffer / throughput +* bottlenecks in a video system. +* Debug functionality should be enabled. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetDbgPixelCount(XRgb2YCrCb *InstancePtr) +{ + u32 DbgPixelCount; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->Config.HasDebug != (u16)0x0); + + /* Pixel Throughput monitor */ + DbgPixelCount = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_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 XRgb2YCrCb instance. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_Setup(XRgb2YCrCb *InstancePtr) +{ + u32 ActiveSize; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + + XRgb2YCrCb_RegUpdateDisable(InstancePtr); + + /* Write into active size register */ + ActiveSize = (u32)(((u32)((InstancePtr->VSize)) << + (u32)(XRGB_ACTSIZE_NUM_LINE_SHIFT)) & + (u32)(XRGB_ACTSIZE_NUM_LINE_MASK)) | + ((u32)((InstancePtr->HSize)) & + (u32)(XRGB_ACTSIZE_NUM_PIXEL_MASK)); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_ACTIVE_SIZE_OFFSET), ActiveSize); + + XRgb2YCrCb_RegUpdateEnable(InstancePtr); +} + +/*****************************************************************************/ +/** +* +* This function sets active H/V sizes in the active size register. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param HSize specifies the number of Active Pixels per scanline that +* needs to be set within the range [32, 7680]. +* @param VSize specifies the number of Active Lines per frame that needs +* to be set within the range [32, 7680]. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetActiveSize(XRgb2YCrCb *InstancePtr, u16 HSize, u16 VSize) +{ + u32 Size; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid((VSize >= (u16)(XRGB_VSIZE_FIRST)) && + (VSize <= (u16)(XRGB_VSIZE_LAST))); + Xil_AssertVoid((HSize >= (u16)(XRGB_HSIZE_FIRST)) && + (HSize <= (u16)(XRGB_HSIZE_LAST))); + + /* The core supports spatial resolutions from 32x32 to 7680x7680 */ + Size = (((u32)VSize) << ((u32)(XRGB_ACTSIZE_NUM_LINE_SHIFT))) | + (HSize); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_ACTIVE_SIZE_OFFSET), Size); +} + +/*****************************************************************************/ +/** +* +* This function gets the active H/V sizes of the Rgb2YCrCb core from +* active size register. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb 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, 7680]. +* @param VSize is a pointer to 16-bit variable in which the number of +* Active Lines per frame is returned within the range +* [32, 7680]. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_GetActiveSize(XRgb2YCrCb *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 */ + *HSize = (u16)(XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_ACTIVE_SIZE_OFFSET))) & + (XRGB_ACTSIZE_NUM_PIXEL_MASK); + + /* Reads number of active lines per frame */ + *VSize = (u16)(XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_ACTIVE_SIZE_OFFSET)) & + (XRGB_ACTSIZE_NUM_LINE_MASK)) >> + (XRGB_ACTSIZE_NUM_LINE_SHIFT); +} + +/*****************************************************************************/ +/** +* +* This function sets the maximum value allowed on the Luma (Y) channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param YMax specifies the maximum value within range [0, 255] of Luma +* channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetYMax(XRgb2YCrCb *InstancePtr, u32 YMax) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(YMax <= (u32)XRGB_YMAX_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_YMAX_OFFSET), YMax); +} + +/*****************************************************************************/ +/** +* +* This function returns the maximum value of the Luma (Y) channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return YMax, Maximum value within range [0, 255] of the Luma channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetYMax(XRgb2YCrCb *InstancePtr) +{ + u32 YMax; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + YMax = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_YMAX_OFFSET)) & (XRGB_16_BIT_MASK)); + + return YMax; +} + +/*****************************************************************************/ +/** +* +* This function sets the minimum value allowed on the Luma (Y) channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param YMin specifies the minimum value within range [0, 255] of Luma +* channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetYMin(XRgb2YCrCb *InstancePtr, u32 YMin) +{ + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(YMin <= (u32)XRGB_YMIN_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_YMIN_OFFSET), YMin); +} + +/*****************************************************************************/ +/** +* +* This function returns the minimum value of the Luma (Y) channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return YMin, minimum value within range [0, 255] of the Luma channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetYMin(XRgb2YCrCb *InstancePtr) +{ + u32 YMin; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + YMin = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_YMIN_OFFSET)) & (XRGB_16_BIT_MASK)); + + return YMin; +} + +/*****************************************************************************/ +/** +* +* This function sets the maximum value allowed on the Cb Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CbMax specifies the maximum value within range [0, 255] of Cb +* Chroma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCbMax(XRgb2YCrCb *InstancePtr, u32 CbMax) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CbMax <= (u32)XRGB_CBMAX_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CBMAX_OFFSET), CbMax); +} + +/*****************************************************************************/ +/** +* +* This function returns the maximum value on the Cb Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CbMax, maximum value within range [0, 255] of the Cb Chroma +* Channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCbMax(XRgb2YCrCb *InstancePtr) +{ + u32 CbMax; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CbMax = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CBMAX_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CbMax; +} + +/*****************************************************************************/ +/** +* +* This function sets the minimum value allowed on the Cb Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CbMin specifies the maximum value within range [0, 255] of Cb +* Chroma channel needs to set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCbMin(XRgb2YCrCb *InstancePtr, u32 CbMin) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CbMin <= (u32)XRGB_CBMIN_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CBMIN_OFFSET), CbMin); +} + +/*****************************************************************************/ +/** +* +* This function returns the minimum value on the Cb Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CbMin, minimum value within range [0, 255] on the Cb Chroma +* Channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCbMin(XRgb2YCrCb *InstancePtr) +{ + u32 CbMin; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CbMin = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CBMIN_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CbMin; +} +/*****************************************************************************/ +/** +* +* This function sets the maximum value allowed on the Cr Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CrMax specifies the maximum value within range [0, 255] of Cr +* Chroma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCrMax(XRgb2YCrCb *InstancePtr, u32 CrMax) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CrMax <= (u32)XRGB_CRMAX_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CRMAX_OFFSET), CrMax); +} + +/*****************************************************************************/ +/** +* +* This function returns the maximum value on the Cr Chroma channel of the +* output +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CrMax, maximum value within range [0, 255] on the Cr Chroma +* Channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCrMax(XRgb2YCrCb *InstancePtr) +{ + u32 CrMax; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CrMax = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CRMAX_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CrMax; +} + +/*****************************************************************************/ +/** +* +* This function sets the minimum value allowed on the Cr Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CrMin specifies the minimum value within range [0, 255] of Cr +* Chroma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCrMin(XRgb2YCrCb *InstancePtr, u32 CrMin) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CrMin <= (u32)XRGB_CRMIN_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CRMIN_OFFSET), CrMin); +} + +/*****************************************************************************/ +/** +* +* This function returns the minimum value on the Cr Chroma channel of the +* output. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CrMin, minimum value within range [0, 255] on the Cr Chroma +* Channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCrMin(XRgb2YCrCb *InstancePtr) +{ + u32 CrMin; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CrMin = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CRMIN_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CrMin; +} + +/*****************************************************************************/ +/** +* +* This function sets the offset compensation value for the Luma (Y) channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param YOffset specifies the compensation value within range [0, 255] +* of Luma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetYOffset(XRgb2YCrCb *InstancePtr, u32 YOffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(YOffset <= (u32)XRGB_YOFFSET_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_YOFFSET_OFFSET), YOffset); +} + +/*****************************************************************************/ +/** +* +* This function returns the offset compensation value for the Luma (Y) channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return YOffset is compensation value within range [0, 255] for the +* Luma (Y) channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetYOffset(XRgb2YCrCb *InstancePtr) +{ + u32 YOffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + YOffset = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_YOFFSET_OFFSET)) & (XRGB_16_BIT_MASK)); + + return YOffset; +} + +/*****************************************************************************/ +/** +* +* This function sets the offset compensation value for the Cb Chroma channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CbOffset specifies the compensation value within range [0, 255] +* of Cb Chroma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCbOffset(XRgb2YCrCb *InstancePtr, u32 CbOffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CbOffset <= (u32)XRGB_CBOFFSET_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CBOFFSET_OFFSET), CbOffset); +} + +/*****************************************************************************/ +/** +* +* This function returns the offset compensation value for the Cb Chroma channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CbOffset is the compensation value within range [0, 255] for +* the Cb Chroma channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCbOffset(XRgb2YCrCb *InstancePtr) +{ + u32 CbOffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CbOffset = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CBOFFSET_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CbOffset; +} + +/*****************************************************************************/ +/** +* +* This function sets the offset compensation value for the Cr Chroma channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CrOffset specifies the compensation value within range [0, 255] +* of Cr Chroma channel that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCrOffset(XRgb2YCrCb *InstancePtr, u32 CrOffset) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CrOffset <= (u32)XRGB_CROFFSET_LAST); + + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CROFFSET_OFFSET), CrOffset); +} + +/*****************************************************************************/ +/** +* +* This function returns the offset compensation value of the Cr Chroma channel. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return CrOffset is the compensation value within range [0, 255] of the +* Cr Chroma channel. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_GetCrOffset(XRgb2YCrCb *InstancePtr) +{ + u32 CrOffset; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + CrOffset = (XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CROFFSET_OFFSET)) & (XRGB_16_BIT_MASK)); + + return CrOffset; +} + +/*****************************************************************************/ +/** +* +* This function sets A, B, C and D coefficients. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param ACoef specifies the A coefficient value within the range +* [0.0 to 1.0] that needs to be set. +* @param BCoef specifies the B coefficient value within the range +* [0.0 to 1.0] that needs to be set. +* @param CCoef specifies the C coefficient value within the range +* [0.0 to 1.0] that needs to be set. +* @param DCoef specifies the D coefficient value within the range +* [0.0 to 1.0] that needs to be set. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_SetCoefs(XRgb2YCrCb *InstancePtr, double ACoef, double BCoef, + double CCoef, double DCoef) +{ + u32 CoefVal; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid((ACoef >= 0.000) && (ACoef <= 1.000)); + Xil_AssertVoid((BCoef >= 0.000) && (BCoef <= 1.000)); + Xil_AssertVoid((CCoef >= 0.000) && (CCoef <= 1.000)); + Xil_AssertVoid((DCoef >= 0.000) && (DCoef <= 1.000)); + + CoefVal = (u32)((ACoef) * (1 << (XRGB_16_BIT_COEF_SHIFT))); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_ACOEF_OFFSET), CoefVal); + + CoefVal = (u32)((BCoef) * (1 << (XRGB_16_BIT_COEF_SHIFT))); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_BCOEF_OFFSET), CoefVal); + + CoefVal = (u32)((CCoef) * (1 << (XRGB_16_BIT_COEF_SHIFT))); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_CCOEF_OFFSET), CoefVal); + + CoefVal = (u32)((DCoef) * (1 << (XRGB_16_BIT_COEF_SHIFT))); + XRgb2YCrCb_WriteReg(InstancePtr->Config.BaseAddress, + (XRGB_DCOEF_OFFSET), CoefVal); +} + +/*****************************************************************************/ +/** +* +* This function returns A, B, C and D coefficients. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param ACoef is a pointer to double variable in which A coefficient is +* returned within the range [0.0 to 1.0]. +* @param BCoef is a pointer to double variable in which B coefficient is +* returned within the range [0.0 to 1.0]. +* @param CCoef is a pointer to double variable in which C coefficient is +* returned within the range [0.0 to 1.0]. +* @param DCoef is a pointer to double variable in which D coefficient is +* returned within the range [0.0 to 1.0]. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_GetCoefs(XRgb2YCrCb *InstancePtr, double *ACoef, double *BCoef, + double *CCoef, double *DCoef) +{ + u32 CoefVal; + + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(ACoef != NULL); + Xil_AssertVoid(BCoef != NULL); + Xil_AssertVoid(CCoef != NULL); + Xil_AssertVoid(DCoef != NULL); + + CoefVal = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_ACOEF_OFFSET)); + *ACoef = (double)CoefVal / + (double)(1 << (XRGB_16_BIT_COEF_SHIFT)); + + CoefVal = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_BCOEF_OFFSET)); + *BCoef = (double)CoefVal / + (double)(1 << (XRGB_16_BIT_COEF_SHIFT)); + + CoefVal = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_CCOEF_OFFSET)); + *CCoef = (double)CoefVal / + (double)(1 << (XRGB_16_BIT_COEF_SHIFT)); + + CoefVal = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_DCOEF_OFFSET)); + *DCoef = (double)CoefVal / + (double)(1 << (XRGB_16_BIT_COEF_SHIFT)); +} + +/*****************************************************************************/ +/** +* +* This function populates an XRgb2YCrCb_Coef_Inputs structure with the values +* from the selected video standard. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param StandardSel needs to be set from enum Standards value as : +* 0 = XRGB_STANDARD_ITU_601_SD +* 1 = XRGB_STANDARD_ITU_709_NTSC +* 2 = XRGB_STANDARD_ITU_709_PAL +* 3 = XRGB_STANDARD_YUV. +* @param InputRange needs to be set from enum OutputRanges value as: +* 0 = XRGB_TV_16_TO_240, +* 1 = XRGB_STUDIO_16_TO_235, +* 2 = XRGB_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 XRgb2YCrCb_Coef_Inputs +* structure which is populated with the values from selected +* video standard. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +void XRgb2YCrCb_Select_Standard(XRgb2YCrCb *InstancePtr, + enum Standards StandardSel, + enum OutputRanges InputRange, u32 DataWidth, + struct XRgb2YCrCb_Coef_Inputs *CoefIn) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CoefIn != NULL); + Xil_AssertVoid((DataWidth == (u32)(XRGB_DATA_WIDTH_16)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_10)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_12)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_8))); + + Xil_AssertVoid(StandardSel <(u32)(XRGB_STANDARD_CUSTOM)); + Xil_AssertVoid(InputRange <= (u32)(XRGB_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 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 + }; + + u32 YOffset = (1 << (DataWidth - 4)); + u32 COffset = (u32)(1 << (DataWidth - 1)); + + 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->YMax = Max[InputRange]; + CoefIn->YMin = Min[InputRange]; + CoefIn->CbMax = Max[InputRange]; + CoefIn->CbMin = Min[InputRange]; + CoefIn->CrMax = Max[InputRange]; + CoefIn->CrMin = Min[InputRange]; +} + +/*****************************************************************************/ +/** +* +* This function translates the XRgb2YCrCb_Coef_Inputs structure into the +* XRgb2YCrCb_Coef_Outputs structure that can be used to program the core's +* registers. The XRgb2YCrCb_Coef_Inputs structure uses the same values as the +* core's GUIs. The XRgb2YCrCb_Coef_Outputs structure uses the values that can +* be programmed into the core's registers. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param CoefIn specifies a pointer to a XRgb2YCrCb_Coef_Inputs +* structure to be translated. +* @param CoefOut specifies a pointer to a XRgb2YCrCb_Coef_Outputs +* structure with translated values. +* @param DataWidth specifies a valid range of [8,10,12,16] that needs +* to be set. +* +* @return RetVal, returns the 32-bit value with following bit information: +* - bit(0)= ACoef + BCoef > 1.0. +* - bit(1)= Y Offset outside data width range as +* [-2^Data_Width, (2^Data_Width)-1]. +* - bit(2)= Cb Offset outside data width range as +* [-2^Data_Width, (2^Data_Width)-1]. +* - bit(3)= Cr Offset outside data width range as +* [-2^Data_Width, (2^Data_Width)-1]. +* - bit(4)= Y Max outside data width range as +* [0, (2^Data_Width)-1]. +* - bit(5)= Y Min outside data width range as +* [0, (2^Data_Width)-1]. +* - bit(6)= Cb Max outside data width range as +* [0, (2^Data_Width)-1]. +* - bit(7)= Cb Min outside data width range as +* [0, (2^Data_Width)-1]. +* - bit(8)= Cr Max outside data width range as +* [0, (2^Data_Width)-1]. +* - bit(9)= Cr Min outside data width range as +* [0, (2^Data_Width)-1]. +* +* @note None. +* +******************************************************************************/ +u32 XRgb2YCrCb_Coefficient_Translation(XRgb2YCrCb *InstancePtr, + struct XRgb2YCrCb_Coef_Inputs *CoefIn, + struct XRgb2YCrCb_Coef_Outputs *CoefOut, + u32 DataWidth) +{ + u32 RetVal = 0; + + /* Verify arguments. */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(CoefIn != NULL); + Xil_AssertNonvoid(CoefOut != NULL); + + Xil_AssertNonvoid( (DataWidth == (u32)(XRGB_DATA_WIDTH_16)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_10)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_12)) || + (DataWidth == (u32)(XRGB_DATA_WIDTH_8))); + + if((CoefIn->ACoef + CoefIn->BCoef) > (1.0)) { + RetVal = (RetVal) | (0x1); + } + if((((int)CoefIn->YOffset) < ((int)-(1 << DataWidth))) || + (((int)CoefIn->YOffset) > ((int)((1 << DataWidth) -1 )))) { + RetVal = (RetVal) | (0x2); + } + if((((int)CoefIn->CbOffset) < ((int)-(1 << DataWidth))) || + (((int)CoefIn->CbOffset) > ((int)((1 << DataWidth) - 1)))) { + RetVal = (RetVal) | (0x4); + } + if((((int)CoefIn->CrOffset) < ((int)-(1 << DataWidth))) || + (((int)CoefIn->CrOffset) > ((int)((1 << DataWidth) - 1)))) { + RetVal = (RetVal) | (0x8); + } + if(((int)CoefIn->YMax) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x10); + } + if(((int)CoefIn->YMin) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x20); + } + if(((int)CoefIn->CbMax) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x40); + } + if(((int)CoefIn->CbMin) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x80); + } + if(((int)CoefIn->CrMax) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x100); + } + if(((int)CoefIn->CrMin) > ((int)((1 << DataWidth) - 1))) { + RetVal = (RetVal) | (0x200); + } + + CoefOut->ACoef = CoefIn->ACoef * (1 << 16); + CoefOut->BCoef = CoefIn->BCoef * (1 << 16); + CoefOut->CCoef = CoefIn->CCoef * (1 << 16); + CoefOut->DCoef = CoefIn->DCoef * (1 << 16); + CoefOut->YOffset = CoefIn->YOffset; + CoefOut->CbOffset = CoefIn->CbOffset; + CoefOut->CrOffset = CoefIn->CrOffset; + CoefOut->YMax = CoefIn->YMax; + CoefOut->YMin = CoefIn->YMin; + CoefOut->CbMax = CoefIn->CbMax; + CoefOut->CbMin = CoefIn->CbMin; + CoefOut->CrMax = CoefIn->CrMax; + CoefOut->CrMin = CoefIn->CrMin; + + return RetVal; +} + +/*****************************************************************************/ +/** +* +* This function governs the range of outputs Y, Cr and Cb by affecting the +* conversion coefficients as well as the clipping and clamping values. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* @param Range needs to be set from the enum OutputRanges values as: +* 0 = XRGB_TV_16_TO_240, +* 1 = XRGB_STUDIO_16_TO_235, +* 2 = XRGB_GRAPHICS_0_TO_255. +* +* @return None. +* +* @note None. +* +*****************************************************************************/ +void XRgb2YCrCb_Select_OutputRange(XRgb2YCrCb *InstancePtr, + enum OutputRanges Range) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(Range <= (u32)(XRGB_GRAPHICS_0_TO_255)); + + /* Sets output range. */ + switch (Range) { + case XRGB_TV_16_TO_240: + (InstancePtr)->OutputRange = + (u32)XRGB_TV_16_TO_240; + break; + + case XRGB_STUDIO_16_TO_235: + (InstancePtr)->OutputRange = + (u32)XRGB_STUDIO_16_TO_235; + break; + + case XRGB_GRAPHICS_0_TO_255: + (InstancePtr)->OutputRange = + (u32)XRGB_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) +{ + Xil_AssertVoid(CallBackRef != NULL); + Xil_AssertVoidAlways(); +} + +/*****************************************************************************/ +/** +* +* 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 XRGB_IXR_*_MASK values defined +* in xrgb2ycrcb_hw.h +* +* @return None. +* +* @note None. +* +******************************************************************************/ +static void StubErrCallBack(void *CallBackRef, u32 ErrorMask) +{ + Xil_AssertVoid(CallBackRef != NULL); + Xil_AssertVoid(ErrorMask != (u32)0x0); + Xil_AssertVoidAlways(); +} + diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h new file mode 100755 index 00000000..56aff325 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h @@ -0,0 +1,840 @@ +/****************************************************************************** +* +* 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 xrgb2ycrcb.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 Rgb2YCrCb core instance. +* +* The RGB to YCrCb 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 RGB2YCRCB core. +* +* XRgb2YCrCb_CfgInitialize() API is used to initialize the RGB2YCRCB core. +* The user needs to first call the XRgb2YCrCb_LookupConfig() API which returns +* the Configuration structure pointer which is passed as a parameter to the +* XRgb2YCrCb_CfgInitialize() API. +* +* Interrupts +* +* The driver provides an interrupt handler XRgb2YCrCb_IntrHandler for handling +* the interrupt from the RGB2YCRCB core. The users of this driver have to +* register this handler with the interrupt system and provide the callback +* functions by using XRgb2YCrCb_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 XRgb2YCrCb 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/27/12 Updated for RGB2YCRCB 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/07/14 Changed the file name from "rgb2ycrcb.h" to
+*                       "xrgb2ycrcb.h".
+*                       Moved register offsets and bit definitions from
+*                       rgb2ycrcb.h file to xrgb2ycrcb_hw.h file.
+*
+*                       Removed RGB_TIMING_STATUS register offset because this
+*                       register is not present in latest product guide.
+*
+*                       Removed following function macros:
+*                       RGB_Enable, RGB_Disable, RGB_RegUpdateEnable,
+*                       RGB_RegUpdateDisable, RGB_Reset, RGB_ClearReset,
+*                       RGB_AutoSyncReset.
+
+*                       Removed following functions:
+*                       RGB_select_standard, RGB_coefficient_translation,
+*                       RGB_set_coefficients, RGB_get_coefficients.
+*
+*                       Added following handler types as enum:
+*                       XRGB_HANDLER_PROCSTART, XRGB_HANDLER_FRAMEDONE,
+*                       XRGB_HANDLER_ERROR.
+*
+*                       Added following standard types as enum:
+*                       XRGB_STANDARD_ITU_601_SD, XRGB_STANDARD_ITU_709_NTSC,
+*                       XRGB_STANDARD_ITU_709_PAL, XRGB_STANDARD_YUV,
+*                       XRGB_STANDARD_CUSTOM.
+*
+*                       Added following output ranges as enum:
+*                       XRGB_TV_16_TO_240, XRGB_STUDIO_16_TO_235,
+*                       XRGB_GRAPHICS_0_TO_255.
+*
+*                       Added range macros for ActiveSize, YMAX, YMIN, YOFFSET,
+*                       CBMAX, CBMIN, CBOFFSET, CRMAX, CRMIN, CROFFSET
+*                       registers.
+*
+*                       Added following function macros:
+*                       XRgb2YCrCb_IntrEnable, XRgb2YCrCb_SyncReset,
+*                       XRgb2YCrCb_IntrDisable, XRgb2YCrCb_StatusGetPending,
+*                       XRgb2YCrCb_IntrGetPending, XRgb2YCrCb_IntrClear,
+*                       XRgb2YCrCb_RegUpdateEnable,
+*                       XRgb2YCrCb_RegUpdateDisable, XRgb2YCrCb_Reset,
+*                       XRgb2YCrCb_Enable, XRgb2YCrCb_Disable,
+*                       XRgb2YCrCb_Start, XRgb2YCrCb_Stop.
+*
+*                       Added core and configuration structure.
+*                       Renamed rgb_coef_inputs -> XRgb2YCrCb_Coef_Inputs and
+*                       rgb_coef_outputs - > XRgb2YCrCb_Coef_Outputs.
+*
+*                       Added callback functions typedef.
+*
+*                       Implemented XRgb2YCrCb_LookupConfig in
+*                       xrgb2ycrcb_sinit.c
+*                       Implemented XRgb2YCrCb_SelfTest in
+*                       xrgb2ycrcb_selftest.c
+*                       Implemented XRgb2YCrCb_IntrHandler,
+*                       XRgb2YCrCb_SetCallBack in xrgb2ycrcb_intr.c.
+*
+*                       Implemented following functions in xrgb2ycrcb.c:
+*                       XRgb2YCrCb_CfgInitialize, XRgb2YCrCb_EnableDbgByPass,
+*                       XRgb2YCrCb_IsDbgByPassEnabled,
+*                       XRgb2YCrCb_DisableDbgBypass,
+*                       XRgb2YCrCb_EnableDbgTestPattern,
+*                       XRgb2YCrCb_IsDbgTestPatternEnabled,
+*                       XRgb2YCrCb_DisableDbgTestPattern,
+*                       XRgb2YCrCb_GetVersion, XRgb2YCrCb_GetDbgFrameCount,
+*                       XRgb2YCrCb_GetDbgLineCount,
+*                       XRgb2YCrCb_GetDbgPixelCount, XRgb2YCrCb_Setup,
+*                       XRgb2YCrCb_SetActiveSize, XRgb2YCrCb_GetActiveSize,
+*                       XRgb2YCrCb_SetYMax, XRgb2YCrCb_GetYMax,
+*                       XRgb2YCrCb_SetYMin, XRgb2YCrCb_GetYMin,
+*                       XRgb2YCrCb_SetCbMax, XRgb2YCrCb_GetCbMax,
+*                       XRgb2YCrCb_SetCbMin, XRgb2YCrCb_GetCbMin,
+*                       XRgb2YCrCb_SetCrMax, XRgb2YCrCb_GetCrMax,
+*                       XRgb2YCrCb_SetCrMin, XRgb2YCrCb_GetCrMin,
+*                       XRgb2YCrCb_SetYOffset, XRgb2YCrCb_GetYOffset,
+*                       XRgb2YCrCb_SetCbOffset, XRgb2YCrCb_GetCbOffset,
+*                       XRgb2YCrCb_SetCrOffset, XRgb2YCrCb_GetCrOffset,
+*                       XRgb2YCrCb_SetCoefs, XRgb2YCrCb_GetCoefs,
+*                       XRgb2YCrCb_Select_Standard,
+*                       XRgb2YCrCb_Coefficient_Translation,
+*                       XRgb2YCrCb_Select_OutputRange.
+*
+* +******************************************************************************/ + +#ifndef XRGB2YCRCB_H_ +#define XRGB2YCRCB_H_ /**< Prevent circular inclusions by using protection + * macros + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ + +#include "xrgb2ycrcb_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 { + XRGB_HANDLER_PROCSTART = 1, /**< A processing start event interrupt + * type */ + XRGB_HANDLER_FRAMEDONE, /**< A frame done event + * interrupt type */ + XRGB_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 { + XRGB_STANDARD_ITU_601_SD = 0, /**< Standard ITU 601 SD. */ + XRGB_STANDARD_ITU_709_NTSC, /**< Standard ITU 709 NTSC. */ + XRGB_STANDARD_ITU_709_PAL, /**< Standard ITU 709 PAL. */ + XRGB_STANDARD_YUV, /**< Standard YUV. */ + XRGB_STANDARD_CUSTOM /**< Standard Custom. */ +} ; +/*@}*/ + +/** @name Output Ranges + * @{ + */ +/** +* +* These constants specify different ranges used for studio equipment, +* television and computer graphics respectively. +*/ +enum OutputRanges { + XRGB_TV_16_TO_240 = 0, /**< 16 to 240, for Television. */ + XRGB_STUDIO_16_TO_235, /**< 16 to 235, for Studio Equipment. */ + XRGB_GRAPHICS_0_TO_255 /**< 0 to 255, for Computer Graphics. */ +} ; +/*@}*/ + +/** @name Active size range macros + * @{ + */ +#define XRGB_VSIZE_FIRST 32 /**< VSize starting value */ +#define XRGB_VSIZE_LAST 7680 /**< VSize ending value */ +#define XRGB_HSIZE_FIRST 32 /**< HSize starting value */ +#define XRGB_HSIZE_LAST 7680 /**< HSize ending value */ +/*@}*/ + +/** @name Ymax range macros + * @{ + */ +#define XRGB_YMAX_FIRST 0 /**< Ymax starting value */ +#define XRGB_YMAX_LAST 255 /**< Ymax ending value */ +/*@}*/ + +/** @name Ymin range macros + * @{ + */ +#define XRGB_YMIN_FIRST 0 /**< Ymin starting value */ +#define XRGB_YMIN_LAST 255 /**< Ymax ending value */ +/*@}*/ + +/** @name Yoffset range macros + * @{ + */ +#define XRGB_YOFFSET_FIRST 0 /**< Yoffset starting value */ +#define XRGB_YOFFSET_LAST 255 /**< Yoffset ending value */ +/*@}*/ + +/** @name Cbmax range macros + * @{ + */ +#define XRGB_CBMAX_FIRST 0 /**< Cbmax starting value */ +#define XRGB_CBMAX_LAST 255 /**< Cbmax ending value */ +/*@}*/ + +/** @name Cbmin range macros + * @{ + */ +#define XRGB_CBMIN_FIRST 0 /**< Cbmin starting value */ +#define XRGB_CBMIN_LAST 255 /**< Cbmin ending value */ +/*@}*/ + +/** @name Cboffset range macros + * @{ + */ +#define XRGB_CBOFFSET_FIRST 0 /**< Cboffset starting value */ +#define XRGB_CBOFFSET_LAST 255 /**< Cboffset ending value */ +/*@}*/ + +/** @name Crmax range macros + * @{ + */ +#define XRGB_CRMAX_FIRST 0 /**< Crmax starting value */ +#define XRGB_CRMAX_LAST 255 /**< Crmax ending value */ +/*@}*/ + +/** @name Crmin range macros + * @{ + */ +#define XRGB_CRMIN_FIRST 0 /**< Crmin starting value */ +#define XRGB_CRMIN_LAST 255 /**< Crmin ending value */ +/*@}*/ + +/** @name Croffset range macros + * @{ + */ +#define XRGB_CROFFSET_FIRST 0 /**< Croffset starting value */ +#define XRGB_CROFFSET_LAST 255 /**< Croffset ending value */ +/*@}*/ + +/***************** Macros (Inline Functions) Definitions *********************/ + +/*****************************************************************************/ +/** +* +* This macro enables the Rgb2YCrCb device/core. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_Enable(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_Enable(InstancePtr) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET))) | (XRGB_CTL_SW_EN_MASK))) + +/*****************************************************************************/ +/** +* +* This macro disables the Rgb2YCrCb device/core. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_Disable(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_Disable(InstancePtr) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET))) & (~(XRGB_CTL_SW_EN_MASK)))) + +/*****************************************************************************/ +/** +* +* This function macro enables/starts the Rgb2YCrCb core. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb instance to be +* worked on +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_Start(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_Start XRgb2YCrCb_Enable + +/*****************************************************************************/ +/** +* +* This function macro disables/stops the Rgb2YCrCb core. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb instance to be +* worked on +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_Stop(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_Stop XRgb2YCrCb_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 Rgb2YCrCb core instance to be +* worked on. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_RegUpdateEnable(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_RegUpdateEnable(InstancePtr)\ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET))) | (XRGB_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 Rgb2YCrCb core instance to be +* worked on. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_RegUpdateDisable(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_RegUpdateDisable(InstancePtr) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET)))) & (~(XRGB_CTL_RUE_MASK))) + +/*****************************************************************************/ +/** +* +* This macro resets the Rgb2YCrCb device, but differs from XRgb_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 +* XRgb2YCrCb_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 Rgb2YCrCb core instance to be +* worked on. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_SyncReset(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_SyncReset(InstancePtr) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), (XRGB_CTL_AUTORESET_MASK)) + +/*****************************************************************************/ +/** +* +* This macro resets the Rgb2YCrCb core. This reset effects the core +* immediately, and may cause image tearing. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_Reset(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_Reset(InstancePtr) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_CONTROL_OFFSET), (XRGB_CTL_RESET_MASK)) + +/*****************************************************************************/ +/** +* +* This function macro enables individual interrupts of the RGB2YCRCB core by +* updating the IRQ_ENABLE register. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb 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 +* XRGB_IXR_*_MASK bits defined in xrgb2ycrcb_hw.h. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_IntrEnable(XRgb2YCrCb *InstancePtr, +* u32 IntrType) +* +* The existing enabled interrupt(s) will remain enabled. +* +******************************************************************************/ +#define XRgb2YCrCb_IntrEnable(InstancePtr, IntrType) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_IRQ_EN_OFFSET), (((IntrType) & \ + (XRGB_IXR_ALLINTR_MASK)) | \ + (XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_IRQ_EN_OFFSET))))) + +/*****************************************************************************/ +/** +* +* This function macro disables individual interrupts of the RGB2YCRCB core by +* updating the IRQ_ENABLE register. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb 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 +* XRGB_IXR_*_MASK bits defined in xrgb2ycrcb_hw.h. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_IntrDisable(XRgb2YCrCb *InstancePtr, +* u32 IntrType) +* +* Any other interrupt not covered by parameter IntrType, if +* enabled before this macro is called, will remain enabled. +* +******************************************************************************/ +#define XRgb2YCrCb_IntrDisable(InstancePtr, IntrType) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_IRQ_EN_OFFSET), \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_IRQ_EN_OFFSET))) & ((~(IntrType)) & \ + (XRGB_IXR_ALLINTR_MASK)))) + +/*****************************************************************************/ +/** +* +* This function macro returns the pending interrupt status of the RGB2YCRCB +* core read from the Status register. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* +* @return The status of pending interrupts of the Rgb2YCrCb core. +* Use XRGB_IXR_*_MASK constants defined in xrgb2ycrcb_hw.h to +* interpret this value. +* +* @note C-style signature: +* u32 XRgb2YCrCb_StatusGePending(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_StatusGetPending(InstancePtr) \ + XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_STATUS_OFFSET)) & (XRgb2YCrCb_IXR_ALLINTR_MASK) + +/*****************************************************************************/ +/** +* +* This function macro returns the pending interrupts of the RGB2YCRCB core for +* the interrupts that have been enabled. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* +* @return The pending interrupts of the Rgb2YCrCb core. Use +* XRGB_IXR_*_MASK constants defined in xrgb2ycrcb_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 XRgb2YCrCb_IntrGetPending(XRgb2YCrCb *InstancePtr) +* +******************************************************************************/ +#define XRgb2YCrCb_IntrGetPending(InstancePtr) \ + XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_IRQ_EN_OFFSET)) & \ + ((XRgb2YCrCb_ReadReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_STATUS_OFFSET))) & ((u32)(XRGB_IXR_ALLINTR_MASK))) + +/*****************************************************************************/ +/** +* +* This function macro clears/acknowledges pending interrupts of the RGB2YCRCB +* core in the Status register. Bit positions of 1 will be cleared. +* +* @param InstancePtr is a pointer to the Rgb2YCrCb core instance to be +* worked on. +* @param IntrType is the pending interrupts to clear/acknowledge. +* Use OR'ing of XRGB_IXR_*_MASK constants defined in +* xrgb2ycrcb_hw.h to create this parameter value. +* +* @return None. +* +* @note C-style signature: +* void XRgb2YCrCb_IntrClear(XRgb2YCrCb *InstancePtr, +* u32 IntrType) +* +******************************************************************************/ +#define XRgb2YCrCb_IntrClear(InstancePtr, IntrType) \ + XRgb2YCrCb_WriteReg((InstancePtr)->Config.BaseAddress, \ + (XRGB_STATUS_OFFSET), ((IntrType) & \ + (XRGB_IXR_ALLINTR_MASK))) + +/**************************** Type Definitions *******************************/ + +/** +* This typedef contains configuration information for a Rgb2YCrCb core. +* Each Rgb2YCrCb core should have a configuration structure associated. +*/ +typedef struct { + u16 DeviceId; /**< DeviceId is the unique ID of the + * RGB2YCRCB core */ + u32 BaseAddress; /**< BaseAddress is the physical base address + * of the RGB2YCRCB core registers */ + u32 SlaveAxisVideoFormat; /**< Slave Axis Video Format */ + u32 MasterAxisVideoFormat; /**< Master Axis Video Format */ + u16 HasDebug; /**< To check debug support */ + u16 HasIntcIf; /**< To check Interrupt controller + * support */ + u32 MaxCols; /**< Maximum number of columns */ + u32 ActiveCols; /**< Number of active columns */ + u32 ActiveRows; /**< Number of active rows */ + u16 HasClip; /**< To check support for clipping */ + u16 HasClamp; /**< To check support for clamping */ + u32 ACoef; /**< A coefficient */ + u32 BCoef; /**< B coefficient */ + u32 CCoef; /**< C coefficient */ + u32 DCoef; /**< D coefficient */ + u32 YOffset; /**< Y Offset value */ + u32 CbOffset; /**< Cb Offset value */ + u32 CrOffset; /**< Cr Offset value */ + u32 YMax; /**< Y Min value */ + u32 YMin; /**< Y Max value */ + u32 CbMax; /**< Cb Max value */ + u32 CbMin; /**< Cb Min value */ + u32 CrMax; /**< Cr Max value */ + u32 CrMin; /**< Cr Min value */ + u32 SlaveAxiClkFreqHz; /**< Slave AXI Clock Frequency in Hz */ + u32 StandardSelection; /**< To select standard */ + u32 OutputRange; /**< To identify output range */ +} XRgb2YCrCb_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 (*XRgb2YCrCb_CallBack)(void *CallBackRef); + +/*****************************************************************************/ +/** +* +* This data type defines a handler that an application defines to communicate +* with interrupt system to retrieve error information while processing video +* frame. +* +* @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 XRGB_IXR_*_MASK values defined +* in xrgb2ycrcb_hw.h. +* +* @return None. +* +* @note None. +* +*****************************************************************************/ +typedef void (*XRgb2YCrCb_ErrorCallBack)(void *CallBackRef, u32 ErrorMask); + +/** +* The XRgb2YCrCb 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 { + XRgb2YCrCb_Config Config; /**< Hardware configuration */ + u32 IsReady; /**< Core and driver instance are initialized */ + u16 HSize; /**< Active Video Horizontal Size */ + u16 VSize; /**< Active Video Vertical Size */ + + /* IRQ callbacks Here */ + XRgb2YCrCb_CallBack ProcStartCallBack; /**< Callback for Processing + * Start interrupt */ + void *ProcStartRef; /**< To be passed to Process start interrupt + * callback */ + XRgb2YCrCb_CallBack FrameDoneCallBack; /**< Callback for Frame Done + * interrupt */ + void *FrameDoneRef; /**< To be passed to the Frame done interrupt + * callback */ + XRgb2YCrCb_ErrorCallBack ErrCallBack; /**< Callback for Error + * interrupt */ + void *ErrRef; /**< To be passed to the Error interrupt callback */ + u32 StandardSelection; /**< Standard Selection */ + u32 OutputRange; /**< Output Range */ +} XRgb2YCrCb; + +/** +* Rgb2YCrCb input coefficient +*/ +struct XRgb2YCrCb_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 YMax; /**< Y Clipping */ + u32 YMin; /**< Y Clamping */ + u32 CbMax; /**< Cb Clipping */ + u32 CbMin; /**< Cb Clamping */ + u32 CrMax; /**< Cr Clipping */ + u32 CrMin; /**< Cr Clamping */ +} ; + +/** +* Rgb2YCrCb output coefficient +*/ +struct XRgb2YCrCb_Coef_Outputs { + /* Translated coefficient/offset data */ + u32 ACoef; /**< Translated ACoef */ + u32 BCoef; /**< Translated BCoef */ + u32 CCoef; /**< Translated CCoef */ + u32 DCoef; /**< Translated DCoef */ + u32 YOffset; /**< Translated Offset for the Luminance Channel */ + u32 CbOffset; /**< Translated Offset for the Chrominance Channels */ + u32 CrOffset; /**< Translated Offset for the Chrominance Channels */ + u32 YMax; /**< Translated Y Clipping */ + u32 YMin; /**< Translated Y Clamping */ + u32 CbMax; /**< Translated Cb Clipping */ + u32 CbMin; /**< Translated Cb Clamping */ + u32 CrMax; /**< Translated Cr Clipping */ + u32 CrMin; /**< Translated Cr Clamping */ +} ; + +/************************** Function Prototypes ******************************/ + +/* Static lookup function implemented in xrgb2ycrcb_sinit.c */ +XRgb2YCrCb_Config *XRgb2YCrCb_LookupConfig(u16 DeviceId); + +/* Following functions implemented in xrgb2ycrcb.c */ +int XRgb2YCrCb_CfgInitialize(XRgb2YCrCb *InstancePtr, + XRgb2YCrCb_Config *CfgPtr, u32 EffectiveAddr); + +void XRgb2YCrCb_EnableDbgByPass(XRgb2YCrCb *InstancePtr); +int XRgb2YCrCb_IsDbgByPassEnabled(XRgb2YCrCb *InstancePtr); +void XRgb2YCrCb_DisableDbgBypass(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_EnableDbgTestPattern(XRgb2YCrCb *InstancePtr); +int XRgb2YCrCb_IsDbgTestPatternEnabled(XRgb2YCrCb *InstancePtr); +void XRgb2YCrCb_DisableDbgTestPattern(XRgb2YCrCb *InstancePtr); + +u32 XRgb2YCrCb_GetVersion(XRgb2YCrCb *InstancePtr); + +u32 XRgb2YCrCb_GetDbgFrameCount(XRgb2YCrCb *InstancePtr); +u32 XRgb2YCrCb_GetDbgLineCount(XRgb2YCrCb *InstancePtr); +u32 XRgb2YCrCb_GetDbgPixelCount(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_Setup(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetActiveSize(XRgb2YCrCb *InstancePtr, u16 HSize, u16 VSize); +void XRgb2YCrCb_GetActiveSize(XRgb2YCrCb *InstancePtr, u16 *HSize, u16 *VSize); + +void XRgb2YCrCb_SetYMax(XRgb2YCrCb *InstancePtr, u32 YMax); +u32 XRgb2YCrCb_GetYMax(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetYMin(XRgb2YCrCb *InstancePtr, u32 YMin); +u32 XRgb2YCrCb_GetYMin(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCbMax(XRgb2YCrCb *InstancePtr, u32 CbMax); +u32 XRgb2YCrCb_GetCbMax(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCbMin(XRgb2YCrCb *InstancePtr, u32 CbMin); +u32 XRgb2YCrCb_GetCbMin(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCrMax(XRgb2YCrCb *InstancePtr, u32 CrMax); +u32 XRgb2YCrCb_GetCrMax(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCrMin(XRgb2YCrCb *InstancePtr, u32 CrMin); +u32 XRgb2YCrCb_GetCrMin(XRgb2YCrCb *InstancePtr); + + +void XRgb2YCrCb_SetYOffset(XRgb2YCrCb *InstancePtr, u32 YOffset); +u32 XRgb2YCrCb_GetYOffset(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCbOffset(XRgb2YCrCb *InstancePtr, u32 CbOffset); +u32 XRgb2YCrCb_GetCbOffset(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCrOffset(XRgb2YCrCb *InstancePtr, u32 CrOffset); +u32 XRgb2YCrCb_GetCrOffset(XRgb2YCrCb *InstancePtr); + +void XRgb2YCrCb_SetCoefs(XRgb2YCrCb *InstancePtr, double ACoef, double BCoef, + double CCoef, double DCoef); +void XRgb2YCrCb_GetCoefs(XRgb2YCrCb *InstancePtr, double *ACoef, double *BCoef, + double *CCoef, double *DCoef); + +void XRgb2YCrCb_Select_Standard(XRgb2YCrCb *InstancePtr, + enum Standards StandardSel, + enum OutputRanges InputRange, u32 DataWidth, + struct XRgb2YCrCb_Coef_Inputs *CoefIn); + +u32 XRgb2YCrCb_Coefficient_Translation(XRgb2YCrCb *InstancePtr, + struct XRgb2YCrCb_Coef_Inputs *CoefIn, + struct XRgb2YCrCb_Coef_Outputs *CoefOut, + u32 Data_Width); + +void XRgb2YCrCb_Select_OutputRange(XRgb2YCrCb *InstancePtr, + enum OutputRanges Range); + +/* Self-test function implemented in xrgb2ycrcb_selftest.c */ +int XRgb2YCrCb_SelfTest(XRgb2YCrCb *InstancePtr); + +/* Interrupt related functions implemented in xrgbycrcb_intr.c */ +void XRgb2YCrCb_IntrHandler(void *InstancePtr); + +int XRgb2YCrCb_SetCallBack(XRgb2YCrCb *InstancePtr, u32 HandlerType, + void *CallBackFunc, + void *CallBackRef); + +/************************** Variable Declarations ****************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* End of protection macro */ diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c new file mode 100755 index 00000000..2b5af030 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c @@ -0,0 +1,87 @@ + +/******************************************************************* +* +* CAUTION: This file is automatically generated by HSM. +* Version: +* DO NOT EDIT. +* +* v (64-bit) +SW Build (by ) on +Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. +* +* Description: Driver configuration +* +*******************************************************************/ + +#include "xparameters.h" +#include "xrgb2ycrcb.h" + +/* +* The configuration table for devices +*/ + +XRgb2YCrCb_Config XRgb2YCrCb_ConfigTable[] = +{ + { + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_DEVICE_ID, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_BASEADDR, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_HIGHADDR, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_S_AXIS_VIDEO_FORMAT, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_M_AXIS_VIDEO_FORMAT, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_HAS_DEBUG, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_HAS_INTC_IF, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_MAX_COLS, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_ACTIVE_COLS, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_ACTIVE_ROWS, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_HAS_CLIP, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_HAS_CLAMP, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_ACOEF, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_BCOEF, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CCOEF, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_DCOEF, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_YOFFSET, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CBOFFSET, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CROFFSET, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_YMAX, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_YMIN, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CBMAX, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CBMIN, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CRMAX, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_CRMIN, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_S_AXI_CLK_FREQ_HZ, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_STANDARD_SEL, + XPAR_FMC_SENSOR_INPUT_V_RGB2YCRCB_1_OUTPUT_RANGE + }, + { + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_DEVICE_ID, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_BASEADDR, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_HIGHADDR, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_S_AXIS_VIDEO_FORMAT, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_M_AXIS_VIDEO_FORMAT, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_HAS_DEBUG, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_HAS_INTC_IF, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_MAX_COLS, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_ACTIVE_COLS, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_ACTIVE_ROWS, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_HAS_CLIP, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_HAS_CLAMP, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_ACOEF, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_BCOEF, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CCOEF, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_DCOEF, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_YOFFSET, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CBOFFSET, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CROFFSET, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_YMAX, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_YMIN, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CBMAX, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CBMIN, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CRMAX, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_CRMIN, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_S_AXI_CLK_FREQ_HZ, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_STANDARD_SEL, + XPAR_HDMI_OUTPUT_V_RGB2YCRCB_1_OUTPUT_RANGE + } +}; + + diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h new file mode 100755 index 00000000..73193475 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h @@ -0,0 +1,371 @@ +/****************************************************************************** +* +* 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 xrgb2ycrcb_hw.h +* +* This header file contains identifiers and register-level driver functions (or +* macros) that can be used to access the Xilinx RGB to YCrCb color space +* converter (RGB2YCRCB) core. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- -----------------------------------------------------
+* 7.0   adk    01/28/14 First release.
+*                       Added the register offsets and bit masks for the
+*                       registers.
+*                       Added backward compatibility macros.
+*
+* +******************************************************************************/ + +#ifndef XRGB2YCRCB_HW_H_ +#define XRGB2YCRCB_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 RGB2YCRCB core. + * @{ + */ +#define XRGB_CONTROL_OFFSET 0x000 /**< Control offset */ +#define XRGB_STATUS_OFFSET 0x004 /**< Status offset */ +#define XRGB_ERROR_OFFSET 0x008 /**< Error offset */ +#define XRGB_IRQ_EN_OFFSET 0x00C /**< IRQ Enable offset */ +#define XRGB_VERSION_OFFSET 0x010 /**< Version offset */ +#define XRGB_SYSDEBUG0_OFFSET 0x014 /**< System Debug 0 offset */ +#define XRGB_SYSDEBUG1_OFFSET 0x018 /**< System Debug 1 offset */ +#define XRGB_SYSDEBUG2_OFFSET 0x01C /**< System Debug 2 offset */ +/*@}*/ + +/** @name Timing Control Registers + * + * Timing control registers offset for RGB2YCRCB core. + * @{ + */ +#define XRGB_ACTIVE_SIZE_OFFSET 0x020 /**< Active Size (V x H) + * offset */ +/*@}*/ + +/** @name Core Specific Registers + * + * Core specific registers offset. + * @{ + */ +#define XRGB_YMAX_OFFSET 0x100 /**< Luma Clipping offset */ +#define XRGB_YMIN_OFFSET 0x104 /**< Luma Clamping offset */ +#define XRGB_CBMAX_OFFSET 0x108 /**< Cb Clipping offset */ +#define XRGB_CBMIN_OFFSET 0x10C /**< Cb Clamping offset */ +#define XRGB_CRMAX_OFFSET 0x110 /**< Cr Clipping offset */ +#define XRGB_CRMIN_OFFSET 0x114 /**< Cr Clamping offset */ +#define XRGB_YOFFSET_OFFSET 0x118 /**< Luma Offset offset */ +#define XRGB_CBOFFSET_OFFSET 0x11C /**< Cb Offset offset */ +#define XRGB_CROFFSET_OFFSET 0x120 /**< Cr Offset offset */ +#define XRGB_ACOEF_OFFSET 0x124 /**< A Coefficient offset */ +#define XRGB_BCOEF_OFFSET 0x128 /**< B Coefficient offset */ +#define XRGB_CCOEF_OFFSET 0x12C /**< C Coefficient offset */ +#define XRGB_DCOEF_OFFSET 0x130 /**< D Coefficient offset */ +/*@}*/ + +/** @name Control Register Bit Masks + * + * Control Register bit definition for RGB2YCRCB core. + * @{ + */ +#define XRGB_CTL_SW_EN_MASK 0x00000001 /**< Software Enable Mask */ +#define XRGB_CTL_RUE_MASK 0x00000002 /**< Register Update + * Enable Mask */ +#define XRGB_CTL_BPE_MASK 0x00000010 /**< Bypass Mask */ +#define XRGB_CTL_TPE_MASK 0x00000020 /**< Test Pattern Mask */ +#define XRGB_CTL_AUTORESET_MASK 0x40000000 /**< Software Reset - + * Auto-synchronize + * to SOF Mask */ +#define XRGB_CTL_RESET_MASK 0x80000000 /**< Software Reset - + * Instantaneous Mask */ +/*@}*/ + +/** @name Slave Error Bit Masks + * @{ + */ +#define XRGB_ERR_EOL_EARLY_MASK 0x000000001 /** +* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ----- -------- --------------------------------------------------- +* 7.0 adk 01/28/14 First release. +* Implemented the following functions: +* XRgb2YCrCb_IntrHandler, +* XRgb2YCrCb_SetCallBack. +* +* +******************************************************************************/ + +#include "xrgb2ycrcb.h" + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/**************************** Type Definitions *******************************/ + + +/************************** Function Prototypes ******************************/ + + +/************************** Variable Definitions *****************************/ + + +/************************** Function Definitions *****************************/ + +/*****************************************************************************/ +/** +* +* This function is the interrupt handler for the RGB2YCRCB driver. +* +* 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 +* XRgb2YCrCb_SetCallBack() during initialization phase. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance that just +* interrupted. +* +* @return None. +* +* @note Interrupt interface (HasIntcIf) should be enabled. +* +******************************************************************************/ +void XRgb2YCrCb_IntrHandler(void *InstancePtr) +{ + u32 PendingIntr; + u32 ErrorStatus; + XRgb2YCrCb *XRgb2YCrCbPtr = NULL; + + XRgb2YCrCbPtr = (XRgb2YCrCb *)((void *)InstancePtr); + + /* Verify arguments. */ + Xil_AssertVoid(XRgb2YCrCbPtr != NULL); + Xil_AssertVoid(XRgb2YCrCbPtr->IsReady == + (u32)(XIL_COMPONENT_IS_READY)); + Xil_AssertVoid(XRgb2YCrCbPtr->Config.HasIntcIf != (u16)0x0); + + /* Get pending interrupts */ + PendingIntr = (u32)XRgb2YCrCb_IntrGetPending(XRgb2YCrCbPtr); + + /* Slave error interrupt has occurred */ + if (((PendingIntr) & (XRGB_IXR_SE_MASK)) == (XRGB_IXR_SE_MASK)) { + + ErrorStatus = (PendingIntr) & (XRGB_IXR_SE_MASK); + XRgb2YCrCbPtr->ErrCallBack(XRgb2YCrCbPtr->ErrRef, ErrorStatus); + } + + /* A processing start interrupt has occurred */ + if (((PendingIntr) & (XRGB_IXR_PROC_STARTED_MASK)) == + (XRGB_IXR_PROC_STARTED_MASK)) { + XRgb2YCrCbPtr->ProcStartCallBack(XRgb2YCrCbPtr->ProcStartRef); + } + + /* A frame done interrupt has occurred */ + if (((PendingIntr) & (XRGB_IXR_EOF_MASK)) == (XRGB_IXR_EOF_MASK)) { + XRgb2YCrCbPtr->FrameDoneCallBack(XRgb2YCrCbPtr->FrameDoneRef); + } + + /* Clear pending interrupt(s) */ + XRgb2YCrCb_IntrClear(XRgb2YCrCbPtr, PendingIntr); +} + +/*****************************************************************************/ +/** +* +* This routine installs an asynchronous callback function for the given +* HandlerType: +* +*
+* HandlerType              Callback Function Type
+* -----------------------  --------------------------------------------------
+* XRGB_HANDLER_PROCSTART   ProcStartCallBack
+* XRGB_HANDLER_FRAMEDONE   FrameDoneCallBack
+* XRGB_HANDLER_ERROR       ErrCallBack
+*
+* +* @param InstancePtr is a pointer to the XRgb2YCrCb 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 XRgb2YCrCb_SetCallBack(XRgb2YCrCb *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)(XRGB_HANDLER_PROCSTART)) && + (HandlerType <= (u32)(XRGB_HANDLER_ERROR))); + + /* Sets the callback according to HandlerType */ + switch (HandlerType) { + case XRGB_HANDLER_PROCSTART: + InstancePtr->ProcStartCallBack = + (XRgb2YCrCb_CallBack)((void *)CallBackFunc); + InstancePtr->ProcStartRef = CallBackRef; + Status = (XST_SUCCESS); + break; + + case XRGB_HANDLER_FRAMEDONE: + InstancePtr->FrameDoneCallBack = + (XRgb2YCrCb_CallBack)((void *)CallBackFunc); + InstancePtr->FrameDoneRef = CallBackRef; + Status = (XST_SUCCESS); + break; + + case XRGB_HANDLER_ERROR: + InstancePtr->ErrCallBack = + (XRgb2YCrCb_ErrorCallBack)((void *)CallBackFunc); + InstancePtr->ErrRef = CallBackRef; + Status = (XST_SUCCESS); + break; + + default: + Status = (XST_INVALID_PARAM); + break; + } + + return Status; +} diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c new file mode 100755 index 00000000..af02a97c --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c @@ -0,0 +1,108 @@ +/****************************************************************************** +* +* 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 xrgb2ycrcb_selftest.c +* +* This file contains the self-test function for the RGB2YCRCB core. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- --------------------------------------------------
+* 7.0   adk    01/28/14 First Release.
+*                       Implemented the following function:
+*                       XRgb2YCrCb_SelfTest.
+* 
+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xrgb2ycrcb.h" + +/************************** Constant Definitions *****************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/**************************** Type Definitions *******************************/ + + +/************************** Function Prototypes ******************************/ + + +/************************** Variable Definitions *****************************/ + + +/************************** Function Definitions *****************************/ + +/*****************************************************************************/ +/** +* +* This function reads version register of RGB2YCRCB core and compares with zero +* as part of self test. +* +* @param InstancePtr is a pointer to the XRgb2YCrCb instance. +* +* @return +* - XST_SUCCESS if the version register read test was successful. +* - XST_FAILURE if the version register read test failed. +* +* @note None. +* +******************************************************************************/ +int XRgb2YCrCb_SelfTest(XRgb2YCrCb *InstancePtr) +{ + u32 Version; + int Status; + + /* Verify argument. */ + Xil_AssertNonvoid(InstancePtr != NULL); + + /* Read RGB2YCRCB core version register. */ + Version = XRgb2YCrCb_ReadReg(InstancePtr->Config.BaseAddress, + (XRGB_VERSION_OFFSET)); + + /* Compare Version with zero */ + if (Version != (u32)0x0) { + Status = (XST_SUCCESS); + } + else { + Status = (XST_FAILURE); + } + + return Status; +} diff --git a/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c new file mode 100755 index 00000000..a0d611b9 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_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 xrgb2ycrcb_sinit.c +* +* This file contains static initialization function for RGB2YCRCB core. +* +*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date     Changes
+* ----- ------ -------- --------------------------------------------------
+* 7.0   adk    01/28/14 First release.
+*                       Implemented following function:
+*                       XRgb2YCrCb_LookupConfig.
+* 
+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xrgb2ycrcb.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 XRgb2YCrCb_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 xrgb2ycrcb_g.c +* file. +* +* @param DeviceId is the unique core ID of the core for the lookup +* operation. +* +* @return XRgb2YCrCb_LookupConfig returns a reference to a config record +* in the configuration table (in xrgb2ycrcb_g.c) corresponding to +* DeviceId, or NULL if no match is found. +* +* @note None. +* +******************************************************************************/ +XRgb2YCrCb_Config *XRgb2YCrCb_LookupConfig(u16 DeviceId) +{ + u32 Index; + XRgb2YCrCb_Config *CfgPtr = NULL; + extern XRgb2YCrCb_Config + XRgb2YCrCb_ConfigTable[XPAR_RGB2YCRCB_NUM_INSTANCES]; + + /* Get the reference pointer to XRgb2YCrCb_Config structure */ + for (Index = (u32)0x0; Index < (u32)(XPAR_RGB2YCRCB_NUM_INSTANCES); + Index++) { + + /* Compare device Id with configTable's device Id */ + if (XRgb2YCrCb_ConfigTable[Index].DeviceId == DeviceId) { + CfgPtr = &XRgb2YCrCb_ConfigTable[Index]; + break; + } + } + + return (XRgb2YCrCb_Config *)CfgPtr; +}