diff --git a/XilinxProcessorIPLib/drivers/osd/data/osd.mdd b/XilinxProcessorIPLib/drivers/osd/data/osd.mdd new file mode 100755 index 00000000..6d92c645 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/data/osd.mdd @@ -0,0 +1,51 @@ +############################################################################### +# +# Copyright (C) 2008 - 2014 Xilinx, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# Use of the Software is limited solely to applications: +# (a) running on a Xilinx device, or +# (b) that interact with a Xilinx device through a bus or interconnect. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Except as contained in this notice, the name of the Xilinx shall not be used +# in advertising or otherwise to promote the sale, use or other dealings in +# this Software without prior written authorization from Xilinx. +# +# MODIFICATION HISTORY: +# +## Ver Who Date Changes +# ----- ------ -------- ------------------------------------------------------ +# 1.00a adk 02/18/14 Removed the implementation of interrupt_handler array. +# +############################################################################### +OPTION psf_version = 2.1; + +BEGIN driver osd + + OPTION supported_peripherals = (v_osd_v[6-9]_[0-9]); + OPTION driver_state = ACTIVE; + OPTION copyfiles = all; + OPTION VERSION = 4.0; + OPTION NAME = osd; + + +END driver + + diff --git a/XilinxProcessorIPLib/drivers/osd/data/osd.tcl b/XilinxProcessorIPLib/drivers/osd/data/osd.tcl new file mode 100755 index 00000000..b70b8d62 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/data/osd.tcl @@ -0,0 +1,125 @@ +############################################################### +# (c) Copyright 2008-2014 Xilinx, Inc. All rights reserved. +# +# This file contains confidential and proprietary information +# of Xilinx, Inc. and is protected under U.S. and +# international copyright and other intellectual property +# laws. +# +# DISCLAIMER +# This disclaimer is not a license and does not grant any +# rights to the materials distributed herewith. Except as +# otherwise provided in a valid license issued to you by +# Xilinx, and to the maximum extent permitted by applicable +# law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND +# WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES +# AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING +# BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- +# INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and +# (2) Xilinx shall not be liable (whether in contract or tort, +# including negligence, or under any other theory of +# liability) for any loss or damage of any kind or nature +# related to, arising under or in connection with these +# materials, including for any direct, or any indirect, +# special, incidental, or consequential loss or damage +# (including loss of data, profits, goodwill, or any type of +# loss or damage suffered as a result of any action brought +# by a third party) even if such damage or loss was +# reasonably foreseeable or Xilinx had been advised of the +# possibility of the same. +# +# CRITICAL APPLICATIONS +# Xilinx products are not designed or intended to be fail- +# safe, or for use in any application requiring fail-safe +# performance, such as life-support or safety devices or +# systems, Class III medical devices, nuclear facilities, +# applications related to the deployment of airbags, or any +# other applications that could lead to death, personal +# injury, or severe property or environmental damage +# (individually and collectively, "Critical +# Applications"). Customer assumes the sole risk and +# liability of any use of Xilinx products in Critical +# Applications, subject only to applicable laws and +# regulations governing limitations on product liability. +# +# THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS +# PART OF THIS FILE AT ALL TIMES. +# MODIFICATION HISTORY: +# Ver Who Date Changes +# -------- ------ -------- ------------------------------------ +# 3.0 adk 12/10/13 Updated as per the New Tcl API's +############################################################### + +proc generate {drv_handle} { + xdefine_include_file $drv_handle "xparameters.h" "XOSD" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_NUM_LAYERS" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_LAYER0_TYPE" "C_LAYER1_TYPE" "C_LAYER2_TYPE" "C_LAYER3_TYPE" "C_LAYER4_TYPE" "C_LAYER5_TYPE" "C_LAYER6_TYPE" "C_LAYER7_TYPE" "C_LAYER0_IMEM_SIZE" "C_LAYER0_INS_BOX_EN" "C_LAYER0_INS_LINE_EN" "C_LAYER0_INS_TEXT_EN" "C_LAYER0_CLUT_SIZE" "C_LAYER0_CLUT_MEMTYPE" "C_LAYER0_FONT_NUM_CHARS" "C_LAYER0_FONT_WIDTH" "C_LAYER0_FONT_HEIGHT" "C_LAYER0_FONT_BPP" "C_LAYER0_FONT_ASCII_OFFSET" "C_LAYER0_TEXT_NUM_STRINGS" "C_LAYER0_TEXT_MAX_STRING_LENGTH" "C_LAYER1_IMEM_SIZE" "C_LAYER1_INS_BOX_EN" "C_LAYER1_INS_LINE_EN" "C_LAYER1_INS_TEXT_EN" "C_LAYER1_CLUT_SIZE" "C_LAYER1_CLUT_MEMTYPE" "C_LAYER1_FONT_NUM_CHARS" "C_LAYER1_FONT_WIDTH" "C_LAYER1_FONT_HEIGHT" "C_LAYER1_FONT_BPP" "C_LAYER1_FONT_ASCII_OFFSET" "C_LAYER1_TEXT_NUM_STRINGS" "C_LAYER1_TEXT_MAX_STRING_LENGTH" "C_LAYER2_IMEM_SIZE" "C_LAYER2_INS_BOX_EN" "C_LAYER2_INS_LINE_EN" "C_LAYER2_INS_TEXT_EN" "C_LAYER2_CLUT_SIZE" "C_LAYER2_CLUT_MEMTYPE" "C_LAYER2_FONT_NUM_CHARS" "C_LAYER2_FONT_WIDTH" "C_LAYER2_FONT_HEIGHT" "C_LAYER2_FONT_BPP" "C_LAYER2_FONT_ASCII_OFFSET" "C_LAYER2_TEXT_NUM_STRINGS" "C_LAYER2_TEXT_MAX_STRING_LENGTH" "C_LAYER3_IMEM_SIZE" "C_LAYER3_INS_BOX_EN" "C_LAYER3_INS_LINE_EN" "C_LAYER3_INS_TEXT_EN" "C_LAYER3_CLUT_SIZE" "C_LAYER3_CLUT_MEMTYPE" "C_LAYER3_FONT_NUM_CHARS" "C_LAYER3_FONT_WIDTH" "C_LAYER3_FONT_HEIGHT" "C_LAYER3_FONT_BPP" "C_LAYER3_FONT_ASCII_OFFSET" "C_LAYER3_TEXT_NUM_STRINGS" "C_LAYER3_TEXT_MAX_STRING_LENGTH" "C_LAYER4_IMEM_SIZE" "C_LAYER4_INS_BOX_EN" "C_LAYER4_INS_LINE_EN" "C_LAYER4_INS_TEXT_EN" "C_LAYER4_CLUT_SIZE" "C_LAYER4_CLUT_MEMTYPE" "C_LAYER4_FONT_NUM_CHARS" "C_LAYER4_FONT_WIDTH" "C_LAYER4_FONT_HEIGHT" "C_LAYER4_FONT_BPP" "C_LAYER4_FONT_ASCII_OFFSET" "C_LAYER4_TEXT_NUM_STRINGS" "C_LAYER4_TEXT_MAX_STRING_LENGTH" "C_LAYER5_IMEM_SIZE" "C_LAYER5_INS_BOX_EN" "C_LAYER5_INS_LINE_EN" "C_LAYER5_INS_TEXT_EN" "C_LAYER5_CLUT_SIZE" "C_LAYER5_CLUT_MEMTYPE" "C_LAYER5_FONT_NUM_CHARS" "C_LAYER5_FONT_WIDTH" "C_LAYER5_FONT_HEIGHT" "C_LAYER5_FONT_BPP" "C_LAYER5_FONT_ASCII_OFFSET" "C_LAYER5_TEXT_NUM_STRINGS" "C_LAYER5_TEXT_MAX_STRING_LENGTH" "C_LAYER6_IMEM_SIZE" "C_LAYER6_INS_BOX_EN" "C_LAYER6_INS_LINE_EN" "C_LAYER6_INS_TEXT_EN" "C_LAYER6_CLUT_SIZE" "C_LAYER6_CLUT_MEMTYPE" "C_LAYER6_FONT_NUM_CHARS" "C_LAYER6_FONT_WIDTH" "C_LAYER6_FONT_HEIGHT" "C_LAYER6_FONT_BPP" "C_LAYER6_FONT_ASCII_OFFSET" "C_LAYER6_TEXT_NUM_STRINGS" "C_LAYER6_TEXT_MAX_STRING_LENGTH" "C_LAYER7_IMEM_SIZE" "C_LAYER7_INS_BOX_EN" "C_LAYER7_INS_LINE_EN" "C_LAYER7_INS_TEXT_EN" "C_LAYER7_CLUT_SIZE" "C_LAYER7_CLUT_MEMTYPE" "C_LAYER7_FONT_NUM_CHARS" "C_LAYER7_FONT_WIDTH" "C_LAYER7_FONT_HEIGHT" "C_LAYER7_FONT_BPP" "C_LAYER7_FONT_ASCII_OFFSET" "C_LAYER7_TEXT_NUM_STRINGS" "C_LAYER7_TEXT_MAX_STRING_LENGTH" + xdefine_config_file $drv_handle "xosd_g.c" "XOSD" "DEVICE_ID" "C_BASEADDR" "C_NUM_LAYERS" "C_S_AXIS_VIDEO_DATA_WIDTH" "C_LAYER0_TYPE" "C_LAYER1_TYPE" "C_LAYER2_TYPE" "C_LAYER3_TYPE" "C_LAYER4_TYPE" "C_LAYER5_TYPE" "C_LAYER6_TYPE" "C_LAYER7_TYPE" "C_LAYER0_IMEM_SIZE" "C_LAYER0_INS_BOX_EN" "C_LAYER0_INS_LINE_EN" "C_LAYER0_INS_TEXT_EN" "C_LAYER0_CLUT_SIZE" "C_LAYER0_CLUT_MEMTYPE" "C_LAYER0_FONT_NUM_CHARS" "C_LAYER0_FONT_WIDTH" "C_LAYER0_FONT_HEIGHT" "C_LAYER0_FONT_BPP" "C_LAYER0_FONT_ASCII_OFFSET" "C_LAYER0_TEXT_NUM_STRINGS" "C_LAYER0_TEXT_MAX_STRING_LENGTH" "C_LAYER1_IMEM_SIZE" "C_LAYER1_INS_BOX_EN" "C_LAYER1_INS_LINE_EN" "C_LAYER1_INS_TEXT_EN" "C_LAYER1_CLUT_SIZE" "C_LAYER1_CLUT_MEMTYPE" "C_LAYER1_FONT_NUM_CHARS" "C_LAYER1_FONT_WIDTH" "C_LAYER1_FONT_HEIGHT" "C_LAYER1_FONT_BPP" "C_LAYER1_FONT_ASCII_OFFSET" "C_LAYER1_TEXT_NUM_STRINGS" "C_LAYER1_TEXT_MAX_STRING_LENGTH" "C_LAYER2_IMEM_SIZE" "C_LAYER2_INS_BOX_EN" "C_LAYER2_INS_LINE_EN" "C_LAYER2_INS_TEXT_EN" "C_LAYER2_CLUT_SIZE" "C_LAYER2_CLUT_MEMTYPE" "C_LAYER2_FONT_NUM_CHARS" "C_LAYER2_FONT_WIDTH" "C_LAYER2_FONT_HEIGHT" "C_LAYER2_FONT_BPP" "C_LAYER2_FONT_ASCII_OFFSET" "C_LAYER2_TEXT_NUM_STRINGS" "C_LAYER2_TEXT_MAX_STRING_LENGTH" "C_LAYER3_IMEM_SIZE" "C_LAYER3_INS_BOX_EN" "C_LAYER3_INS_LINE_EN" "C_LAYER3_INS_TEXT_EN" "C_LAYER3_CLUT_SIZE" "C_LAYER3_CLUT_MEMTYPE" "C_LAYER3_FONT_NUM_CHARS" "C_LAYER3_FONT_WIDTH" "C_LAYER3_FONT_HEIGHT" "C_LAYER3_FONT_BPP" "C_LAYER3_FONT_ASCII_OFFSET" "C_LAYER3_TEXT_NUM_STRINGS" "C_LAYER3_TEXT_MAX_STRING_LENGTH" "C_LAYER4_IMEM_SIZE" "C_LAYER4_INS_BOX_EN" "C_LAYER4_INS_LINE_EN" "C_LAYER4_INS_TEXT_EN" "C_LAYER4_CLUT_SIZE" "C_LAYER4_CLUT_MEMTYPE" "C_LAYER4_FONT_NUM_CHARS" "C_LAYER4_FONT_WIDTH" "C_LAYER4_FONT_HEIGHT" "C_LAYER4_FONT_BPP" "C_LAYER4_FONT_ASCII_OFFSET" "C_LAYER4_TEXT_NUM_STRINGS" "C_LAYER4_TEXT_MAX_STRING_LENGTH" "C_LAYER5_IMEM_SIZE" "C_LAYER5_INS_BOX_EN" "C_LAYER5_INS_LINE_EN" "C_LAYER5_INS_TEXT_EN" "C_LAYER5_CLUT_SIZE" "C_LAYER5_CLUT_MEMTYPE" "C_LAYER5_FONT_NUM_CHARS" "C_LAYER5_FONT_WIDTH" "C_LAYER5_FONT_HEIGHT" "C_LAYER5_FONT_BPP" "C_LAYER5_FONT_ASCII_OFFSET" "C_LAYER5_TEXT_NUM_STRINGS" "C_LAYER5_TEXT_MAX_STRING_LENGTH" "C_LAYER6_IMEM_SIZE" "C_LAYER6_INS_BOX_EN" "C_LAYER6_INS_LINE_EN" "C_LAYER6_INS_TEXT_EN" "C_LAYER6_CLUT_SIZE" "C_LAYER6_CLUT_MEMTYPE" "C_LAYER6_FONT_NUM_CHARS" "C_LAYER6_FONT_WIDTH" "C_LAYER6_FONT_HEIGHT" "C_LAYER6_FONT_BPP" "C_LAYER6_FONT_ASCII_OFFSET" "C_LAYER6_TEXT_NUM_STRINGS" "C_LAYER6_TEXT_MAX_STRING_LENGTH" "C_LAYER7_IMEM_SIZE" "C_LAYER7_INS_BOX_EN" "C_LAYER7_INS_LINE_EN" "C_LAYER7_INS_TEXT_EN" "C_LAYER7_CLUT_SIZE" "C_LAYER7_CLUT_MEMTYPE" "C_LAYER7_FONT_NUM_CHARS" "C_LAYER7_FONT_WIDTH" "C_LAYER7_FONT_HEIGHT" "C_LAYER7_FONT_BPP" "C_LAYER7_FONT_ASCII_OFFSET" "C_LAYER7_TEXT_NUM_STRINGS" "C_LAYER7_TEXT_MAX_STRING_LENGTH" + xdefine_canonical_xpars $drv_handle "xparameters.h" "OSD" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_NUM_LAYERS" "C_LAYER0_TYPE" "C_LAYER1_TYPE" "C_LAYER2_TYPE" "C_LAYER3_TYPE" "C_LAYER4_TYPE" "C_LAYER5_TYPE" "C_LAYER6_TYPE" "C_LAYER7_TYPE" "C_LAYER0_IMEM_SIZE" "C_LAYER0_INS_BOX_EN" "C_LAYER0_INS_LINE_EN" "C_LAYER0_INS_TEXT_EN" "C_LAYER0_CLUT_SIZE" "C_LAYER0_CLUT_MEMTYPE" "C_LAYER0_FONT_NUM_CHARS" "C_LAYER0_FONT_WIDTH" "C_LAYER0_FONT_HEIGHT" "C_LAYER0_FONT_BPP" "C_LAYER0_FONT_ASCII_OFFSET" "C_LAYER0_TEXT_NUM_STRINGS" "C_LAYER0_TEXT_MAX_STRING_LENGTH" "C_LAYER1_IMEM_SIZE" "C_LAYER1_INS_BOX_EN" "C_LAYER1_INS_LINE_EN" "C_LAYER1_INS_TEXT_EN" "C_LAYER1_CLUT_SIZE" "C_LAYER1_CLUT_MEMTYPE" "C_LAYER1_FONT_NUM_CHARS" "C_LAYER1_FONT_WIDTH" "C_LAYER1_FONT_HEIGHT" "C_LAYER1_FONT_BPP" "C_LAYER1_FONT_ASCII_OFFSET" "C_LAYER1_TEXT_NUM_STRINGS" "C_LAYER1_TEXT_MAX_STRING_LENGTH" "C_LAYER2_IMEM_SIZE" "C_LAYER2_INS_BOX_EN" "C_LAYER2_INS_LINE_EN" "C_LAYER2_INS_TEXT_EN" "C_LAYER2_CLUT_SIZE" "C_LAYER2_CLUT_MEMTYPE" "C_LAYER2_FONT_NUM_CHARS" "C_LAYER2_FONT_WIDTH" "C_LAYER2_FONT_HEIGHT" "C_LAYER2_FONT_BPP" "C_LAYER2_FONT_ASCII_OFFSET" "C_LAYER2_TEXT_NUM_STRINGS" "C_LAYER2_TEXT_MAX_STRING_LENGTH" "C_LAYER3_IMEM_SIZE" "C_LAYER3_INS_BOX_EN" "C_LAYER3_INS_LINE_EN" "C_LAYER3_INS_TEXT_EN" "C_LAYER3_CLUT_SIZE" "C_LAYER3_CLUT_MEMTYPE" "C_LAYER3_FONT_NUM_CHARS" "C_LAYER3_FONT_WIDTH" "C_LAYER3_FONT_HEIGHT" "C_LAYER3_FONT_BPP" "C_LAYER3_FONT_ASCII_OFFSET" "C_LAYER3_TEXT_NUM_STRINGS" "C_LAYER3_TEXT_MAX_STRING_LENGTH" "C_LAYER4_IMEM_SIZE" "C_LAYER4_INS_BOX_EN" "C_LAYER4_INS_LINE_EN" "C_LAYER4_INS_TEXT_EN" "C_LAYER4_CLUT_SIZE" "C_LAYER4_CLUT_MEMTYPE" "C_LAYER4_FONT_NUM_CHARS" "C_LAYER4_FONT_WIDTH" "C_LAYER4_FONT_HEIGHT" "C_LAYER4_FONT_BPP" "C_LAYER4_FONT_ASCII_OFFSET" "C_LAYER4_TEXT_NUM_STRINGS" "C_LAYER4_TEXT_MAX_STRING_LENGTH" "C_LAYER5_IMEM_SIZE" "C_LAYER5_INS_BOX_EN" "C_LAYER5_INS_LINE_EN" "C_LAYER5_INS_TEXT_EN" "C_LAYER5_CLUT_SIZE" "C_LAYER5_CLUT_MEMTYPE" "C_LAYER5_FONT_NUM_CHARS" "C_LAYER5_FONT_WIDTH" "C_LAYER5_FONT_HEIGHT" "C_LAYER5_FONT_BPP" "C_LAYER5_FONT_ASCII_OFFSET" "C_LAYER5_TEXT_NUM_STRINGS" "C_LAYER5_TEXT_MAX_STRING_LENGTH" "C_LAYER6_IMEM_SIZE" "C_LAYER6_INS_BOX_EN" "C_LAYER6_INS_LINE_EN" "C_LAYER6_INS_TEXT_EN" "C_LAYER6_CLUT_SIZE" "C_LAYER6_CLUT_MEMTYPE" "C_LAYER6_FONT_NUM_CHARS" "C_LAYER6_FONT_WIDTH" "C_LAYER6_FONT_HEIGHT" "C_LAYER6_FONT_BPP" "C_LAYER6_FONT_ASCII_OFFSET" "C_LAYER6_TEXT_NUM_STRINGS" "C_LAYER6_TEXT_MAX_STRING_LENGTH" "C_LAYER7_IMEM_SIZE" "C_LAYER7_INS_BOX_EN" "C_LAYER7_INS_LINE_EN" "C_LAYER7_INS_TEXT_EN" "C_LAYER7_CLUT_SIZE" "C_LAYER7_CLUT_MEMTYPE" "C_LAYER7_FONT_NUM_CHARS" "C_LAYER7_FONT_WIDTH" "C_LAYER7_FONT_HEIGHT" "C_LAYER7_FONT_BPP" "C_LAYER7_FONT_ASCII_OFFSET" "C_LAYER7_TEXT_NUM_STRINGS" "C_LAYER7_TEXT_MAX_STRING_LENGTH" +} + + +# +# Given a list of arguments, define each as a canonical constant name, using +# the driver name, in an include file. +# +proc xdefine_canonical_xpars {drv_handle file_name drv_string args} { + # Open include file + set file_handle [::hsm::utils::open_include_file $file_name] + + # Get all the peripherals connected to this driver + set periphs [::hsm::utils::get_common_driver_ips $drv_handle] + + # Get the names of all the peripherals connected to this driver + foreach periph $periphs { + set peripheral_name [string toupper [get_property NAME $periph]] + lappend peripherals $peripheral_name + } + + # Get possible canonical names for all the peripherals connected to this driver + set device_id 0 + foreach periph $periphs { + set canonical_name [string toupper [format "%s_%s" $drv_string $device_id]] + lappend canonicals $canonical_name + + # Create a list of IDs of the peripherals whose hardware instance name + # doesn't match the canonical name. These IDs can be used later to + # generate canonical definitions + if { [lsearch $peripherals $canonical_name] < 0 } { + lappend indices $device_id + } + incr device_id + } + + set i 0 + foreach periph $periphs { + set periph_name [string toupper [get_property NAME $periph]] + + # Generate canonical definitions only for the peripherals whose + # canonical name is not the same as hardware instance name + if { [lsearch $canonicals $periph_name] < 0 } { + puts $file_handle "/* Canonical definitions for peripheral $periph_name */" + set canonical_name [format "%s_%s" $drv_string [lindex $indices $i]] + + foreach arg $args { + set lvalue [::hsm::utils::get_driver_param_name $canonical_name $arg] + + # The commented out rvalue is the name of the instance-specific constant + # set rvalue [::hsm::utils::get_ip_param_name $periph $arg] + + # The rvalue set below is the actual value of the parameter + set rvalue [get_property CONFIG.$arg $periph] + if {[llength $rvalue] == 0} { + set rvalue 0 + } + set rvalue [::hsm::utils::format_addr_string $rvalue $arg] + + puts $file_handle "#define $lvalue $rvalue" + + } + puts $file_handle "" + incr i + } + } + + puts $file_handle "\n/******************************************************************/\n" + close $file_handle +} diff --git a/XilinxProcessorIPLib/drivers/osd/examples/example.c b/XilinxProcessorIPLib/drivers/osd/examples/example.c new file mode 100755 index 00000000..a8e51444 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/examples/example.c @@ -0,0 +1,460 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** + * + * @file example.c + * + * This file demonstrates how to use Xilinx Video On-Screen-Display (OSD) + * driver on Xilinx MVI OSD device. + * + * This code makes the following assumptions: + * + * - The OSD device contains at least 2 layers + * - Layer 0 has type GPU + * - Each layer has the following configuration during the hardware build + * - Font width = 8 + * - Font height = 8 + * - Font bits per pixel = 1 + * - Number of the font characters = 128 + * - Caching is disabled. Flushing and Invalidation operations for data buffer + * need to be added to this code if it is not the case. + * + *
+ * MODIFICATION HISTORY: + * + * Ver Who Date Changes + * ----- ---- -------- ------------------------------------------------------- + * 1.00a xd 05/12/09 First release + *+ * + * **************************************************************************** + */ + +#include "xosd.h" +#include "xparameters.h" + +/* + * Device related constants. Defined in xparameters.h + */ +#define OSD_DEVICE_ID XPAR_OSD_0_DEVICE_ID + +/* + * OSD Device related data structures + */ +XOSD Osd; /* OSD Device driver instance */ +XOSD_Config *OsdCfgPtr; /* OSD device configuration pointer */ + +/* + * Color table definition + */ +u32 ColorData[16] = { + 0x00000000, 0xa0a25f58, 0xa08080ff, 0xa0808010, + 0xa0ef5a51, 0x00000000, 0xa0465289, 0x00000000, + 0xa065ba6b, 0x00000000, 0xa09017c5, 0xa0a9c860, + 0xa0bc3198, 0xa010a5a9, 0xa0808080, 0xa0ada1ab +}; + +/* + * Text table definition + */ +char __attribute__ ((aligned (4))) TextData[8][32] = { + "String #1", + "String #2", + "String #3", + "String #4", + "String #5", + "String #6", + "String #7", + "String #8" +}; + +/* + * Font definition + */ +unsigned char __attribute__ ((aligned (4))) Font[128][8] = { + {0x00, 0x36, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00}, // NULL + {0x18, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x18}, + {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}, + {0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00}, + {0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18}, + {0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18}, + {0x03, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xC0}, + {0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0x07, 0x03}, + {0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}, + {0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F}, + {0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF}, + {0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00}, + {0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00}, + {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}, + {0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0}, + {0x00, 0x1C, 0x1C, 0x77, 0x77, 0x08, 0x1C, 0x00}, + {0x00, 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18}, + {0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00}, + {0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 0x18, 0x18}, + {0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x3C, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}, + {0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0}, + {0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x18, 0x18}, + {0x18, 0x18, 0x18, 0xFF, 0xFF, 0x00, 0x00, 0x00}, + {0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0}, + {0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, 0x00}, + {0x78, 0x60, 0x78, 0x60, 0x7E, 0x18, 0x1E, 0x00}, + {0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x00}, + {0x00, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00}, + {0x00, 0x18, 0x30, 0x7E, 0x30, 0x18, 0x00, 0x00}, + {0x00, 0x18, 0x0C, 0x7E, 0x0C, 0x18, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Space + {0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00}, + {0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x66, 0xFF, 0x66, 0x66, 0xFF, 0x66, 0x00}, + {0x18, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x18, 0x00}, + {0x00, 0x66, 0x6C, 0x18, 0x30, 0x66, 0x46, 0x00}, + {0x1C, 0x36, 0x1C, 0x38, 0x6F, 0x66, 0x3B, 0x00}, + {0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x0E, 0x1C, 0x18, 0x18, 0x1C, 0x0E, 0x00}, + {0x00, 0x70, 0x38, 0x18, 0x18, 0x38, 0x70, 0x00}, + {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, + {0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30}, + {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}, + {0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, + {0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x3C, 0x00}, + {0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E, 0x00}, + {0x00, 0x3C, 0x66, 0x0C, 0x18, 0x30, 0x7E, 0x00}, + {0x00, 0x7E, 0x0C, 0x18, 0x0C, 0x66, 0x3C, 0x00}, + {0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0x7E, 0x0C, 0x00}, + {0x00, 0x7E, 0x60, 0x7C, 0x06, 0x66, 0x3C, 0x00}, + {0x00, 0x3C, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00}, + {0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x00}, + {0x00, 0x3C, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00}, + {0x00, 0x3C, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00}, + {0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00}, + {0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30}, + {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, + {0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00}, + {0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00}, + {0x00, 0x3C, 0x66, 0x0C, 0x18, 0x00, 0x18, 0x00}, + + {0x00, 0x3C, 0x66, 0x6E, 0x6E, 0x60, 0x3E, 0x00}, // @ + {0x00, 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x00}, // A + {0x00, 0x7C, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00}, + {0x00, 0x3C, 0x66, 0x60, 0x60, 0x66, 0x3C, 0x00}, + {0x00, 0x78, 0x6C, 0x66, 0x66, 0x6C, 0x78, 0x00}, + {0x00, 0x7E, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00}, + {0x00, 0x7E, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x00}, + {0x00, 0x3E, 0x60, 0x60, 0x6E, 0x66, 0x3E, 0x00}, + {0x00, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00}, + {0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00}, + {0x00, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3C, 0x00}, + {0x00, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0x00}, + {0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00}, + {0x00, 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x00}, + {0x00, 0x66, 0x76, 0x7E, 0x7E, 0x6E, 0x66, 0x00}, + {0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, + {0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x00}, + {0x00, 0x3C, 0x66, 0x66, 0x66, 0x6C, 0x36, 0x00}, + {0x00, 0x7C, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0x00}, + {0x00, 0x3C, 0x60, 0x3C, 0x06, 0x06, 0x3C, 0x00}, + {0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}, + {0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7E, 0x00}, + {0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00}, + {0x00, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, + {0x00, 0x66, 0x66, 0x3C, 0x3C, 0x66, 0x66, 0x00}, + {0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00}, + {0x00, 0x7E, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00}, + {0x00, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, + {0x00, 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00}, + {0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00}, + {0x00, 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00}, + + {0x40, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}, // ` + {0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00}, // a + {0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00}, + {0x00, 0x00, 0x3C, 0x60, 0x60, 0x60, 0x3C, 0x00}, + {0x00, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x00}, + {0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00}, + {0x00, 0x0E, 0x18, 0x3E, 0x18, 0x18, 0x18, 0x00}, + {0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x7C}, + {0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x00}, + {0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3C, 0x00}, + {0x00, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x3C}, + {0x00, 0x60, 0x60, 0x6C, 0x78, 0x6C, 0x66, 0x00}, + {0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00}, + {0x00, 0x00, 0x66, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, + {0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00}, + {0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00}, + {0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60}, + {0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x06}, + {0x00, 0x00, 0x7C, 0x66, 0x60, 0x60, 0x60, 0x00}, + {0x00, 0x00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x00}, + {0x00, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x0E, 0x00}, + {0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00}, + {0x00, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00}, + {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x3E, 0x36, 0x00}, + {0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00}, + {0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x0C, 0x78}, + {0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00}, + + {0x14, 0x10, 0x10, 0x40, 0x10, 0x10, 0x14, 0x00}, // { + {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}, + {0x50, 0x10, 0x10, 0x04, 0x10, 0x10, 0x50, 0x00}, // } + {0x11, 0x11, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00}, // ~ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 127 DEL +}; + +/* + * Function prototypes + */ +static int OsdExample(int DeviceID); +static int OsdInit(int DeviceID); +static void OsdConfig(void); +static void OsdDrawBox(void); + +/*****************************************************************************/ +/** +* +* This is the main function for the OSD example. +* +* @param None. +* +* @return 0 to indicate success, otherwise 1. +* +* @note None. +* +******************************************************************************/ +int main(void) +{ + int Status; + + /* + * Call the OSD example, use the Device IDs generated in xparameters.h + */ + Status = OsdExample(OSD_DEVICE_ID); + if (Status != 0) + return 1; + + return 0; +} + +/*****************************************************************************/ +/** +* +* This function is the entry of the feature demonstrations on MVI Video OSD +* device. It initialized an OSD device, configures 2 layers, load +* text/color/font information, and draws a box to the OSD output. +* +* @param DeviceID is the device ID of the OSD device. +* +* @return 0 if all tests pass, 1 otherwise. +* +* @note None. +* +******************************************************************************/ +static int OsdExample(int DeviceID) +{ + int Status; + + /* Initialize the OSD instance */ + + Status = OsdInit(DeviceID); + if (Status != XST_SUCCESS) + return 1; + + /* Configure the OSD instance */ + + OsdConfig(); + + /* Draw a box */ + + OsdDrawBox(); + + /* Return success */ + + return 0; +} + +/*****************************************************************************/ +/** +* +* This function initializes the OSD device and its driver instance. +* +* @param DeviceID is the device ID of the OSD device. +* +* @return 0 if the initialization is successful; 1 otherwise. +* +* @note None. +* +******************************************************************************/ +int OsdInit(int DeviceID) +{ + int Status; + + /* Initialize the OSD instance */ + + OsdCfgPtr = XOSD_LookupConfig(DeviceID); + Status = XOSD_CfgInitialize(&Osd, OsdCfgPtr, OsdCfgPtr->BaseAddress); + if (Status != XST_SUCCESS) + return 1; + + /* Reset the devices */ + + XOSD_Reset(&Osd); + + /* Enable the OSD device and tell it to pick up the register changes */ + + XOSD_Enable(&Osd); + XOSD_RegUpdateEnable(&Osd); + + return 0; +} + +/*****************************************************************************/ +/** +* +* This function does the general configuration on an OSD device. The +* configuration includes: +* +* - Screen Size +* - Background Color +* - Layer 0 setup: Alpha, Priority, Dimension and enabling +* - Layer 1 setup: Alpha, Priority, Dimension and enabling +* - Loading Color/Font/Text configuration +* +* @param None. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +static void OsdConfig(void) +{ + /* Dimension definition */ + + int Width = 1280; + int Height = 720; + + /* Background color definition */ + + u8 Red = 0xFF; + u8 Blue = 0; + u8 Green = 0; + + /* Layer 0/1 property definition */ + + int Layer0AlphaValue = 0xFF; + int Layer0Priority = XOSD_LAYER_PRIORITY_0; + int Layer0GlobalAlphaEnable = 1; + + int Layer1AlphaValue = 0x80; /* 50% transparent */ + int Layer1Priority = XOSD_LAYER_PRIORITY_1; + int Layer1GlobalAlphaEnable = 0; + + /* Set screen size */ + + XOSD_SetScreenSize(&Osd, Width, Height); + + /* Set Background color */ + + XOSD_SetBackgroundColor(&Osd, Red, Blue, Green); + + /* Set up Layer 0's Alpha, Priority, Dimension and enable it */ + + XOSD_SetLayerAlpha(&Osd, 0, Layer0GlobalAlphaEnable, Layer0AlphaValue); + XOSD_SetLayerPriority(&Osd, 0, Layer0Priority); + XOSD_SetLayerDimension(&Osd, 0, 0, 0, Width, Height); + XOSD_EnableLayer(&Osd, 0); + + /* Set up Layer 1's Alpha, Priority, Dimension and enable it */ + + XOSD_SetLayerAlpha(&Osd, 1, Layer1GlobalAlphaEnable, Layer1AlphaValue); + XOSD_SetLayerPriority(&Osd, 1, Layer1Priority); + XOSD_SetLayerDimension(&Osd, 1, 0, 0, Width, Height); + XOSD_EnableLayer(&Osd, 1); + + /* Load color, font and text and set the active banks */ + + XOSD_LoadColorLUTBank(&Osd, 0, 0, ColorData); + XOSD_LoadCharacterSetBank(&Osd, 0, 0, (u32 *)Font); + XOSD_LoadTextBank(&Osd, 0, 0, (u32 *)TextData); + XOSD_SetActiveBank(&Osd, 0, 0, 0, 0, 0); + + return; +} + +/*****************************************************************************/ +/** +* +* This function draws a box using the OSD device +* +* @param None. +* +* @return None. +* +* @note None. +* +******************************************************************************/ +static void OsdDrawBox(void) +{ + /* Instruction buffer */ + + u32 Instruction[XOSD_INS_SIZE]; + + /* Instruction property definition */ + + u16 ObjType = XOSD_INS_OPCODE_BOX; /* A box */ + u8 ObjSize = 1; /* Box boarder width */ + u16 XStart = 100; /* Horizontal start pixel of the box */ + u16 YStart = 100; /* Vertical start line of the box */ + u16 XEnd = 200; /* Horizontal end pixel of the box */ + u16 YEnd = 200; /* Vertical end line of the box */ + u8 TextIndex = 0; /* Ignored in box instruction case */ + u8 ColorIndex = 0; /* Draw the box w/ the 1st color */ + + /* Create a box command instruction for GC #0 */ + + XOSD_CreateInstruction(&Osd, Instruction, 0, + ObjType, ObjSize, + XStart, YStart, XEnd, YEnd, + TextIndex, ColorIndex); + + /* Load the instruction to draw the box in the OSD output */ + + XOSD_LoadInstructionList(&Osd, 0, 0, Instruction, 1); + + return; +} diff --git a/XilinxProcessorIPLib/drivers/osd/examples/index.html b/XilinxProcessorIPLib/drivers/osd/examples/index.html new file mode 100755 index 00000000..55bf2979 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/examples/index.html @@ -0,0 +1,17 @@ + + + + + +
Copyright � 1995-2014 Xilinx, Inc. All rights reserved.
+ + \ No newline at end of file diff --git a/XilinxProcessorIPLib/drivers/osd/src/Makefile b/XilinxProcessorIPLib/drivers/osd/src/Makefile new file mode 100755 index 00000000..8ebb71ba --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/Makefile @@ -0,0 +1,29 @@ +COMPILER= +ARCHIVER= +CP=cp +COMPILER_FLAGS= +EXTRA_COMPILER_FLAGS= +LIB=libxil.a +LEVEL=0 + +RELEASEDIR=../../../lib +INCLUDEDIR=../../../include +INCLUDES=-I./. -I${INCLUDEDIR} + +INCLUDEFILES=*.h +LIBSOURCES=*.c + +OUTS = *.o + +libs: + echo "Compiling osd" + $(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES) + $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS} + make clean + +include: + ${CP} $(INCLUDEFILES) $(INCLUDEDIR) + +clean: + rm -rf ${OUTS} + diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd.c b/XilinxProcessorIPLib/drivers/osd/src/xosd.c new file mode 100755 index 00000000..53df6c48 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd.c @@ -0,0 +1,1323 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file xosd.c +* +* This is main code of Xilinx MVI Video On-Screen-Display (OSD) device driver. +* Please see xosd.h for more details of the driver. +* +*+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ------------------------------------------------------- +* 1.00a xd 08/18/08 First release +* 1.02a xd 12/21/10 Removed endian conversion for text bank loading +* 1.03a cm 09/07/11 Updated XOSD_GetLayerAlpha(), XOSD_SetLayerAlpha(), +* XOSD_SetBackgroundColor() and XOSD_GetBackgroundColor() +* to allow 10 and 12 bit alpha and background colors. +* 2.00a cjm 12/18/12 Converted from xio.h to xil_io.h, translating +* basic types, MB cache functions, exceptions and +* assertions to xil_io format. +*+* +******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xosd.h" +#include "xenv.h" + +/************************** Constant Definitions *****************************/ + + +/**************************** Type Definitions *******************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/************************** Function Prototypes ******************************/ + +static void PopulateLayerProperty(XOSD *InstancePtr, XOSD_Config *CfgPtr); +static void StubCallBack(void *CallBackRef); +static void StubErrCallBack(void *CallBackRef, u32 ErrorMask); + +/************************** Function Definition ******************************/ + +/*****************************************************************************/ +/** + * This function initializes an OSD device. This function must be called + * prior to using an OSD device. Initialization of an OSD includes + * setting up the instance data, and ensuring the hardware is in a quiescent + * state. + * + * @param InstancePtr is a pointer to the OSD device instance to be worked on. + * @param CfgPtr points to the configuration structure associated with the + * OSD device. + * @param EffectiveAddr is the base address of the device. If address + * translation is being used, then this parameter must reflect the + * virtual base address. Otherwise, the physical address should be + * used. + * @return XST_SUCCESS + * + *****************************************************************************/ +int XOSD_CfgInitialize(XOSD *InstancePtr, XOSD_Config *CfgPtr, + u32 EffectiveAddr) +{ + /* Verify arguments */ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(CfgPtr != NULL); + Xil_AssertNonvoid(CfgPtr->LayerNum <= XOSD_MAX_NUM_OF_LAYERS); + Xil_AssertNonvoid(EffectiveAddr != (u32)NULL); + + /* Setup the instance */ + memset((void *)InstancePtr, 0, sizeof(XOSD)); + + memcpy((void *)&(InstancePtr->Config), (const void *)CfgPtr, + sizeof(XOSD_Config)); + InstancePtr->Config.BaseAddress = EffectiveAddr; + + /* Reset to use instruction from the OSD internal buffer */ + InstancePtr->InstructionInExternalMem = 0; + + /* Set all handlers to stub values, let user configure this data later + */ + InstancePtr->VbiStartCallBack = (XOSD_CallBack) StubCallBack; + InstancePtr->VbiEndCallBack = (XOSD_CallBack) StubCallBack; + InstancePtr->FrameDoneCallBack = (XOSD_CallBack) StubCallBack; + InstancePtr->ErrCallBack = (XOSD_ErrorCallBack) StubErrCallBack; + + /* Populate the layer properties into a array to help easy fetch later + */ + PopulateLayerProperty(InstancePtr, CfgPtr); + + /* Reset the hardware and set the flag to indicate the driver is ready + */ + XOSD_Reset(InstancePtr); + InstancePtr->IsReady = XIL_COMPONENT_IS_READY; + + return XST_SUCCESS; +} + +/*****************************************************************************/ +/** + * This function chooses the type of Vertical and Horizontal Blank Input + * Polarities. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param VerticalBlankPolarity indicates the type of vertical blank input + * polarity. Use any non-0 value for Active High and 0 for Active Low. + * @param HorizontalBlankPolarity indicates the type of horizontal blank input + * polarity. Use any non-0 value for Active High and 0 for Active Low. + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetBlankPolarity(XOSD *InstancePtr, int VerticalBlankPolarity, + int HorizontalBlankPolarity) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + + + /* Read control register and clear the current polarity setup leftover + */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_CTL); + RegValue &= ~(XOSD_CTL_VBP_MASK | XOSD_CTL_HBP_MASK); + + /* Set up new blank polarities */ + if (VerticalBlankPolarity) + RegValue |= XOSD_CTL_VBP_MASK; + + if (HorizontalBlankPolarity) + RegValue |= XOSD_CTL_HBP_MASK; + + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_CTL, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function sets the screen size of the OSD Output. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param Width defines the width of the OSD output + * @param Height defines the height of the OSD output + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetScreenSize(XOSD *InstancePtr, u32 Width, u32 Height) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(Width > 0); + Xil_AssertVoid(Height > 0); + Xil_AssertVoid(Width <= XOSD_SS_XSIZE_MASK); + Xil_AssertVoid(Height <= (XOSD_SS_YSIZE_MASK >> XOSD_SS_YSIZE_SHIFT)); + + /* Save the dimension info in the driver instance for error handling */ + InstancePtr->ScreenWidth = Width; + InstancePtr->ScreenHeight = Height; + + /* Update the Screen Size register */ + RegValue = Width; + RegValue |= (Height << XOSD_SS_YSIZE_SHIFT) & XOSD_SS_YSIZE_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_SS, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function gets the screen size of the OSD Output. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param WidthPtr will point to the width of the OSD output after this + * function returns. + * @param HeightPtr will point to the height of the OSD output after this + * function returns. + * @return NONE. + * + *****************************************************************************/ +void XOSD_GetScreenSize(XOSD *InstancePtr, u32 *WidthPtr, u32 *HeightPtr) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(WidthPtr != NULL); + Xil_AssertVoid(HeightPtr != NULL); + + /* Get the screen size info */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_SS); + *WidthPtr = RegValue & XOSD_SS_XSIZE_MASK; + *HeightPtr = (RegValue & XOSD_SS_YSIZE_MASK) >> XOSD_SS_YSIZE_SHIFT; + + return; +} + +/*****************************************************************************/ +/** + * This function sets the Background color used by the OSD output. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param Red indicates the red value used in the background color. + * @param Blue indicates the blue value used in the background color. + * @param Green indicates the green value used in the background color. + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetBackgroundColor(XOSD *InstancePtr, u16 Red, u16 Blue, u16 Green) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + + /* Update the Background Color register */ + RegValue = Green & XOSD_BC0_YG_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_BC0, RegValue); + + RegValue = Blue & XOSD_BC1_UCBB_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_BC1, RegValue); + + RegValue = Red & XOSD_BC2_VCRR_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_BC2, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function gets the Background color used by the OSD output. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param RedPtr will point to the red value used in the background color + * after this function returns. + * @param BluePtr will point to the blue value used in the background color + * after this function returns. + * @param GreenPtr will point to the green value used in the background color + * after this function returns. + * @return NONE. + * + *****************************************************************************/ +void XOSD_GetBackgroundColor(XOSD *InstancePtr, u16 *RedPtr, u16 *BluePtr, + u16 *GreenPtr) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(RedPtr != NULL); + Xil_AssertVoid(BluePtr != NULL); + Xil_AssertVoid(GreenPtr != NULL); + + /* Get the background color */ + RegValue = XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_BC0); + *GreenPtr = (u16)(RegValue & XOSD_BC0_YG_MASK); + + RegValue = XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_BC1); + *BluePtr = (u16)(RegValue & XOSD_BC1_UCBB_MASK); + + RegValue = XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_BC2); + *RedPtr = (u16)(RegValue & XOSD_BC2_VCRR_MASK); + + return; +} + +/*****************************************************************************/ +/** + * This function sets the start position and size of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param XStart indicates the Horizontal start pixel of origin of the layer. + * @param YStart indicates the Vertical start line of origin of the layer. + * @param XSize indicates the Horizontal Size of the layer. + * @param YSize indicates the Vertical Size of the layer. + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetLayerDimension(XOSD *InstancePtr, u8 LayerIndex, u16 XStart, + u16 YStart, u16 XSize, u16 YSize) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + Xil_AssertVoid(XSize > 0); + Xil_AssertVoid(YSize > 0); + Xil_AssertVoid((XStart + XSize) <= InstancePtr->ScreenWidth); + Xil_AssertVoid((YStart + YSize) <= InstancePtr->ScreenHeight); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Set the origin of the layer */ + RegValue = XStart & XOSD_LXP_XSTART_MASK; + RegValue |= (((u32)YStart) << XOSD_LXP_YSTART_SHIFT) & + XOSD_LXP_YSTART_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXP, + RegValue); + + /* Set the size of the layer */ + RegValue = XSize & XOSD_LXS_XSIZE_MASK; + RegValue |= (((u32)YSize) << XOSD_LXS_YSIZE_SHIFT) & + XOSD_LXS_YSIZE_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXS, + RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function gets the start position and size of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param XStartPtr will point to the Horizontal start pixel value of origin + * of the layer after this function returns. + * @param YStartPtr will point to the Vertical start line of origin of the + * layer after this function returns. + * @param XSizePtr will point to the Horizontal Size value of the layer after + * this function returns. + * @param YSizePtr will point to the Vertical Size value of the layer after + * this function returns. + * @return NONE. + * + *****************************************************************************/ +void XOSD_GetLayerDimension(XOSD *InstancePtr, u8 LayerIndex, u16 *XStartPtr, + u16 *YStartPtr, u16 *XSizePtr, u16 *YSizePtr) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + Xil_AssertVoid(XStartPtr != NULL); + Xil_AssertVoid(YStartPtr != NULL); + Xil_AssertVoid(XSizePtr != NULL); + Xil_AssertVoid(YSizePtr != NULL); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Get the origin of the layer */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXP); + *XStartPtr = (u16) (RegValue & XOSD_LXP_XSTART_MASK); + *YStartPtr = (u16) ((RegValue & XOSD_LXP_YSTART_MASK) >> + XOSD_LXP_YSTART_SHIFT); + + /* Get the size of the layer */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXS); + *XSizePtr = (u16) (RegValue & XOSD_LXS_XSIZE_MASK); + *YSizePtr = (u16) ((RegValue & XOSD_LXS_YSIZE_MASK) >> + XOSD_LXS_YSIZE_SHIFT); + + return; +} + +/*****************************************************************************/ +/** + * This function sets the Alpha value and mode of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param GlobalAlphaEnble indicates whether to enable the global Alpha. Use + * any non-0 value to enable the global Alpha, and 0 to disable it. + * @param GlobalAlphaValue indicates the transparent level. 0 for 100% + * transparent, 255 (8bit) for 0% transparent (100% opaque). This argument + * will be ignored if parameter GlobalAlphaEnble has value 0. + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetLayerAlpha(XOSD *InstancePtr, u8 LayerIndex, u16 GlobalAlphaEnble, + u16 GlobalAlphaValue) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Update the Global Alpha Enable and the Global Alpha Value fields */ + if (GlobalAlphaEnble) + RegValue |= XOSD_LXC_GALPHAEN_MASK; + else + RegValue &= ~XOSD_LXC_GALPHAEN_MASK; + + RegValue &= ~XOSD_LXC_ALPHA_MASK; + RegValue |= (((u32)GlobalAlphaValue) << XOSD_LXC_ALPHA_SHIFT) & + XOSD_LXC_ALPHA_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function gets the Alpha value and mode of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param GlobalAlphaEnblePtr will point to a flag indicating whether the + * global Alpha is enabled on a layer after this function returns. + * Flag 1 indicates that the global Alpha is enabled, 0 indicates that + * it is not. + * @param GlobalAlphaValuePtr will point to the transparent level after this + * function returns. 0 for 100% transparent, 255 (8bit) for 0% transparent + * (100% opaque). + * @return NONE. + * + *****************************************************************************/ +void XOSD_GetLayerAlpha(XOSD *InstancePtr, u8 LayerIndex, + u16 *GlobalAlphaEnblePtr, u16 *GlobalAlphaValuePtr) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + Xil_AssertVoid(GlobalAlphaEnblePtr != NULL); + Xil_AssertVoid(GlobalAlphaValuePtr != NULL); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Get the info of the Global Alpha Enable and the Global Alpha Value + * fields + */ + *GlobalAlphaEnblePtr = (u16) + ((RegValue & XOSD_LXC_GALPHAEN_MASK) ? 1 : 0); + *GlobalAlphaValuePtr = (u16) ((RegValue & XOSD_LXC_ALPHA_MASK) >> + XOSD_LXC_ALPHA_SHIFT); + + return; +} + +/*****************************************************************************/ +/** + * This function sets the priority of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param Priority indicates the priority to be applied on the layer. Use + * one of XOSD_LAYER_PRIORITY_0 (the lowest priority) through + * XOSD_LAYER_PRIORITY_7 (the highest priority) defined in xosd_hw.h + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetLayerPriority(XOSD *InstancePtr, u8 LayerIndex, u8 Priority) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + Xil_AssertVoid(Priority <= XOSD_LAYER_PRIORITY_7); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Update the Priority field */ + RegValue &= ~XOSD_LXC_PRIORITY_MASK; + RegValue |= (((u32)Priority) << XOSD_LXC_PRIORITY_SHIFT) + & XOSD_LXC_PRIORITY_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function gets the priority of an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @param PriorityPtr will point to the priority used on the layer after this + * function returns. Use XOSD_LAYER_PRIORITY_... defined in xosd_hw.h + * to interpret the value. + * @return NONE. + * + *****************************************************************************/ +void XOSD_GetLayerPriority(XOSD *InstancePtr, u8 LayerIndex, u8 *PriorityPtr) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + Xil_AssertVoid(PriorityPtr != NULL); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Get the Priority field */ + *PriorityPtr = (u8)((RegValue & XOSD_LXC_PRIORITY_MASK) >> + XOSD_LXC_PRIORITY_SHIFT); + + return; +} + +/*****************************************************************************/ +/** + * This function enables an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @return NONE. + * + *****************************************************************************/ +void XOSD_EnableLayer(XOSD *InstancePtr, u8 LayerIndex) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Set the Layer Enable field */ + RegValue |= XOSD_LXC_EN_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC, + RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function disables an OSD layer. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param LayerIndex indicates which layer to be worked on. Valid value range + * is from 0 to (the number of layers implemented in the device - 1). + * @return NONE. + * + *****************************************************************************/ +void XOSD_DisableLayer(XOSD *InstancePtr, u8 LayerIndex) +{ + u32 LayerBaseRegAddr; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(LayerIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[LayerIndex].LayerType != \ + XOSD_LAYER_TYPE_DISABLE); + + /* Calculate the base register address of the layer to work on */ + LayerBaseRegAddr = XOSD_L0C + (LayerIndex * XOSD_LAYER_SIZE); + + /* Read the current Layer Control register value */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC); + + /* Clear the Layer Enable field */ + RegValue &= ~XOSD_LXC_EN_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + LayerBaseRegAddr + XOSD_LXC, + RegValue); +} + +/*****************************************************************************/ +/** + * This function loads color LUT data into an OSD Graphics Controller Bank. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param GcIndex indicates which Graphics Controller to work on. Valid value + * range is from 0 to (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param BankIndex indicates which GC Bank to be worked on. Valid value range + * is from 0 to XOSD_GC_BANK_NUM - 1. + * @param ColorData points to the color LUT data to be loaded. + * @return NONE. + * + *****************************************************************************/ +void XOSD_LoadColorLUTBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *ColorData) +{ + u32 i; + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid(BankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(ColorData != NULL); + + /* Choose which bank to be loaded */ + RegValue = (((u32)BankIndex) + XOSD_GCWBA_COL0) & XOSD_GCWBA_BANK_MASK; + RegValue |= (((u32)GcIndex) << XOSD_GCWBA_GCNUM_SHIFT) + & XOSD_GCWBA_GCNUM_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCWBA, RegValue); + + /* Load color data */ + if(InstancePtr->Config.S_AXIS_VIDEO_DATA_WIDTH == 8) + { + for (i = 0; + i < (InstancePtr->Layers[GcIndex].ColorLutSize * XOSD_COLOR_ENTRY_SIZE) + / sizeof(u32); + i++) { + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + XOSD_GCD, ColorData[i]); + } + } + else // for video channel size of 10 or 12, the color size is 64bits + { + for (i = 0; + i < (InstancePtr->Layers[GcIndex].ColorLutSize * 2 * XOSD_COLOR_ENTRY_SIZE) + / sizeof(u32); + i++) { + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + XOSD_GCD, ColorData[i]); + } + + } + /* Set the active color LUT bank */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_GCABA); + RegValue &= ~(1 << (XOSD_GCABA_COL_SHIFT + GcIndex)); + RegValue |= ((u32)BankIndex) << (XOSD_GCABA_COL_SHIFT + (u32)GcIndex); + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCABA, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function loads Character Set data (font) into an OSD Graphics + * Controller Bank. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param GcIndex indicates which Graphics Controller to work on. Valid value + * range is from 0 to (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param BankIndex indicates which GC Bank to be worked on. Valid value range + * is from 0 to XOSD_GC_BANK_NUM - 1. + * @param CharSetData points to the Character Set data to be loaded. + * @return NONE. + * + *****************************************************************************/ +void XOSD_LoadCharacterSetBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *CharSetData) +{ + u32 RegValue; + u32 FontWriteNum; + u32 i; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid(BankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(CharSetData != NULL); + + /* Choose which bank to be loaded */ + RegValue = (((u32)BankIndex) + XOSD_GCWBA_CHR0) & XOSD_GCWBA_BANK_MASK; + RegValue |= (((u32)GcIndex) << XOSD_GCWBA_GCNUM_SHIFT) + & XOSD_GCWBA_GCNUM_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCWBA, RegValue); + + /* Calculate the number of write to load the whole font data set */ + FontWriteNum = ((u32)InstancePtr->Layers[GcIndex].FontWidth) * + ((u32)InstancePtr->Layers[GcIndex].FontHeight) * + ((u32)InstancePtr->Layers[GcIndex].FontBitsPerPixel); + FontWriteNum /= XOSD_FONT_BIT_TO_BYTE; + FontWriteNum *= ((u32)InstancePtr->Layers[GcIndex].FontNumChars); + FontWriteNum /= sizeof(u32); + + /* Load the font data */ + for (i = 0; i < FontWriteNum; i++) { + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCD, + CharSetData[i]); + } + + /* Set the bank to be active so the font is used by the core */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_GCABA); + RegValue &= ~(1 << (XOSD_GCABA_CHR_SHIFT + GcIndex)); + RegValue |= ((u32)BankIndex) << (XOSD_GCABA_CHR_SHIFT + (u32)GcIndex); + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCABA, RegValue); +} + +/*****************************************************************************/ +/** + * This function loads Text data into an OSD Graphics Controller Bank. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param GcIndex indicates which Graphics Controller to work on. Valid value + * range is from 0 to (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param BankIndex indicates which GC Bank to be worked on. Valid value range + * is from 0 to XOSD_GC_BANK_NUM - 1. + * @param TextData points to the Text data to be loaded. + * @return NONE. + * + *****************************************************************************/ +void XOSD_LoadTextBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *TextData) +{ + u32 i; + u32 RegValue; + u32 Data; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid(BankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(TextData != NULL); + + /* Choose which bank to be loaded */ + RegValue = (((u32)BankIndex) + XOSD_GCWBA_TXT0) & XOSD_GCWBA_BANK_MASK; + RegValue |= (((u32)GcIndex) << XOSD_GCWBA_GCNUM_SHIFT) + & XOSD_GCWBA_GCNUM_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCWBA, RegValue); + + /* Load text data */ + for (i = 0; + i < (u32)(InstancePtr->Layers[GcIndex].TextNumStrings) * + (u32)(InstancePtr->Layers[GcIndex].TextMaxStringLength) / + sizeof(u32); + i++) { + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + XOSD_GCD, TextData[i]); + } + + /* Set the active text bank */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_GCABA); + RegValue &= ~(1 << (XOSD_GCABA_TXT_SHIFT + GcIndex)); + RegValue |= ((u32)BankIndex) << (XOSD_GCABA_TXT_SHIFT + (u32)GcIndex); + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCABA, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function chooses active banks for a GC in an OSD device. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param GcIndex indicates which Graphics Controller to work on. Valid value + * range is from 0 to (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param ColorBankIndex indicates the Color LUT bank to be choose as active. + * @param CharBankIndex indicates the Character Set bank to be choose as + * active. + * @param TextBankIndex indicates the Text Data bank to be choose as active. + * @param InstructionBankIndex indicates the Instruction bank to be choose as + * active. + * @return NONE. + * + *****************************************************************************/ +void XOSD_SetActiveBank(XOSD *InstancePtr, u8 GcIndex, u8 ColorBankIndex, + u8 CharBankIndex, u8 TextBankIndex, + u8 InstructionBankIndex) +{ + u32 RegValue; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid(ColorBankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(CharBankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(TextBankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(InstructionBankIndex < XOSD_GC_BANK_NUM); + + /* Clear the current active bank setting first */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_GCABA); + RegValue &= ~(1 << GcIndex) & XOSD_GCABA_INS_MASK; + RegValue &= ~(1 << (XOSD_GCABA_COL_SHIFT + GcIndex)) & + XOSD_GCABA_COL_MASK; + RegValue &= ~(1 << (XOSD_GCABA_TXT_SHIFT + GcIndex)) & + XOSD_GCABA_TXT_MASK; + RegValue &= ~(1 << (XOSD_GCABA_CHR_SHIFT + GcIndex)) & + XOSD_GCABA_CHR_MASK; + + /* Choose the active banks */ + RegValue |= (((u32)InstructionBankIndex) << GcIndex) & + XOSD_GCABA_INS_MASK; + RegValue |= (((u32)ColorBankIndex) << (XOSD_GCABA_COL_SHIFT + GcIndex)) + & XOSD_GCABA_COL_MASK; + RegValue |= (((u32)TextBankIndex) << (XOSD_GCABA_TXT_SHIFT + GcIndex)) + & XOSD_GCABA_TXT_MASK; + RegValue |= (((u32)CharBankIndex) << (XOSD_GCABA_CHR_SHIFT + GcIndex)) + & XOSD_GCABA_CHR_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCABA, RegValue); + + return; +} + +/*****************************************************************************/ +/** + * This function creates an instruction for an OSD. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param InstructionPtr is a pointer to the instruction buffer to be + * populated with the instruction to be created. The upper level + * application is responsible for allocating this instruction buffer. + * @param GcIndex indicates the Graphics Controller that will consume the + * instruction. Valid value range is from 0 to + * (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param ObjType indicates the type of object to draw. Use + * one of XOSD_INS_OPCODE_... constants defined in xosd_hw.h. + * @param ObjSize indicates line width of boxes and lines and the text scale + * factor for text boxes. + * @param XStart indicates the horizontal start pixel of the Object. + * @param YStart indicates the vertical start line of the Object. + * @param XEnd indicates the horizontal end pixel of the Object. + * @param YEnd indicates the vertical end line of the Object. + * @param TextIndex indicates the string index. + * @param ColorIndex indicates the color index. + * @return NONE. + * + *****************************************************************************/ +void XOSD_CreateInstruction(XOSD *InstancePtr, u32 *InstructionPtr, + u8 GcIndex, u16 ObjType, u8 ObjSize, + u16 XStart, u16 YStart, u16 XEnd, u16 YEnd, + u8 TextIndex, u8 ColorIndex) +{ + u32 Value; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(InstructionPtr != NULL); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid((ObjType == XOSD_INS_OPCODE_END) || + (ObjType == XOSD_INS_OPCODE_NOP) || + (ObjType == XOSD_INS_OPCODE_BOX) || + (ObjType == XOSD_INS_OPCODE_LINE) || + (ObjType == XOSD_INS_OPCODE_TXT) || + (ObjType == XOSD_INS_OPCODE_BOXTXT)); + Xil_AssertVoid(XEnd < InstancePtr->ScreenWidth); + Xil_AssertVoid(YEnd < InstancePtr->ScreenHeight); + Xil_AssertVoid(TextIndex < InstancePtr->Layers[GcIndex].TextNumStrings); + Xil_AssertVoid(ColorIndex < InstancePtr->Layers[GcIndex].ColorLutSize); + + /* Clear the whole instruction first */ + memset((void *)InstructionPtr, 0, XOSD_INS_SIZE * sizeof(u32)); + + /* Populate instruction word 0 fields */ + Value = ((u32)XStart) & XOSD_INS0_XSTART_MASK; + Value |= (((u32)XEnd) << XOSD_INS0_XEND_SHIFT) & + XOSD_INS0_XEND_MASK; + Value |= (((u32)GcIndex) << XOSD_INS0_GCNUM_SHIFT) & + XOSD_INS0_GCNUM_MASK; + Value |= (((u32)ObjType) << XOSD_INS0_OPCODE_SHIFT) + & XOSD_INS0_OPCODE_MASK; + InstructionPtr[XOSD_INS0] = Value; + + /* Populate instruction word 1 fields */ + Value = ((u32)TextIndex) & XOSD_INS1_TXTINDEX_MASK; + InstructionPtr[XOSD_INS1] = Value; + + /* Populate instruction word 2 fields */ + Value = ((u32)YStart) & XOSD_INS2_YSTART_MASK; + Value |= (((u32)YEnd) << XOSD_INS2_YEND_SHIFT) & XOSD_INS2_YEND_MASK; + Value |= (((u32)ObjSize) << XOSD_INS2_OBJSIZE_SHIFT) + & XOSD_INS2_OBJSIZE_MASK; + InstructionPtr[XOSD_INS2] = Value; + + /* Populate instruction word 3 fields */ + Value = ((u32)ColorIndex) & XOSD_INS3_COL_MASK; + InstructionPtr[XOSD_INS3] = Value; + + return; +} + +/*****************************************************************************/ +/** + * This function load an instruction list to be used by an Graphic Controller + * in an OSD device. + * + * @param InstancePtr is a pointer to the OSD device instance to be + * worked on. + * @param GcIndex indicates which Graphics Controller to work on. Valid value + * range is from 0 to (The Number of Layers) - 1. The layer's type must + * be set to XOSD_LAYER_TYPE_GPU (defined in xosd_hw.h) for this + * function to work properly. + * @param BankIndex indicates which GC Bank to be worked on. Valid value range + * is from 0 to XOSD_GC_BANK_NUM. + * @param InstSetPtr is a pointer to the start of the instruction list to load + * into the OSD device. The last instruction in the list must has + * XOSD_INS_OPCODE_END type. + * @param InstNum indicates the number of the instructions in the list to + * load. Valid value range is from 1 to the half of the size of the + * instruction memory created for the Graphic Controller + * @return NONE. + * + *****************************************************************************/ +void XOSD_LoadInstructionList(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *InstSetPtr, u32 InstNum) +{ + u32 RegValue; + u32 i; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertVoid(GcIndex < InstancePtr->Config.LayerNum); + Xil_AssertVoid(InstancePtr->Layers[GcIndex].LayerType == + XOSD_LAYER_TYPE_GPU); + Xil_AssertVoid(BankIndex < XOSD_GC_BANK_NUM); + Xil_AssertVoid(InstSetPtr != NULL); + Xil_AssertVoid(InstNum <= InstancePtr->Layers[GcIndex].InstructionNum); + + /* Choose which bank to be loaded */ + RegValue = (((u32)BankIndex) + XOSD_GCWBA_INS0) & XOSD_GCWBA_BANK_MASK; + RegValue |= (((u32)GcIndex) << XOSD_GCWBA_GCNUM_SHIFT) + & XOSD_GCWBA_GCNUM_MASK; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCWBA, RegValue); + + for (i = 0; i < InstNum * XOSD_INS_SIZE; i++) + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCD, + InstSetPtr[i]); + + /* + * Notify OSD this is the end of the instruction list by adding an END + * instruction + */ + if (InstNum < InstancePtr->Layers[GcIndex].InstructionNum) + for (i = 0; i < XOSD_INS_SIZE; i++) + XOSD_WriteReg(InstancePtr->Config.BaseAddress, + XOSD_GCD, 0); + + + /* Set the active instruction bank */ + RegValue = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_GCABA); + RegValue &= ~(1 << GcIndex); + RegValue |= BankIndex << GcIndex; + XOSD_WriteReg(InstancePtr->Config.BaseAddress, XOSD_GCABA, RegValue); + + return; +} + +/*****************************************************************************/ +/* + * This function populates the Layer array in the OSD driver instance with + * the properties of all layers. This is to help fetch the info faster later. + * + * @param InstancePtr is a pointer to the OSD device instance to be worked on. + * @param CfgPtr points to the configuration structure associated with the + * OSD device. + * @return None + * + *****************************************************************************/ +static void PopulateLayerProperty(XOSD *InstancePtr, XOSD_Config *CfgPtr) +{ + XOSD *IP; + XOSD_Config *Cfg; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(CfgPtr != NULL); + + /* Use short variable names to keep the lines in this function + * shorter + */ + IP = InstancePtr; + Cfg = CfgPtr; + + /* Layer #0 */ + IP->Layers[0].LayerType = Cfg->Layer0Type; + IP->Layers[0].InstructionNum = Cfg->Layer0InstructionMemSize; + IP->Layers[0].InstructionBoxEnable = Cfg->Layer0InstructionBoxEnable; + IP->Layers[0].InstructionLineEnable = Cfg->Layer0InstructionLineEnable; + IP->Layers[0].InstructionTextEnable = Cfg->Layer0InstructionTextEnable; + IP->Layers[0].ColorLutSize = Cfg->Layer0ColorLutSize; + IP->Layers[0].ColorLutMemoryType = Cfg->Layer0ColorLutMemoryType; + IP->Layers[0].FontNumChars = Cfg->Layer0FontNumChars; + IP->Layers[0].FontWidth = Cfg->Layer0FontWidth; + IP->Layers[0].FontHeight = Cfg->Layer0FontHeight; + IP->Layers[0].FontBitsPerPixel = Cfg->Layer0FontBitsPerPixel; + IP->Layers[0].FontAsciiOffset = Cfg->Layer0FontAsciiOffset; + IP->Layers[0].TextNumStrings = Cfg->Layer0TextNumStrings; + IP->Layers[0].TextMaxStringLength = Cfg->Layer0TextMaxStringLength; + + /* Layer #1 */ + IP->Layers[1].LayerType = Cfg->Layer1Type; + IP->Layers[1].InstructionNum = Cfg->Layer1InstructionMemSize; + IP->Layers[1].InstructionBoxEnable = Cfg->Layer1InstructionBoxEnable; + IP->Layers[1].InstructionLineEnable = Cfg->Layer1InstructionLineEnable; + IP->Layers[1].InstructionTextEnable = Cfg->Layer1InstructionTextEnable; + IP->Layers[1].ColorLutSize = Cfg->Layer1ColorLutSize; + IP->Layers[1].ColorLutMemoryType = Cfg->Layer1ColorLutMemoryType; + IP->Layers[1].FontNumChars = Cfg->Layer1FontNumChars; + IP->Layers[1].FontWidth = Cfg->Layer1FontWidth; + IP->Layers[1].FontHeight = Cfg->Layer1FontHeight; + IP->Layers[1].FontBitsPerPixel = Cfg->Layer1FontBitsPerPixel; + IP->Layers[1].FontAsciiOffset = Cfg->Layer1FontAsciiOffset; + IP->Layers[1].TextNumStrings = Cfg->Layer1TextNumStrings; + IP->Layers[1].TextMaxStringLength = Cfg->Layer1TextMaxStringLength; + + /* Layer #2 */ + IP->Layers[2].LayerType = Cfg->Layer2Type; + IP->Layers[2].InstructionNum = Cfg->Layer2InstructionMemSize; + IP->Layers[2].InstructionBoxEnable = Cfg->Layer2InstructionBoxEnable; + IP->Layers[2].InstructionLineEnable = Cfg->Layer2InstructionLineEnable; + IP->Layers[2].InstructionTextEnable = Cfg->Layer2InstructionTextEnable; + IP->Layers[2].ColorLutSize = Cfg->Layer2ColorLutSize; + IP->Layers[2].ColorLutMemoryType = Cfg->Layer2ColorLutMemoryType; + IP->Layers[2].FontNumChars = Cfg->Layer2FontNumChars; + IP->Layers[2].FontWidth = Cfg->Layer2FontWidth; + IP->Layers[2].FontHeight = Cfg->Layer2FontHeight; + IP->Layers[2].FontBitsPerPixel = Cfg->Layer2FontBitsPerPixel; + IP->Layers[2].FontAsciiOffset = Cfg->Layer2FontAsciiOffset; + IP->Layers[2].TextNumStrings = Cfg->Layer2TextNumStrings; + IP->Layers[2].TextMaxStringLength = Cfg->Layer2TextMaxStringLength; + + /* Layer #3 */ + IP->Layers[3].LayerType = Cfg->Layer3Type; + IP->Layers[3].InstructionNum = Cfg->Layer3InstructionMemSize; + IP->Layers[3].InstructionBoxEnable = Cfg->Layer3InstructionBoxEnable; + IP->Layers[3].InstructionLineEnable = Cfg->Layer3InstructionLineEnable; + IP->Layers[3].InstructionTextEnable = Cfg->Layer3InstructionTextEnable; + IP->Layers[3].ColorLutSize = Cfg->Layer3ColorLutSize; + IP->Layers[3].ColorLutMemoryType = Cfg->Layer3ColorLutMemoryType; + IP->Layers[3].FontNumChars = Cfg->Layer3FontNumChars; + IP->Layers[3].FontWidth = Cfg->Layer3FontWidth; + IP->Layers[3].FontHeight = Cfg->Layer3FontHeight; + IP->Layers[3].FontBitsPerPixel = Cfg->Layer3FontBitsPerPixel; + IP->Layers[3].FontAsciiOffset = Cfg->Layer3FontAsciiOffset; + IP->Layers[3].TextNumStrings = Cfg->Layer3TextNumStrings; + IP->Layers[3].TextMaxStringLength = Cfg->Layer3TextMaxStringLength; + + /* Layer #4 */ + IP->Layers[4].LayerType = Cfg->Layer4Type; + IP->Layers[4].InstructionNum = Cfg->Layer4InstructionMemSize; + IP->Layers[4].InstructionBoxEnable = Cfg->Layer4InstructionBoxEnable; + IP->Layers[4].InstructionLineEnable = Cfg->Layer4InstructionLineEnable; + IP->Layers[4].InstructionTextEnable = Cfg->Layer4InstructionTextEnable; + IP->Layers[4].ColorLutSize = Cfg->Layer4ColorLutSize; + IP->Layers[4].ColorLutMemoryType = Cfg->Layer4ColorLutMemoryType; + IP->Layers[4].FontNumChars = Cfg->Layer4FontNumChars; + IP->Layers[4].FontWidth = Cfg->Layer4FontWidth; + IP->Layers[4].FontHeight = Cfg->Layer4FontHeight; + IP->Layers[4].FontBitsPerPixel = Cfg->Layer4FontBitsPerPixel; + IP->Layers[4].FontAsciiOffset = Cfg->Layer4FontAsciiOffset; + IP->Layers[4].TextNumStrings = Cfg->Layer4TextNumStrings; + IP->Layers[4].TextMaxStringLength = Cfg->Layer4TextMaxStringLength; + + /* Layer #5 */ + IP->Layers[5].LayerType = Cfg->Layer5Type; + IP->Layers[5].InstructionNum = Cfg->Layer5InstructionMemSize; + IP->Layers[5].InstructionBoxEnable = Cfg->Layer5InstructionBoxEnable; + IP->Layers[5].InstructionLineEnable = Cfg->Layer5InstructionLineEnable; + IP->Layers[5].InstructionTextEnable = Cfg->Layer5InstructionTextEnable; + IP->Layers[5].ColorLutSize = Cfg->Layer5ColorLutSize; + IP->Layers[5].ColorLutMemoryType = Cfg->Layer5ColorLutMemoryType; + IP->Layers[5].FontNumChars = Cfg->Layer5FontNumChars; + IP->Layers[5].FontWidth = Cfg->Layer5FontWidth; + IP->Layers[5].FontHeight = Cfg->Layer5FontHeight; + IP->Layers[5].FontBitsPerPixel = Cfg->Layer5FontBitsPerPixel; + IP->Layers[5].FontAsciiOffset = Cfg->Layer5FontAsciiOffset; + IP->Layers[5].TextNumStrings = Cfg->Layer5TextNumStrings; + IP->Layers[5].TextMaxStringLength = Cfg->Layer5TextMaxStringLength; + + /* Layer #6 */ + IP->Layers[6].LayerType = Cfg->Layer6Type; + IP->Layers[6].InstructionNum = Cfg->Layer6InstructionMemSize; + IP->Layers[6].InstructionBoxEnable = Cfg->Layer6InstructionBoxEnable; + IP->Layers[6].InstructionLineEnable = Cfg->Layer6InstructionLineEnable; + IP->Layers[6].InstructionTextEnable = Cfg->Layer6InstructionTextEnable; + IP->Layers[6].ColorLutSize = Cfg->Layer6ColorLutSize; + IP->Layers[6].ColorLutMemoryType = Cfg->Layer6ColorLutMemoryType; + IP->Layers[6].FontNumChars = Cfg->Layer6FontNumChars; + IP->Layers[6].FontWidth = Cfg->Layer6FontWidth; + IP->Layers[6].FontHeight = Cfg->Layer6FontHeight; + IP->Layers[6].FontBitsPerPixel = Cfg->Layer6FontBitsPerPixel; + IP->Layers[6].FontAsciiOffset = Cfg->Layer6FontAsciiOffset; + IP->Layers[6].TextNumStrings = Cfg->Layer6TextNumStrings; + IP->Layers[6].TextMaxStringLength = Cfg->Layer6TextMaxStringLength; + + /* Layer #7 */ + IP->Layers[7].LayerType = Cfg->Layer7Type; + IP->Layers[7].InstructionNum = Cfg->Layer7InstructionMemSize; + IP->Layers[7].InstructionBoxEnable = Cfg->Layer7InstructionBoxEnable; + IP->Layers[7].InstructionLineEnable = Cfg->Layer7InstructionLineEnable; + IP->Layers[7].InstructionTextEnable = Cfg->Layer7InstructionTextEnable; + IP->Layers[7].ColorLutSize = Cfg->Layer7ColorLutSize; + IP->Layers[7].ColorLutMemoryType = Cfg->Layer7ColorLutMemoryType; + IP->Layers[7].FontNumChars = Cfg->Layer7FontNumChars; + IP->Layers[7].FontWidth = Cfg->Layer7FontWidth; + IP->Layers[7].FontHeight = Cfg->Layer7FontHeight; + IP->Layers[7].FontBitsPerPixel = Cfg->Layer7FontBitsPerPixel; + IP->Layers[7].FontAsciiOffset = Cfg->Layer7FontAsciiOffset; + IP->Layers[7].TextNumStrings = Cfg->Layer7TextNumStrings; + IP->Layers[7].TextMaxStringLength = Cfg->Layer7TextMaxStringLength; + + /* Convert instruction memory sizes into the maximum numbers of + * instructions supported + */ + IP->Layers[0].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[1].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[2].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[3].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[4].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[5].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[6].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + IP->Layers[7].InstructionNum /= XOSD_INS_MEM_SIZE_TO_NUM; + return; +} + +/*****************************************************************************/ +/** +* +* This function returns the version of an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be +* worked on. +* @param Major points to an unsigned 16-bit variable that will be assigned +* with the major version number after this function returns. Value +* range is from 0x0 to 0xF. +* @param Minor points to an unsigned 16-bit variable that will be assigned +* with the minor version number after this function returns. Value +* range is from 0x00 to 0xFF. +* @param Revision points to an unsigned 16-bit variable that will be assigned +* with the revision version number after this function returns. Value +* range is from 0xA to 0xF. +* @return None. +* @note Example: Device version should read v2.01.c if major version number +* is 0x2, minor version number is 0x1, and revision version number is +* 0xC. +* +******************************************************************************/ +void XOSD_GetVersion(XOSD *InstancePtr, u16 *Major, u16 *Minor, u16 *Revision) +{ + u32 Version; + + /* Verify arguments */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(Major != NULL); + Xil_AssertVoid(Minor != NULL); + Xil_AssertVoid(Revision != NULL); + + /* Read device version */ + Version = XOSD_ReadReg(InstancePtr->Config.BaseAddress, XOSD_VER); + + /* Parse the version and pass the info to the caller via output + * parameters + */ + *Major = (u16) + ((Version & XOSD_VER_MAJOR_MASK) >> XOSD_VER_MAJOR_SHIFT); + + *Minor = (u16) + ((Version & XOSD_VER_MINOR_MASK) >> XOSD_VER_MINOR_SHIFT); + + *Revision = (u16) + ((Version & XOSD_VER_REV_MASK) >> XOSD_VER_REV_SHIFT); + + return; +} + +/*****************************************************************************/ +/* + * This routine is a stub for the asynchronous callbacks. The stub is here in + * case the upper layer forgot to set the handlers. On initialization, All + * handlers except error handler are set to this callback. It is considered an + * error for this handler to be invoked. + * + *****************************************************************************/ +static void StubCallBack(void *CallBackRef) +{ + Xil_AssertVoidAlways(); +} + +/*****************************************************************************/ +/* + * This routine is a stub for the asynchronous error interrupt callback. The + * stub is here in case the upper layer forgot to set the handler. On + * initialization, Error interrupt handler is set to this callback. It is + * considered an error for this handler to be invoked. + * + *****************************************************************************/ +static void StubErrCallBack(void *CallBackRef, u32 ErrorMask) +{ + Xil_AssertVoidAlways(); +} diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd.h b/XilinxProcessorIPLib/drivers/osd/src/xosd.h new file mode 100755 index 00000000..feccf66f --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd.h @@ -0,0 +1,694 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file xosd.h +* +* This is main header file of the Xilinx MVI On-Screen-Display (OSD) device +* driver. +* +* An OSD is an image superimposed on a screen picture, commonly used by modern +* televisions, VCRs, and DVD players to display information such as volume, +* channel, and time. +* +* Xilinx MVI OSD has the following main features: +* +* - Read Video Data one of three sources +* - VFBC/Frame Buffer +* - VideoBus +* - Graphics Controller +* - Alpha Compositing and Alpha Blending of up to 8 layers +* - Up to 8 priorities, one for each of the layers +* - Real-Time Graphics Controller +* - Write Composited Video Data to either +* - VFBC/Frame Buffer, or +* - VideoBus +* +* For a full description of OSD features, please see the hardware spec. +* +* Interrupt Service +* +* Four interrupt types are supported: +* +* - Vertical Blank Interval Start Interrupt +* - Vertical Blank Interval End Interrupt +* - Frame Done Interrupt +* - Error Interrupt +* +* Software Initialization +* +* Please follow the example provided with this driver for the steps +* to use this driver. +* +* Cache Coherency +* +* Alignment +* +* Limitations +* +* BUS Interface +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ------------------------------------------------------- +* 1.00a xd 08/18/08 First release +* 1.01a xd 07/30/10 Added device version support; Supported doxygen; Fixed +* CR #534952 +* 1.02a xd 12/21/10 Removed endian conversion for text bank loading +* 1.03a cm 09/07/11 Updated XOSD_GetLayerAlpha(), XOSD_SetLayerAlpha(), +* XOSD_SetBackgroundColor() and XOSD_GetBackgroundColor() +* to allow 10 and 12 bit alpha and background colors. +* 2.00a cjm 12/18/12 Converted from xio.h to xil_io.h, translating +* basic types, MB cache functions, exceptions and +* assertions to xil_io format. +* 3.0 adk 19/12/13 Updated as per the New Tcl API's +* +*+* +******************************************************************************/ + +#ifndef XOSD_H /* prevent circular inclusions */ +#define XOSD_H /* by using protection macros */ + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ + +#include "xosd_hw.h" +#include "xil_assert.h" +#include "xstatus.h" + +/************************** Constant Definitions *****************************/ + +/** @name Interrupt types for setting up callbacks + * @{ + */ +#define XOSD_HANDLER_FRAMEDONE 1 /**< Frame Done interrupt */ +#define XOSD_HANDLER_VBISTART 2 /**< Vertical Blank Interval Start + * interrupt */ +#define XOSD_HANDLER_VBIEND 3 /**< Vertical Blank Interval End + * interrupt */ +#define XOSD_HANDLER_ERROR 4 /**< Error condition interrupt */ +/*@}*/ + +/**************************** Type Definitions *******************************/ + +/** + * OSD device configuration structure. + * Each OSD device should have a configuration structure associated + */ +typedef struct { + u16 DeviceId; /**< DeviceId is the unique ID of the device */ + u32 BaseAddress; /**< BaseAddress is the physical base address of + * the device's registers */ + u16 LayerNum; /**< The number of Layers */ + u16 S_AXIS_VIDEO_DATA_WIDTH; + u16 Layer0Type; /**< Type of Layer #0 */ + u16 Layer1Type; /**< Type of Layer #1 */ + u16 Layer2Type; /**< Type of Layer #2 */ + u16 Layer3Type; /**< Type of Layer #3 */ + u16 Layer4Type; /**< Type of Layer #4 */ + u16 Layer5Type; /**< Type of Layer #5 */ + u16 Layer6Type; /**< Type of Layer #6 */ + u16 Layer7Type; /**< Type of Layer #7 */ + + /**< Layer 0 */ + u16 Layer0InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer0InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer0InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer0InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer0ColorLutSize; /**< Color Lut Size */ + u16 Layer0ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer0FontNumChars; /**< Font: Number of characters */ + u16 Layer0FontWidth; /**< Font: Width */ + u16 Layer0FontHeight; /**< Font: Height */ + u16 Layer0FontBitsPerPixel; /**< Font: Number of bits per pixel + */ + u16 Layer0FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer0TextNumStrings; /**< Text: Number of Strings */ + u16 Layer0TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 1 */ + u16 Layer1InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer1InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer1InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer1InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer1ColorLutSize; /**< Color Lut Size */ + u16 Layer1ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer1FontNumChars; /**< Font: Number of characters */ + u16 Layer1FontWidth; /**< Font: Width */ + u16 Layer1FontHeight; /**< Font: Height */ + u16 Layer1FontBitsPerPixel; /**< Font: Number of bits per pixel + */ + u16 Layer1FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer1TextNumStrings; /**< Text: Number of Strings */ + u16 Layer1TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 2 */ + u16 Layer2InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer2InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer2InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer2InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer2ColorLutSize; /**< Color Lut Size */ + u16 Layer2ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer2FontNumChars; /**< Font: Number of characters */ + u16 Layer2FontWidth; /**< Font: Width */ + u16 Layer2FontHeight; /**< Font: Height */ + u16 Layer2FontBitsPerPixel; /**< Font: Number of bits per + * pixel */ + u16 Layer2FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer2TextNumStrings; /**< Text: Number of Strings */ + u16 Layer2TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 3 */ + u16 Layer3InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer3InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer3InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer3InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer3ColorLutSize; /**< Color Lut Size */ + u16 Layer3ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer3FontNumChars; /**< Font: Number of characters */ + u16 Layer3FontWidth; /**< Font: Width */ + u16 Layer3FontHeight; /**< Font: Height */ + u16 Layer3FontBitsPerPixel; /**< Font: Number of bits per pixel + */ + u16 Layer3FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer3TextNumStrings; /**< Text: Number of Strings */ + u16 Layer3TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 4 */ + u16 Layer4InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer4InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer4InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer4InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer4ColorLutSize; /**< Color Lut Size */ + u16 Layer4ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer4FontNumChars; /**< Font: Number of characters */ + u16 Layer4FontWidth; /**< Font: Width */ + u16 Layer4FontHeight; /**< Font: Height */ + u16 Layer4FontBitsPerPixel; /**< Font: Number of bits per + * pixel */ + u16 Layer4FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer4TextNumStrings; /**< Text: Number of Strings */ + u16 Layer4TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 5 */ + u16 Layer5InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer5InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer5InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer5InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer5ColorLutSize; /**< Color Lut Size */ + u16 Layer5ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer5FontNumChars; /**< Font: Number of characters */ + u16 Layer5FontWidth; /**< Font: Width */ + u16 Layer5FontHeight; /**< Font: Height */ + u16 Layer5FontBitsPerPixel; /**< Font: Number of bits per + * pixel */ + u16 Layer5FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer5TextNumStrings; /**< Text: Number of Strings */ + u16 Layer5TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 6 */ + u16 Layer6InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer6InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer6InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer6InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer6ColorLutSize; /**< Color Lut Size */ + u16 Layer6ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer6FontNumChars; /**< Font: Number of characters */ + u16 Layer6FontWidth; /**< Font: Width */ + u16 Layer6FontHeight; /**< Font: Height */ + u16 Layer6FontBitsPerPixel; /**< Font: Number of bits per + * pixel */ + u16 Layer6FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer6TextNumStrings; /**< Text: Number of Strings */ + u16 Layer6TextMaxStringLength; /**< Text: Maximum length of a + * String */ + + /**< Layer 7 */ + u16 Layer7InstructionMemSize; /**< Instruction Memory Size */ + u16 Layer7InstructionBoxEnable; /**< Instruction Box Enable */ + u16 Layer7InstructionLineEnable; /**< Instruction Line Enable */ + u16 Layer7InstructionTextEnable; /**< Instruction Text Enable */ + u16 Layer7ColorLutSize; /**< Color Lut Size */ + u16 Layer7ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 Layer7FontNumChars; /**< Font: Number of characters */ + u16 Layer7FontWidth; /**< Font: Width */ + u16 Layer7FontHeight; /**< Font: Height */ + u16 Layer7FontBitsPerPixel; /**< Font: Number of bits per + * pixel */ + u16 Layer7FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 Layer7TextNumStrings; /**< Text: Number of Strings */ + u16 Layer7TextMaxStringLength; /**< Text: Maximum length of a + * String */ + +} XOSD_Config; + +/** + * The XOSD Layer info structure + */ +typedef struct { + u16 LayerType; /**< Type of the layer */ + u16 InstructionNum; /**< The Number of Instructions */ + u16 InstructionBoxEnable; /**< Instruction Box Enable */ + u16 InstructionLineEnable; /**< Instruction Line Enable */ + u16 InstructionTextEnable; /**< Instruction Text Enable */ + u16 ColorLutSize; /**< Color Lut Size */ + u16 ColorLutMemoryType; /**< Color Lut Memory Type */ + u16 FontNumChars; /**< Font: Number of characters */ + u16 FontWidth; /**< Font: Width */ + u16 FontHeight; /**< Font: Height */ + u16 FontBitsPerPixel; /**< Font: Number of bits per pixel */ + u16 FontAsciiOffset; /**< Font: ASCII offset of 1st + * character */ + u16 TextNumStrings; /**< Text: Number of Strings */ + u16 TextMaxStringLength; /**< Text: Maximum length of a + * String */ + +} XOSD_Layer; + +/** + * Callback type for all interrupts except error interrupt. + * + * @param CallBackRef is a callback reference passed in by the upper layer + * when setting the callback functions, and passed back to the + * upper layer when the callback is invoked. + */ +typedef void (*XOSD_CallBack) (void *CallBackRef); + +/** + * Callback type for Error interrupt. + * + * @param CallBackRef is a callback reference passed in by the upper layer + * when setting the callback functions, and passed back to the + * upper layer when the callback is invoked. + * @param ErrorMask is a bit mask indicating the cause of the error. Its + * value equals 'OR'ing one or more XOSD_IXR_* values defined in + * xosd_hw.h + */ +typedef void (*XOSD_ErrorCallBack) (void *CallBackRef, u32 ErrorMask); + +/** + * The XOSD driver instance data. An instance must be allocated for each + * OSD device in use. + */ +typedef struct { + XOSD_Config Config; /**< Hardware configuration */ + u32 IsReady; /**< Device and the driver instance are + * initialized */ + int InstructionInExternalMem; /**< Flag indicating if the instruction + list is from external memory */ + u32 ScreenHeight; /**< Screen Height of the OSD output */ + u32 ScreenWidth; /**< Screen Width of the OSD output */ + + XOSD_Layer Layers[XOSD_MAX_NUM_OF_LAYERS]; /**< Properties of layers */ + + XOSD_CallBack VbiStartCallBack; /**< Call back for Vertical Blank + * Interval (VBI) Start interrupt */ + void *VbiStartRef; /**< To be passed to the VBI Start + * interrupt callback */ + + XOSD_CallBack VbiEndCallBack; /**< Call back for Vertical Blank + * Interval (VBI) End interrupt */ + void *VbiEndRef; /**< To be passed to the VBI End + * interrupt callback */ + + XOSD_CallBack FrameDoneCallBack;/**< Call back for Frame Done interrupt + */ + void *FrameDoneRef; /**< To be passed to the Frame Done + * interrupt callback */ + + XOSD_ErrorCallBack ErrCallBack; /**< Call back for Error interrupt */ + void *ErrRef; /**< To be passed to the Error + * interrupt callback */ + +} XOSD; + +/** + * The XOSD_Instruction data structure for holding one GC instruction. + */ +typedef u32 XOSD_Instruction[XOSD_INS_SIZE]; + +/***************** Macros (Inline Functions) Definitions *********************/ + +/*****************************************************************************/ +/** +* +* This macro enables an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_Enable(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_Enable(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_CTL, \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_CTL) | \ + XOSD_CTL_EN_MASK) + +/*****************************************************************************/ +/** +* +* This macro disables an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_Disable(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_Disable(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_CTL, \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_CTL) & \ + (~XOSD_CTL_EN_MASK)) + +/*****************************************************************************/ +/** +* +* This macro tell an OSD device to pick up the register updates. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_RegUpdateEnable(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_RegUpdateEnable(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_CTL, \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_CTL) | \ + XOSD_CTL_RUE_MASK) + +/*****************************************************************************/ +/** +* +* This macro tell an OSD device to ignore the register updates. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_RegUpdateDisable(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_RegUpdateDisable(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_CTL, \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_CTL) & \ + (~XOSD_CTL_RUE_MASK)) + +/*****************************************************************************/ +/** +* +* This macro resets an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_Reset(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_Reset(InstancePtr) \ +{ \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_RST, \ + XOSD_RST_RESET); \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_CTL, 0); \ + (InstancePtr)->InstructionInExternalMem = 0; \ + (InstancePtr)->ScreenHeight = 0; \ + (InstancePtr)->ScreenWidth = 0; \ +} + +/*****************************************************************************/ +/** +* +* This macro enables the global interrupt on an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_IntrEnableGlobal(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_IntrEnableGlobal(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_GIER, \ + XOSD_GIER_GIE_MASK) + +/*****************************************************************************/ +/** +* +* This macro disables the global interrupt on an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_IntrDisableGlobal(XOSD *InstancePtr); +* +******************************************************************************/ +#define XOSD_IntrDisableGlobal(InstancePtr) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_GIER, 0) + +/*****************************************************************************/ +/** +* +* This macro enables the given individual interrupt(s) on an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @param IntrType is the type of the interrupts to enable. Use OR'ing of +* XOSD_IXR_* constants defined in xosd_hw.h to create this parameter +* value. +* +* @return None +* +* @note +* +* The existing enabled interrupt(s) will remain enabled. +* +* C-style signature: +* void XOSD_IntrEnable(XOSD *InstancePtr, u32 IntrType) +* +******************************************************************************/ +#define XOSD_IntrEnable(InstancePtr, IntrType) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_IER, \ + ((IntrType) & XOSD_IXR_ALLINTR_MASK) | \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_IER)) + +/*****************************************************************************/ +/** +* +* This macro disables the given individual interrupt(s) on an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @param IntrType is the type of the interrupts to disable. Use OR'ing of +* XOSD_IXR_* constants defined in xosd_hw.h to create this parameter +* value. +* +* @return None +* +* @note +* +* Any other interrupt not covered by parameter IntrType, if enabled before +* this macro is called, will remain enabled. +* +* C-style signature: +* void XOSD_IntrDisable(XOSD *InstancePtr, u32 IntrType) +* +******************************************************************************/ +#define XOSD_IntrDisable(InstancePtr, IntrType) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_IER, \ + ((~(IntrType)) & XOSD_IXR_ALLINTR_MASK) & \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_IER)) + +/*****************************************************************************/ +/** +* +* This macro returns the pending interrupts of an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @return The pending interrupts of the OSD. Use XOSD_IXR_* constants +* defined in xosd_hw.h to interpret this value. +* +* @note +* +* C-style signature: +* u32 XOSD_IntrGetPending(XOSD *InstancePtr) +* +******************************************************************************/ +#define XOSD_IntrGetPending(InstancePtr) \ + (XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_IER) & \ + XOSD_ReadReg((InstancePtr)->Config.BaseAddress, XOSD_ISR) & \ + XOSD_IXR_ALLINTR_MASK) + +/*****************************************************************************/ +/** +* +* This macro clears/acknowledges pending interrupts of an OSD device. +* +* @param InstancePtr is a pointer to the OSD device instance to be worked on. +* +* @param IntrType is the pending interrupts to clear/acknowledge. Use OR'ing +* of XOSD_IXR_* constants defined in xosd_hw.h to create this +* parameter value. +* +* @return None +* +* @note +* +* C-style signature: +* void XOSD_IntrClear(XOSD *InstancePtr, u32 IntrType) +* +******************************************************************************/ +#define XOSD_IntrClear(InstancePtr, IntrType) \ + XOSD_WriteReg((InstancePtr)->Config.BaseAddress, XOSD_ISR, \ + (IntrType) & XOSD_IXR_ALLINTR_MASK) + +/************************** Function Prototypes ******************************/ + +/* + * Initialization and control functions in xosd.c + */ + +/* Initialization */ +int XOSD_CfgInitialize(XOSD *InstancePtr, XOSD_Config *CfgPtr, + u32 EffectiveAddr); + +/* Set Vertical and Horizontal Blank Input Polarity Types */ +void XOSD_SetBlankPolarity(XOSD *InstancePtr, int VerticalBlankPolarity, + int HorizontalBlankPolarity); + +/* Set/Get Screen Size of the OSD Output */ +void XOSD_SetScreenSize(XOSD *InstancePtr, u32 Width, u32 Height); +void XOSD_GetScreenSize(XOSD *InstancePtr, u32 *WidthPtr, u32 *HeightPtr); + +/* Set/Get Background color */ +void XOSD_SetBackgroundColor(XOSD *InstancePtr, u16 Red, u16 Blue, u16 Green); +void XOSD_GetBackgroundColor(XOSD *InstancePtr, u16 *RedPtr, u16 *BluePtr, + u16 *GreenPtr); + +/* Layer related functions */ +void XOSD_SetLayerDimension(XOSD *InstancePtr, u8 LayerIndex, u16 XStart, + u16 YStart, u16 XSize, u16 YSize); +void XOSD_GetLayerDimension(XOSD *InstancePtr, u8 LayerIndex, u16 *XStartPtr, + u16 *YStartPtr, u16 *XSizePtr, u16 *YSizePtr); + +void XOSD_SetLayerAlpha(XOSD *InstancePtr, u8 LayerIndex, + u16 GlobalAlphaEnble, u16 GlobalAlphaValue); +void XOSD_GetLayerAlpha(XOSD *InstancePtr, u8 LayerIndex, + u16 *GlobalAlphaEnblePtr, + u16 *GlobalAlphaValuePtr); + +void XOSD_SetLayerPriority(XOSD *InstancePtr, u8 LayerIndex, u8 Priority); +void XOSD_GetLayerPriority(XOSD *InstancePtr, u8 LayerIndex, u8 *PriorityPtr); + +void XOSD_EnableLayer(XOSD *InstancePtr, u8 LayerIndex); +void XOSD_DisableLayer(XOSD *InstancePtr, u8 LayerIndex); + +/* Graphics Controller related functions */ +void XOSD_LoadColorLUTBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *ColorData); +void XOSD_LoadCharacterSetBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *CharSetData); +void XOSD_LoadTextBank(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *TextData); +void XOSD_SetActiveBank(XOSD *InstancePtr, u8 GcIndex, u8 ColorBankIndex, + u8 CharBankIndex, u8 TextBankIndex, + u8 InstructionBankIndex); + +/* Create and load instruction(s) */ +void XOSD_CreateInstruction(XOSD *InstancePtr, u32 *InstructionPtr, + u8 GcIndex, u16 ObjType, u8 ObjSize, + u16 XStart, u16 YStart, u16 XEnd, u16 YEnd, + u8 TextIndex, u8 ColorIndex); +void XOSD_LoadInstructionList(XOSD *InstancePtr, u8 GcIndex, u8 BankIndex, + u32 *InstSetPtr, u32 InstNum); + +/* Version functions */ +void XOSD_GetVersion(XOSD *InstancePtr, u16 *Major, u16 *Minor, u16 *Revision); + +/* + * Initialization functions in xosd_sinit.c + */ +XOSD_Config *XOSD_LookupConfig(u16 DeviceId); + +/* + * Interrupt related functions in xosd_intr.c + */ +void XOSD_IntrHandler(void *InstancePtr); +int XOSD_SetCallBack(XOSD *InstancePtr, u32 IntrType, + void *CallBackFunc, void *CallBackRef); + + +#ifdef __cplusplus +} +#endif + +#endif /* end of protection macro */ diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd_g.c b/XilinxProcessorIPLib/drivers/osd/src/xosd_g.c new file mode 100755 index 00000000..d9d9b282 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd_g.c @@ -0,0 +1,191 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file xosd_g.c +* +* This file contains a template for configuration table of Xilinx MVI Video +* On-Screen-Display (OSD) devices. For a real hardware system, Xilinx Platform +* Studio (XPS) will automatically generate a real configuration table to match +* the configuration of the OSD devices. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ------------------------------------------------------- +* 1.00a xd 08/18/08 First release +*+* +******************************************************************************/ + + +/***************************** Include Files *********************************/ + + +#include "xparameters.h" +#include "xosd.h" + +/** + * The configuration table for On-Screen-Display devices + */ +XOSD_Config XOSD_ConfigTable[] = +{ + { + XPAR_OSD_0_DEVICE_ID, + XPAR_OSD_0_BASEADDR, + XPAR_OSD_0_NUM_LAYERS, + XPAR_OSD_0_S_AXIS_VIDEO_DATA_WIDTH, + + XPAR_OSD_0_LAYER0_TYPE, + XPAR_OSD_0_LAYER1_TYPE, + XPAR_OSD_0_LAYER2_TYPE, + XPAR_OSD_0_LAYER3_TYPE, + XPAR_OSD_0_LAYER4_TYPE, + XPAR_OSD_0_LAYER5_TYPE, + XPAR_OSD_0_LAYER6_TYPE, + XPAR_OSD_0_LAYER7_TYPE, + + XPAR_OSD_0_LAYER0_IMEM_SIZE, + XPAR_OSD_0_LAYER0_INS_BOX_EN, + XPAR_OSD_0_LAYER0_INS_LINE_EN, + XPAR_OSD_0_LAYER0_INS_TEXT_EN, + XPAR_OSD_0_LAYER0_CLUT_SIZE, + XPAR_OSD_0_LAYER0_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER0_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER0_FONT_WIDTH, + XPAR_OSD_0_LAYER0_FONT_HEIGHT, + XPAR_OSD_0_LAYER0_FONT_BPP, + XPAR_OSD_0_LAYER0_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER0_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER0_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER1_IMEM_SIZE, + XPAR_OSD_0_LAYER1_INS_BOX_EN, + XPAR_OSD_0_LAYER1_INS_LINE_EN, + XPAR_OSD_0_LAYER1_INS_TEXT_EN, + XPAR_OSD_0_LAYER1_CLUT_SIZE, + XPAR_OSD_0_LAYER1_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER1_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER1_FONT_WIDTH, + XPAR_OSD_0_LAYER1_FONT_HEIGHT, + XPAR_OSD_0_LAYER1_FONT_BPP, + XPAR_OSD_0_LAYER1_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER1_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER1_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER2_IMEM_SIZE, + XPAR_OSD_0_LAYER2_INS_BOX_EN, + XPAR_OSD_0_LAYER2_INS_LINE_EN, + XPAR_OSD_0_LAYER2_INS_TEXT_EN, + XPAR_OSD_0_LAYER2_CLUT_SIZE, + XPAR_OSD_0_LAYER2_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER2_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER2_FONT_WIDTH, + XPAR_OSD_0_LAYER2_FONT_HEIGHT, + XPAR_OSD_0_LAYER2_FONT_BPP, + XPAR_OSD_0_LAYER2_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER2_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER2_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER3_IMEM_SIZE, + XPAR_OSD_0_LAYER3_INS_BOX_EN, + XPAR_OSD_0_LAYER3_INS_LINE_EN, + XPAR_OSD_0_LAYER3_INS_TEXT_EN, + XPAR_OSD_0_LAYER3_CLUT_SIZE, + XPAR_OSD_0_LAYER3_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER3_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER3_FONT_WIDTH, + XPAR_OSD_0_LAYER3_FONT_HEIGHT, + XPAR_OSD_0_LAYER3_FONT_BPP, + XPAR_OSD_0_LAYER3_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER3_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER3_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER4_IMEM_SIZE, + XPAR_OSD_0_LAYER4_INS_BOX_EN, + XPAR_OSD_0_LAYER4_INS_LINE_EN, + XPAR_OSD_0_LAYER4_INS_TEXT_EN, + XPAR_OSD_0_LAYER4_CLUT_SIZE, + XPAR_OSD_0_LAYER4_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER4_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER4_FONT_WIDTH, + XPAR_OSD_0_LAYER4_FONT_HEIGHT, + XPAR_OSD_0_LAYER4_FONT_BPP, + XPAR_OSD_0_LAYER4_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER4_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER4_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER5_IMEM_SIZE, + XPAR_OSD_0_LAYER5_INS_BOX_EN, + XPAR_OSD_0_LAYER5_INS_LINE_EN, + XPAR_OSD_0_LAYER5_INS_TEXT_EN, + XPAR_OSD_0_LAYER5_CLUT_SIZE, + XPAR_OSD_0_LAYER5_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER5_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER5_FONT_WIDTH, + XPAR_OSD_0_LAYER5_FONT_HEIGHT, + XPAR_OSD_0_LAYER5_FONT_BPP, + XPAR_OSD_0_LAYER5_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER5_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER5_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER6_IMEM_SIZE, + XPAR_OSD_0_LAYER6_INS_BOX_EN, + XPAR_OSD_0_LAYER6_INS_LINE_EN, + XPAR_OSD_0_LAYER6_INS_TEXT_EN, + XPAR_OSD_0_LAYER6_CLUT_SIZE, + XPAR_OSD_0_LAYER6_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER6_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER6_FONT_WIDTH, + XPAR_OSD_0_LAYER6_FONT_HEIGHT, + XPAR_OSD_0_LAYER6_FONT_BPP, + XPAR_OSD_0_LAYER6_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER6_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER6_TEXT_MAX_STRING_LENGTH, + + XPAR_OSD_0_LAYER7_IMEM_SIZE, + XPAR_OSD_0_LAYER7_INS_BOX_EN, + XPAR_OSD_0_LAYER7_INS_LINE_EN, + XPAR_OSD_0_LAYER7_INS_TEXT_EN, + XPAR_OSD_0_LAYER7_CLUT_SIZE, + XPAR_OSD_0_LAYER7_CLUT_MEMTYPE, + XPAR_OSD_0_LAYER7_FONT_NUM_CHARS, + XPAR_OSD_0_LAYER7_FONT_WIDTH, + XPAR_OSD_0_LAYER7_FONT_HEIGHT, + XPAR_OSD_0_LAYER7_FONT_BPP, + XPAR_OSD_0_LAYER7_FONT_ASCII_OFFSET, + XPAR_OSD_0_LAYER7_TEXT_NUM_STRINGS, + XPAR_OSD_0_LAYER7_TEXT_MAX_STRING_LENGTH + } +}; diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd_hw.h b/XilinxProcessorIPLib/drivers/osd/src/xosd_hw.h new file mode 100755 index 00000000..9269cf0d --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd_hw.h @@ -0,0 +1,467 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file xosd_hw.h +* +* This header file contains identifiers and register-level driver functions (or +* macros) that can be used to access the Xilinx MVI Video On-Screen-Display +* (OSD) device. +* +* For more information about the operation of this device, see the hardware +* specification and documentation in the higher level driver xosd.h source +* code file. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ------------------------------------------------------- +* 1.00a xd 08/01/08 First release +* 2.00a cm 06/12/12 14.1/14.2 release with address map updated to match +* Video over AXI4-Stream Specification +* 2.00a cjm 12/18/12 Converted from xio.h to xil_io.h, translating +* basic types, MB cache functions, exceptions and +* assertions to xil_io format. +*+* +******************************************************************************/ + +#ifndef XOSD_HW_H /* prevent circular inclusions */ +#define XOSD_HW_H /* by using protection macros */ + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ + +#include "xil_io.h" + +/************************** Constant Definitions *****************************/ + +/** @name Register Offsets + * @{ + */ +#define XOSD_CTL 0x000 /**< Control */ +#define XOSD_SS 0x020 /**< Screen Size */ +#define XOSD_BC0 0x100 /**< Background Color Channel 0 */ +#define XOSD_BC1 0x104 /**< Background Color Channel 1 */ +#define XOSD_BC2 0x108 /**< Background Color Channel 2 */ + +#define XOSD_L0C 0x110 /**< Layer 0 Control */ +#define XOSD_L0P 0x114 /**< Layer 0 Position */ +#define XOSD_L0S 0x118 /**< Layer 0 Size */ + +#define XOSD_L1C 0x120 /**< Layer 1 Control */ +#define XOSD_L1P 0x124 /**< Layer 1 Position */ +#define XOSD_L1S 0x128 /**< Layer 1 Size */ + +#define XOSD_L2C 0x130 /**< Layer 2 Control */ +#define XOSD_L2P 0x134 /**< Layer 2 Position */ +#define XOSD_L2S 0x138 /**< Layer 2 Size */ + +#define XOSD_L3C 0x140 /**< Layer 3 Control */ +#define XOSD_L3P 0x144 /**< Layer 3 Position */ +#define XOSD_L3S 0x148 /**< Layer 3 Size */ + +#define XOSD_L4C 0x150 /**< Layer 4 Control */ +#define XOSD_L4P 0x154 /**< Layer 4 Position */ +#define XOSD_L4S 0x158 /**< Layer 4 Size */ + +#define XOSD_L5C 0x160 /**< Layer 5 Control */ +#define XOSD_L5P 0x164 /**< Layer 5 Position */ +#define XOSD_L5S 0x168 /**< Layer 5 Size */ + +#define XOSD_L6C 0x170 /**< Layer 6 Control */ +#define XOSD_L6P 0x174 /**< Layer 6 Position */ +#define XOSD_L6S 0x178 /**< Layer 6 Size */ + +#define XOSD_L7C 0x180 /**< Layer 7 Control */ +#define XOSD_L7P 0x184 /**< Layer 7 Position */ +#define XOSD_L7S 0x188 /**< Layer 7 Size */ + +#define XOSD_GCWBA 0x190 /**< GPU Write Bank Address */ +#define XOSD_GCABA 0x194 /**< GPU Active Bank Address */ +#define XOSD_GCD 0x198 /**< GPU Data */ + +#define XOSD_VER 0x010 /**< Version Register */ +#define XOSD_RST 0x000 /**< Software Reset */ + +#define XOSD_GIER 0x010 /**< Global Interrupt Enable Register */ +#define XOSD_ISR 0x004 /**< Interrupt Status Register */ +#define XOSD_IER 0x00c /**< Interrupt Enable Register */ +/*@}*/ + +/** @name Memory footprint of layers + * @{ + */ +#define XOSD_LAYER_SIZE 0x10 +#define XOSD_LXC 0x00 /**< Layer Control */ +#define XOSD_LXP 0x04 /**< Layer Position */ +#define XOSD_LXS 0x08 /**< Layer Size */ +/*@}*/ + +/** @name Graphics Controller Bank related constants + * @{ + */ +#define XOSD_GC_BANK_NUM 2 /**< The number of Banks in each + * Graphics controller */ +/*@}*/ + +/** @name OSD Control Register bit definition + * @{ + */ +#define XOSD_CTL_VBP_MASK 0x00000020 /**< Vertical Blank Polarity */ +#define XOSD_CTL_HBP_MASK 0x00000010 /**< Horizontal Blank Polarity */ +#define XOSD_CTL_RUE_MASK 0x00000002 /**< OSD Register Update Enable */ +#define XOSD_CTL_EN_MASK 0x00000001 /**< OSD Enable */ +/*@}*/ + +/** @name OSD Screen Size Register bit definition + * @{ + */ +#define XOSD_SS_YSIZE_MASK 0x0FFF0000 /**< Vertical Height of OSD Output */ +#define XOSD_SS_YSIZE_SHIFT 16 /**< Bit shift of XOSD_SS_YSIZE_MASK */ +#define XOSD_SS_XSIZE_MASK 0x00000FFF /**< Horizontal Width of OSD Output */ +/*@}*/ + +/** @name OSD Background Color Channel 0 + * @{ + */ +#define XOSD_BC0_YG_MASK 0x00000FFF /**< Y (luma) or Green */ +/*@}*/ + +/** @name OSD Background Color Channel 1 + * @{ + */ +#define XOSD_BC1_UCBB_MASK 0x00000FFF /**< U (Cb) or Blue */ +/*@}*/ + +/** @name OSD Background Color Channel 2 + * @{ + */ +#define XOSD_BC2_VCRR_MASK 0x00000FFF /**< V(Cr) or Red */ +/*@}*/ + +/** @name Maximum number of the layers + * @{ + */ +#define XOSD_MAX_NUM_OF_LAYERS 8 /**< The max number of layers */ +/*@}*/ + +/** @name OSD Layer Control (Layer 0 through (XOSD_MAX_NUM_OF_LAYERS - 1)) + * @{ + */ +#define XOSD_LXC_ALPHA_MASK 0x0FFF0000 /**< Global Alpha Value */ +#define XOSD_LXC_ALPHA_SHIFT 16 /**< Bit shift number of Global + * Alpha Value */ +#define XOSD_LXC_PRIORITY_MASK 0x00000700 /**< Layer Priority */ +#define XOSD_LXC_PRIORITY_SHIFT 8 /**< Bit shift number of Layer + * Priority */ +#define XOSD_LXC_GALPHAEN_MASK 0x00000002 /**< Global Alpha Enable */ +#define XOSD_LXC_EN_MASK 0x00000001 /**< Layer Enable */ +/*@}*/ + +/** @name OSD Layer Position (Layer 0 through (XOSD_MAX_NUM_OF_LAYERS - 1)) + * @{ + */ +#define XOSD_LXP_YSTART_MASK 0x0FFF0000 /**< Vertical start line of origin + * of layer */ +#define XOSD_LXP_YSTART_SHIFT 16 /**< Bit shift of vertical start + * line of origin of layer */ +#define XOSD_LXP_XSTART_MASK 0x00000FFF /**< Horizontal start pixel of + * origin of layer */ +/*@}*/ + +/** @name OSD Layer Size (Layer 0 through (XOSD_MAX_NUM_OF_LAYERS - 1)) + * @{ + */ +#define XOSD_LXS_YSIZE_MASK 0x0FFF0000 /**< Vertical size of layer */ +#define XOSD_LXS_YSIZE_SHIFT 16 /**< Bit shift number of vertical + * size of layer */ +#define XOSD_LXS_XSIZE_MASK 0x00000FFF /**< Horizontal size of layer */ +/*@}*/ + +/** @name OSD Graphics Controller Write Bank Address + * @{ + */ +#define XOSD_GCWBA_GCNUM_MASK 0x00000700 /**< Graphics Controller Number */ +#define XOSD_GCWBA_GCNUM_SHIFT 8 /**< Bit shift of Graphics + * Controller Number */ +#define XOSD_GCWBA_BANK_MASK 0x00000007 /**< Controls which bank to write + * GPU instructions and Color + * LUT data into. */ + +#define XOSD_GCWBA_INS0 0x00000000 /** Instruction RAM 0 */ +#define XOSD_GCWBA_INS1 0x00000001 /** Instruction RAM 1 */ +#define XOSD_GCWBA_COL0 0x00000002 /** Color LUT RAM 0 */ +#define XOSD_GCWBA_COL1 0x00000003 /** Color LUT RAM 1 */ +#define XOSD_GCWBA_TXT0 0x00000004 /** Text RAM 0 */ +#define XOSD_GCWBA_TXT1 0x00000005 /** Text RAM 1 */ +#define XOSD_GCWBA_CHR0 0x00000006 /** Character Set RAM 0 */ +#define XOSD_GCWBA_CHR1 0x00000007 /** Character Set RAM 1 */ +/*@}*/ + +/** @name OSD Graphics Controller Active Bank Address + * @{ + */ +#define XOSD_GCABA_CHR_MASK 0xFF000000 /**< Set the active Character Bank*/ +#define XOSD_GCABA_CHR_SHIFT 24 /**< Bit shift of active Character + * Bank */ +#define XOSD_GCABA_TXT_MASK 0x00FF0000 /**< Set the active Text Bank */ +#define XOSD_GCABA_TXT_SHIFT 16 /**< Bit shift of active Text Bank*/ +#define XOSD_GCABA_COL_MASK 0x0000FF00 /**< Set the active Color Table + * Bank */ +#define XOSD_GCABA_COL_SHIFT 8 /**< Bit shift of active Color Table + * Bank */ +#define XOSD_GCABA_INS_MASK 0x000000FF /**< Set the active instruction Bank + */ +/*@}*/ + +/** @name Version Register bit definition + * @{ + */ +#define XOSD_VER_MAJOR_MASK 0xFF000000 /**< Major Version*/ +#define XOSD_VER_MAJOR_SHIFT 24 /**< Major Version Bit Shift*/ +#define XOSD_VER_MINOR_MASK 0x00FF0000 /**< Minor Version */ +#define XOSD_VER_MINOR_SHIFT 16 /**< Minor Version Bit Shift*/ +#define XOSD_VER_REV_MASK 0x0000F000 /**< Revision Version */ +#define XOSD_VER_REV_SHIFT 12 /**< Revision Bit Shift*/ +/*@}*/ + +/** @name OSD Software Reset + * @{ + */ +#define XOSD_RST_RESET 0x80000000 /**< Software Reset */ +/*@}*/ + +/** @name Global Interrupt Enable Register bit definition + * @{ + */ +#define XOSD_GIER_GIE_MASK 0x80000000 /**< Global interrupt enable */ +/*@}*/ + +/** @name Interrupt Status/Enable Register bit definition + * @{ + */ +#define XOSD_IXR_GAO_MASK 0xFF000000 /**< Graphics Controller Instruction + * Overflow */ +#define XOSD_IXR_GIE_MASK 0x00FF0000 /**< Graphics Controller Instruction + * Error */ +#define XOSD_IXR_OOE_MASK 0x00000010 /**< OSD Output Overflow Error */ +#define XOSD_IXR_IUE_MASK 0x00ff0000 /**< OSD Input Underflow Error */ +#define XOSD_IXR_VBIE_MASK 0x00000004 /**< Vertical Blank Interval End */ +#define XOSD_IXR_VBIS_MASK 0x00000002 /**< Vertical Blank Interval Start*/ +#define XOSD_IXR_FE_MASK 0x00000008 /**< OSD did not complete + * processing frame before next + * Vblank */ +#define XOSD_IXR_FD_MASK 0x00000001 /**< OSD completed processing + * Frame */ +#define XOSD_IXR_ALLIERR_MASK (XOSD_IXR_GAO_MASK | \ + XOSD_IXR_GIE_MASK | \ + XOSD_IXR_OOE_MASK | \ + XOSD_IXR_IUE_MASK | \ + XOSD_IXR_FE_MASK) /**< Mask for all error + * interrupts */ + +#define XOSD_IXR_ALLINTR_MASK (XOSD_IXR_VBIE_MASK | \ + XOSD_IXR_VBIS_MASK | \ + XOSD_IXR_FD_MASK | \ + XOSD_IXR_ALLIERR_MASK) /**< Mask for all + * interrupts */ +/*@}*/ + +/** @name Layer Types + * @{ + */ +#define XOSD_LAYER_TYPE_DISABLE 0 /**< Layer is disabled */ +#define XOSD_LAYER_TYPE_GPU 1 /**< Layer's type is GPU */ +#define XOSD_LAYER_TYPE_VFBC 2 /**< Layer's type is VFBC */ +/*@}*/ + +/** @name Supported Instruction numbers given an instruction memory size + * @{ + */ +#define XOSD_INS_MEM_SIZE_TO_NUM 1 /**< Conversion to the number of + * instructions from the + * instruction memory size */ +/*@}*/ + +/** @name GC Instruction word offset definition + * @{ + */ +#define XOSD_INS0 0 /**< Instruction word 0 offset */ +#define XOSD_INS1 1 /**< Instruction word 1 offset */ +#define XOSD_INS2 2 /**< Instruction word 2 offset */ +#define XOSD_INS3 3 /**< Instruction word 3 offset */ +#define XOSD_INS_SIZE 4 /**< Size of an instruction in words */ +/*@}*/ + +/** @name GC Instruction word 0 definition + * @{ + */ +#define XOSD_INS0_OPCODE_MASK 0xF0000000 /**< Operation Code (OpCode) */ +#define XOSD_INS0_OPCODE_SHIFT 28 /**< Bit shift number of OpCode */ +#define XOSD_INS0_GCNUM_MASK 0x07000000 /**< Graphics controller number + * (GC#) */ +#define XOSD_INS0_GCNUM_SHIFT 24 /**< Bit shift number of GC# */ +#define XOSD_INS0_XEND_MASK 0x00FFF000 /**< Horizontal end pixel of the + * object */ +#define XOSD_INS0_XEND_SHIFT 12 /**< Bit shift number of Horizontal + * end pixel of the object */ +#define XOSD_INS0_XSTART_MASK 0x00000FFF /**< Horizontal start pixel of the + * Object */ +/*@}*/ + +/** @name GC Instruction word 1 definition + * @{ + */ +#define XOSD_INS1_TXTINDEX_MASK 0x0000000F /**< String Index */ +/*@}*/ + +/** @name GC Instruction word 2 definition + * @{ + */ +#define XOSD_INS2_OBJSIZE_MASK 0xFF000000 /**< Object Size */ +#define XOSD_INS2_OBJSIZE_SHIFT 24 /**< Bit shift number of Object + * Size */ +#define XOSD_INS2_YEND_MASK 0x00FFF000 /**< Vertical end line of the + * object */ +#define XOSD_INS2_YEND_SHIFT 12 /**< Bit shift number of Vertical + * end line of the object */ +#define XOSD_INS2_YSTART_MASK 0x00000FFF /**< Vertical start line of the + * Object */ +/*@}*/ + +/** @name GC Instruction word 3 definition + * @{ + */ +#define XOSD_INS3_COL_MASK 0x0000000F /**< Color Index for Box/Text */ +/*@}*/ + +/** @name GC Instruction Operation Code definition (used in Instruction word 0) + * @{ + */ +#define XOSD_INS_OPCODE_END 0x0 /**< End of instruction list */ +#define XOSD_INS_OPCODE_NOP 0x8 /**< NOP */ +#define XOSD_INS_OPCODE_BOX 0xA /**< Box */ +#define XOSD_INS_OPCODE_LINE 0xC /**< Line */ +#define XOSD_INS_OPCODE_TXT 0xE /**< Text */ +#define XOSD_INS_OPCODE_BOXTXT 0xF /**< Box Text */ +/*@}*/ + +/** @name GC color size + * @{ + */ +#define XOSD_COLOR_ENTRY_SIZE 4 /**< Size of each color entry in + * bytes */ +/*@}*/ + +/** @name GC font unit size + * @{ + */ +#define XOSD_FONT_BIT_TO_BYTE 8 /**< Ratio to convert font size + * to byte */ +/*@}*/ + +/** @name Layer priority + * @{ + */ +#define XOSD_LAYER_PRIORITY_0 0 /**< Priority 0 --- Lowest */ +#define XOSD_LAYER_PRIORITY_1 1 /**< Priority 1 */ +#define XOSD_LAYER_PRIORITY_2 2 /**< Priority 2 */ +#define XOSD_LAYER_PRIORITY_3 3 /**< Priority 3 */ +#define XOSD_LAYER_PRIORITY_4 4 /**< Priority 4 */ +#define XOSD_LAYER_PRIORITY_5 5 /**< Priority 5 */ +#define XOSD_LAYER_PRIORITY_6 6 /**< Priority 6 */ +#define XOSD_LAYER_PRIORITY_7 7 /**< Priority 7 --- Highest */ +/*@}*/ + +/**************************** Type Definitions *******************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + +/** @name Device register I/O APIs + * @{ + */ + +#define XOSD_In32 Xil_In32 +#define XOSD_Out32 Xil_Out32 + +/*****************************************************************************/ +/** +* +* Read the given register. +* +* @param BaseAddress is the base address of the device +* @param RegOffset is the register offset to be read +* +* @return The 32-bit value of the register +* +* @note +* C-style signature: +* u32 XOSD_ReadReg(u32 BaseAddress, u32 RegOffset) +* +******************************************************************************/ +#define XOSD_ReadReg(BaseAddress, RegOffset) \ + XOSD_In32((BaseAddress) + (RegOffset)) + +/*****************************************************************************/ +/** +* +* Write the given register. +* +* @param BaseAddress is the base address of the device +* @param RegOffset is the register offset to be written +* @param Data is the 32-bit value to write to the register +* +* @return None. +* +* @note +* C-style signature: +* void XOSD_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data) +* +******************************************************************************/ +#define XOSD_WriteReg(BaseAddress, RegOffset, Data) \ + XOSD_Out32((BaseAddress) + (RegOffset), (Data)) +/*@}*/ + +/************************** Function Prototypes ******************************/ + +#ifdef __cplusplus +} +#endif + +#endif /* end of protection macro */ diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd_intr.c b/XilinxProcessorIPLib/drivers/osd/src/xosd_intr.c new file mode 100755 index 00000000..b873fb97 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd_intr.c @@ -0,0 +1,193 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file xosd_intr.c +* +* This code contains interrupt related functions of Xilinx MVI Video +* On-Screen-Display device driver. Please see xosd.h for more details of +* the driver. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ------------------------------------------------------- +* 1.00a xd 08/18/08 First release +* 2.00a cjm 12/18/12 Converted from xio.h to xil_io.h, translating +* basic types, MB cache functions, exceptions and +* assertions to xil_io format. +*+* +******************************************************************************/ + +#include "xosd.h" + +/*****************************************************************************/ +/** +* +* This function is the interrupt handler for the On-Screen-Display driver. +* +* This handler reads the pending interrupt from the IER/ISR, determines the +* source of the interrupts, calls according callbacks, and finally clears the +* interrupts. +* +* The application is responsible for connecting this function to the interrupt +* system. Application beyond this driver is also responsible for providing +* callbacks to handle interrupts and installing the callbacks using +* XOSD_SetCallBack() during initialization phase. An example delivered with +* this driver demonstrates how this could be done. +* +* @param InstancePtr is a pointer to the XOSD instance that just interrupted. +* @return None. +* @note None. +* +******************************************************************************/ +void XOSD_IntrHandler(void *InstancePtr) +{ + u32 PendingIntr; + u32 ErrorStatus; + XOSD *XOSDPtr; + + XOSDPtr = (XOSD *)InstancePtr; + + /* Validate parameters */ + Xil_AssertVoid(XOSDPtr != NULL); + Xil_AssertVoid(XOSDPtr->IsReady == XIL_COMPONENT_IS_READY); + + /* Get pending interrupts */ + PendingIntr = XOSD_IntrGetPending(XOSDPtr); + + /* Clear pending interrupts */ + XOSD_IntrClear(XOSDPtr, PendingIntr); + + /* Error interrupt is occurring or spurious interrupt */ + if ((0 == (PendingIntr & XOSD_IXR_ALLINTR_MASK)) || + (PendingIntr & XOSD_IXR_ALLIERR_MASK)) { + + ErrorStatus = PendingIntr & XOSD_IXR_ALLIERR_MASK; + XOSDPtr->ErrCallBack(XOSDPtr->ErrRef, ErrorStatus); + + /* The Error CallBack should reset the device and so + * there is no need to handle other interrupts + */ + return; + } + + /* A VBI Start has happened */ + if ((PendingIntr & XOSD_IXR_VBIS_MASK)) + XOSDPtr->VbiStartCallBack(XOSDPtr->VbiStartRef); + + /* A VBI End has happened */ + if ((PendingIntr & XOSD_IXR_VBIE_MASK)) + XOSDPtr->VbiEndCallBack(XOSDPtr->VbiEndRef); + + /* A Frame Done interrupt has happened */ + if ((PendingIntr & XOSD_IXR_FD_MASK)) + XOSDPtr->FrameDoneCallBack(XOSDPtr->FrameDoneRef); + +} + +/*****************************************************************************/ +/** +* +* This routine installs an asynchronous callback function for the given +* HandlerType: +* +*
+* HandlerType Callback Function Type +* ----------------------- --------------------------- +* XOSD_HANDLER_VBISTART XOSD_CallBack +* XOSD_HANDLER_VBIEND XOSD_CallBack +* XOSD_HANDLER_FRAMEDONE XOSD_CallBack +* XOSD_HANDLER_ERROR XOSD_ErrCallBack +* +* HandlerType Invoked by this driver when: +* ----------------------- -------------------------------------------------- +* XOSD_HANDLER_VBISTART A Vertical Blank Interval Start Interrupt happens +* XOSD_HANDLER_VBIEND A Vertical Blank Interval End Interrupt happens +* XOSD_HANDLER_FRAMEDONE A Frame Done Interrupt happens +* XOSD_HANDLER_ERROR An error condition happens +* +*+* +* @param InstancePtr is a pointer to the XOSD instance to be worked on. +* @param HandlerType specifies which callback is to be attached. +* @param CallbackFunc is the address of the callback function. +* @param CallbackRef is a user data item that will be passed to the +* callback function when it is invoked. +* +* @return +* - XST_SUCCESS when handler is installed. +* - XST_INVALID_PARAM when HandlerType is invalid. +* +* @note +* Invoking this function for a handler that already has been installed replaces +* it with the new handler. +* +******************************************************************************/ +int XOSD_SetCallBack(XOSD *InstancePtr, u32 HandlerType, + void *CallBackFunc, void *CallBackRef) +{ + Xil_AssertNonvoid(InstancePtr != NULL); + Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); + Xil_AssertNonvoid(CallBackFunc != NULL); + Xil_AssertNonvoid(CallBackRef != NULL); + + switch (HandlerType) { + case XOSD_HANDLER_VBISTART: + InstancePtr->VbiStartCallBack = (XOSD_CallBack)CallBackFunc; + InstancePtr->VbiStartRef = CallBackRef; + break; + + case XOSD_HANDLER_VBIEND: + InstancePtr->VbiEndCallBack = (XOSD_CallBack)CallBackFunc; + InstancePtr->VbiEndRef = CallBackRef; + break; + + case XOSD_HANDLER_FRAMEDONE: + InstancePtr->FrameDoneCallBack = (XOSD_CallBack)CallBackFunc; + InstancePtr->FrameDoneRef = CallBackRef; + break; + + case XOSD_HANDLER_ERROR: + InstancePtr->ErrCallBack = (XOSD_ErrorCallBack)CallBackFunc; + InstancePtr->ErrRef = CallBackRef; + break; + + default: + return XST_INVALID_PARAM; + + } + return XST_SUCCESS; +} diff --git a/XilinxProcessorIPLib/drivers/osd/src/xosd_sinit.c b/XilinxProcessorIPLib/drivers/osd/src/xosd_sinit.c new file mode 100755 index 00000000..26ec97d3 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/osd/src/xosd_sinit.c @@ -0,0 +1,98 @@ +/****************************************************************************** +* +* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ +/*****************************************************************************/ +/** + * + * @file xosd_sinit.c + * + * This file contains the static initialization method for Xilinx MVI Video + * On-Screen-Display (OSD) device driver. + * + *
+ * MODIFICATION HISTORY: + * + * Ver Who Date Changes + * ----- ---- -------- ------------------------------------------------------- + * 1.00a xd 08/18/08 First release + * 2.00a cjm 12/18/12 Converted from xio.h to xil_io.h, translating + * basic types, MB cache functions, exceptions and + * assertions to xil_io format. + *+ * + ******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "xosd.h" +#include "xparameters.h" + +/************************** Constant Definitions *****************************/ + + +/**************************** Type Definitions *******************************/ + + +/***************** Macros (Inline Functions) Definitions *********************/ + + +/************************** Function Prototypes ******************************/ + +/*****************************************************************************/ +/** + * XOSD_LookupConfig returns a reference to an XOSD_Config structure + * based on the unique device id, DeviceId. The return value will refer + * to an entry in the device configuration table defined in the xosd_g.c + * file. + * + * @param DeviceId is the unique device ID of the device for the lookup + * operation. + * + * @return XOSD_LookupConfig returns a reference to a config record in the + * configuration table (in xosd_g.c) corresponding to DeviceId, + * or NULL if no match is found. + * + ******************************************************************************/ +XOSD_Config *XOSD_LookupConfig(u16 DeviceId) +{ + extern XOSD_Config XOSD_ConfigTable[]; + XOSD_Config *CfgPtr = NULL; + int i; + + for (i = 0; i < XPAR_XOSD_NUM_INSTANCES; i++) { + if (XOSD_ConfigTable[i].DeviceId == DeviceId) { + CfgPtr = &XOSD_ConfigTable[i]; + break; + } + } + + return (CfgPtr); +}