#ifndef IMAPIEXTENSION_H
#define IMAPIEXTENSION_H

/*============================================================================
FILE: IMapiExtension.h

SERVICES:  BREW MultiMedia Services for YAMAHA MA5/MA-7 device

DESCRIPTION:
   This file defines MA-5/MA-7 specific parameters and functions.

PUBLIC CLASSES:  Not applicable

INITIALIZATION AND SEQUENCING REQUIREMENTS:  Not Applicable

        Copyright © 1999-2005 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
============================================================================*/

/*===============================================================================
    INCLUDES AND VARIABLE DEFINITIONS
===============================================================================*/
/*-------------------------------------------------------------------
            Defines
-------------------------------------------------------------------*/

/*-------------------------------------------------------------------
      Include Files
-------------------------------------------------------------------*/

#include "AEEMedia.h"

/* Class ID for device control interface (IMapiExtension) */
#define	AEECLSID_MAPI_EXTENSION		0x0102c63f

/*===========================================================================

                      Definition for IMAPIEXTENSION Interface

===========================================================================*/

/* error code */
#define MAPI_TIMEOUT                        (1)
#define MAPI_SUCCESS                        (0)
#define MAPI_ERROR                          (-1)
#define MAPI_ERROR_ARGUMENT                 (-2)
#define MAPI_ERROR_RESOURCE_OVER            (-3)
#define MAPI_ERROR_ID                       (-4)

#define MAPI_ERROR_STATE                    (-8)
#define MAPI_ERROR_NOT_OPENED               (-9)
#define MAPI_ERROR_BUT_CLOSED               (-10)
#define MAPI_ERROR_BUT_UNLOADED             (-11)

#define MAPI_ERROR_FILE                     (-16)
#define MAPI_ERROR_CONTENTS_CLASS           (-17)
#define MAPI_ERROR_CONTENTS_TYPE            (-18)
#define MAPI_ERROR_CHUNK_SIZE               (-19)
#define MAPI_ERROR_CHUNK                    (-20)
#define MAPI_ERROR_UNMATCHED_TAG            (-21)
#define MAPI_ERROR_SHORT_LENGTH             (-22)
#define MAPI_ERROR_LONG_LENGTH              (-23)
#define MAPI_ERROR_UNSUPPORTED              (-24)
#define MAPI_ERROR_NO_INFORMATION           (-25)
#define MAPI_ERROR_HV_CONFLICT              (-26)

/*=====================================================*/
/* Mapi_DeviceControl */
/* command */
#define MAPI_WRITE_IMREG			17
#define MAPI_READ_IMREG				18

/*=====================================================*/
/* Mapi_DeviceControlEx */
/* command */
#define MAPI_GET_PEAKHOLD			0x00001
#define MAPI_SET_SP_PARAM			0x00002
#define MAPI_SET_STEREOEX_PARAM		0x00003
#define MAPI_HW_INITIALIZE          0x10000
#define MAPI_GET_HW_ID              0x10001
#define MAPI_SET_POWERDOWN          0x10002
#define MAPI_GET_POWERDOWN          0x10003
#define MAPI_SET_ANALOG_VOL         0x10010
#define MAPI_GET_ANALOG_VOL         0x10011
#define MAPI_SET_HPOUT_BASS         0x10012
#define MAPI_GET_HPOUT_BASS         0x10013
#define MAPI_SET_ANALOG_MIX         0x10014
#define MAPI_GET_ANALOG_MIX         0x10015
#define MAPI_SET_ANALOG_OUT_MODE    0x10016
#define MAPI_GET_ANALOG_OUT_MODE    0x10017
#define MAPI_SET_SYNC_MODE          0x10018
#define MAPI_GET_SYNC_MODE          0x10019
#define MAPI_SET_SYNC_LFO           0x1001A
#define MAPI_GET_SYNC_LFO           0x1001B
#define MAPI_SET_SYNC_ON            0x1001C
#define MAPI_GET_SYNC_ON            0x1001D
#define MAPI_SET_LED_COLOR          0x1001E
#define MAPI_GET_LED_COLOR			0x10032
#define MAPI_OUTPUT_CONTROL         0x10029
#define MAPI_LROUT_CONTROL          0x10030
#define MAPI_3DG_CONTROL            0x10031
#define MAPI_SET_DOUT_MODE			0x10033
#define MAPI_GET_DOUT_MODE			0x10034

/* peak hold */
typedef struct
{
	unsigned char	bLch;
	unsigned char	bRch;
} MAPI_PEAKHOLD;

/* sp param */
typedef struct
{
	unsigned long	dMode;
	unsigned short	awParam1[32];
	unsigned short	awParam2[32];
} MAPI_SPPARAM;

/* stereo ex param */
typedef struct 
{
	unsigned long	dwScGain;
	unsigned short	awParam[68];
} MAPI_EXSTPARAM;

/* power */
typedef struct
{
	unsigned long dMode;
	unsigned long dDmode;
	unsigned long dAmode;
	unsigned long dPowerSynth;
	unsigned long dPowerDigitalIn;
	unsigned long dPowerSpOut;
	unsigned long dPowerHpOut;
	unsigned long dPowerTxOut;
	unsigned long dPowerExtOut;
	unsigned long dPowerRxIn;
	unsigned long dPowerExtIn;
} MAPI_POWERS;
	
/* volume */
typedef struct 
{
	signed char	sbVolL;
	signed char	sbVolR;
} MAPI_STVOLUME;

/* led sequence */
typedef struct 
{
	unsigned char	bSeqLength;
	unsigned char	bRed;
	unsigned char	bGreen;
	unsigned char	bBlue;
} MAPI_LEDSEQ;

/* dout mode */
typedef struct
{
	unsigned char	bEnable;
	unsigned char	bStopMode;
	unsigned char	bBitClk;
	unsigned char	bMode;
	unsigned char	bWidth;
	unsigned long	dFs;
} MAPI_DOUTMODE;

/* 3D Sound */
/* output environmental command */
#define MAPI_SET_OUT_MODE		0
#define MAPI_GET_OUT_MODE		1
#define MAPI_SET_OUT_SWAP		2
#define MAPI_GET_OUT_SWAP		3
#define MAPI_SET_OUT_EQ			4
#define MAPI_GET_OUT_EQ			5
#define MAPI_SET_OUT_HPC		6
#define MAPI_GET_OUT_HPC		7
#define MAPI_SET_OUT_COMP		8
#define MAPI_GET_OUT_COMP		9
#define MAPI_SET_OUT_DIGITALVOL	10
#define MAPI_GET_OUT_DIGITALVOL	11

/* EQ parameter */
typedef struct 
{
	unsigned long	dEnable;
	signed long	sdEQ00;
	signed long	sdEQ01;
	signed long	sdEQ02;
	signed long	sdEQ03;
	signed long	sdEQ04;
	signed long	sdEQ10;
	signed long	sdEQ11;
	signed long	sdEQ12;
	signed long	sdEQ13;
	signed long	sdEQ14;
	signed long	sdEQ20;
	signed long	sdEQ21;
	signed long	sdEQ22;
	signed long	sdEQ23;
	signed long	sdEQ24;
} MAPI_EQPARAM;

/* enhanced stereo command */
#define MAPI_EXLR_SET_ENABLE		0
#define MAPI_EXLR_IS_ENABLED		1

/* common to 3D command */
#define MAPI_3DG_RESET              0
#define MAPI_3DG_ENABLE_REVERB      1
#define MAPI_3DG_IS_ENABLED_REVERB  2
#define MAPI_3DG_GET_NUM_MAX_3D     3
#define MAPI_3DG_GET_NUM_FREE_3D    4
#define MAPI_3DG_SET_DOPPLER        5
#define MAPI_3DG_GET_DOPPLER        6
#define MAPI_3DG_SET_REVERB_PARAM   7
#define MAPI_3DG_GET_REVERB_PARAM   8
#define MAPI_3DG_SET_ALL            9
#define MAPI_3DG_GET_ALL            10
/* #define MAPI_3DG_COMMIT             11 */
#define MAPI_3DG_SET_REVERB_DEFAULT 12
#define MAPI_3DG_GET_REVERB_DEFAULT 13

/* MAPI_3DG_SET_REVERB_DEFAULT's parameter */
#define MAPI_3DG_REVERB_GENERIC      0
#define MAPI_3DG_REVERB_ARENA        1
#define MAPI_3DG_REVERB_BATHROOM     2
#define MAPI_3DG_REVERB_CAVE         3
#define MAPI_3DG_REVERB_CITY         4
#define MAPI_3DG_REVERB_CONCERTHALL  5
#define MAPI_3DG_REVERB_FOREST       6
#define MAPI_3DG_REVERB_MOUNTAIN     7
#define MAPI_3DG_REVERB_ROOM         8
#define MAPI_3DG_REVERB_UNDERWATER   9

/* reverb properties */
typedef struct 
{
	unsigned long dUpdateFlags;
	unsigned long dRoomGain;
	signed long sdRoomHfLevel;
	unsigned long dReflectionsGain;
	unsigned long dReflectionsDelay;
	unsigned long dReverbGain;
	unsigned long dReverbDelay;
	unsigned long dDecayTime;
	unsigned long dDecayTimeHfRatio;
	unsigned long dDensity;
	unsigned long dRoomRolloff;
} MAPI_P3DAREVERBPARAMS;

typedef struct 
{
	unsigned long dUpdateFlags;
	unsigned long dEnableReverb;
	unsigned long dDopplerFactor;
	MAPI_P3DAREVERBPARAMS sReverbInfo;
} MAPI_P3DAMIXERPARAMS;

/* update flags for MAPI_REVERBPARAMS */
#define	MAPI_FLAG_REVERB_ROOMGAIN			(0x00000001)
#define	MAPI_FLAG_REVERB_ROOMHFLEVEL		(0x00000002)
#define	MAPI_FLAG_REVERB_REFLECTIONSGAIN	(0x00000004)
#define	MAPI_FLAG_REVERB_REFLECTIONSDELAY	(0x00000008)
#define	MAPI_FLAG_REVERB_REVERBGAIN			(0x00000010)
#define	MAPI_FLAG_REVERB_REVERBDELAY		(0x00000020)
#define	MAPI_FLAG_REVERB_DECAYTIME			(0x00000040)
#define	MAPI_FLAG_REVERB_DECAYTIMEHFRATIO	(0x00000080)
#define	MAPI_FLAG_REVERB_DENSITY			(0x00000100)
#define	MAPI_FLAG_REVERB_ROOMROLLOFF		(0x00000200)
#define	MAPI_FLAG_REVERB_ALL				(0x000003ff)

/* update flags for MAPI_P3DAMIXERPARAMS */
#define	MAPI_FLAG_MIXER_ENABLEREVERB		(0x00000001)
#define	MAPI_FLAG_MIXER_DOPPLERFACTOR		(0x00000002)
#define	MAPI_FLAG_MIXER_REVERBINFO			(0x00000004)
#define	MAPI_FLAG_MIXER_ALL					(0x00000007)

/* update flags for MAPI_EXSTPARAM */
#define	MAPI_FLAG_EXST_TIME					(0x00000001)
#define	MAPI_FLAG_EXST_POSITION				(0x00000002)
#define	MAPI_FLAG_EXST_DIRECTGAIN			(0x00000004)
#define	MAPI_FLAG_EXST_DIRECTHFLEVEL		(0x00000008)
#define	MAPI_FLAG_EXST_ROOMGAIN				(0x00000010)
#define	MAPI_FLAG_EXST_ROOMHFLEVEL			(0x00000020)
#define	MAPI_FLAG_EXST_DRYGAIN				(0x00000040)
#define	MAPI_FLAG_EXST_WETGAIN				(0x00000080)
#define	MAPI_FLAG_EXST_ALL					(0x000000FF)


/*===========================================================================

                      Definition for IMAPIEXTENSION functions

===========================================================================*/

typedef struct IMapiExtension   IMapiExtension;
AEEINTERFACE(IMapiExtension)
{
	INHERIT_IQueryInterface(IMapiExtension);
	int32	(*DeviceControlEx)	(IMapiExtension *po, uint32 cmd, uint32 dPrm1, void *pvPrm2);
};

/* IBase function */
#define IMAPIEXTENSION_AddRef(p)						AEEGETPVTBL(p, IMapiExtension)->AddRef(p)
#define IMAPIEXTENSION_Release(p)						AEEGETPVTBL(p, IMapiExtension)->Release(p)

/* IQueryInterface compatible function */
#define IMAPIEXTENSION_QueryInterface(p, i, p2)			AEEGETPVTBL(p, IMapiExtension)->QueryInterface(p, i, p2)

/* IMAPIEXTENSION newly defined function */
#define IMAPIEXTENSION_DeviceControlEx(p, dw, dw1, pd)	AEEGETPVTBL(p, IMapiExtension)->DeviceControlEx(p, dw, dw1, pd)


/*=====================================================================
  INTERFACES   DOCUMENTATION
=====================================================================

Interface Name: IMapiExtension

Description:
IMapiExtension class provides functions to control YAMAHA MA-5/7 chipsets.
Most of the operations affects all IMedia objects which are played thru MA-5/7 device.

Some of functions are for system applications only. Applications which doesn't
have PL_SYSTEM can't control such parameters.

***** NOTE ******
We're planning to design this interface compatible with IMediaEnv interface.

=============================================================================

IMAPIEXTENSION_AddRef()
IMAPIEXTENSION_Release()
IMAPIEXTENSION_QueryInterface() - only returns IQI and IMapiExtension.

=============================================================================

IMAPIEXTENSION_DeviceControlEx()

Description:
   This function sends a device-specific control command.
   
Prototype:
   int IMAPIEXTENSION_DeviceControl(IMapiExtension * po, uint32 cmd, uint32 dPrm1, void *pvPrm2);

Parameters:
   po       : [in]Pointer to the IMapiExtension Interface object
   cmd      : [in]Command code.
              The following cmd codes are defined:
				GET_PEAKHOLD
				3DG_CONTROL
	dPrm1   : [in] Command-specific param. To be confirmed by YAMAHA.
	pvPrm2  : Command-specific param. To be confirmed by YAMAHA.

Return Value:
   >=0           : Success. The return value is to be confirmed by YAMAHA.
   < 0           : Error. The return value is to be confirmed by YAMAHA.

Comments:

Side Effects:
   None

See Also:
   None

=============================================================================
============================================================================= */

#endif /* IMAPIEXTENSION_H */
