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 <shaduls@xilinx.com> Acked-by: Srikanth Vemula <svemula@xilinx.com>
This commit is contained in:
parent
54d7a3f1da
commit
b52598a34e
15 changed files with 3550 additions and 918 deletions
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 5.00a tb 02/27/12 Updates for the v5.00.a release
|
||||
* </pre>
|
||||
*
|
||||
* ***************************************************************************
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +1,21 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver rgb2ycrcb_v6_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>example.c <a href="example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright <20> 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver rgb2ycrcb_v7_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>rgb2ycrcb_selftest_example.c <a href="rgb2ycrcb_selftest_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>rgb2ycrcb_example.c <a href="rgb2ycrcb_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright ? 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
217
XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c
Executable file
217
XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_example.c
Executable file
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 7.00 adk 07/07/14 First release.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
149
XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_selftest_example.c
Executable file
149
XilinxProcessorIPLib/drivers/rgb2ycrcb/examples/rgb2ycrcb_selftest_example.c
Executable file
|
@ -0,0 +1,149 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file rgb2ycrcb_selftest_example.c
|
||||
*
|
||||
* This file contains an example using the XRgb2YCrCb driver to do self test
|
||||
* on the device.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 7.0 adk 01/20/14 First Release.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** 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;
|
||||
}
|
|
@ -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<<data_width)-1)};
|
||||
u32 min[3] = { (16*(1<<(data_width-8))), (16*(1<<(data_width-8))), 0};
|
||||
|
||||
coef_in->acoef = acoef[standard_sel][input_range];
|
||||
coef_in->bcoef = bcoef[standard_sel][input_range];
|
||||
coef_in->ccoef = ccoef[standard_sel][input_range];
|
||||
coef_in->dcoef = dcoef[standard_sel][input_range];
|
||||
coef_in->yoffset = yoffset;
|
||||
coef_in->cboffset = coffset;
|
||||
coef_in->croffset = coffset;
|
||||
coef_in->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<<data_width) || coef_in->yoffset > (1<<data_width)-1) {
|
||||
printf("WARNING: Y Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)coef_in->yoffset, (unsigned int)-(1<<data_width), (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x2;
|
||||
}
|
||||
if(coef_in->cboffset < -(1<<data_width) || coef_in->cboffset > (1<<data_width)-1) {
|
||||
printf("WARNING: Cb Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)coef_in->cboffset, (unsigned int)-(1<<data_width), (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x4;
|
||||
}
|
||||
if(coef_in->croffset < -(1<<data_width) || coef_in->croffset > (1<<data_width)-1) {
|
||||
printf("WARNING: Cr Offset (%u) is outside the data width range [%u, %u]\r\n",
|
||||
(unsigned int)coef_in->croffset, (unsigned int)-(1<<data_width), (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x8;
|
||||
}
|
||||
if(coef_in->ymax < 0 || coef_in->ymax > (1<<data_width)-1) {
|
||||
printf("WARNING: Y Max (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->ymax, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x10;
|
||||
}
|
||||
if(coef_in->ymin < 0 || coef_in->ymin > (1<<data_width)-1) {
|
||||
printf("WARNING: Y Min (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->ymin, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x20;
|
||||
}
|
||||
if(coef_in->cbmax < 0 || coef_in->cbmax > (1<<data_width)-1) {
|
||||
printf("WARNING: Cb Max (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->cbmax, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x40;
|
||||
}
|
||||
if(coef_in->cbmin < 0 || coef_in->cbmin > (1<<data_width)-1) {
|
||||
printf("WARNING: Cb Min (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->cbmin, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x80;
|
||||
}
|
||||
if(coef_in->crmax < 0 || coef_in->crmax > (1<<data_width)-1) {
|
||||
printf("WARNING: Cr Max (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->crmax, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x100;
|
||||
}
|
||||
if(coef_in->crmin < 0 || coef_in->crmin > (1<<data_width)-1) {
|
||||
printf("WARNING: Cr Min (%u) is outside the data width range [0, %u]\r\n",
|
||||
(unsigned int)coef_in->crmin, (unsigned int)(1<<data_width)-1);
|
||||
ret_val = ret_val | 0x200;
|
||||
}
|
||||
|
||||
coef_out->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);
|
||||
|
||||
}
|
|
@ -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 */
|
1436
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c
Executable file
1436
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c
Executable file
File diff suppressed because it is too large
Load diff
840
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h
Executable file
840
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.h
Executable file
|
@ -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.
|
||||
*
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* <b> Interrupts </b>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* <b> Virtual Memory </b>
|
||||
*
|
||||
* This driver supports Virtual Memory. The RTOS is responsible for calculating
|
||||
* the correct device base address in Virtual Memory space.
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The 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.
|
||||
*
|
||||
*<pre>
|
||||
* 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.
|
||||
*</pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#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 */
|
87
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c
Executable file
87
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_g.c
Executable file
|
@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
371
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h
Executable file
371
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_hw.h
Executable file
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
* 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.
|
||||
*</pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#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 /**<Error: End of line Early
|
||||
* Mask */
|
||||
#define XRGB_ERR_EOL_LATE_MASK 0x000000002 /**<Error: End of line Late
|
||||
* Mask */
|
||||
#define XRGB_ERR_SOF_EARLY_MASK 0x000000004 /**<Error: Start of frame
|
||||
* Early Mask */
|
||||
#define XRGB_ERR_SOF_LATE_MASK 0x000000008 /**<Error: Start of frame
|
||||
* Late Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name Interrupt Register Bit Masks
|
||||
*
|
||||
* Interrupt Register bit definition for RGB2YCRCB core. It is applicable for
|
||||
* STATUS and IRQ_ENABLE Registers.
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_IXR_PROC_STARTED_MASK 0x00000001 /**< Process Started
|
||||
* Mask */
|
||||
#define XRGB_IXR_EOF_MASK 0x00000002 /**< End-Of-Frame
|
||||
* Mask */
|
||||
#define XRGB_IXR_SE_MASK 0x00010000 /**< Slave Error
|
||||
* Mask */
|
||||
#define XRGB_IXR_ALLINTR_MASK 0x00010003 /**< Interrupt All
|
||||
* Error Mask (ORing
|
||||
* (of All Interrupt
|
||||
* Mask) */
|
||||
/*@}*/
|
||||
|
||||
/** @name Version Register Bit Masks and Shifts
|
||||
*
|
||||
* Version Register bit definition for RGB2YCRCB core.
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_VER_REV_NUM_MASK 0x000000FF /**< Revision Number Mask */
|
||||
#define XRGB_VER_PID_MASK 0x00000F00 /**< Patch ID Mask */
|
||||
#define XRGB_VER_REV_MASK 0x0000F000 /**< Revision Mask */
|
||||
#define XRGB_VER_MINOR_MASK 0x00FF0000 /**< Minor Mask */
|
||||
#define XRGB_VER_MAJOR_MASK 0xFF000000 /**< Major Mask */
|
||||
#define XRGB_VER_MAJOR_SHIFT 24 /**< Major Shift */
|
||||
#define XRGB_VER_MINOR_SHIFT 16 /**< Minor Shift */
|
||||
#define XGMA_VER_REV_SHIFT 12 /**< Revision Shift */
|
||||
#define XRGB_VER_INTERNAL_SHIFT 8 /**< Internal Shift */
|
||||
/*@}*/
|
||||
|
||||
/** @name ActiveSize Register Bit Masks and Shift
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_ACTSIZE_NUM_PIXEL_MASK 0x00001FFF /**< The number of pixels
|
||||
* in source image */
|
||||
#define XRGB_ACTSIZE_NUM_LINE_MASK 0x1FFF0000 /**< The number of lines in
|
||||
* source image */
|
||||
#define XRGB_ACTSIZE_NUM_LINE_SHIFT 16 /**< Shift for number of
|
||||
* lines */
|
||||
/*@}*/
|
||||
|
||||
/** @name YMax Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_YMAX_MASK 0x0000FFFF /**< Luma clipping value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name YMin Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_YMIN_MASK 0x0000FFFF /**< Luma clamping value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CBMax Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CBMAX_MASK 0x0000FFFF /**< Chroma Cb clipping value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CBMin Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CBMIN_MASK 0x0000FFFF /**< Chroma Cb clamping value mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CRMax Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CRMAX_MASK 0x0000FFFF /**< Chroma Cr clipping value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CRMin Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CRMIN_MASK 0x0000FFFF /**< Chroma Cr clamping value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name YOffset Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_YOFFSET_MASK 0x0001FFFF /**< Luma offset compensation
|
||||
* value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CbOffset Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CBOFFSET_MASK 0x0001FFFF /**< Chroma(Cb) offset
|
||||
* compensation value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name CrOffset Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_CROFFSET_MASK 0x0001FFFF /**< Chroma(Cr) offset
|
||||
* compensation value Mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name ACOEF, BCOEF, CCOEF, DCOEF Register Bit Mask
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_COEFF_MASK 0x0001FFFF /**< Matrix Conversion
|
||||
* Coefficient value mask */
|
||||
/*@}*/
|
||||
|
||||
/** @name General purpose Bit Mask and Shifts
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_8_BIT_MASK 0x000000FF /**< 8-Bit mask */
|
||||
#define XRGB_16_BIT_MASK 0x0000FFFF /**< 16-Bit mask */
|
||||
#define XRGB_16_BIT_COEF_SHIFT 16 /**< 16-Bit Coefficient
|
||||
* shift */
|
||||
/*@}*/
|
||||
|
||||
/** @name Data widths in bits per color.
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_DATA_WIDTH_8 8 /**< 8-bit Data Width */
|
||||
#define XRGB_DATA_WIDTH_10 10 /**< 10-bit Data Width */
|
||||
#define XRGB_DATA_WIDTH_12 12 /**< 12-bit Data Width */
|
||||
#define XRGB_DATA_WIDTH_16 16 /**< 16-bit Data Width */
|
||||
/*@}*/
|
||||
|
||||
/**@name Backward Compatibility Macros
|
||||
*
|
||||
* To support backward compatibility, following macro definitions are
|
||||
* re-defined.
|
||||
* @{
|
||||
*/
|
||||
#define RGB_CONTROL XRGB_CONTROL_OFFSET
|
||||
#define RGB_STATUS XRGB_STATUS_OFFSET
|
||||
#define RGB_ERROR XRGB_ERROR_OFFSET
|
||||
#define RGB_IRQ_EN XRGB_IRQ_EN_OFFSET
|
||||
#define RGB_VERSION XRGB_VERSION_OFFSET
|
||||
#define RGB_SYSDEBUG0 XRGB_SYSDEBUG0_OFFSET
|
||||
#define RGB_SYSDEBUG1 XRGB_SYSDEBUG1_OFFSET
|
||||
#define RGB_SYSDEBUG2 XRGB_SYSDEBUG2_OFFSET
|
||||
#define RGB_ACTIVE_SIZE XRGB_ACTIVE_SIZE_OFFSET
|
||||
#define RGB_YMAX XRGB_YMAX_OFFSET
|
||||
#define RGB_YMIN XRGB_YMIN_OFFSET
|
||||
#define RGB_CBMAX XRGB_CBMAX_OFFSET
|
||||
#define RGB_CBMIN XRGB_CBMIN_OFFSET
|
||||
#define RGB_CRMAX XRGB_CRMAX_OFFSET
|
||||
#define RGB_CRMIN XRGB_CRMIN_OFFSET
|
||||
#define RGB_YOFFSET XRGB_YOFFSET_OFFSET
|
||||
#define RGB_CBOFFSET XRGB_CBOFFSET_OFFSET
|
||||
#define RGB_CROFFSET XRGB_CROFFSET_OFFSET
|
||||
#define RGB_ACOEF XRGB_ACOEF_OFFSET
|
||||
#define RGB_BCOEF XRGB_BCOEF_OFFSET
|
||||
#define RGB_CCOEF XRGB_CCOEF_OFFSET
|
||||
#define RGB_DCOEF XRGB_DCOEF_OFFSET
|
||||
#define RGB_CTL_EN_MASK XRGB_CTL_EN_MASK
|
||||
#define RGB_CTL_RUE_MASK XRGB_CTL_RUE_MASK
|
||||
#define RGB_RST_RESET XRGB_CTL_RESET_MASK
|
||||
#define RGB_RST_AUTORESET XRGB_CTL_AUTORESET_MASK
|
||||
#define RGB_In32 XRgb2YCrCb_In32
|
||||
#define RGB_Out32 XRgb2YCrCb_Out32
|
||||
/* @}*/
|
||||
|
||||
/** @name Interrupt Registers
|
||||
*
|
||||
* Interrupt status register generates a interrupt if the corresponding bits
|
||||
* of interrupt enable register bits are set.
|
||||
* @{
|
||||
*/
|
||||
#define XRGB_ISR_OFFSET XRGB_STATUS_OFFSET /**< Interrupt Status Offset */
|
||||
#define XRGB_IER_OFFSET XRGB_IRQ_EN_OFFSET /**< Interrupt Enable Offset */
|
||||
/*@}*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
#define XRgb2YCrCb_In32 Xil_In32 /**< Input operation */
|
||||
#define XRgb2YCrCb_Out32 Xil_Out32 /**< Output operation */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro reads the given register.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx base address of the RGB2YCRCB core.
|
||||
* @param RegOffset is the register offset of the register (defined at
|
||||
* top of this file).
|
||||
*
|
||||
* @return 32-bit value of the register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XRgb2YCrCb_ReadReg(u32 BaseAddress, u32 RegOffset)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XRgb2YCrCb_ReadReg(BaseAddress, RegOffset) \
|
||||
XRgb2YCrCb_In32((BaseAddress) + (u32)(RegOffset))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function macro writes the given register.
|
||||
*
|
||||
* @param BaseAddress is the Xilinx base address of the RGB2YCRCB core.
|
||||
* @param RegOffset is the register offset of the register (defined at
|
||||
* top of this file).
|
||||
* @param Data is the 32-bit value to write to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XRgb2YCrCb_WriteReg(u32 BaseAddress, u32 RegOffset,
|
||||
* u32 Data)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XRgb2YCrCb_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
XRgb2YCrCb_Out32((BaseAddress) + (u32)(RegOffset),(u32)(Data))
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Declarations ****************************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of protection macro */
|
202
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_intr.c
Executable file
202
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_intr.c
Executable file
|
@ -0,0 +1,202 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* 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_intr.c
|
||||
*
|
||||
* This file contains interrupt related functions for the RGB2YCRCB core.
|
||||
* Please see xrgb2crcb.h for more details of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- ---------------------------------------------------
|
||||
* 7.0 adk 01/28/14 First release.
|
||||
* Implemented the following functions:
|
||||
* XRgb2YCrCb_IntrHandler,
|
||||
* XRgb2YCrCb_SetCallBack.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#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:
|
||||
*
|
||||
* <pre>
|
||||
* HandlerType Callback Function Type
|
||||
* ----------------------- --------------------------------------------------
|
||||
* XRGB_HANDLER_PROCSTART ProcStartCallBack
|
||||
* XRGB_HANDLER_FRAMEDONE FrameDoneCallBack
|
||||
* XRGB_HANDLER_ERROR ErrCallBack
|
||||
*</pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
108
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c
Executable file
108
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_selftest.c
Executable file
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- --------------------------------------------------
|
||||
* 7.0 adk 01/28/14 First Release.
|
||||
* Implemented the following function:
|
||||
* XRgb2YCrCb_SelfTest.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** 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;
|
||||
}
|
110
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c
Executable file
110
XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb_sinit.c
Executable file
|
@ -0,0 +1,110 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xrgb2ycrcb_sinit.c
|
||||
*
|
||||
* This file contains static initialization function for RGB2YCRCB core.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- --------------------------------------------------
|
||||
* 7.0 adk 01/28/14 First release.
|
||||
* Implemented following function:
|
||||
* XRgb2YCrCb_LookupConfig.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** 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, <i>DeviceId</i>. 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
|
||||
* <i>DeviceId</i>, 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue