osd: Added source files

Added source files, doxygen files. Removed example.c for osd_v4_0 driver

Signed-off-by: Shravan Kumar A <skumara@xilinx.com>
Acked-by: Srikanth Vemula <svemula@xilinx.com>
This commit is contained in:
Shravan Kumar A 2014-07-25 18:42:50 +05:30 committed by Jagannadha Sutradharudu Teki
parent 7f35cf3fa5
commit 459d6594a7

View file

@ -1,460 +0,0 @@
/******************************************************************************
*
* 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.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ---- -------- -------------------------------------------------------
* 1.00a xd 05/12/09 First release
* </pre>
*
* ****************************************************************************
*/
#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;
}