//***************************************************************************
//!file     si_drv_edid.h
//!brief    Silicon Image EDID driver.  Basic EDID Ram read/write, NVRAM
//          read/program.
//
// No part of this work may be reproduced, modified, distributed,
// transmitted, transcribed, or translated into any language or computer
// format, in any form or by any means without written permission of
// Silicon Image, Inc., 1060 East Arques Avenue, Sunnyvale, California 94085
//
// Copyright 2002-2010, Silicon Image, Inc.  All rights reserved.
//***************************************************************************/

#ifndef __SI_DRVEDID_H__
#define __SI_DRVEDID_H__
#include "si_datatypes.h"
#include "si_c99support.h"
//------------------------------------------------------------------------------
//  EDID Driver Manifest Constants
//------------------------------------------------------------------------------

typedef enum
{
    EDID_RAM_0      = 0x00,
    EDID_RAM_1,
    EDID_RAM_2,
    EDID_RAM_3,
    EDID_RAM_4,     // NOTE: Even though 4 & 5 are not existing ports in SiI9687,
    EDID_RAM_5,     // these definitions are required by generic EDID Inp Proc component

    EDID_RAM_VGA    = 0x10,
    EDID_RAM_BOOT   = 0x20,

    EDID_NVRAM      = 0x30,

    EDID_NVRAM_VGA  = 0x40,
    EDID_NVRAM_BOOT = 0x50,
} EdidType_t;

#define EDID_TABLE_LEN              256
#define EDID_BLOCK_LEN              128
#define EDID_VGA_TABLE_LEN          128
#define EDID_DEVBOOT_LEN            64

//------------------------------------------------------------------------------
//  Module Data
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//  Function:       SiiDrvEdidRamBlockRead
//  Description:    Read data from the specified port EDID RAM and offset.
//                  The portIndex value determines the amount of data
//                  written to the pDest array.
//  Parameters:     portIndex - 0x00-0x04       read 128 bytes at the specified
//                                              offset from port rams 0-4
//                              EDID_RAM_VGA    read 128 bytes from VGA port ram
//                              EDID_RAM_BOOT   read 64 bytes from Boot Data ram
//                  offset    - 0 or 1, specifies the 128-byte block offset
//                              within the port RAM space (256 bytes)
//------------------------------------------------------------------------------

bool_t SiiDrvEdidRamBlockRead( uint_t portIndex, uint_t offset, uint8_t *pDest );

//------------------------------------------------------------------------------
//  Function:       SiiDrvEdidRamBlockWrite
//  Description:    Write an EDID block (128 bytes) to the specified port RAM
//                  and offset.
//  Description:    Write data to the specified port EDID RAM and offset.
//                  The portIndex value determines the amount of data
//                  read from the pSource array.
//  Parameters:     portIndex - 0x00-0x04       write 128 bytes to the specified
//                                              offset in port rams 0-4
//                              EDID_RAM_VGA    write 128 bytes to VGA port ram
//                              EDID_RAM_BOOT   write 64 bytes to Boot Data ram
//                  offset    - 0 or 1, specifies the 128-byte block offset
//                              within the port RAM space (256 bytes)
//------------------------------------------------------------------------------

bool_t SiiDrvEdidRamBlockWrite( uint_t portIndex, uint_t offset, const uint8_t *pSource );

//------------------------------------------------------------------------------
//  Function:       SiiEdidNvramRead
//  Description:    Read data from the NVRAM of the specified type.
//                  The type determines the amount of data written to
//                  the pDest array.
//  Parameters:     nvramType - EDID_NVRAM, specifies 256 byte main NVRAM
//                              EDID_NVRAM_VGA, specifies 128 byte VGA EDID
//                              EDID_NVRAM_BOOT, specifies 64  byte Boot Data
//------------------------------------------------------------------------------

bool_t SiiEdidNvramRead( uint_t nvramType, uint8_t *pDest );

//------------------------------------------------------------------------------
//  Function:       SiiEdidNvramWrite
//  Description:    Program the passed data into the NVRAM of the specified
//                  type.  The type determines the amount of data read from
//                  the pSource array.
//  Parameters:     nvramType - EDID_NVRAM, specifies 256 byte main NVRAM
//                              EDID_NVRAM_VGA, specifies 128 byte VGA EDID
//                              EDID_NVRAM_BOOT, specifies 64  byte Boot Data
//------------------------------------------------------------------------------

bool_t SiiEdidNvramWrite( uint_t nvramType, const uint8_t *pSource );


//------------------------------------------------------------------------------
//  Function:       SiiDrvEdidBlockRead
//  Description:    Read a block from the selected EDID source into the passed array.
//------------------------------------------------------------------------------

bool_t SiiDrvEdidBlockRead ( uint8_t source, int_t blockIndex, uint8_t *pDest );


//------------------------------------------------------------------------------
//  Function:       SiiDrvEdidCopyFromNvram
//  Description:    Force a boot load to get the new EDID data from the NVRAM to the chip.
//------------------------------------------------------------------------------

void SiiDrvEdidCopyFromNvram(void);


#endif      // __SI_DRVEDID_H__
