v_letterbox: Added new driver
HLS generated driver along with manually written layer 2. Driver tcl update is pending Signed-off-by: Rohit Consul <rohit.consul@xilinx.com>
This commit is contained in:
parent
531499fd65
commit
a93e316656
10 changed files with 1176 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
# ==============================================================
|
||||
# File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
# Version: 2015.1
|
||||
# Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
#
|
||||
# ==============================================================
|
||||
|
||||
OPTION psf_version = 2.1;
|
||||
|
||||
BEGIN driver v_letterbox
|
||||
|
||||
OPTION supported_peripherals = (v_letterbox_v1_0 );
|
||||
OPTION driver_state = ACTIVE;
|
||||
OPTION copyfiles = all;
|
||||
OPTION name = v_letterbox;
|
||||
OPTION version = 1.0;
|
||||
|
||||
END driver
|
|
@ -0,0 +1,23 @@
|
|||
# ==============================================================
|
||||
# File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
# Version: 2015.1
|
||||
# Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
#
|
||||
# ==============================================================
|
||||
|
||||
proc generate {drv_handle} {
|
||||
xdefine_include_file $drv_handle "xparameters.h" "XV_letterbox" \
|
||||
"NUM_INSTANCES" \
|
||||
"DEVICE_ID" \
|
||||
"C_S_AXI_CTRL_BASEADDR" \
|
||||
"C_S_AXI_CTRL_HIGHADDR"
|
||||
|
||||
xdefine_config_file $drv_handle "xv_letterbox_g.c" "XV_letterbox" \
|
||||
"DEVICE_ID" \
|
||||
"C_S_AXI_CTRL_BASEADDR"
|
||||
|
||||
xdefine_canonical_xpars $drv_handle "xparameters.h" "XV_letterbox" \
|
||||
"DEVICE_ID" \
|
||||
"C_S_AXI_CTRL_BASEADDR" \
|
||||
"C_S_AXI_CTRL_HIGHADDR"
|
||||
}
|
34
XilinxProcessorIPLib/drivers/v_letterbox/src/Makefile
Normal file
34
XilinxProcessorIPLib/drivers/v_letterbox/src/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
|||
# ==============================================================
|
||||
# File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
# Version: 2015.1
|
||||
# Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
#
|
||||
# ==============================================================
|
||||
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
INCLUDES=-I./. -I${INCLUDEDIR}
|
||||
|
||||
INCLUDEFILES=*.h
|
||||
LIBSOURCES=*.c
|
||||
OUTS = *.o
|
||||
|
||||
|
||||
libs:
|
||||
echo "Compiling v_letterbox"
|
||||
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
|
||||
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} $(OUTS)
|
||||
make clean
|
||||
|
||||
include:
|
||||
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
|
||||
|
||||
clean:
|
||||
rm -rf ${OUTS}
|
302
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox.c
Normal file
302
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox.c
Normal file
|
@ -0,0 +1,302 @@
|
|||
// ==============================================================
|
||||
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
// Version: 2015.1
|
||||
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
//
|
||||
// ==============================================================
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xv_letterbox.h"
|
||||
|
||||
/************************** Function Implementation *************************/
|
||||
#ifndef __linux__
|
||||
int XV_letterbox_CfgInitialize(XV_letterbox *InstancePtr, XV_letterbox_Config *ConfigPtr) {
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
|
||||
InstancePtr->Ctrl_BaseAddress = ConfigPtr->Ctrl_BaseAddress;
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void XV_letterbox_Start(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL) & 0x80;
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL, Data | 0x01);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_IsDone(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL);
|
||||
return (Data >> 1) & 0x1;
|
||||
}
|
||||
|
||||
u32 XV_letterbox_IsIdle(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL);
|
||||
return (Data >> 2) & 0x1;
|
||||
}
|
||||
|
||||
u32 XV_letterbox_IsReady(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL);
|
||||
// check ap_start to see if the pcore is ready for next input
|
||||
return !(Data & 0x1);
|
||||
}
|
||||
|
||||
void XV_letterbox_EnableAutoRestart(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL, 0x80);
|
||||
}
|
||||
|
||||
void XV_letterbox_DisableAutoRestart(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL, 0);
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_width(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_WIDTH_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_width(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_WIDTH_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_height(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_HEIGHT_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_height(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_HEIGHT_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_video_format(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_VIDEO_FORMAT_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_video_format(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_VIDEO_FORMAT_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_col_start(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_COL_START_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_col_start(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_COL_START_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_col_end(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_COL_END_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_col_end(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_COL_END_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_row_start(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_START_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_row_start(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_START_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_row_end(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_END_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_row_end(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_END_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_Y_R_value(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_Y_R_VALUE_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_Y_R_value(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_Y_R_VALUE_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_Cb_G_value(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_CB_G_VALUE_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_Cb_G_value(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_CB_G_VALUE_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_Set_HwReg_Cr_B_value(XV_letterbox *InstancePtr, u32 Data) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_CR_B_VALUE_DATA, Data);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_Get_HwReg_Cr_B_value(XV_letterbox *InstancePtr) {
|
||||
u32 Data;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Data = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_HWREG_CR_B_VALUE_DATA);
|
||||
return Data;
|
||||
}
|
||||
|
||||
void XV_letterbox_InterruptGlobalEnable(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_GIE, 1);
|
||||
}
|
||||
|
||||
void XV_letterbox_InterruptGlobalDisable(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_GIE, 0);
|
||||
}
|
||||
|
||||
void XV_letterbox_InterruptEnable(XV_letterbox *InstancePtr, u32 Mask) {
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Register = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_IER);
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_IER, Register | Mask);
|
||||
}
|
||||
|
||||
void XV_letterbox_InterruptDisable(XV_letterbox *InstancePtr, u32 Mask) {
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Register = XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_IER);
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_IER, Register & (~Mask));
|
||||
}
|
||||
|
||||
void XV_letterbox_InterruptClear(XV_letterbox *InstancePtr, u32 Mask) {
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XV_letterbox_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_ISR, Mask);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_InterruptGetEnabled(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
return XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_IER);
|
||||
}
|
||||
|
||||
u32 XV_letterbox_InterruptGetStatus(XV_letterbox *InstancePtr) {
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
return XV_letterbox_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_ISR);
|
||||
}
|
123
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox.h
Normal file
123
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox.h
Normal file
|
@ -0,0 +1,123 @@
|
|||
// ==============================================================
|
||||
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
// Version: 2015.1
|
||||
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
//
|
||||
// ==============================================================
|
||||
|
||||
#ifndef XV_LETTERBOX_H
|
||||
#define XV_LETTERBOX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#ifndef __linux__
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
#include "xil_io.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#include "xv_letterbox_hw.h"
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
#ifdef __linux__
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
#else
|
||||
typedef struct {
|
||||
u16 DeviceId;
|
||||
u32 Ctrl_BaseAddress;
|
||||
} XV_letterbox_Config;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
u32 Ctrl_BaseAddress;
|
||||
u32 IsReady;
|
||||
} XV_letterbox;
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#ifndef __linux__
|
||||
#define XV_letterbox_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data))
|
||||
#define XV_letterbox_ReadReg(BaseAddress, RegOffset) \
|
||||
Xil_In32((BaseAddress) + (RegOffset))
|
||||
#else
|
||||
#define XV_letterbox_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
*(volatile u32*)((BaseAddress) + (RegOffset)) = (u32)(Data)
|
||||
#define XV_letterbox_ReadReg(BaseAddress, RegOffset) \
|
||||
*(volatile u32*)((BaseAddress) + (RegOffset))
|
||||
|
||||
#define Xil_AssertVoid(expr) assert(expr)
|
||||
#define Xil_AssertNonvoid(expr) assert(expr)
|
||||
|
||||
#define XST_SUCCESS 0
|
||||
#define XST_DEVICE_NOT_FOUND 2
|
||||
#define XST_OPEN_DEVICE_FAILED 3
|
||||
#define XIL_COMPONENT_IS_READY 1
|
||||
#endif
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
#ifndef __linux__
|
||||
int XV_letterbox_Initialize(XV_letterbox *InstancePtr, u16 DeviceId);
|
||||
XV_letterbox_Config* XV_letterbox_LookupConfig(u16 DeviceId);
|
||||
int XV_letterbox_CfgInitialize(XV_letterbox *InstancePtr, XV_letterbox_Config *ConfigPtr);
|
||||
#else
|
||||
int XV_letterbox_Initialize(XV_letterbox *InstancePtr, const char* InstanceName);
|
||||
int XV_letterbox_Release(XV_letterbox *InstancePtr);
|
||||
#endif
|
||||
|
||||
void XV_letterbox_Start(XV_letterbox *InstancePtr);
|
||||
u32 XV_letterbox_IsDone(XV_letterbox *InstancePtr);
|
||||
u32 XV_letterbox_IsIdle(XV_letterbox *InstancePtr);
|
||||
u32 XV_letterbox_IsReady(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_EnableAutoRestart(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_DisableAutoRestart(XV_letterbox *InstancePtr);
|
||||
|
||||
void XV_letterbox_Set_HwReg_width(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_width(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_height(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_height(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_video_format(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_video_format(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_col_start(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_col_start(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_col_end(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_col_end(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_row_start(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_row_start(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_row_end(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_row_end(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_Y_R_value(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_Y_R_value(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_Cb_G_value(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_Cb_G_value(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_Set_HwReg_Cr_B_value(XV_letterbox *InstancePtr, u32 Data);
|
||||
u32 XV_letterbox_Get_HwReg_Cr_B_value(XV_letterbox *InstancePtr);
|
||||
|
||||
void XV_letterbox_InterruptGlobalEnable(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_InterruptGlobalDisable(XV_letterbox *InstancePtr);
|
||||
void XV_letterbox_InterruptEnable(XV_letterbox *InstancePtr, u32 Mask);
|
||||
void XV_letterbox_InterruptDisable(XV_letterbox *InstancePtr, u32 Mask);
|
||||
void XV_letterbox_InterruptClear(XV_letterbox *InstancePtr, u32 Mask);
|
||||
u32 XV_letterbox_InterruptGetEnabled(XV_letterbox *InstancePtr);
|
||||
u32 XV_letterbox_InterruptGetStatus(XV_letterbox *InstancePtr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,92 @@
|
|||
// ==============================================================
|
||||
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
// Version: 2015.1
|
||||
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
//
|
||||
// ==============================================================
|
||||
|
||||
// CTRL
|
||||
// 0x00 : Control signals
|
||||
// bit 0 - ap_start (Read/Write/COH)
|
||||
// bit 1 - ap_done (Read/COR)
|
||||
// bit 2 - ap_idle (Read)
|
||||
// bit 3 - ap_ready (Read)
|
||||
// bit 7 - auto_restart (Read/Write)
|
||||
// others - reserved
|
||||
// 0x04 : Global Interrupt Enable Register
|
||||
// bit 0 - Global Interrupt Enable (Read/Write)
|
||||
// others - reserved
|
||||
// 0x08 : IP Interrupt Enable Register (Read/Write)
|
||||
// bit 0 - Channel 0 (ap_done)
|
||||
// bit 1 - Channel 1 (ap_ready)
|
||||
// others - reserved
|
||||
// 0x0c : IP Interrupt Status Register (Read/TOW)
|
||||
// bit 0 - Channel 0 (ap_done)
|
||||
// bit 1 - Channel 1 (ap_ready)
|
||||
// others - reserved
|
||||
// 0x10 : Data signal of HwReg_width
|
||||
// bit 15~0 - HwReg_width[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x14 : reserved
|
||||
// 0x18 : Data signal of HwReg_height
|
||||
// bit 15~0 - HwReg_height[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x1c : reserved
|
||||
// 0x20 : Data signal of HwReg_video_format
|
||||
// bit 15~0 - HwReg_video_format[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x24 : reserved
|
||||
// 0x28 : Data signal of HwReg_col_start
|
||||
// bit 15~0 - HwReg_col_start[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x2c : reserved
|
||||
// 0x30 : Data signal of HwReg_col_end
|
||||
// bit 15~0 - HwReg_col_end[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x34 : reserved
|
||||
// 0x38 : Data signal of HwReg_row_start
|
||||
// bit 15~0 - HwReg_row_start[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x3c : reserved
|
||||
// 0x40 : Data signal of HwReg_row_end
|
||||
// bit 15~0 - HwReg_row_end[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x44 : reserved
|
||||
// 0x48 : Data signal of HwReg_Y_R_value
|
||||
// bit 15~0 - HwReg_Y_R_value[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x4c : reserved
|
||||
// 0x50 : Data signal of HwReg_Cb_G_value
|
||||
// bit 15~0 - HwReg_Cb_G_value[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x54 : reserved
|
||||
// 0x58 : Data signal of HwReg_Cr_B_value
|
||||
// bit 15~0 - HwReg_Cr_B_value[15:0] (Read/Write)
|
||||
// others - reserved
|
||||
// 0x5c : reserved
|
||||
// (SC = Self Clear, COR = Clear on Read, TOW = Toggle on Write, COH = Clear on Handshake)
|
||||
|
||||
#define XV_LETTERBOX_CTRL_ADDR_AP_CTRL 0x00
|
||||
#define XV_LETTERBOX_CTRL_ADDR_GIE 0x04
|
||||
#define XV_LETTERBOX_CTRL_ADDR_IER 0x08
|
||||
#define XV_LETTERBOX_CTRL_ADDR_ISR 0x0c
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_WIDTH_DATA 0x10
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_WIDTH_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_HEIGHT_DATA 0x18
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_HEIGHT_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_VIDEO_FORMAT_DATA 0x20
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_VIDEO_FORMAT_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_COL_START_DATA 0x28
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_COL_START_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_COL_END_DATA 0x30
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_COL_END_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_START_DATA 0x38
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_ROW_START_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_ROW_END_DATA 0x40
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_ROW_END_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_Y_R_VALUE_DATA 0x48
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_Y_R_VALUE_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_CB_G_VALUE_DATA 0x50
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_CB_G_VALUE_DATA 16
|
||||
#define XV_LETTERBOX_CTRL_ADDR_HWREG_CR_B_VALUE_DATA 0x58
|
||||
#define XV_LETTERBOX_CTRL_BITS_HWREG_CR_B_VALUE_DATA 16
|
249
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox_l2.c
Normal file
249
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox_l2.c
Normal file
|
@ -0,0 +1,249 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 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 xv_letterbox_l2.c
|
||||
*
|
||||
* The Letterbox Layer-2 Driver.
|
||||
* The functions in this file provides an abstraction from the register peek/poke
|
||||
* methodology by implementing most common use-case provided by the sub-core.
|
||||
* See xv_letterbox_l2.h for a detailed description of the layer-2 driver
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00 rc 05/01/15 Initial Release
|
||||
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xv_letterbox_l2.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/* Pixel definition in 8 bit resolution in YUV color space*/
|
||||
const u8 bkgndColorYUV[XLBOX_BKGND_LAST][3] =
|
||||
{
|
||||
{ 0, 128, 128}, //Black
|
||||
{255, 128, 128}, //White
|
||||
{ 76, 85, 255}, //Red
|
||||
{149, 43, 21}, //Green
|
||||
{ 29, 255, 107} //Blue
|
||||
};
|
||||
|
||||
/* Pixel map in RGB color space*/
|
||||
const u8 bkgndColorRGB[XLBOX_BKGND_LAST][3] =
|
||||
{
|
||||
{0, 0, 0}, //Black
|
||||
{1, 1, 1}, //White
|
||||
{1, 0, 0}, //Red
|
||||
{0, 1, 0}, //Green
|
||||
{0, 0, 1} //Blue
|
||||
};
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**************************** Local Global *******************************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function starts the letter box core
|
||||
*
|
||||
* @param InstancePtr is a pointer to the core instance to be worked on.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
void XV_LBoxStart(XV_letterbox *InstancePtr)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
XV_letterbox_EnableAutoRestart(InstancePtr);
|
||||
XV_letterbox_Start(InstancePtr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function stops the letter box core
|
||||
*
|
||||
* @param InstancePtr is a pointer to the core instance to be worked on.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
void XV_LBoxStop(XV_letterbox *InstancePtr)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
XV_letterbox_DisableAutoRestart(InstancePtr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function configures the letterbox active window. All pixels within the
|
||||
* window are passed to the output as-is. Any pixel outside the defined window
|
||||
* will be clamped to the programmed background color
|
||||
*
|
||||
* @param InstancePtr is a pointer to the core instance to be worked on.
|
||||
* @param ActiveWindow is structure that contains window coordinates and size
|
||||
* @param FrameWidth is the input stream width
|
||||
* @param FrameHeight is the input stream height
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
void XV_LBoxSetActiveWin(XV_letterbox *InstancePtr,
|
||||
XVidC_VideoWindow *ActiveWindow,
|
||||
u32 FrameWidth,
|
||||
u32 FrameHeight)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
XV_letterbox_Set_HwReg_col_start(InstancePtr, ActiveWindow->StartX);
|
||||
XV_letterbox_Set_HwReg_col_end(InstancePtr, (ActiveWindow->StartX+ActiveWindow->Width-1));
|
||||
XV_letterbox_Set_HwReg_row_start(InstancePtr, ActiveWindow->StartY);
|
||||
XV_letterbox_Set_HwReg_row_end(InstancePtr, (ActiveWindow->StartY+ActiveWindow->Height-1));
|
||||
|
||||
XV_letterbox_Set_HwReg_height(InstancePtr, FrameHeight);
|
||||
XV_letterbox_Set_HwReg_width(InstancePtr, FrameWidth);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function configures the background color to be painted outside active
|
||||
* window
|
||||
*
|
||||
* @param InstancePtr is a pointer to the core instance to be worked on.
|
||||
* @param ColorId is the background color requested
|
||||
* @param cfmt is the color format of the input stream
|
||||
* @param bpc is the color depth (bits per channel)
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
void XV_LboxSetBackgroundColor(XV_letterbox *InstancePtr,
|
||||
XLboxColorId ColorId,
|
||||
XVidC_ColorFormat cfmt,
|
||||
XVidC_ColorDepth bpc)
|
||||
{
|
||||
u16 Cr_b_val,y_r_val,Cb_g_val;
|
||||
u16 scale;
|
||||
|
||||
/*
|
||||
* Assert validates the input arguments
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
if(cfmt == XVIDC_CSF_RGB)
|
||||
{
|
||||
scale = ((1<<bpc)-1);
|
||||
y_r_val = bkgndColorRGB[ColorId][0] * scale;
|
||||
Cb_g_val = bkgndColorRGB[ColorId][1] * scale;
|
||||
Cr_b_val = bkgndColorRGB[ColorId][2] * scale;
|
||||
}
|
||||
else //YUV
|
||||
{
|
||||
scale = (((bpc>=8) && (bpc<=16)) ? (bpc-8) : 8);
|
||||
y_r_val = bkgndColorYUV[ColorId][0]<<scale;
|
||||
Cb_g_val = bkgndColorYUV[ColorId][1]<<scale;
|
||||
Cr_b_val = bkgndColorYUV[ColorId][2]<<scale;
|
||||
}
|
||||
|
||||
//Set Background (outside window) to be Black
|
||||
XV_letterbox_Set_HwReg_Y_R_value(InstancePtr, y_r_val);
|
||||
XV_letterbox_Set_HwReg_Cb_G_value(InstancePtr, Cb_g_val);
|
||||
XV_letterbox_Set_HwReg_Cr_B_value(InstancePtr, Cr_b_val);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function prints LBox IP status on the console
|
||||
*
|
||||
* @param InstancePtr is the pointer to the core instance.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
void XV_LBoxDbgReportStatus(XV_letterbox *InstancePtr)
|
||||
{
|
||||
XV_letterbox *pLbox = InstancePtr;
|
||||
u32 done, idle, ready, ctrl;
|
||||
u32 colstart, colend, rowstart, rowend;
|
||||
u32 yr,cbg,crb, width, height;
|
||||
|
||||
/*
|
||||
* Assert validates the input arguments
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
xil_printf("\r\n\r\n----->LBOX IP STATUS<----\r\n");
|
||||
|
||||
done = XV_letterbox_IsDone(pLbox);
|
||||
idle = XV_letterbox_IsIdle(pLbox);
|
||||
ready = XV_letterbox_IsReady(pLbox);
|
||||
ctrl = XV_letterbox_ReadReg(pLbox->Ctrl_BaseAddress, XV_LETTERBOX_CTRL_ADDR_AP_CTRL);
|
||||
|
||||
colstart = XV_letterbox_Get_HwReg_col_start(pLbox);
|
||||
colend = XV_letterbox_Get_HwReg_col_end(pLbox);
|
||||
rowstart = XV_letterbox_Get_HwReg_row_start(pLbox);
|
||||
rowend = XV_letterbox_Get_HwReg_row_end(pLbox);
|
||||
yr = XV_letterbox_Get_HwReg_Y_R_value(pLbox);
|
||||
cbg = XV_letterbox_Get_HwReg_Cb_G_value(pLbox);
|
||||
crb = XV_letterbox_Get_HwReg_Cr_B_value(pLbox);
|
||||
height = XV_letterbox_Get_HwReg_height(pLbox);
|
||||
width = XV_letterbox_Get_HwReg_width(pLbox);
|
||||
|
||||
|
||||
xil_printf("IsDone: %d\r\n", done);
|
||||
xil_printf("IsIdle: %d\r\n", idle);
|
||||
xil_printf("IsReady: %d\r\n", ready);
|
||||
xil_printf("Ctrl: 0x%x\r\n\r\n", ctrl);
|
||||
|
||||
xil_printf(" Window Start X : %d\r\n",colstart);
|
||||
xil_printf(" Window End X : %d\r\n",colend);
|
||||
xil_printf(" Window Start Y : %d\r\n",rowstart);
|
||||
xil_printf(" Window End Y : %d\r\n",rowend);
|
||||
xil_printf(" Frame Width : %d\r\n",width);
|
||||
xil_printf(" Frame Height : %d\r\n",height);
|
||||
xil_printf(" Bkgnd Color Y/R: %d\r\n",yr);
|
||||
xil_printf(" Bkgnd Color U/G: %d\r\n",cbg);
|
||||
xil_printf(" Bkgnd Color V/B: %d\r\n",crb);
|
||||
}
|
140
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox_l2.h
Normal file
140
XilinxProcessorIPLib/drivers/v_letterbox/src/xv_letterbox_l2.h
Normal file
|
@ -0,0 +1,140 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 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 xv_letterbox_l2.h
|
||||
*
|
||||
* This header file contains layer 2 API's of the letter box sub-core driver.
|
||||
* The functions contained herein provides a high level implementation of
|
||||
* features provided by the IP, abstracting away the register level details from
|
||||
* the user
|
||||
*
|
||||
* <b>Letter Box IP Features </b>
|
||||
*
|
||||
* This Letterbox IP supports following features
|
||||
* - Apply black bars (horizontal or vertical) on input stream
|
||||
* - Programmable background colors
|
||||
* - up to 16bits color depth
|
||||
* - 1, 2 or 4 pixel per clock processing
|
||||
* - Input stream up to 4k2k 60Hz
|
||||
*
|
||||
* <b>Dependency</b>
|
||||
*
|
||||
* This driver makes use of the video enumerations and data types defined in the
|
||||
* Xilinx Video Common Driver (video_common_vX.x) and as such the common driver
|
||||
* must be included as dependency to compile this driver
|
||||
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate to the lbox core.
|
||||
*
|
||||
* Before using the layer-2 API's user must initialize the core by calling
|
||||
* Layer-1 API XV_letterbox_Initialize(). This function will look for a
|
||||
* configuration structure for the device and initialize it to defined HW
|
||||
* settings. After initialization Layer-2 API's can be used to configure
|
||||
* the core. It is recommended user always make use of Layer-2 API to
|
||||
* interact with this core.
|
||||
* Advanced users always have the capability to directly interact with the IP
|
||||
* core using Layer-1 API's that perform low level register peek/poke.
|
||||
*
|
||||
* <b> Interrupts </b>
|
||||
*
|
||||
* This driver does not have any interrupts
|
||||
*
|
||||
* <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.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00 rc 05/01/15 Initial Release
|
||||
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XV_LETTERBOX_L2_H /* prevent circular inclusions */
|
||||
#define XV_LETTERBOX_L2_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "xvidc.h"
|
||||
#include "xv_letterbox.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* This typedef contains the different background colors available
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
XLBOX_BKGND_BLACK = 0,
|
||||
XLBOX_BKGND_WHITE,
|
||||
XLBOX_BKGND_RED,
|
||||
XLBOX_BKGND_GREEN,
|
||||
XLBOX_BKGND_BLUE,
|
||||
XLBOX_BKGND_LAST
|
||||
}XLboxColorId;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
void XV_LBoxStart(XV_letterbox *InstancePtr);
|
||||
void XV_LBoxStop(XV_letterbox *InstancePtr);
|
||||
|
||||
void XV_LBoxSetActiveWin(XV_letterbox *InstancePtr,
|
||||
XVidC_VideoWindow *ActiveWindow,
|
||||
u32 FrameWidth,
|
||||
u32 FrameHeight);
|
||||
|
||||
void XV_LboxSetBackgroundColor(XV_letterbox *InstancePtr,
|
||||
XLboxColorId ColorId,
|
||||
XVidC_ColorFormat cfmt,
|
||||
XVidC_ColorDepth bpc);
|
||||
|
||||
void XV_LBoxDbgReportStatus(XV_letterbox *InstancePtr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,150 @@
|
|||
// ==============================================================
|
||||
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
// Version: 2015.1
|
||||
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
//
|
||||
// ==============================================================
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xv_letterbox.h"
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#define MAX_UIO_PATH_SIZE 256
|
||||
#define MAX_UIO_NAME_SIZE 64
|
||||
#define MAX_UIO_MAPS 5
|
||||
#define UIO_INVALID_ADDR 0
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
typedef struct {
|
||||
u32 addr;
|
||||
u32 size;
|
||||
} XV_letterbox_uio_map;
|
||||
|
||||
typedef struct {
|
||||
int uio_fd;
|
||||
int uio_num;
|
||||
char name[ MAX_UIO_NAME_SIZE ];
|
||||
char version[ MAX_UIO_NAME_SIZE ];
|
||||
XV_letterbox_uio_map maps[ MAX_UIO_MAPS ];
|
||||
} XV_letterbox_uio_info;
|
||||
|
||||
/***************** Variable Definitions **************************************/
|
||||
static XV_letterbox_uio_info uio_info;
|
||||
|
||||
/************************** Function Implementation *************************/
|
||||
static int line_from_file(char* filename, char* linebuf) {
|
||||
char* s;
|
||||
int i;
|
||||
FILE* fp = fopen(filename, "r");
|
||||
if (!fp) return -1;
|
||||
s = fgets(linebuf, MAX_UIO_NAME_SIZE, fp);
|
||||
fclose(fp);
|
||||
if (!s) return -2;
|
||||
for (i=0; (*s)&&(i<MAX_UIO_NAME_SIZE); i++) {
|
||||
if (*s == '\n') *s = 0;
|
||||
s++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uio_info_read_name(XV_letterbox_uio_info* info) {
|
||||
char file[ MAX_UIO_PATH_SIZE ];
|
||||
sprintf(file, "/sys/class/uio/uio%d/name", info->uio_num);
|
||||
return line_from_file(file, info->name);
|
||||
}
|
||||
|
||||
static int uio_info_read_version(XV_letterbox_uio_info* info) {
|
||||
char file[ MAX_UIO_PATH_SIZE ];
|
||||
sprintf(file, "/sys/class/uio/uio%d/version", info->uio_num);
|
||||
return line_from_file(file, info->version);
|
||||
}
|
||||
|
||||
static int uio_info_read_map_addr(XV_letterbox_uio_info* info, int n) {
|
||||
int ret;
|
||||
char file[ MAX_UIO_PATH_SIZE ];
|
||||
info->maps[n].addr = UIO_INVALID_ADDR;
|
||||
sprintf(file, "/sys/class/uio/uio%d/maps/map%d/addr", info->uio_num, n);
|
||||
FILE* fp = fopen(file, "r");
|
||||
if (!fp) return -1;
|
||||
ret = fscanf(fp, "0x%x", &info->maps[n].addr);
|
||||
fclose(fp);
|
||||
if (ret < 0) return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uio_info_read_map_size(XV_letterbox_uio_info* info, int n) {
|
||||
int ret;
|
||||
char file[ MAX_UIO_PATH_SIZE ];
|
||||
sprintf(file, "/sys/class/uio/uio%d/maps/map%d/size", info->uio_num, n);
|
||||
FILE* fp = fopen(file, "r");
|
||||
if (!fp) return -1;
|
||||
ret = fscanf(fp, "0x%x", &info->maps[n].size);
|
||||
fclose(fp);
|
||||
if (ret < 0) return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XV_letterbox_Initialize(XV_letterbox *InstancePtr, const char* InstanceName) {
|
||||
XV_letterbox_uio_info *InfoPtr = &uio_info;
|
||||
struct dirent **namelist;
|
||||
int i, n;
|
||||
char* s;
|
||||
char file[ MAX_UIO_PATH_SIZE ];
|
||||
char name[ MAX_UIO_NAME_SIZE ];
|
||||
int flag = 0;
|
||||
|
||||
assert(InstancePtr != NULL);
|
||||
|
||||
n = scandir("/sys/class/uio", &namelist, 0, alphasort);
|
||||
if (n < 0) return XST_DEVICE_NOT_FOUND;
|
||||
for (i = 0; i < n; i++) {
|
||||
strcpy(file, "/sys/class/uio/");
|
||||
strcat(file, namelist[i]->d_name);
|
||||
strcat(file, "/name");
|
||||
if ((line_from_file(file, name) == 0) && (strcmp(name, InstanceName) == 0)) {
|
||||
flag = 1;
|
||||
s = namelist[i]->d_name;
|
||||
s += 3; // "uio"
|
||||
InfoPtr->uio_num = atoi(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag == 0) return XST_DEVICE_NOT_FOUND;
|
||||
|
||||
uio_info_read_name(InfoPtr);
|
||||
uio_info_read_version(InfoPtr);
|
||||
for (n = 0; n < MAX_UIO_MAPS; ++n) {
|
||||
uio_info_read_map_addr(InfoPtr, n);
|
||||
uio_info_read_map_size(InfoPtr, n);
|
||||
}
|
||||
|
||||
sprintf(file, "/dev/uio%d", InfoPtr->uio_num);
|
||||
if ((InfoPtr->uio_fd = open(file, O_RDWR)) < 0) {
|
||||
return XST_OPEN_DEVICE_FAILED;
|
||||
}
|
||||
|
||||
// NOTE: slave interface 'Ctrl' should be mapped to uioX/map0
|
||||
InstancePtr->Ctrl_BaseAddress = (u32)mmap(NULL, InfoPtr->maps[0].size, PROT_READ|PROT_WRITE, MAP_SHARED, InfoPtr->uio_fd, 0 * getpagesize());
|
||||
assert(InstancePtr->Ctrl_BaseAddress);
|
||||
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
int XV_letterbox_Release(XV_letterbox *InstancePtr) {
|
||||
XV_letterbox_uio_info *InfoPtr = &uio_info;
|
||||
|
||||
assert(InstancePtr != NULL);
|
||||
assert(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
munmap((void*)InstancePtr->Ctrl_BaseAddress, InfoPtr->maps[0].size);
|
||||
|
||||
close(InfoPtr->uio_fd);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
// ==============================================================
|
||||
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
|
||||
// Version: 2015.1
|
||||
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
|
||||
//
|
||||
// ==============================================================
|
||||
|
||||
#ifndef __linux__
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xparameters.h"
|
||||
#include "xv_letterbox.h"
|
||||
|
||||
extern XV_letterbox_Config XV_letterbox_ConfigTable[];
|
||||
|
||||
XV_letterbox_Config *XV_letterbox_LookupConfig(u16 DeviceId) {
|
||||
XV_letterbox_Config *ConfigPtr = NULL;
|
||||
|
||||
int Index;
|
||||
|
||||
for (Index = 0; Index < XPAR_XV_LETTERBOX_NUM_INSTANCES; Index++) {
|
||||
if (XV_letterbox_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
ConfigPtr = &XV_letterbox_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ConfigPtr;
|
||||
}
|
||||
|
||||
int XV_letterbox_Initialize(XV_letterbox *InstancePtr, u16 DeviceId) {
|
||||
XV_letterbox_Config *ConfigPtr;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
|
||||
ConfigPtr = XV_letterbox_LookupConfig(DeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
InstancePtr->IsReady = 0;
|
||||
return (XST_DEVICE_NOT_FOUND);
|
||||
}
|
||||
|
||||
return XV_letterbox_CfgInitialize(InstancePtr, ConfigPtr);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue