v_hcresampler: 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:
Rohit Consul 2015-05-27 08:11:30 +08:00 committed by Nava kishore Manne
parent 1de32ec506
commit f37b5011ea
10 changed files with 1201 additions and 0 deletions

View file

@ -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_hcresampler
OPTION supported_peripherals = (v_hcresampler_v1_0 );
OPTION driver_state = ACTIVE;
OPTION copyfiles = all;
OPTION name = v_hcresampler;
OPTION version = 1.0;
END driver

View file

@ -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_hcresampler" \
"NUM_INSTANCES" \
"DEVICE_ID" \
"C_S_AXI_CTRL_BASEADDR" \
"C_S_AXI_CTRL_HIGHADDR"
xdefine_config_file $drv_handle "xv_hcresampler_g.c" "XV_hcresampler" \
"DEVICE_ID" \
"C_S_AXI_CTRL_BASEADDR"
xdefine_canonical_xpars $drv_handle "xparameters.h" "XV_hcresampler" \
"DEVICE_ID" \
"C_S_AXI_CTRL_BASEADDR" \
"C_S_AXI_CTRL_HIGHADDR"
}

View 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_hcresampler"
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} $(OUTS)
make clean
include:
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
clean:
rm -rf ${OUTS}

View file

@ -0,0 +1,336 @@
// ==============================================================
// 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_hcresampler.h"
/************************** Function Implementation *************************/
#ifndef __linux__
int XV_hcresampler_CfgInitialize(XV_hcresampler *InstancePtr, XV_hcresampler_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_hcresampler_Start(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL) & 0x80;
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL, Data | 0x01);
}
u32 XV_hcresampler_IsDone(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL);
return (Data >> 1) & 0x1;
}
u32 XV_hcresampler_IsIdle(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL);
return (Data >> 2) & 0x1;
}
u32 XV_hcresampler_IsReady(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL);
// check ap_start to see if the pcore is ready for next input
return !(Data & 0x1);
}
void XV_hcresampler_EnableAutoRestart(XV_hcresampler *InstancePtr) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL, 0x80);
}
void XV_hcresampler_DisableAutoRestart(XV_hcresampler *InstancePtr) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL, 0);
}
void XV_hcresampler_Set_HwReg_width(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_WIDTH_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_width(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_WIDTH_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_height(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_HEIGHT_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_height(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_HEIGHT_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_input_video_format(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_INPUT_VIDEO_FORMAT_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_input_video_format(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_INPUT_VIDEO_FORMAT_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_output_video_format(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_OUTPUT_VIDEO_FORMAT_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_output_video_format(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_OUTPUT_VIDEO_FORMAT_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_0_0(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_0_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_0_0(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_0_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_0_1(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_1_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_0_1(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_1_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_0_2(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_2_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_0_2(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_2_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_0_3(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_3_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_0_3(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_3_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_1_0(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_0_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_1_0(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_0_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_1_1(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_1_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_1_1(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_1_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_1_2(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_2_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_1_2(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_2_DATA);
return Data;
}
void XV_hcresampler_Set_HwReg_coefs_1_3(XV_hcresampler *InstancePtr, u32 Data) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_3_DATA, Data);
}
u32 XV_hcresampler_Get_HwReg_coefs_1_3(XV_hcresampler *InstancePtr) {
u32 Data;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Data = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_3_DATA);
return Data;
}
void XV_hcresampler_InterruptGlobalEnable(XV_hcresampler *InstancePtr) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_GIE, 1);
}
void XV_hcresampler_InterruptGlobalDisable(XV_hcresampler *InstancePtr) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_GIE, 0);
}
void XV_hcresampler_InterruptEnable(XV_hcresampler *InstancePtr, u32 Mask) {
u32 Register;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Register = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_IER);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_IER, Register | Mask);
}
void XV_hcresampler_InterruptDisable(XV_hcresampler *InstancePtr, u32 Mask) {
u32 Register;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Register = XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_IER);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_IER, Register & (~Mask));
}
void XV_hcresampler_InterruptClear(XV_hcresampler *InstancePtr, u32 Mask) {
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
XV_hcresampler_WriteReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_ISR, Mask);
}
u32 XV_hcresampler_InterruptGetEnabled(XV_hcresampler *InstancePtr) {
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
return XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_IER);
}
u32 XV_hcresampler_InterruptGetStatus(XV_hcresampler *InstancePtr) {
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
return XV_hcresampler_ReadReg(InstancePtr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_ISR);
}

View file

@ -0,0 +1,127 @@
// ==============================================================
// 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_HCRESAMPLER_H
#define XV_HCRESAMPLER_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_hcresampler_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_hcresampler_Config;
#endif
typedef struct {
u32 Ctrl_BaseAddress;
u32 IsReady;
} XV_hcresampler;
/***************** Macros (Inline Functions) Definitions *********************/
#ifndef __linux__
#define XV_hcresampler_WriteReg(BaseAddress, RegOffset, Data) \
Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data))
#define XV_hcresampler_ReadReg(BaseAddress, RegOffset) \
Xil_In32((BaseAddress) + (RegOffset))
#else
#define XV_hcresampler_WriteReg(BaseAddress, RegOffset, Data) \
*(volatile u32*)((BaseAddress) + (RegOffset)) = (u32)(Data)
#define XV_hcresampler_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_hcresampler_Initialize(XV_hcresampler *InstancePtr, u16 DeviceId);
XV_hcresampler_Config* XV_hcresampler_LookupConfig(u16 DeviceId);
int XV_hcresampler_CfgInitialize(XV_hcresampler *InstancePtr, XV_hcresampler_Config *ConfigPtr);
#else
int XV_hcresampler_Initialize(XV_hcresampler *InstancePtr, const char* InstanceName);
int XV_hcresampler_Release(XV_hcresampler *InstancePtr);
#endif
void XV_hcresampler_Start(XV_hcresampler *InstancePtr);
u32 XV_hcresampler_IsDone(XV_hcresampler *InstancePtr);
u32 XV_hcresampler_IsIdle(XV_hcresampler *InstancePtr);
u32 XV_hcresampler_IsReady(XV_hcresampler *InstancePtr);
void XV_hcresampler_EnableAutoRestart(XV_hcresampler *InstancePtr);
void XV_hcresampler_DisableAutoRestart(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_width(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_width(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_height(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_height(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_input_video_format(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_input_video_format(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_output_video_format(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_output_video_format(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_0_0(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_0_0(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_0_1(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_0_1(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_0_2(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_0_2(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_0_3(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_0_3(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_1_0(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_1_0(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_1_1(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_1_1(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_1_2(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_1_2(XV_hcresampler *InstancePtr);
void XV_hcresampler_Set_HwReg_coefs_1_3(XV_hcresampler *InstancePtr, u32 Data);
u32 XV_hcresampler_Get_HwReg_coefs_1_3(XV_hcresampler *InstancePtr);
void XV_hcresampler_InterruptGlobalEnable(XV_hcresampler *InstancePtr);
void XV_hcresampler_InterruptGlobalDisable(XV_hcresampler *InstancePtr);
void XV_hcresampler_InterruptEnable(XV_hcresampler *InstancePtr, u32 Mask);
void XV_hcresampler_InterruptDisable(XV_hcresampler *InstancePtr, u32 Mask);
void XV_hcresampler_InterruptClear(XV_hcresampler *InstancePtr, u32 Mask);
u32 XV_hcresampler_InterruptGetEnabled(XV_hcresampler *InstancePtr);
u32 XV_hcresampler_InterruptGetStatus(XV_hcresampler *InstancePtr);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,104 @@
// ==============================================================
// 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_input_video_format
// bit 7~0 - HwReg_input_video_format[7:0] (Read/Write)
// others - reserved
// 0x24 : reserved
// 0x28 : Data signal of HwReg_output_video_format
// bit 7~0 - HwReg_output_video_format[7:0] (Read/Write)
// others - reserved
// 0x2c : reserved
// 0x30 : Data signal of HwReg_coefs_0_0
// bit 15~0 - HwReg_coefs_0_0[15:0] (Read/Write)
// others - reserved
// 0x34 : reserved
// 0x38 : Data signal of HwReg_coefs_0_1
// bit 15~0 - HwReg_coefs_0_1[15:0] (Read/Write)
// others - reserved
// 0x3c : reserved
// 0x40 : Data signal of HwReg_coefs_0_2
// bit 15~0 - HwReg_coefs_0_2[15:0] (Read/Write)
// others - reserved
// 0x44 : reserved
// 0x48 : Data signal of HwReg_coefs_0_3
// bit 15~0 - HwReg_coefs_0_3[15:0] (Read/Write)
// others - reserved
// 0x4c : reserved
// 0x50 : Data signal of HwReg_coefs_1_0
// bit 15~0 - HwReg_coefs_1_0[15:0] (Read/Write)
// others - reserved
// 0x54 : reserved
// 0x58 : Data signal of HwReg_coefs_1_1
// bit 15~0 - HwReg_coefs_1_1[15:0] (Read/Write)
// others - reserved
// 0x5c : reserved
// 0x60 : Data signal of HwReg_coefs_1_2
// bit 15~0 - HwReg_coefs_1_2[15:0] (Read/Write)
// others - reserved
// 0x64 : reserved
// 0x68 : Data signal of HwReg_coefs_1_3
// bit 15~0 - HwReg_coefs_1_3[15:0] (Read/Write)
// others - reserved
// 0x6c : reserved
// (SC = Self Clear, COR = Clear on Read, TOW = Toggle on Write, COH = Clear on Handshake)
#define XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL 0x00
#define XV_HCRESAMPLER_CTRL_ADDR_GIE 0x04
#define XV_HCRESAMPLER_CTRL_ADDR_IER 0x08
#define XV_HCRESAMPLER_CTRL_ADDR_ISR 0x0c
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_WIDTH_DATA 0x10
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_WIDTH_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_HEIGHT_DATA 0x18
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_HEIGHT_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_INPUT_VIDEO_FORMAT_DATA 0x20
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_INPUT_VIDEO_FORMAT_DATA 8
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_OUTPUT_VIDEO_FORMAT_DATA 0x28
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_OUTPUT_VIDEO_FORMAT_DATA 8
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_0_DATA 0x30
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_0_0_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_1_DATA 0x38
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_0_1_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_2_DATA 0x40
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_0_2_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_0_3_DATA 0x48
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_0_3_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_0_DATA 0x50
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_1_0_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_1_DATA 0x58
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_1_1_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_2_DATA 0x60
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_1_2_DATA 16
#define XV_HCRESAMPLER_CTRL_ADDR_HWREG_COEFS_1_3_DATA 0x68
#define XV_HCRESAMPLER_CTRL_BITS_HWREG_COEFS_1_3_DATA 16

View file

@ -0,0 +1,238 @@
/******************************************************************************
*
* 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_hcresampler_l2.c
*
* The Horizontal Chroma Resampler 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_hcresampler_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_hcresampler_l2.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/**************************** Local Global *******************************/
/************************** Function Prototypes ******************************/
static void hcrUpdateCoefficients(XV_hcresampler *pHCrsmplr, u32 coeff[2][4]);
/*****************************************************************************/
/**
* This function starts the Chroma resampler core
*
* @param InstancePtr is a pointer to the core instance to be worked on.
*
* @return None
*
*****************************************************************************/
void XV_HCrsmplStart(XV_hcresampler *InstancePtr)
{
Xil_AssertVoid(InstancePtr != NULL);
XV_hcresampler_EnableAutoRestart(InstancePtr);
XV_hcresampler_Start(InstancePtr);
}
/*****************************************************************************/
/**
* This function stops the Chroma resampler core
*
* @param InstancePtr is a pointer to the core instance to be worked on.
*
* @return None
*
*****************************************************************************/
void XV_HCrsmplStop(XV_hcresampler *InstancePtr)
{
Xil_AssertVoid(InstancePtr != NULL);
XV_hcresampler_DisableAutoRestart(InstancePtr);
}
/*****************************************************************************/
/**
* This function configures the Chroma resampler active resolution
*
* @param InstancePtr is a pointer to the core instance to be worked on.
* @param width is the active frame width
* @param height is the active frame height
*
* @return None
*
******************************************************************************/
void XV_HCrsmplSetActiveSize(XV_hcresampler *InstancePtr,
u32 width,
u32 height)
{
Xil_AssertVoid(InstancePtr != NULL);
XV_hcresampler_Set_HwReg_width(InstancePtr, width);
XV_hcresampler_Set_HwReg_height(InstancePtr, height);
}
/*****************************************************************************/
/**
* This function configures the Chroma resampler for the required format
* conversion
*
* @param InstancePtr is a pointer to the core instance to be worked on.
* @param formatIn is the input chroma format
* @param formatOut is required chroma format
*
* @return None
*
******************************************************************************/
void XV_HCrsmplSetFormat(XV_hcresampler *InstancePtr,
XVidC_ColorFormat formatIn,
XVidC_ColorFormat formatOut)
{
u32 K[2][4] = {{0}};
/*
* Assert validates the input arguments
*/
Xil_AssertVoid(InstancePtr != NULL);
XV_hcresampler_Set_HwReg_input_video_format(InstancePtr, formatIn);
XV_hcresampler_Set_HwReg_output_video_format(InstancePtr, formatOut);
if((formatIn == XVIDC_CSF_YCRCB_422) &&
(formatOut == XVIDC_CSF_YCRCB_444))
{
K[0][0] = 0;
K[0][1] = 0;
K[0][2] = 4096;
K[0][3] = 0;
K[1][0] = 506;
K[1][1] = 1542;
K[1][2] = 1542;
K[1][3] = 506;
}
else if((formatIn == XVIDC_CSF_YCRCB_444) &&
(formatOut == XVIDC_CSF_YCRCB_422))
{
K[0][0] = 0;
K[0][1] = 1024;
K[0][2] = 2048;
K[0][3] = 1024;
K[1][0] = 0;
K[1][1] = 0;
K[1][2] = 0;
K[1][3] = 0;
}
hcrUpdateCoefficients(InstancePtr, K);
}
/*****************************************************************************/
/**
* This function updates the core registers with computed coefficients for
* required conversion
*
* @param pHCrsmplr is a pointer to the core instance to be worked on.
* @param coeff is the array holding computed coefficients
*
* @return None
*
******************************************************************************/
static void hcrUpdateCoefficients(XV_hcresampler *pHCrsmplr, u32 coeff[2][4])
{
XV_hcresampler_Set_HwReg_coefs_0_0(pHCrsmplr, coeff[0][0]);
XV_hcresampler_Set_HwReg_coefs_0_1(pHCrsmplr, coeff[0][1]);
XV_hcresampler_Set_HwReg_coefs_0_2(pHCrsmplr, coeff[0][2]);
XV_hcresampler_Set_HwReg_coefs_0_3(pHCrsmplr, coeff[0][3]);
XV_hcresampler_Set_HwReg_coefs_1_0(pHCrsmplr, coeff[1][0]);
XV_hcresampler_Set_HwReg_coefs_1_1(pHCrsmplr, coeff[1][1]);
XV_hcresampler_Set_HwReg_coefs_1_2(pHCrsmplr, coeff[1][2]);
XV_hcresampler_Set_HwReg_coefs_1_3(pHCrsmplr, coeff[1][3]);
}
/*****************************************************************************/
/**
*
* This function prints Chroma Resampler status on the console
*
* @param InstancePtr is a pointer to the core instance to be worked on.
*
* @return None
*
******************************************************************************/
void XV_HCrsmplDbgReportStatus(XV_hcresampler *InstancePtr)
{
XV_hcresampler *pHCrsmplr = InstancePtr;
u32 done, idle, ready, ctrl;
u32 vidfmtIn, vidfmtOut, height, width;
/*
* Assert validates the input arguments
*/
Xil_AssertVoid(InstancePtr != NULL);
xil_printf("\r\n\r\n----->H Chroma Resampler IP STATUS<----\r\n");
done = XV_hcresampler_IsDone(pHCrsmplr);
idle = XV_hcresampler_IsIdle(pHCrsmplr);
ready = XV_hcresampler_IsReady(pHCrsmplr);
ctrl = XV_hcresampler_ReadReg(pHCrsmplr->Ctrl_BaseAddress, XV_HCRESAMPLER_CTRL_ADDR_AP_CTRL);
vidfmtIn = XV_hcresampler_Get_HwReg_input_video_format(pHCrsmplr);
vidfmtOut = XV_hcresampler_Get_HwReg_output_video_format(pHCrsmplr);
height = XV_hcresampler_Get_HwReg_height(pHCrsmplr);
width = XV_hcresampler_Get_HwReg_width(pHCrsmplr);
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("Video Format In: %d\r\n", vidfmtIn);
xil_printf("Video Format Out: %d\r\n", vidfmtOut);
xil_printf("Width: %d\r\n", width);
xil_printf("Height: %d\r\n", height);
}

View file

@ -0,0 +1,126 @@
/******************************************************************************
*
* 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_hcresampler_l2.h
*
* This header file contains layer 2 API's of the horizontal chroma resampler
* 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>H Chroma Resampler IP Features </b>
*
* The horizontal chroma resampler IP supports following features
* - convert YUV422 -> YUV444 and YUV444 -> YUV422
* - Supports resolution up to 4k2k 60Hz
* - up to 16 bits color depth
* - 1, 2 or 4 pixel per clock processing
*
* <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 hcresampler core.
*
* Before using the layer-2 API's user must initialize the core by calling
* Layer-1 API XV_hcresampler_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_HCHROMA_RESAMPLER_L2_H /* prevent circular inclusions */
#define XV_HCHROMA_RESAMPLER_L2_H /* by using protection macros */
#ifdef __cplusplus
extern "C" {
#endif
#include "xvidc.h"
#include "xv_hcresampler.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/************************** Function Prototypes ******************************/
void XV_HCrsmplStart(XV_hcresampler *InstancePtr);
void XV_HCrsmplStop(XV_hcresampler *InstancePtr);
void XV_HCrsmplSetActiveSize(XV_hcresampler *InstancePtr,
u32 width,
u32 height);
void XV_HCrsmplSetFormat(XV_hcresampler *InstancePtr,
XVidC_ColorFormat formatIn,
XVidC_ColorFormat formatOut);
void XV_HCrsmplDbgReportStatus(XV_hcresampler *InstancePtr);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -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_hcresampler.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_hcresampler_uio_map;
typedef struct {
int uio_fd;
int uio_num;
char name[ MAX_UIO_NAME_SIZE ];
char version[ MAX_UIO_NAME_SIZE ];
XV_hcresampler_uio_map maps[ MAX_UIO_MAPS ];
} XV_hcresampler_uio_info;
/***************** Variable Definitions **************************************/
static XV_hcresampler_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_hcresampler_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_hcresampler_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_hcresampler_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_hcresampler_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_hcresampler_Initialize(XV_hcresampler *InstancePtr, const char* InstanceName) {
XV_hcresampler_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_hcresampler_Release(XV_hcresampler *InstancePtr) {
XV_hcresampler_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

View file

@ -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_hcresampler.h"
extern XV_hcresampler_Config XV_hcresampler_ConfigTable[];
XV_hcresampler_Config *XV_hcresampler_LookupConfig(u16 DeviceId) {
XV_hcresampler_Config *ConfigPtr = NULL;
int Index;
for (Index = 0; Index < XPAR_XV_HCRESAMPLER_NUM_INSTANCES; Index++) {
if (XV_hcresampler_ConfigTable[Index].DeviceId == DeviceId) {
ConfigPtr = &XV_hcresampler_ConfigTable[Index];
break;
}
}
return ConfigPtr;
}
int XV_hcresampler_Initialize(XV_hcresampler *InstancePtr, u16 DeviceId) {
XV_hcresampler_Config *ConfigPtr;
Xil_AssertNonvoid(InstancePtr != NULL);
ConfigPtr = XV_hcresampler_LookupConfig(DeviceId);
if (ConfigPtr == NULL) {
InstancePtr->IsReady = 0;
return (XST_DEVICE_NOT_FOUND);
}
return XV_hcresampler_CfgInitialize(InstancePtr, ConfigPtr);
}
#endif