scaler: Added integration files.

Added integration files to scaler.

Signed-off-by: Durga challa <vnsldurg@xilinx.com>
This commit is contained in:
Durga challa 2014-08-22 18:58:36 +05:30 committed by Jagannadha Sutradharudu Teki
parent 93cb2b2a2e
commit 4b76b9679b
8 changed files with 2164 additions and 0 deletions

View file

@ -0,0 +1,275 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2008 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file ct.h
*
* Code test (CT) utility driver.
*
* This package is intented to help designers test their Xilinx device drivers
* in unit and integration testing environments. The macros and functions
* provide the following services:
*
* - Automated data comparison
* - Xilinx driver assert testing
* - Interrupt utilities
* - Error & message logging
* - Test sequencing utilities
* - Timing utilities
*
* The main benefit of this package is to simplify test code and make it easier
* for the tester to get more coverage in their integration and unit testing
* without having to replicate common testing constructs.
*
* <b>Integrating CT Source code</b>
*
* This package consists of this header file and an implementation file. The
* implementation can be operating system specific. When including this package
* in your test, use this file and one of the CT implementation files such as
* ct_vxworks.c.
*
* There are GNU specific "C" extensions used in this package and as a result
* make it non-ANSI compliant. The tester must compile this package and their
* other test code with the GNU compiler suite.
*
* The CT package requires that there be available standard header files
* stdio.h, string.h, and stdarg.h.
*
*
* <b>Setup and Test Sequencing</b>
*
* Before calling any comparison or utility function in this package, the tester
* should call CT_Init() to initialize the library. This function only needs to
* be called once.
*
* During tests, your code may be segmented into subtests where you would want
* separate out the results. At the end of all subtests, you may want to
* summarize all the tests run. The following pseudo code shows how this is done
* with CT sequencing function calls:
*
* <pre>
*
* CT_Init();
*
* // Subtest #1
* CT_TestReset("This is my Subtest #1");
* ...
* // Subtest code
* ...
* Failures = CT_GetTestFailures();
* CT_Message("Subtest #1 had %d failures\n", Failures);
*
* // Subtest #2
* CT_TestReset("This is my Subtest #2");
* ...
* // Subtest code
* ...
* Failures = CT_GetTestFailures();
* CT_Message("Subtest #2 had %d failures\n", Failures);
*
* Failures = CT_GetTotalFailures();
* CT_Message("Total test failures = %d\n", Failures);
*
* </pre>
*
* <b>General Usage</b>
*
* The heart of this package utilizes macros to compare variables or memory
* areas. For example,
*
* <pre>
*
* CT_CMP_NUM(int, ActualValue, ExpectedValue);
*
* </pre>
*
* compares two values of type int. If they are not equal, then an error message
* is logged and an internal counter is incremented. If they are equal, then the
* test proceeds as if nothing had occurred. Other examples:
*
* <pre>
*
* CT_CMP_NUM(int, *ActualPtr, 5);
* CT_CMP_NUM(int*, ActualPtr, 0x20002100);
*
* </pre>
*
* With each failure, a descriptive message is printed along with the line
* number of the invoking code.
*
* If the tester needs to make a comparison manually, then they can use the
* CT_LOG_FAILURE() macro to note the error in case the comparison is negative.
* If the tester needs to emit an informational message, then they can use the
* CT_Mesage() function. Calling this function does not increment error
* counters.
*
*
* <b>Message Logging</b>
*
* This package uses the printf() library for message logging.
*
* Ideally, the tester's environment should include some sort of UART. By
* default CT utilizes a pre configured console UART.
*
* If your system does not contain a UART, then another method of providing
* results includes printf'ing messages to memory. To enable this method,
* enable the definition of IO_USE_BUFFER in this file. To further tailor this
* method of logging, change IO_BUF_SIZE and IO_BUF_CUSHION. All output will
* be written to the TextBuf array. Use your debugger or your own test
* utilities to examine this buffer for generated output.
*
*
* <b>Limitations</b>
*
* - This package must be compiled under the GNU compiler suite.
* - CT_CMP macros can compare only ordinal data types. Structure type
* comparisons require the tester to implement their own function.
* - Some sort of BSP is required to support implementation of string.h,
* stdio.h, and stdarg.h at a minimum.
* - Advanced BSP support of signal.h is required to use CT_SetAlarm().
* If support is not available, then this function will return an error.
* - Testing asserts requires that NDEBUG not be defined in your driver under
* test code.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* --- ---- -------- -----------------------------------------------
* 1 rmm 12/23/03 First release for VxWorks
* </pre>
*
******************************************************************************/
#ifndef CT_H
#define CT_H
/***************************** Include Files *********************************/
#include "xil_types.h" /* Needed for assert testing */
#include "xil_assert.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
/************************** Constant Definitions *****************************/
/*
* This is what the CT_Log* lines will be prepended with. The numerical arg
* should be the line number within the source file containing the call to
* the CT library function or macro.
*/
#define CT_ERR_FMT "FAIL: %04d: "
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/*****************************************************************************/
/**
*
* Log a failure with a supplied message. This provides a useful wrapper
* around the CT_LogFailure function that prints messages of the same format
* as other CT macros:
*
* <pre>
* 1 int i;
* 2
* 3 i = 10;
* 4 if (i != 5)
* 5 {
* 6 CT_LOG_FAILURE("GetDataFromDevice() returned %d instead of 5", i);
* 7 CT_LOG_FAILURE("D'oh");
* 8 }
*
* yields the output:
*
* FAIL: 0006: GetDataFromDevice() returned 10 instead of 5
* FAIL: 0007: D'oh
* </pre>
*
* @param fmt is a printf style format string
* @param args is a variable argument list that matches fields in the
* fmt string.
* @note
* Usage: CT_LOG_FAILURE(char* fmt, ...)
*
*****************************************************************************/
#define CT_LOG_FAILURE(fmt, args...) \
CT_LogFailure(CT_ERR_FMT fmt "\n", __LINE__ , ## args)
/*****************************************************************************/
/**
*
* Compare numbers. If not equal, then output message and increment fail
* counter. The message contains the line number of the failure, the
* name of the variable, and its actual and expected values in hex and
* decimal. An example:
*
* <pre>
* 1 UINT32 result = 5;
* 2 UINT32 expected = 17;
* 3
* 4 CT_CMP_NUM(UINT32, result, expected)
*
* yields the output:
*
* FAIL: 0004: result=5(5h), expected 17(11h)
*
* </pre>
*
* @param type is data type to compare (must be an ordinal type such as
* int)
* @param actual is the actual data retrieved from test
* @param expected is the expected value
*
* @note Usage: CT_CMP_NUM(<type>, actual, expected)
*
****************************************************************************/
#define CT_CMP_NUM(type, actual, expected) \
if ((type)(actual) != (type)(expected)) \
{ \
CT_LogFailure(CT_ERR_FMT "%s=%d(%Xh), expected %d(%Xh)\n", \
__LINE__, #actual, (int)actual, (int)actual, \
(int)expected, (int)expected); \
}
/************************** Function Prototypes ******************************/
void CT_Init(void);
void CT_TestReset(char *fmt, ...);
void CT_NotifyNextPass(void);
void CT_LogFailure(char* fmt, ...);
unsigned CT_GetTestFailures(void);
unsigned CT_GetTotalFailures(void);
void CT_Message(char *fmt, ...);
void CT_MemSet(void *Address, char Value, unsigned Bytes);
int CT_IsAssertDisabled(void);
void CT_VerboseOn(void);
void CT_VerboseOff(void);
int CT_GetUserInput(char* Prompt, char* Response, int MaxChars);
extern char inbyte(void); /* Implemented by standalone BSP */
extern void outbyte(char); /* Implemented by standalone BSP */
#endif /* CT_H */

View file

@ -0,0 +1,366 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file ct_standalone.c
*
* Implements Code test (CT) utility driver. Test.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- -----------------------------------------------
* 7.0 adk 01/09/14 First release.
* </pre>
*
******************************************************************************/
/***************************** Include Files *********************************/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include "ct.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
/************************** Variable Definitions *****************************/
unsigned CT_TotalFailures;
unsigned CT_TestFailures;
unsigned CT_TestPass;
static int Verbose = 0; /* Verbosity flag */
/*****************************************************************************/
/**
*
* Initialize the CT subsystem.
*
* @return None
*
******************************************************************************/
void CT_Init(void)
{
CT_TestFailures = 0;
CT_TotalFailures = 0;
CT_TestPass = 0;
}
/*****************************************************************************/
/**
*
* Reset for a new test and display a test specific message. This involves:
*
* - Zero out test failure counter.
* - Print a message specified by the fmt parameter and its associated
* arguments.
*
* @param Fmt is a "printf" style format string.
* @param ... is a variable number of arguments that match "Fmt"
*
* @return None
*
******************************************************************************/
void CT_TestReset(char *Fmt, ...)
{
va_list Args;
CT_TestFailures = 0;
CT_TestPass = 1;
/*
* Print out the format and its associated argument list
*/
va_start(Args, Fmt);
vprintf(Fmt, Args);
CT_Message("\n========================================================");
va_end(Args);
CT_Message("\n");
}
/*****************************************************************************/
/**
* Display current test pass number to user
*
* @return None
*
******************************************************************************/
void CT_NotifyNextPass(void)
{
CT_Message("\n=====>Pass %d\n", CT_TestPass++);
}
/*****************************************************************************/
/**
*
* Log a test failure. This involves incrementing test failure and total test
* failure counters, and displaying test specific message.
*
* @param Fmt is a "printf" style format string.
* @param ... is a variable number of arguments that match "fmt"
*
* @return None
*
******************************************************************************/
void CT_LogFailure(char* Fmt, ...)
{
va_list Args;
/*
* Increment failure counters
*/
CT_TestFailures++;
CT_TotalFailures++;
/*
* Print out the format and its associated argument list.
*/
va_start(Args, Fmt);
vprintf(Fmt, Args);
va_end(Args);
}
/*****************************************************************************/
/**
*
* Return the number of test failures since CT_TestReset() was called.
*
* @return Number of failures logged.
*
******************************************************************************/
unsigned CT_GetTestFailures(void)
{
return(CT_TestFailures);
}
/*****************************************************************************/
/**
*
* Return the number of test failures since CT_Init() was called.
*
* @return Total number of failures logged.
*
******************************************************************************/
unsigned CT_GetTotalFailures(void)
{
return(CT_TotalFailures);
}
/*****************************************************************************/
/**
* Return status of the Xilinx driver assert mechanism.
*
* @return 1 if asserts are disabled, 0 otherwise
*
*****************************************************************************/
int CT_IsAssertDisabled(void)
{
#ifdef NDEBUG
return(1);
#else
return(0);
#endif
}
/*****************************************************************************/
/**
*
* Print a message based on the given format string and parameters.
*
* @param Fmt is a "printf" style format string.
* @param ... is a variable number of arguments that match "fmt"
*
* @return None
*
******************************************************************************/
void CT_Message(char *Fmt, ...)
{
va_list Args;
va_start(Args, Fmt);
vprintf(Fmt, Args);
va_end(Args);
}
/*****************************************************************************/
/**
*
* Set a series of bytes in memory to a specific value
*
* @param AddressPtr is the start address in memory to write
* @param Value is the value to set memory to
* @param Bytes is the number of bytes to set
*
* @return None
*
******************************************************************************/
void CT_MemSet(void *AddressPtr, char Value, unsigned Bytes)
{
char* AdrPtr = AddressPtr;
while(Bytes--)
{
*AdrPtr++ = Value;
}
}
/*****************************************************************************/
/**
*
* Retrieve a line of input from the user. A line is defined as all characters
* up to a new line.
*
* @param PromptPtr Printed before string is accepted to que the user to
* enter something.
*
* @param ResponsePtr Null terminated string with new line stripped
*
* @param MaxChars Maximum number of characters to read (excluding null)
*
* @return Number of characters read (excluding new line)
*
* @note None
*
******************************************************************************/
int CT_GetUserInput(char* PromptPtr, char* ResponsePtr, int MaxChars)
{
u32 Index;
u8 Finished;
/*
* Display prompt
*/
if (PromptPtr) printf(PromptPtr);
/*
* This basically implements a fgets function. The standalone EDK stdin
* is apparently buggy because it behaves differently when new line is
* entered by itself vs. when it is entered after a number of regular chars
* have been entered.Characters entered are echoed back.
*/
Finished = 0;
Index = 0;
while(!Finished)
{
/*
* Flush out any output pending in stdout
*/
fflush(stdout);
/*
* Wait for a character to arrive
*/
ResponsePtr[Index] = inbyte();
/*
* Normal chars, add them to the string and keep going
*/
if ((ResponsePtr[Index] >= 0x20) && (ResponsePtr[Index] <=0x7E))
{
printf("%c", ResponsePtr[Index++]);
continue;
}
/*
* Control chars
*/
switch(ResponsePtr[Index])
{
/*
* Carriage return
*/
case '\r':
case '\n':
ResponsePtr[Index] = 0;
Finished = 1;
printf("\n");
break;
/*
* Backspace
*/
case 0x08:
if (Index != 0)
{
/*
* Erase previous character and move cursor back one space
*/
printf("\b \b");
ResponsePtr[--Index] = 0;
}
break;
/*
* Ignore all other control chars
*/
default:
continue;
}
}
return(Index);
}
/*****************************************************************************/
/**
*
* Enable output of CT_MessageV().
*
* @return None
*
* @note None
*
******************************************************************************/
void CT_VerboseOn(void)
{
Verbose = 1;
}
/*****************************************************************************/
/**
* Disable output of CT_MessageV().
*
* @return None
*
* @note None
*
******************************************************************************/
void CT_VerboseOff(void)
{
Verbose = 0;
}

View file

@ -0,0 +1,671 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file scaler_intg_basic.c
*
* @note
*
* This test works with Zynq702 system.
*
* <pre>
*
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- ---------------------------------------------
* 7.0 adk 22/08/14 First release.
* </pre>
*
******************************************************************************/
/***************************** Include Files *********************************/
#include "xscaler.h"
#include "xscaler_hw.h"
#include "xparameters.h"
#include "scaler_intgtest.h"
/************************** Constant Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *********************/
/*****************************************************************************/
/**
*
* Compare numbers. If not equal, then output message and increment fail
* counter. The message contains the line number of the failure, the
* name of the variable, and its actual and expected values in hex and
* decimal. If equal, display current test pass number to user.
* An example:
*
* <pre>
* 1 UINT32 result = 5;
* 2 UINT32 expected = 17;
* 3
* 4 CT_CMP_NUM(UINT32, result, expected)
*
* yields the output:
*
* FAIL: 0004: result=5(5h), expected 17(11h)
* </pre>
*
* @param Type is data type to compare (must be an ordinal type such
* as int)
* @param Val_16 is the actual data retrieved from test
* @param Val_32 is the expected value
*
* @note Usage: CT_CMP_NUM(<type>, actual, expected)
*
*****************************************************************************/
#define check_status_update(Type, Val_16, Val_32) \
if((Type)(Val_16) != (Type)(Val_32)){ \
CT_CMP_NUM(Type, XST_FAILURE, XST_SUCCESS); \
} \
else{ \
CT_NotifyNextPass(); \
} \
/**************************** Type Definitions *******************************/
#define round(x) ((x) >= 0 ? (s32)((x) + 0.5) : (s32)((x) - 0.5))
/************************** Function Prototypes ******************************/
/************************** Variable Definitions *****************************/
/************************** Function Definitions *****************************/
/*****************************************************************************/
/**
*
* This function executes the XScaler Self test.
*
* @param TestLoops is the number of times to execute test.
*
* @return Returns the total number of test failures.
*
* @note None.
*
******************************************************************************/
int Scaler_Intg_SelfTest(int TestLoops)
{
u32 Status = (u32)XST_SUCCESS;
double HoriScaleFactor;
double VertScaleFactor;
u32 OldScalerReg;
u32 NewScalerReg;
u32 LumaLeftH;
u32 LumaTopV;
u32 ChromaLeftH;
u32 ChromaTopV;
u32 OutSize;
u32 InLine;
u32 InPixel;
u32 SrcSize;
u32 QuantizedHoriSize;
u32 QuantizedVertSize;
u32 QuantizedInLastPixel;
u32 QuantizedInLastLine;
u32 PhaseRegValue;
u16 VertPhaseNum;
u16 HoriPhaseNum;
u8 ChromaFormat;
u8 ChromaLumaShareCoeff;
u8 HoriVertShareCoeff;
u8 VertSetIndex;
u8 HoriSetIndex;
u32 InLine_1;
u32 InPixel_1;
u32 OutSize_1 ;
u32 SrcSize_1 ;
double HoriScaleFactor_1;
double VertScaleFactor_1;
XScaler ScalerInst;
XScalerStartFraction StartFractionInst;
XScalerCoeffBank CoeffBankPtr;
XScalerAperture AperturePtr;
XScalerAperture AperturePtr_1;
XScaler_Config *Config;
CT_TestReset("Scaler Self Test .. ..");
while (TestLoops--) {
CT_NotifyNextPass();
/* Initialize the XScaler instance. */
Status = Scaler_Initialize(&ScalerInst, (u16)SCALER_0_DEVICE_ID);
if (Status != XST_SUCCESS) {
return Status;
}
/*****************************************************************************/
/* XScaler_GetVersion */
/*Test case 1 */
NewScalerReg = XScaler_GetVersion(&ScalerInst);
if (NewScalerReg != 0x00000000) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*Test case 3 */
// XScaler_GetVersion(Null);
/*****************************************************************************/
/* XScaler_Disable */
/*Test case 1 */
XScaler_Disable(&ScalerInst);
if (0x0 == ((XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_CTL_OFFSET)) & ~(XSCL_CTL_SW_EN_MASK))) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
// XScaler_Disable(&ScalerInst);
/*****************************************************************************/
/* XScaler_Enable */
/* check the bit 0 of control register, default is 0*/
/*Test case 1 */
XScaler_Enable(&ScalerInst);
if(0x00000001 == ((XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_CTL_OFFSET)) | (XSCL_CTL_SW_EN_MASK))){
check_status_update(u32, 1, 1);
}
else{
check_status_update(u32, 0, 1);
}
XScaler_Enable(&ScalerInst);
/*****************************************************************************/
/* XScaler_SetPhaseNum */
/* Test case 1*/
VertPhaseNum = 1;
ScalerInst.Config.MaxPhaseNum = 1;
HoriPhaseNum = 1;
ScalerInst.Config.MaxPhaseNum = 1;
XScaler_SetPhaseNum(&ScalerInst, VertPhaseNum, HoriPhaseNum);
OldScalerReg = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_NUMPHASE_OFFSET);
NewScalerReg = (VertPhaseNum << XSCL_NUMPHASE_VERT_SHIFT) &
XSCL_NUMPHASE_VERT_MASK;
NewScalerReg |= HoriPhaseNum & XSCL_NUMPHASE_HORI_MASK;
if (NewScalerReg == OldScalerReg) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/* Test case 2 */
XScaler_SetPhaseNum(&ScalerInst, VertPhaseNum, HoriPhaseNum);
OldScalerReg = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_NUMPHASE_OFFSET);
if ((VertPhaseNum == (OldScalerReg & XSCL_NUMPHASE_VERT_MASK) >>
XSCL_NUMPHASE_VERT_SHIFT) &&
(HoriPhaseNum == (OldScalerReg &
XSCL_NUMPHASE_HORI_MASK))) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
/* Test case 3 */
//XScaler_SetPhaseNum(Null, VertPhaseNum, HoriPhaseNum);
/*****************************************************************************/
/* XScaler_GetPhaseNum */
XScaler_GetPhaseNum(&ScalerInst, &VertPhaseNum, &HoriPhaseNum);
PhaseRegValue = XScaler_ReadReg((ScalerInst).Config.BaseAddress,
XSCL_NUMPHASE_OFFSET);
OldScalerReg = (PhaseRegValue & XSCL_NUMPHASE_VERT_MASK) >>
XSCL_NUMPHASE_VERT_SHIFT;
NewScalerReg = PhaseRegValue & XSCL_NUMPHASE_HORI_MASK;
if ((NewScalerReg == HoriPhaseNum) && (OldScalerReg == VertPhaseNum)) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
/* Test case 3 */
//XScaler_GetPhaseNum(Null, &VertPhaseNum, &HoriPhaseNum);
/*****************************************************************************/
XScaler_SetStartFraction(&ScalerInst, &StartFractionInst);
LumaLeftH = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTLUMALEFT_OFFSET);
LumaTopV = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTLUMATOP_OFFSET);
ChromaLeftH = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTCHROMALEFT_OFFSET);
ChromaTopV = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTCHROMATOP_OFFSET);
if(((LumaLeftH)==((u32)StartFractionInst.LumaLeftHori &
XSCL_FRCTLUMALEFT_VALUE_MASK)) &&
( LumaTopV == ((u32)StartFractionInst.LumaTopVert &
XSCL_FRCTLUMATOP_VALUE_MASK)) &&
(ChromaLeftH == ((u32)StartFractionInst.ChromaLeftHori &
XSCL_FRCTCHROMALEFT_VALUE_MASK)) &&
(ChromaTopV == ((u32)StartFractionInst.ChromaTopVert &
XSCL_FRCTCHROMATOP_VALUE_MASK))) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
//XScaler_SetStartFraction(Null, Null1);
/*****************************************************************************/
XScaler_GetStartFraction(&ScalerInst, &StartFractionInst);
LumaLeftH = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTLUMALEFT_OFFSET) &
XSCL_FRCTLUMALEFT_VALUE_MASK;
LumaTopV = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTLUMATOP_OFFSET) &
XSCL_FRCTLUMATOP_VALUE_MASK;
ChromaLeftH = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTCHROMALEFT_OFFSET) &
XSCL_FRCTCHROMALEFT_VALUE_MASK;
ChromaTopV = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTCHROMATOP_OFFSET) &
XSCL_FRCTCHROMATOP_VALUE_MASK;
if ((LumaLeftH == StartFractionInst.LumaLeftHori) &&
(LumaTopV == StartFractionInst.LumaTopVert) &&
(ChromaLeftH == StartFractionInst.ChromaLeftHori) &&
(ChromaTopV == StartFractionInst.ChromaTopVert)) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
//XScaler_GetStartFraction(Null, Null1);
/*****************************************************************************/
XScaler_GetCoeffBankSharingInfo(&ScalerInst,
&ChromaFormat,
&ChromaLumaShareCoeff,
&HoriVertShareCoeff);
if (ChromaFormat == ScalerInst.Config.ChromaFormat) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
if (ScalerInst.Config.SeparateHvCoef !=0 ) {
if (HoriVertShareCoeff == 0) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
}
else {
if (HoriVertShareCoeff == 1) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
}
if (ChromaFormat ==XSCL_CHROMA_FORMAT_422 ) {
if(ScalerInst.Config.SeparateYcCoef!=0)
{
if (ChromaLumaShareCoeff == 0) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
}
}
if(ChromaFormat == XSCL_CHROMA_FORMAT_422){
if (ChromaLumaShareCoeff == 1) {
check_status_update(u32, 1, 1);
}
else
{
check_status_update(u32, 0, 1);
}
}
/*****************************************************************************/
InLine_1= 23;
OutSize_1 = 22;
SrcSize_1 = 11 ;
InPixel_1 = 63;
XScaler_CoefValueLookup(InLine_1, OutSize_1, SrcSize_1, InPixel_1);
if(Xil_AssertStatus == XIL_ASSERT_NONE) {
check_status_update(u32, 1, 1);
}
else{
check_status_update(u32, 0, 1);
}
/*****************************************************************************/
/* Xil_AssertVoid(CoeffBankPtr->SetIndex <
InstancePtr->Config.CoeffSetNum);
Xil_AssertVoid(CoeffBankPtr->CoeffValueBuf != NULL);
Xil_AssertVoid(CoeffBankPtr->PhaseNum >= (XSCL_MIN_PHASE_NUM));
Xil_AssertVoid(CoeffBankPtr->PhaseNum <=
InstancePtr->Config.MaxPhaseNum);
Xil_AssertVoid(CoeffBankPtr->TapNum > 0U);
Xil_AssertVoid(CoeffBankPtr->TapNum <= (XSCL_MAX_TAP_NUM)); */
CoeffBankPtr.SetIndex = 1;
ScalerInst.Config.CoeffSetNum = 2;
CoeffBankPtr.PhaseNum = 6;
ScalerInst.Config.MaxPhaseNum = 6;
CoeffBankPtr.TapNum = (XSCL_MAX_TAP_NUM);
CoeffBankPtr.CoeffValueBuf = XScaler_CoefValueLookup(640, 480,CoeffBankPtr.TapNum, CoeffBankPtr.PhaseNum);
XScaler_LoadCoeffBank(&ScalerInst, &CoeffBankPtr);
NewScalerReg = CoeffBankPtr.SetIndex & XSCL_COEFFSETADDR_ADDR_MASK;
OldScalerReg = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_COEFFSETADDR_OFFSET);
if (NewScalerReg == OldScalerReg) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
//XScaler_LoadCoeffBank(Null, Null2);
/****************************************************************************/
VertSetIndex = 0 ;
ScalerInst.Config.CoeffSetNum = 1 ;
HoriSetIndex = 0;
ScalerInst.Config.CoeffSetNum = 1;
XScaler_SetActiveCoeffSet(&ScalerInst, VertSetIndex, HoriSetIndex);
OldScalerReg = ((u32)HoriSetIndex) & XSCL_COEFFSETS_HORI_MASK;
OldScalerReg |= (((u32)VertSetIndex) << XSCL_COEFFSETS_VERT_SHIFT) &
XSCL_COEFFSETS_VERT_MASK;
NewScalerReg = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_COEFFSETS_OFFSET);
if (NewScalerReg == OldScalerReg) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
//XScaler_SetActiveCoeffSet(Null, VertSetIndex, HoriSetIndex);
/*****************************************************************************/
XScaler_GetActiveCoeffSet(&ScalerInst, &VertSetIndex, &HoriSetIndex);
NewScalerReg = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_COEFFSETS_OFFSET);
if (((u8)(NewScalerReg & XSCL_COEFFSETS_VERT_MASK) >>
XSCL_COEFFSETS_VERT_SHIFT) == VertSetIndex &&
(u8)(NewScalerReg & XSCL_COEFFSETS_HORI_MASK) ==
HoriSetIndex) {
check_status_update(u32, 1, 1);
} else {
check_status_update(u32, 0, 1);
}
/*****************************************************************************/
memset((void *)&AperturePtr, 0, sizeof(XScalerAperture));
memset((void *)&AperturePtr_1, 0, sizeof(XScalerAperture));
// memset((void *)&ScalerInst, 0, sizeof(XScaler));
AperturePtr.InFirstLine = 0;
AperturePtr.InLastLine = 719;
AperturePtr.InLastPixel = 1279;
AperturePtr.InFirstPixel = 0;
AperturePtr.OutVertSize = 1280;
AperturePtr.OutHoriSize =720;
XScaler_SetAperture(&ScalerInst, &AperturePtr);
/* Calculate vertical and horizontal scale factors */
VertScaleFactor = (double)(AperturePtr.InLastLine -
AperturePtr.InFirstLine + 1.0);
VertScaleFactor /= (double)(AperturePtr.OutVertSize);
HoriScaleFactor = (double)(AperturePtr.InLastPixel -
AperturePtr.InFirstPixel + 1.0);
HoriScaleFactor /= (double)AperturePtr.OutHoriSize;
/* Convert HoriScaleFactor and VertScaleFactor values into a format
* to write to HSF and VSF registers.
*/
VertScaleFactor = (u32)(VertScaleFactor * XSCL_SHRINK_FACTOR);
HoriScaleFactor = (u32)(HoriScaleFactor * XSCL_SHRINK_FACTOR);
/* Quantize Aperture - feed scale-factor back in to provide the
* actual aperture required to generate the desired number of output
* samples.
*/
QuantizedHoriSize = AperturePtr.OutHoriSize - 1;
QuantizedHoriSize = (u32)(((double)QuantizedHoriSize *
HoriScaleFactor) / XSCL_SHRINK_FACTOR);
QuantizedHoriSize += 1 + (ScalerInst.Config.HoriTapNum + 1) / 2;
QuantizedInLastPixel = AperturePtr.InFirstPixel + QuantizedHoriSize
- 1;
if (QuantizedInLastPixel > AperturePtr.InLastPixel)
QuantizedInLastPixel = AperturePtr.InLastPixel;
QuantizedVertSize = AperturePtr.OutVertSize - 1;
QuantizedVertSize = (u32)(((float)QuantizedVertSize *
VertScaleFactor) / XSCL_SHRINK_FACTOR);
QuantizedVertSize += 1 + (ScalerInst.Config.VertTapNum + 1) / 2;
QuantizedInLastLine = AperturePtr.InFirstLine + QuantizedVertSize - 1;
if (QuantizedInLastLine > AperturePtr.InLastLine)
QuantizedInLastLine = AperturePtr.InLastLine;
/* Calculate input line, pixel and output size values */
InLine = AperturePtr.InFirstLine & XSCL_APTVERT_FIRSTLINE_MASK;
InLine |= (QuantizedInLastLine << XSCL_APTVERT_LASTLINE_SHIFT)
& XSCL_APTVERT_LASTLINE_MASK;
InPixel = AperturePtr.InFirstPixel & XSCL_APTHORI_FIRSTPXL_MASK;
InPixel |= (QuantizedInLastPixel << XSCL_APTHORI_LASTPXL_SHIFT)
& XSCL_APTHORI_LASTPXL_MASK;
OutSize = AperturePtr.OutHoriSize & XSCL_OUTSIZE_NUMPXL_MASK;
OutSize |= (AperturePtr.OutVertSize << XSCL_OUTSIZE_NUMLINE_SHIFT)
& XSCL_OUTSIZE_NUMLINE_MASK;
SrcSize = AperturePtr.SrcHoriSize & XSCL_SRCSIZE_NUMPXL_MASK;
SrcSize |= (AperturePtr.SrcVertSize << XSCL_SRCSIZE_NUMLINE_SHIFT)
& XSCL_SRCSIZE_NUMLINE_MASK;
//InLine_1 = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
// XSCL_FRCTLUMALEFT_OFFSET);
InLine_1 = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_APTVERT_OFFSET);
InPixel_1 = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_APTHORI_OFFSET);
OutSize_1 =XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_OUTSIZE_OFFSET);
SrcSize_1 =XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_SRCSIZE_OFFSET);
HoriScaleFactor_1 =XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_HSF_OFFSET);
HoriScaleFactor_1 = (u32)round(HoriScaleFactor_1);
VertScaleFactor_1=XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_VSF_OFFSET);
VertScaleFactor_1 = (u32)round(VertScaleFactor_1);
/*if ((InLine == XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_FRCTLUMALEFT_OFFSET)) && (InPixel ==
XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_APTHORI_OFFSET)) &&
(OutSize == XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_OUTSIZE_OFFSET)) &&
(SrcSize == XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_SRCSIZE_OFFSET)) &&
((u32)(round(HoriScaleFactor)) ==
XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_HSF_OFFSET)) &&
((u32)(round(VertScaleFactor)) ==
XScaler_ReadReg(ScalerInst.Config.BaseAddress,
XSCL_VSF_OFFSET))) */
if (InLine == InLine_1 && InPixel == InPixel_1 && OutSize == OutSize_1
&& SrcSize== SrcSize_1 && HoriScaleFactor == HoriScaleFactor_1
&& VertScaleFactor == VertScaleFactor_1) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Negative Test Case
*/
//XScaler_SetAperture(Null, Null3);
/****************************************************************************/
AperturePtr.InFirstLine = 0;
AperturePtr.InLastLine = 719;
AperturePtr.InLastPixel = 1279;
AperturePtr.InFirstPixel = 0;
AperturePtr.OutVertSize = 1280;
AperturePtr.OutHoriSize = 720;
XScaler_GetAperture(&ScalerInst, &AperturePtr);
InLine = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
(XSCL_APTVERT_OFFSET));
InPixel = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
(XSCL_APTHORI_OFFSET));
OutSize = XScaler_ReadReg(ScalerInst.Config.BaseAddress,
(XSCL_OUTSIZE_OFFSET));
/* Parse the info and populate the aperture structure */
AperturePtr_1.InFirstLine = (InLine) & (XSCL_APTVERT_FIRSTLINE_MASK);
AperturePtr_1.InLastLine = ((InLine) & (XSCL_APTVERT_LASTLINE_MASK)) >>
(XSCL_APTVERT_LASTLINE_SHIFT);
AperturePtr_1.InFirstPixel = (InPixel) & (XSCL_APTHORI_FIRSTPXL_MASK);
AperturePtr_1.InLastPixel = ((InPixel) &
(XSCL_APTHORI_LASTPXL_MASK)) >>
(XSCL_APTHORI_LASTPXL_SHIFT);
AperturePtr_1.OutHoriSize = (OutSize) & (XSCL_OUTSIZE_NUMPXL_MASK);
AperturePtr_1.OutVertSize = ((OutSize) &
(XSCL_OUTSIZE_NUMLINE_MASK)) >>
(XSCL_OUTSIZE_NUMLINE_SHIFT);
if(!(memcmp(&AperturePtr, &AperturePtr_1, sizeof(XScalerAperture)))) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
/*
* Run XScaler self test.
*/
// Status = XScaler_SelfTest(&ScalerInst);
// if (Status != XST_SUCCESS) {
// check_status_update(u32, 0, 1);
// return XST_FAILURE;
// }
// else{
// check_status_update(u32, 1, 1);
// }
/*
* Test case for lookupconfig
*/
Config = XScaler_LookupConfig(XSCALAR_DEVICEID);
if(Config == NULL) {
check_status_update(u32, 1, 1);
}
else {
check_status_update(u32, 0, 1);
}
CT_CMP_NUM(int, Status, XST_SUCCESS);
}
return (u32)(CT_GetTestFailures());
}

View file

@ -0,0 +1,237 @@
/*****************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
*****************************************************************************/
/*****************************************************************************/
/**
*
* @file scaler_intg_intr.c
*
* This file contains an integration test on Scaler driver in interrupt mode.
*
* @note
*
* This code assumes that Zynq702 is the processor in the hardware system.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- ---------------------------------------------
* 7.0 adk 22/08/14 First release.
* </pre>
*
******************************************************************************/
/***************************** Include Files *********************************/
#include "scaler_intgtest.h"
/************************** Constant Definitions *****************************/
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
static int SetupInterruptSystem(XScaler *ScalerInstPtr);
/* void Handler(void *CallBackRef, u32 Event, unsigned int EventData);*/
void Handler(void *CallBackRef, u32 Event);
static int ScalerInterruptTest(int TestLoops);
/************************** Variable Definitions *****************************/
/*****************************************************************************/
/**
*
* This function setups the interrupt system so interrupts can occur for the
* SCALER core. The function is application-specific since the actual system may
* or may not have an interrupt controller. The SCALER device could be directly
* connected to a processor without an interrupt controller. The user should
* modify this function to fit the application.
*
* @param ScalerInstPtr contains a pointer to the instance of the XScaler
* which is going to be connected to the interrupt controller.
*
* @return XST_SUCCESS if successful, or a specific error code defined in
* "xstatus.h" if an error occurs.
*
* @note This function assumes a Zynq702 system and no operating system
* is used.
*
******************************************************************************/
static int SetupInterruptSystem(XScaler * ScalerInstPtr)
{
int Status;
/* The configuration parameters of the interrupt controller */
XScuGic_Config *IntcConfig;
/* Initialize the interrupt controller driver so that it is ready
* to use
*/
IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
if (NULL == IntcConfig) {
return XST_FAILURE;
}
Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
IntcConfig->CpuBaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/* Connect the interrupt controller interrupt handler to the hardware
* interrupt handling logic in the Zynq702 processor.
*/
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler,
&InterruptController);
/* Connect the device driver handler that will be called when an interrupt
* for the device occurs, the handler defined above performs the specific
* interrupt processing for the device
*/
Status = XScuGic_Connect(&InterruptController,
SCALER_INT_IRQ_ID,
(Xil_ExceptionHandler)XScaler_IntrHandler,
ScalerInstPtr);
if (Status != XST_SUCCESS) {
return Status;
}
/* Enable the interrupt for the Scaler device */
XScuGic_Enable(&InterruptController, SCALER_INT_IRQ_ID);
/* Enable interrupts in the Zynq702 */
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function tests the interrupt functionality of the Scaler driver.
*
* @param TestLoops is the number of times to run the test.
*
* @return the number of errors that occurred.
*
* @note None.
*
****************************************************************************/
int Scaler_Intg_InterruptTest(int TestLoops)
{
int Status = 0;
CT_TestReset("Scaler interrupt mode test .. ..");
while (TestLoops--) {
CT_NotifyNextPass();
Status = ScalerInterruptTest(TestLoops);
}
CT_CMP_NUM(int, Status, XST_SUCCESS);
return (CT_GetTestFailures());
}
/*****************************************************************************/
/**
*
* This function implements the Scaler interrupt mode test functionality.
*
* @param TestLoops is the number of times to run the test.
*
* @return XST_SUCCESS if successful else XST_FAILURE.
*
* @note None.
*
******************************************************************************/
static int ScalerInterruptTest(int TestLoops)
{
int Status;
/* u32 LoopCount;
u32 IntrMask;
u8 Bytes; */
/* Initialize XScaler instance. */
Status = Scaler_Initialize(&ScalerInst, (u16)SCALER_0_DEVICE_ID);
if (Status != XST_SUCCESS) {
return Status;
}
/* Setup interrupt system */
Status = SetupInterruptSystem(&ScalerInst);
CT_CMP_NUM(int, Status, XST_SUCCESS);
if (Status != XST_SUCCESS) {
CT_Message("Failed test(s): %u\n", CT_GetTestFailures());
return Status;
}
/* Set Handler, so the application specific processing can be
* performed for state change due to interrupt.
*/
XScaler_SetCallBack(&ScalerInst,
(XScaler_CallBack)Handler, (void *)(&ScalerInst));
// XScaler_SetCallBack(&ScalerInst, 5,
// (XScaler_CallBack)Handler, (void *)(&ScalerInst));
/* Enable interrupts for the device. */
XScaler_IntrEnable(&ScalerInst);
/* Disable interrupts for the device. */
XScaler_IntrDisable(&ScalerInst);
/* IntrMask = ;*/
return (CT_GetTestFailures());
}
/*****************************************************************************/
/**
*
* This function handles application specific processing for the interrupt.
*
* @param CallBackRef pointer to the provided argument.
* @param Event is event that triggered the interrupt.
*
* @return None.
*
* @note None.
*
******************************************************************************/
void Handler(void *CallBackRef, u32 Event)
{
xil_printf("Scaler Intr\n");
/* Implement what you want to after interrupt */
}

View file

@ -0,0 +1,310 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
* @file scaler_intg_main.c
*
* This file contains the integration test functions for the SCALER device.
*
* This file contains a list of functions providing the menu driven test
* functionality for various integration tests.
*
* @note None
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- ------------------------------------------------
* 7.0 adk 22/08/14 First release.
* </pre>
*
******************************************************************************/
/***************************** Include Files *********************************/
#include "scaler_intgtest.h"
#include <stdlib.h>
/************************** Constant Definitions *****************************/
/************************** Constant Definitions *****************************/
/*
* Main menu selections.
*/
#define MENU_MAIN_TEST 1 /**<Menu test */
#define MENU_MAIN_EXIT 99 /**<Menu Exit */
/*
* Test sub-menu selections.
*/
#define MENU_TEST_ALL 0 /**<Menu test all */
#define MENU_TEST_BASIC 1 /**<Menu test basic */
//#define MENU_TEST_POLLED 2 /**<Menu test polled */
#define MENU_TEST_INTR 2 /**<Menu test interrupt */
#define MENU_TEST_EXIT 99 /**<Menu test exit */
/* Create unique bit masks from the test numbers. */
#define SCALER_INTG_TEST_ALL 0xFFFFFFFF /**<SCALER Menu test all */
#define SCALER_INTG_TEST_BASIC (1 << MENU_TEST_BASIC) /**<Scaler Menu test
* basic */
#define SCALER_INTG_TEST_POLLED (1 << MENU_TEST_POLLED) /**<Scaler Menu test
* polled */
#define SCALER_INTG_TEST_INTR (1 << MENU_TEST_INTR) /**<Scaler menu test
* Interrupt */
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
static int GetMainMenuCommand(char *CmdLine);
static void RunTestMenu(char *CmdLine);
/************************** Variable Definitions *****************************/
char CmdLine[132]; /**< To read Menu Command arguments */
/*****************************************************************************/
/**
*
* Main entry point for integration tests on Scaler.
*
* @return XST_SUCCESS if successful else XST_FAILURE.
*
* @note None.
*
******************************************************************************/
int main()
{
int Status;
#ifdef AUTOMATIC_TEST_MODE
int TestLoops;
int TestFailures;
#endif
printf("\nScaler COMPONENT INTEGRATION TEST\n");
printf("Created on %s\n\n", __DATE__);
printf("================================\n");
Status = Scaler_Initialize(&ScalerInst, (u16)SCALER_0_DEVICE_ID);
if (Status != XST_SUCCESS) {
return Status;
}
#ifndef AUTOMATIC_TEST_MODE
/*
* Prompt user for menu selections.
*/
while (1) {
switch (GetMainMenuCommand(CmdLine)) {
case MENU_MAIN_TEST:
RunTestMenu(CmdLine);
break;
case MENU_MAIN_EXIT:
printf("\nBye\n");
return (0);
default:
printf("Invalid selections.\n");
}
}
#else
/* set defaults */
TestLoops = 1;
TestFailures = 0;
TestFailures += Scaler_Intg_SelfTest(TestLoops);
/* TestFailures += Scaler_Intg_PolledTest(TestLoops); */
TestFailures += Scaler_Intg_InterruptTest(TestLoops);
if (TestFailures) {
XIL_FAIL(TestFailures);
}
else {
XIL_PASS();
}
#endif
return 0;
}
/*****************************************************************************/
/**
*
* Prompt the user for selections in the main menu. The user is allowed to
* enter one command at a time.
*
* @param CmdLine - Storage to use for User input.
*
* @return Numeric command entered.
*
* @note None.
*
******************************************************************************/
static int GetMainMenuCommand(char *CmdLine)
{
/* Prompt user. */
printf("\nMain Menu:\n");
printf("1 - Test menu\n");
/* printf("2 - Util menu\n");*/
/* printf("3 - One of, experimental & misc functions\n");*/
printf("99 - Exit\n");
/*
* Wait for input.
*/
while (!CT_GetUserInput("Enter selection: ", CmdLine,
sizeof(CmdLine) - 1));
return (atoi(CmdLine));
}
/*****************************************************************************/
/**
*
* Prompt the user for a sequence of tests to run in the test sub-menu.
*
* @param CmdLine - Storage to use for User input.
*
* @return None.
*
* @note None.
*
*****************************************************************************/
static void RunTestMenu(char *CmdLine)
{
char *Token;
char *tmp;
int QuitToMain = 0;
int TestLoops;
int TestFailures;
u32 RunTestMask;
while (!QuitToMain) {
/*
* Set defaults.
*/
TestLoops = 1;
RunTestMask = 0;
TestFailures = 0;
/*
* Prompt user.
*/
printf("\nTest Menu:\n");
printf("0 - All tests\n");
printf("1 - Basic Self test\n");
/* printf("2 - Polled mode tests\n"); */
printf("2 - Interrupt mode tests\n");
printf("99 - Exit to main menu\n");
printf("Adding l<number> sets the number of test loops\n");
/*
* Wait for input.
*/
while (!CT_GetUserInput("Enter selection: ", CmdLine,
sizeof(CmdLine) - 1));
/*
* Parse input line.
*/
Token = strtok_r(CmdLine, " ", &tmp);
while (Token) {
if ((*Token == 'l') || (*Token == 'L')) {
TestLoops = atoi(Token + 1);
}
else {
switch (atoi(Token)) {
case MENU_TEST_ALL:
RunTestMask |= SCALER_INTG_TEST_ALL;
break;
case MENU_TEST_BASIC:
RunTestMask |= SCALER_INTG_TEST_BASIC;
break;
/* case MENU_TEST_POLLED:
RunTestMask |= SCALER_INTG_TEST_POLLED;
break; */
case MENU_TEST_INTR:
RunTestMask |= SCALER_INTG_TEST_INTR;
break;
case MENU_TEST_EXIT:
QuitToMain = 1;
break;
default:
printf("Unknown test id %s\n", Token);
}
}
Token = strtok_r(0, " ", &tmp);
}
if(!QuitToMain) {
/*
* Execute selected tests.
*/
printf("\n********************************************\
*******\n");
printf("* Test sequence mask = %08X, TestLoops = %d\n",
(int) RunTestMask, TestLoops);
printf("**********************************************\
*******\n");
if (RunTestMask & SCALER_INTG_TEST_BASIC) {
TestFailures +=
Scaler_Intg_SelfTest(TestLoops);
}
/*if (RunTestMask & SCALER_INTG_TEST_POLLED) {
TestFailures +=
Scaler_Intg_PolledTest(TestLoops);
}*/
if (RunTestMask & SCALER_INTG_TEST_INTR) {
TestFailures +=
Scaler_Intg_InterruptTest(TestLoops);
}
printf("\n********************************************\
******\n");
if (TestFailures) {
printf("* %d test FAILURES recorded\n", \
TestFailures);
}
else {
printf("* Tests pass.\n");
}
printf("\n********************************************\
******\n");
}
}
}

View file

@ -0,0 +1,108 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file scaler_intg_util.c
*
* This file contains utility functions used by all integration test on
* Scaler driver.
*
* @note
*
* This code works for Zynq702 system.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- --------------------------------------------
* 7.0 adk 22/08/14 First release.
* </pre>
*
******************************************************************************/
/***************************** Include Files *********************************/
#include "scaler_intgtest.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
/************************** Variable Definitions *****************************/
/* Instance of SCALER driver core struct XScaler. */
XScaler ScalerInst; /**< Instance of XScaler */
/* Instance of the XIntc driver. */
XScuGic InterruptController;
/*****************************************************************************/
/**
*
* This function initializes the Scaler core.
*
* @param InstancePtr to the instance under test.
* @param DeviceId is unique ID which identifies the device
*
* @return - XST_FAILURE if there are errors.
* - XST_SUCCESS if there are no errors.
*
* @note None.
*
******************************************************************************/
int Scaler_Initialize(XScaler *InstancePtr, u16 DeviceId)
{
XScaler_Config *Config;
int Status;
/*
* Initialize the Scaler driver so that it's ready to use
* Look up the configuration in the config table,
* then initialize it.
*/
Config = XScaler_LookupConfig(DeviceId);
if (NULL == Config)
{
return XST_FAILURE;
}
Status = XScaler_CfgInitialize(InstancePtr, Config, Config->BaseAddress);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Need to set standard and data_width if at all core is supported.
*/
return XST_SUCCESS;
}

View file

@ -0,0 +1,127 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file scaler_intgtest.h
*
* This header file contains the integration test functions prototypes,
* constants and variable definitions used in the test. This test runs on a
* Zynq702 system.
*
* @note None
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- -----------------------------------------------------
* 7.0 adk 22/08/14 First release.
* </pre>
*
******************************************************************************/
#ifndef SCALER_INTEGTEST_H
#define SCALER_INTEGTEST_H /**< Prevent circular inclusions by using
* protection macros. */
#ifdef __cplusplus
extern "C" {
#endif
/***************************** Include Files *********************************/
/*
* Includes that define system hardware constants.
*/
#include "xparameters.h"
#include "xscaler.h"
#include "xscugic.h"
#include "xstatus.h"
#include "xil_testlib.h"
/*
* Includes that define test utility APIs.
*/
#include "ct.h"
#include "xil_exception.h"
/************************** Constant Definitions *****************************/
#define LOOP_TIME_OUT 0x000FFFFF /**< Loop time out macro */
/*
* Constants indicating INTC device ID and interrupt ID. They are defined in
* xparameters.h.
*/
#ifndef SCALER_XSCALER_0_INTR
#define SCALER_XSCALER_0_INTR 92 /**<SCALER Interrupt */
#endif
#define SCALER_0_DEVICE_ID XPAR_XSCALER_0_DEVICE_ID /**<SCALER Device
* Id */
#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID /**<INTC Device
* Id */
#define SCALER_INT_IRQ_ID SCALER_XSCALER_0_INTR /**<Scaler Interrupt
* IRQ Id */
#define XSCALAR_DEVICEID 5 /**< Random device id*/
/* Pele Regression tests */
#define AUTOMATIC_TEST_MODE /**<Automatic Test Mode */
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Variable Definitions *****************************/
/* Instance of the Scaler driver. */
extern XScaler ScalerInst;
/* Instance of the XScuGic driver. */
extern XScuGic InterruptController;
/* User command storage */
extern char CmdLine[132];
/************************** Function Prototypes ******************************/
/* Basic self test implemented in scaler_intg_basic.c. */
int Scaler_Intg_SelfTest(int TestLoops);
/* Polled mode test implemented in scaler_intg_polled.c. */
/*int Scaler_Intg_PolledTest(int TestLoops);*/
/* Interrupt mode test implemented in scaler_intg_intr.c. */
int Scaler_Intg_InterruptTest(int TestLoops);
/* Scaler initialization that restores the format and operation mode in
* scaler_intg_util.c.
*/
int Scaler_Initialize(XScaler *InstancePtr, u16 DeviceID);
#ifdef __cplusplus
}
#endif
#endif /* End of protection macro. */

View file

@ -0,0 +1,70 @@
/******************************************************************************
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* (c) Copyright 2002-2014 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file xil_testlib.h
*
* This file contains Xilinx software exit messages. These messages are set to
* be matched with the scan strings for board test such that board test would
* know the result of a standalone test program.
*
******************************************************************************/
/***************************** Include Files *********************************/
#include <xil_printf.h>
#ifndef XIL_TESTLIB_H /* prevent circular inclusions */
#define XIL_TESTLIB_H /* by using protection macros */
#ifdef __cplusplus
extern "C" {
#endif
/***************** Macros (Inline Functions) Definitions *********************/
/*
* XIL_PASS puts out a message to signal board test that a program has pass
* the testing program without errors
*
* @return None.
*
* @note None.
*/
#define XIL_PASS() xil_printf("\r\nREGRESSION TEST PASS.\r\n")
/* XIL_FAIL puts out a message to signal board test that a program has not
* pass the testing program
*
* @param numErrors, number of errors.
*
* @return None.
*
* @note None.
*/
#define XIL_FAIL(numErrors) xil_printf("\r\nREGRESSION TEST FAIL WITH %d \
ERRORS.\r\n", numErrors)
#ifdef __cplusplus
}
#endif
#endif /* end of protection macro */