#ifndef PHSTBCOMMON_H    /* Multi-include protection.   <FILENAME>_H */
#define PHSTBCOMMON_H

/*  Copyright (C) 2005 Koninklijke Philips Electronics N.V.
    All Rights Reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    Copyright (C) 2006 NXP B.V.
    All Rights Reserved.

*//**
    @file   phStbCommon.h
    @brief  Map internal Philips Semiconductor Types to GNU/Linux types

@b  Component: IphStbCommon

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
001 15042005    laird       First Revision
002 18042005    laird       More common types added.
003 20042005    batelaan    Make it compile and work!
004 05052005    batelaan    Prevent including <tmNxTypes.h> under Linux/MIPS.
005 13062005    laird       Adding colour LUT stuff so it is available for both processors.
006 09082005    batelaan    Only define Null if not yet defined.
                            Don't redefine types if tmtypes.h has been included.
007 17082005    batelaan    Build for WinCE
008 28092005    batelaan    Build for WinNT.
009 11112005    batelaan    Added various defs used by tmman port.
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

/*******************
* INCLUDE FILES    *
********************/

#include "tmFlags.h"                /* DVP platform-dependent build flags */

/* Only on TriMedia do we use the standard tmNxTypes.h file, for
   Linux and WinCE we have our own cutdown version. */
#if defined(__TCS__) || (TMFL_CPU_IS_TM==1)
#include <tmNxTypes.h>
#else

#define TMNXTYPES_H

/**************************************************************
* EXPORTED MACROS         PH[<LAYER>]_<MODULE><_WORD>+        *
***************************************************************/

/**************************************************************
* EXPORTED TYPEDEFS       [p]ph[<Layer>]<Module>_<Word>+_t  *
***************************************************************/
#if !defined(_TMtypes_h)
/** Standard Type mappings. */
typedef void            Void;       /* Void (typeless) */
typedef signed   char   Int8;       /*  8-bit   signed integer */
typedef signed   short  Int16;      /* 16-bit   signed integer */
typedef signed   long   Int32;      /* 32-bit   signed integer */
typedef unsigned char   UInt8;      /*  8-bit unsigned integer */
typedef unsigned short  UInt16;     /* 16-bit unsigned integer */
typedef unsigned int    UInt32;     /* 32-bit unsigned integer */
typedef float           Float;      /* 32-bit floating point */
typedef float           Float32;    /* 32-bit floating point */
typedef unsigned int    Bool;       /* Boolean (True/False) */
typedef char            Char;       /* character, character array ptr */
typedef int             Int;        /* machine-natural integer */
typedef unsigned int    UInt;       /* machine-natural unsigned integer */
typedef char           *String;     /* Null-terminated 8-bit char str */

#if (defined(_WIN32) || defined(_WIN64)) && !defined(UNDER_CE)
typedef INT64  Int64;   /* 64-bit signed   integer */
typedef UINT32 UInt64;  /* 64-bit unsigned integer */
#else
typedef signed   long long int Int64;   /* 64-bit signed   integer */
typedef unsigned long long int UInt64;  /* 64-bit unsigned integer */
#endif

#endif //!defined(_TMtypes_h)

#ifndef TM_OK
/** Global success return status */
#define TM_OK 0U
#endif

/** Standard Type mappings
    NOTE: IBits32/UBits32 types are defined for use with 32-bit bitfields.
    This is done because ANSI/ISO compliant compilers require bitfields
    to be of type "int" else a large number of compiler warnings will
    result.  To avoid the risks associated with redefining Int32/UInt32
    to type "int" instead of type "long" (which are the same size on 32-
    bit CPUs) separate 32-bit signed/unsigned bitfield types are defined.
*/
typedef signed   int    IBits32;    /* 32-bit   signed integer bitfields */
typedef unsigned int    UBits32;    /* 32-bit unsigned integer bitfields */

typedef Int8    *pInt8;             /*  8-bit   signed integer ptr */
typedef Int16   *pInt16;            /* 16-bit   signed integer ptr */
typedef Int32   *pInt32;            /* 32-bit   signed integer ptr */
typedef Int64   *pInt64;            /* 64-bit   signed integer ptr */
typedef IBits32 *pIBits32;          /* 32-bit   signed integer bitfield ptr */
typedef UBits32 *pUBits32;          /* 32-bit unsigned integer bitfield ptr */
typedef UInt8   *pUInt8;            /*  8-bit unsigned integer ptr */
typedef UInt16  *pUInt16;           /* 16-bit unsigned integer ptr */
typedef UInt32  *pUInt32;           /* 32-bit unsigned integer ptr */
typedef UInt64  *pUInt64;           /* 64-bit unsigned integer ptr */
typedef Void    *pVoid;             /* Void (typeless) ptr */
typedef Float   *pFloat;            /* 32-bit floating point, float ptr */
typedef double  Double, *pDouble;   /* 32/64-bit floating point, double ptr */
typedef Bool    *pBool;             /* Boolean (True/False) ptr */
typedef Char    *pChar;             /* character, character array ptr */
typedef Int     *pInt;              /* machine-natural integer ptr */
typedef UInt    *pUInt;             /* machine-natural unsigned integer ptr */
typedef String  *pString;           /* Null-terminated 8-bit char str ptr */

/** Map an error Code to UInt32*/
typedef UInt32 tmErrorCode_t;

/** Map Null to linux NULL*/
#ifndef Null
#define Null   NULL
#endif

/*-----------------------------------------------------------------------------
** Hardware device power states
*/
typedef enum tmPowerState
{
    tmPowerOn,                          /* Device powered on      (D0 state) */
    tmPowerStandby,                     /* Device power standby   (D1 state) */
    tmPowerSuspend,                     /* Device power suspended (D2 state) */
    tmPowerOff                          /* Device powered off     (D3 state) */

}   tmPowerState_t, *ptmPowerState_t;

/*-----------------------------------------------------------------------------
** Software Version Structure
*/
typedef struct tmSWVersion
{
    UInt32      compatibilityNr;        /* Interface compatibility number */
    UInt32      majorVersionNr;         /* Interface major version number */
    UInt32      minorVersionNr;         /* Interface minor version number */

}   tmSWVersion_t, *ptmSWVersion_t;

/*-----------------------------------------------------------------------------
** NOTE: This macro converts four characters into a UInt32 value.  It is used
**       instead of multi-character constants (i.e. 'ABCD') to prevent some
**       compiler warnings, especially with GNU-based compilers.
*/
#define TM_CHARS_TO_UINT32(a,b,c,d) ((UInt32) ((UInt8) (a) << 24 | (UInt8) (b) << 16 | (UInt8) (c) << 8 | (UInt8) (d)))

#endif /* #if (!defined(__mips__)) || (TMFL_CPU_IS_TM==1) */

/*******************************************************************
* EXPORTED DATA      g[k|p|kp|pk|kpk]tm[<layer>]<Module>_<Word>+ *
********************************************************************/

/** 3-byte color structure */
typedef union phStbColour3
{
    UBits32 u32;
#if (TMFL_ENDIAN == TMFL_ENDIAN_BIG)
    struct {
        UBits32       : 8;
        UBits32 red   : 8;
        UBits32 green : 8;
        UBits32 blue  : 8;
    } rgb;
    struct {
        UBits32   : 8;
        UBits32 y : 8;
        UBits32 u : 8;
        UBits32 v : 8;
    } yuv;
    struct {
        UBits32   : 8;
        UBits32 u : 8;
        UBits32 m : 8;
        UBits32 l : 8;
    } uml;
#else /* (TMFL_ENDIAN == TMFL_ENDIAN_LITTLE) */
    struct {
        UBits32 blue  : 8;
        UBits32 green : 8;
        UBits32 red   : 8;
        UBits32       : 8;
    } rgb;
    struct {
        UBits32 v : 8;
        UBits32 u : 8;
        UBits32 y : 8;
        UBits32   : 8;
    } yuv;
    struct {
        UBits32 l : 8;
        UBits32 m : 8;
        UBits32 u : 8;
        UBits32   : 8;
    } uml;
#endif /* (TMFL_ENDIAN == TMFL_ENDIAN_BIG) */
}   phStbColour3_t;

/** 4-byte color structure */
typedef union phStbColour4
{
    UBits32 u32;
#if (TMFL_ENDIAN == TMFL_ENDIAN_BIG)
    struct {
        UBits32 alpha    : 8;
        UBits32 red      : 8;
        UBits32 green    : 8;
        UBits32 blue     : 8;
    } argb;
    struct {
        UBits32 alpha    : 8;
        UBits32 y        : 8;
        UBits32 u        : 8;
        UBits32 v        : 8;
    } ayuv;
    struct {
        UBits32 alpha    : 8;
        UBits32 u        : 8;
        UBits32 m        : 8;
        UBits32 l        : 8;
    } auml;
#else /* (TMFL_ENDIAN == TMFL_ENDIAN_LITTLE) */
    struct {
        UBits32 blue     : 8;
        UBits32 green    : 8;
        UBits32 red      : 8;
        UBits32 alpha    : 8;
    } argb;
    struct {
        UBits32 v        : 8;
        UBits32 u        : 8;
        UBits32 y        : 8;
        UBits32 alpha    : 8;
    } ayuv;
    struct {
        UBits32 l        : 8;
        UBits32 m        : 8;
        UBits32 u        : 8;
        UBits32 alpha    : 8;
    } auml;
#endif /* (TMFL_ENDIAN == TMFL_ENDIAN_BIG) */
}   phStbColour4_t;

/** A Colour LUT that has 255 possible values, each one
    has a type of ::phStbColour4_t.
    */
typedef struct phStb8BitColourLut
{
    phStbColour4_t   values[255];
} phStb8BitColourLut_t;

#endif /* PHSTBCOMMON_H      Do not add any thing below this line */
