/*****************************************************************************/
/* Copyright (c) 2009 NXP B.V.                                               */
/*                                                                           */
/* 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, using version 2 of the License.             */
/*                                                                           */
/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307       */
/* USA.                                                                      */
/*                                                                           */
/*****************************************************************************/
/**
    @file   phStbScartSwitchApi.h
    @brief  This file contains the types and the literals used for 
            the Scart Switch module.

    @b  Module:  UDA3000 (AV Scart switch) driver.

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
    20061010    frq06781    Creation
    20061219    frq06781    Added GetVolume ioctl.
    20061221    frq06781    Changed to allow CVBS and RGB mode simultaneously
    20070130    frq06781    - Modify to externalize API (for ALSA).
                            - Changed ioctl enum definition by IOWR/IOR
    20081015    frq06751    Import component into stb225 database
  3 20090121    batelaan    Update license header
  4 20090226    boudy       Add Get/Set IOCTL to control slow blanking and video format
                            with one IOCTL and one associated data structure
  5 20090226    boudy       Changed file release (->PR15)
  6 20090325    boudy       Add enable/disable output (shadow of PR SHZ_STB2#251)
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

#ifndef __PHSTBSCARTSWITCH_H__
#define __PHSTBSCARTSWITCH_H__


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

#if defined(__cplusplus)
extern "C" {
#endif


/*============================================================================*/
/*                       MACRO DEFINITION                                     */
/*============================================================================*/
/* Id of the differents implementation */
#define DEBUG_PH_STB_SCARTSWITCH 0

#define PHSTB_SCART_SWITCH_UDA   0x01
#define PH_STB_SCART_SWITCH_DESCRIPTION "Scart Switch driver (UDA3000)"
#define PH_STB_SCART_SWITCH_DEVNAME "uda3000"

#if DEBUG_PH_STB_SCARTSWITCH
#define dprintk printk
#else
#define dprintk(...)
#endif

/* Definitions for specific audio levels */
#define PH_STB_SCART_SWITCH_AUDIO_MUTE    0
#define PH_STB_SCART_SWITCH_NORMAL_LEVEL  31
#define PH_STB_SCART_SWITCH_MAX_LEVEL  115

/*============================================================================*/
/*                       ENUM OR TYPE DEFINITION                              */
/*============================================================================*/
typedef enum
{
	PHSTB_SCART_SWITCH_SCART_TV,
	PHSTB_SCART_SWITCH_SCART_VCR,
    PHSTB_SCART_NUMBER
} phStbScartSwitchScartId_t;

typedef enum 
{
    PHSTB_SCART_SWITCH_OUTPUT_FROM_INT_DENC,
    PHSTB_SCART_SWITCH_OUTPUT_FROM_EXT_DENC,
    PHSTB_SCART_SWITCH_OUTPUT_OFF,
    PHSTB_SCART_SWITCH_OUTPUT_LOOP_OTHER,
    PHSTB_SCART_SWITCH_OUTPUT_LOOP_SELF,
    PHSTB_SCART_SWITCH_OUTPUT_DISABLE,
    PHSTB_SCART_SWITCH_OUTPUT_ENABLE
} phStbScartSwitchOutputMode_t;

typedef enum
{
    PHSTB_SCART_SWITCH_RGB  = 0x00000001,
    PHSTB_SCART_SWITCH_CVBS = 0x00000002,
    PHSTB_SCART_SWITCH_YC   = 0x00000004
} phStbScartSwitchVideoFormat_t;

typedef enum
{
    PHSTB_SCART_SWITCH_SB_IN,      /* sb in                                                    */
    PHSTB_SCART_SWITCH_SB_OUT,     /* sb out (manual control by SBValue)                       */
    PHSTB_SCART_SWITCH_SB_OUT_LOOP /* sb out (controled by other scart configured as an input) */
} phStbScartSwitchSBMode_t;

typedef enum
{
    PHSTB_SCART_SWITCH_SB_4_3,
    PHSTB_SCART_SWITCH_SB_16_9,
    PHSTB_SCART_SWITCH_SB_LOW
} phStbScartSwitchSBValue_t;

typedef enum
{
    PHSTB_SCART_SWITCH_FB_OUT_0V,  /* fb out 0V                                                 */
    PHSTB_SCART_SWITCH_FB_OUT_4V,  /* fb out 4V                                                 */
    PHSTB_SCART_SWITCH_FB_OUT_LOOP,/* fb out loop from other scart                              */
    PHSTB_SCART_SWITCH_FB_IN       /* fb in                                                     */
} phStbScartSwitchFBMode_t;

typedef enum
{
    PHSTB_SCART_SWITCH_MUTE_OFF,
    PHSTB_SCART_SWITCH_MUTE_ON
} phStbScartSwitchAudioCommonMute_t;

typedef enum
{
    PHSTB_SCART_SWITCH_AUDIO_SOURCE_DAC,
    PHSTB_SCART_SWITCH_AUDIO_SOURCE_TVIN,
    PHSTB_SCART_SWITCH_AUDIO_SOURCE_VCRIN,
    PHSTB_SCART_SWITCH_AUDIO_SOURCE_MUTE
} phStbScartSwitchAudioSource_t;

/* Define callback pointer type */
typedef void (*pScartSwitchCallback_t) (uint32_t events, void *pData, uint32_t userData);


/* --------------- MODULE IOCTL Data Structure   (Switch Mode)   ------------ */
/* IOCTL phStbScartSwitch_SET_VOLUME */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    uint8_t kVolume;
} phStbScartSwitchSetVolumeData_t;

/* IOCTL phStbScartSwitch_GET_VOLUME */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    uint8_t kVolume;
} phStbScartSwitchGetVolumeData_t;

/* IOCTL phStbScartSwitch_SET_OUTPUT_MODE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchOutputMode_t kMode;
} phStbScartSwitchSetOuputModeData_t;

/* IOCTL phStbScartSwitch_SET_VIDEO_FORMAT */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchVideoFormat_t kFormat;
} phStbScartSwitchSetVideoFormatData_t;

/* IOCTL phStbScartSwitch_SET_SB_MODE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchSBMode_t kMode;
} phStbScartSwitchSetSBModeData_t;

/* IOCTL phStbScartSwitch_SET_SB_VALUE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchSBValue_t kValue;
} phStbScartSwitchSetSBValueData_t;

/* IOCTL phStbScartSwitch_GET_SB_VALUE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchSBValue_t kValue;
} phStbScartSwitchGetSBValueData_t;

/* IOCTL phStbScartSwitch_INSTALL_SB_CALLBACK */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    pScartSwitchCallback_t pFunc;
} phStbScartSwitchInstallSBCallbackData_t;

/* IOCTL phStbScartSwitch_SET_FB_MODE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchFBMode_t kFBMode;
} phStbScartSwitchSetFBModeData_t;

/* IOCTL phStbScartSwitch_SET_AUDIO_SOURCE */
typedef struct
{
    phStbScartSwitchScartId_t kScartNumber;
    phStbScartSwitchAudioSource_t kAudioSource;
} phStbScartSwitchSetAudioSourceData_t;

typedef struct
{
    phStbScartSwitchVideoFormat_t display_mode;
    phStbScartSwitchSBValue_t     slow_blanking;
} phStbScartSwitch_outputAttr;

typedef struct
{
    int loopthrough;
    phStbScartSwitch_outputAttr attribute[PHSTB_SCART_NUMBER];
} phStbScartSwitch_data_t;


/* function table for accessing switch driver */
typedef struct _phStbScartSwitchFunctionList_t
{
    int32_t (*Init)                ( void );
    int32_t (*Terminate)           ( void );
    int32_t (*SetVolume)           ( phStbScartSwitchScartId_t kScartNumber, uint8_t kVolume );
    int32_t (*GetVolume)           ( phStbScartSwitchScartId_t kScartNumber, uint8_t *kVolume );
    int32_t (*SetOutputMode)       ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchOutputMode_t kMode );
    int32_t (*SetVideoFormat)      ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchVideoFormat_t kFormat );
    int32_t (*SetSBMode)           ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchSBMode_t kMode );
    int32_t (*SetSBValue)          ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchSBValue_t kValue );
    int32_t (*GetSBValue)          ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchSBValue_t *pValue );
    int32_t (*InstallSBCallback)   ( phStbScartSwitchScartId_t kScartNumber, pScartSwitchCallback_t pFunc );
    int32_t (*SetFBMode)           ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchFBMode_t kFBMode );
    int32_t (*SetAudioSource)      ( phStbScartSwitchScartId_t kScartNumber, phStbScartSwitchAudioSource_t kAudioSource );
    int32_t (*SetAudioCommonMute)  ( phStbScartSwitchAudioCommonMute_t kMute );
    int32_t (*GetSwitchSettings)   ( phStbScartSwitch_data_t *pScartSwitchData );
    int32_t (*SetSwitchSettings)   ( phStbScartSwitch_data_t *pScartSwitchData );
} phStbScartSwitchFunctionList_t;


/* ------------ MODULE IOCTL Control Structure   (Switch Mode)   ------------ */
/* IOCTL definition */
#define phStbScartSwitch_SET_VOLUME             _IOW ('o',  1, phStbScartSwitchSetVolumeData_t)
#define phStbScartSwitch_GET_VOLUME             _IOWR('o',  2, phStbScartSwitchGetVolumeData_t)
#define phStbScartSwitch_SET_OUTPUT_MODE        _IOW ('o',  3, phStbScartSwitchSetOuputModeData_t)
#define phStbScartSwitch_SET_VIDEO_FORMAT       _IOW ('o',  4, phStbScartSwitchSetVideoFormatData_t)
#define phStbScartSwitch_SET_SB_MODE            _IOW ('o',  5, phStbScartSwitchSetSBModeData_t)
#define phStbScartSwitch_SET_SB_VALUE           _IOW ('o',  6, phStbScartSwitchSetSBValueData_t)
#define phStbScartSwitch_GET_SB_VALUE           _IOWR('o',  7, phStbScartSwitchGetSBValueData_t)
#define phStbScartSwitch_INSTALL_SB_CALLBACK    _IOW ('o',  8, phStbScartSwitchInstallSBCallbackData_t)
#define phStbScartSwitch_SET_FB_MODE            _IOW ('o',  9, phStbScartSwitchSetFBModeData_t)
#define phStbScartSwitch_SET_AUDIO_COMMON_MUTE  _IOW ('o', 10, phStbScartSwitchAudioCommonMute_t)
#define phStbScartSwitch_SET_AUDIO_SOURCE       _IOW ('o', 11, phStbScartSwitchSetAudioSourceData_t)
#define phStbScartSwitch_GET_DEVICE_ID          _IOR ('o', 12, uint8_t)
#define phStbScartSwitch_GET_SWITCH_SETTINGS    _IOR ('o', 13, phStbScartSwitch_data_t)
#define phStbScartSwitch_SET_SWITCH_SETTINGS    _IOW ('o', 14, phStbScartSwitch_data_t)

/*============================================================================*/
/*                       EXTERN DATA DEFINITION                               */
/*============================================================================*/


/*============================================================================*/
/*                       EXTERN FUNCTION PROTOTYPES                           */
/*============================================================================*/

#if defined(__cplusplus)
}
#endif

#endif /* __PHSTBSCARTSWITCH_H__ */

