UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
4,056 Views
Registered: ‎09-21-2016

Cannot draw a box or text by OSD IP.

Jump to solution

Hi,

I am using OSD IP v 6.0. I have initialized the OSD IP and generated two layer output. My 1st layer is camera output and 2nd layer is Internal graphics controller. After initialization of layers, I tried to draw some boxes or text box. But, I failed. I followed Xilinx reference design. I found initialization code from there. I modified the code according to my application. I am uploading the code below.

 

How will I change this code to draw a text or boxes by the OSD IP?
Any suggestion will really helpful.
If you need more information to understand my problem, please let me know.

Thank you
Rappy 

/*----------------------------------------------------------------
//      _____
//     /     \
//    /____   \____
//   / \===\   \==/
//  /___\===\___\/  AVNET
//       \======/
//        \====/
//---------------------------------------------------------------
//
// This design is the property of Avnet.  Publication of this
// design is not authorized without written consent from Avnet.
//
// Please direct any questions to:  technical.support@avnet.com
//
// Disclaimer:
//    Avnet, Inc. makes no warranty for the use of this code or design.
//    This code is provided  "As Is". Avnet, Inc assumes no responsibility for
//    any errors, which may appear in this code, nor does it make a commitment
//    to update the information contained herein. Avnet, Inc specifically
//    disclaims any implied warranties of fitness for a particular purpose.
//                     Copyright(c) 2010 Avnet, Inc.
//                             All rights reserved.
//
//----------------------------------------------------------------
//
// Create Date:         Mar 19, 2010
// Design Name:         IVK OSD Tutorial
// Module Name:         ivk_osd.c
// Project Name:        IVK
// Target Devices:      Spartan-6
// Avnet Boards:        IVK
//
// Tool versions:       ISE 11.4
//
// Description:         IVK OSD Tutorial
//                      - using the Xilinx OSD LogiCore
//
// Dependencies:
//
// Revision:            Mar 19, 2010: 1.00 Initial version
//                      Apr 16, 2010: 1.01 Update OSD code:
//                                         - convert Font to big-endian
//                                         - draw box (ivk_osd_test1)
//                                         - draw text (ivk_osd_test2)
//
//----------------------------------------------------------------*/

#include "ivk_osd.h"

// Located in: microblaze_0/include/
#include "xbasic_types.h"
//#include "xutil.h"
#include "xparameters.h"
#include "xstatus.h"

//#include "ivk_osd.h"
//#include "ivk_video_resolution.h"

#include "xosd.h"
#include "stdio.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] = {
    "Xilinx Virtex6 Video", //"String #1",
    "Scaler/MANR/OSD Demo",                       //"String #2",
    "Hello",
    "Xilinx",
    "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
 */
 int  OsdInit(int DeviceID);
 void OsdConfig(int Width, int Height);
 void OsdDrawBox(int x_start, int y_start, int x_last, int y_last, int color);
 void OsdDrawText(int x_pos, int y_pos, int color, int string_index, int text_size);
int bOsdInitialized = 0;
//extern unsigned int only_tpg;
void ivk_osd_init(void)
{

   Xuint32 Width  = 1280;
   Xuint32 Height = 1024;
      bOsdInitialized = 0;
    
   if ( !bOsdInitialized )
   {
      OsdInit(OSD_DEVICE_ID);
      OsdConfig(Width,Height);

     bOsdInitialized = 1;
   }

}
 void ivk_osd_enable(void)
{
   XOSD_Enable(&Osd);
}


void ivk_osd_test1(void)
{
   OsdDrawBox(
        350, // X start
        350, // Y start
      400, // X end
       400, // Y end
         0x07  // color index
         );
}

void ivk_osd_test2(void)
{
   OsdDrawText(
       128, // X start
        500, // Y start
         2, // color index
         0, // string index
         4  // text scale
         );
}

void ivk_osd_test3(void)
{
   Xuint32 idx = 0x00;
   Xuint32 reg = 0x00000000;
#if 0
   reg = XOSD_ReadReg(Osd.Config.BaseAddress, XOSD_CTL);
   xil_printf( "XOSD_CTL = 0x%08X\n\r", reg );
#endif
#if 1
   for ( idx = 0x0000; idx < 0x0050; idx += 4 )
   {
      if ( !(idx%16) ) xil_printf( "\r\n[0x%04X] = ", idx );
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "0x%08X ", reg );
   }
   for ( idx = 0xA0; idx < 0xB0; idx += 4 )
   {
      if ( !(idx%16) ) xil_printf( "\r\n[0x%04X] = ", idx );
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "0x%08X ", reg );
   }
   idx = 0x100;
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "\r\n[0x%04X] = 0x%08X ", idx, reg );
   idx = 0x21C;
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "\r\n[0x%04X] = 0x%08X ", idx, reg );
   idx = 0x220;
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "\r\n[0x%04X] = 0x%08X ", idx, reg );
   idx = 0x228;
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "\r\n[0x%04X] = 0x%08X ", idx, reg );
   idx = 0x22C;
      reg = XOSD_ReadReg(Osd.Config.BaseAddress, idx);
      xil_printf( "\r\n[0x%04X] = 0x%08X ", idx, reg );
   xil_printf( "\r\n" );
#endif
}



/*****************************************************************************/
/**
*
* 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;

   xil_printf("OsdInit(%d) Start\r\n", DeviceID );

    /* Initialize the OSD instance */
   xil_printf("-- Initialize the OSD instance ...\r\n" );

    OsdCfgPtr = XOSD_LookupConfig(DeviceID);
    xil_printf("The ID ptr is 0x%x\r\n",OsdCfgPtr);
    Status = XOSD_CfgInitialize(&Osd, OsdCfgPtr, OsdCfgPtr->BaseAddress);
    if (Status != XST_SUCCESS) {
        return 1;
    }

    /* Reset the devices */
   xil_printf("-- Reset the devices ...\r\n" );

   // XOSD_Reset(&Osd);


    /* Set Vertical and Horizontal Blank Polarity */
   xil_printf("-- Set Vertical and Horizontal Blank Polarity ...\r\n" );

   // XOSD_SetBlankPolarity(&Osd,TRUE,TRUE);



    /* Tell the OSD to pick up the register changes */
   xil_printf("-- Tell the OSD to pick up the register changes ...\r\n" );

    XOSD_RegUpdateEnable(&Osd);

   xil_printf("OsdInit Done\r\n" );
    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.
*
******************************************************************************/
void OsdConfig( int Width, int Height )
{
   /* Background color definition */

   u16 Red = 0xFFF; //0xFF;
   u16 Blue = 0xFFF; //0;
   u16 Green = 0xFFF; //0;

   /* Layer 0/1 property definition */

   int Layer0AlphaValue = 0xFFF;
   int Layer0Priority = XOSD_LAYER_PRIORITY_0;
   int Layer0GlobalAlphaEnable = 1;

   int Layer1AlphaValue = 0xFFF;
   int Layer1Priority = XOSD_LAYER_PRIORITY_1;
   int Layer1GlobalAlphaEnable = 1;

   xil_printf("OsdConfig(%d,%d) Start\r\n", Width, Height );

   /* Set screen size */
   xil_printf("-- Set screen size ...\r\n" );

   XOSD_SetScreenSize(&Osd, Width, Height);

   /* Set Background color */
   xil_printf("-- Set Background color ...\r\n" );

   XOSD_SetBackgroundColor(&Osd, Red, Blue, Green);

   /* Set up Layer 0's Alpha, Priority, Dimension and enable it */
   xil_printf("-- Set up Layer 0's Alpha, Priority, Dimension and enable it ...\r\n" );
   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 */

   xil_printf("-- Set up Layer 1's Alpha, Priority, Dimension and enable it ...\r\n" );
   XOSD_SetLayerAlpha(&Osd, 1, Layer1GlobalAlphaEnable, Layer1AlphaValue);
   XOSD_SetLayerPriority(&Osd, 1, Layer1Priority);
   XOSD_SetLayerDimension(&Osd, 1, 0, 0, Width, Height);
   XOSD_EnableLayer(&Osd, 1);

   ivk_osd_test1();
   XOsd_LoadColorLUTBank (&Osd, 1,1,10);
    /* Enable the OSD device and tell it to pick up the register changes */
   xil_printf("-- Enable the OSD device ...\r\n" );

   //XOSD_Enable(&Osd);


   xil_printf("OsdConfig Done\r\n" );
   return;
}

/*****************************************************************************/
/**
*
* This function draws a box using the OSD device
*
* @param    None.
*
* @return   None.
*
* @note     None.
*
******************************************************************************/
 void OsdDrawBox(int x_start, int y_start, int x_last, int y_last, int color)
{
   xil_printf("OsdDrawBox Start\r\n" );

   /* Instruction buffer */
   u32 Instruction[XOSD_INS_SIZE];

   /* Instruction property definition */
   xil_printf("-- Instruction property definition ...\r\n" );

   u16 ObjType = XOSD_INS_OPCODE_BOX; /* A box */
   u8  ObjSize = 100;                   /* Box boarder width */
   u16 XStart = x_start;                   /* Horizontal start pixel of the box */
   u16 YStart = y_start;                   /* Vertical start line of the box */
   u16 XEnd = x_last;                /* Horizontal end pixel of the box */
   u16 YEnd =  y_last;                   /* Vertical end line of the box */
   u8 TextIndex = 0;                  /* Ignored in box instruction case */
   u8 ColorIndex = color;             /* Color used to draw the box */

   /* Create a box command instruction */
   xil_printf("-- Create a box command instruction ...\r\n" );

   XOSD_CreateInstruction(&Osd, Instruction, 1,
                           ObjType, ObjSize,
                           XStart, YStart, XEnd, YEnd,
                           TextIndex, ColorIndex);

   /* Load the instruction to draw the box in the OSD output */
   xil_printf("-- Load the instruction to draw the box in the OSD output ...\r\n" );

   XOSD_LoadInstructionList(&Osd, 1, 0, Instruction, 0);

   xil_printf("OsdDrawBox Done\r\n" );
   return;
}


/*****************************************************************************/
/**
*
* This function draws text using the OSD device
*
* @param    None.
*
* @return   None.
*
* @note     None.
*
******************************************************************************/
 void OsdDrawText(int x_pos, int y_pos, int color, int string_index, int text_size)
{
   xil_printf("OsdDrawText Start\r\n" );

   /* Instruction buffer */
   u32 Instruction[XOSD_INS_SIZE];


   u16 ObjType = XOSD_INS_OPCODE_TXT; /* A text string */
   u8  ObjSize = (text_size<<4);      /* Text Scale factor (1x, 2x, 4x, 8x) */
   u16 XStart = x_pos;                /* Horizontal start pixel of the text */
   u16 YStart = y_pos;                /* Vertical start line of the text */
   u16 XEnd =   x_pos;                /* Horizontal end pixel of the text (not used) */
   u16 YEnd =   y_pos;                /* Vertical end line of the text (must be same as YStart) */
   u8 TextIndex = 0;                  /* Index of Text String */
   u8 ColorIndex = color;             /* Color used to draw text */

   /* Create a text command instruction */
   xil_printf("-- Create a box command instruction ...\r\n" );

   XOSD_CreateInstruction(&Osd, Instruction, 1,
                           ObjType, ObjSize,
                           XStart, YStart, XEnd, YEnd,
                           TextIndex, ColorIndex);

   /* Load the instruction to draw the box in the OSD output */
   xil_printf("-- Load the instruction to draw the box in the OSD output ...\r\n" );

   XOSD_LoadInstructionList(&Osd, 1, 1, Instruction, 1);

   xil_printf("OsdDrawBox Done\r\n" );
   return;
}

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
4,327 Views
Registered: ‎07-31-2012

Re: Cannot draw a box or text by OSD IP.

Jump to solution
For latest designs use the Video Mixer IP which is the replacement for the OSD IP. https://www.xilinx.com/products/intellectual-property/ef-di-vid-mix.html
Thanks,
Anirudh

PS: Please MARK this as an answer in case it helped resolve your query.Give kudos in case the post guided you to a solution.
0 Kudos
6 Replies
Xilinx Employee
Xilinx Employee
4,328 Views
Registered: ‎07-31-2012

Re: Cannot draw a box or text by OSD IP.

Jump to solution
For latest designs use the Video Mixer IP which is the replacement for the OSD IP. https://www.xilinx.com/products/intellectual-property/ef-di-vid-mix.html
Thanks,
Anirudh

PS: Please MARK this as an answer in case it helped resolve your query.Give kudos in case the post guided you to a solution.
0 Kudos
Adventurer
Adventurer
3,988 Views
Registered: ‎09-21-2016

Re: Cannot draw a box or text by OSD IP.

Jump to solution

Hi,

Thank you for replying back.

I have read the features of the "Video Mixer IP". But, I think with that IP I can not create any box, text or text box. Only, I can do mix 2 or 3 layers(upto 8 layers) of video by "Video Mixer IP".

 

But, I want to generate box, text or textbox. What should I do if I want to do this?

 

Thanks

Rappy Saha

Adventurer
Adventurer
3,968 Views
Registered: ‎09-21-2016

Re: Cannot draw a box or text by OSD IP.

Jump to solution

Hi,

 

I also want to know,  is it possible to draw boxes or text by OSD IP now a days? Because, I saw a notice that OSD IP is in maintenance mode. I also did not find instructions on the user guide of OSD ip about how to draw a box or text.

 

Any suggestion will be really helpful.

 

Thanks

Rappy  

 

Voyager
Voyager
1,254 Views
Registered: ‎05-30-2017

Re: Cannot draw a box or text by OSD IP.

Jump to solution

@rappysahaIf you look at Video on screen display 5.01a UG is more detailed than 6.0 and explain very well in the last pages how to write and configure OSD memory bank. Now I can draw boxes but I can't write text. I don't understand where is the mistake. Did you solve your problem?

0 Kudos
Adventurer
Adventurer
1,230 Views
Registered: ‎09-21-2016

Re: Cannot draw a box or text by OSD IP.

Jump to solution

Hello, I could not solve my problem using OSD IP. Besides, after that , I used 'Video mixer IP' instead of OSD IP. To generate text or box, you can create a layer by writing data directly into memory. In this case, VDMA ip can help you. After creating your own layer, you can mix them with 'Video mixer IP'.

 

Thank you

Rappy

Tags (2)
Voyager
Voyager
1,210 Views
Registered: ‎05-30-2017

Re: Cannot draw a box or text by OSD IP.

Jump to solution

@rappysaha Thank for the help! And sorry if I asked for help in an old post. You used video mixer because OSD IP have some problem and doesn't work? I've been working on this IP for many days but text doesn't appear. I think that OSD IP is a little buggy, So now you are using video mixer to mix the layer while you are generating OSD with your own custom logic? In my design I'm successfully using OSD IP+VDMA but the only thing that doesn't work is text. Thanks for the help! 

0 Kudos