/**
 * Message definitions for communication between:
 * - test controller
 * - ivs
 * - ul processing
 * - dl processing
 * - psap
 *
 * @copyright 2008, Research In Motion Ltd.
 *
 * @version $Id: //depot/rel/dsp/ecall/2/c/testlab/msg.h#1 $
 */

#ifndef __MSG_H__
#define __MSG_H__

#include "rimtypes.h"
#include "modem.h"

/* System constants */
#define ERROR_MAX_LENGTH         (300)
#define ERROR_PATTERN_MAX_LENGTH (300)

typedef enum {
    CodecTypeFr,
    CodecTypeAmr,
    CodecTypeNone,
    CodecTypeBypass
} CodecType;

typedef enum {
    CodecModeNa,
    CodecModeAmr12_2,
    CodecModeAmr10_2,
    CodecModeAmr7_95,
    CodecModeAmr7_4,
    CodecModeAmr6_7,
    CodecModeAmr5_9,
    CodecModeAmr5_15,
    CodecModeAmr4_75
} CodecMode;

typedef enum {
    VadType1,
    VadType2,
} VadType;

typedef enum {
    MsgChReset,
    MsgIvsReset,
    MsgPsapReset,
    MsgReady,
    MsgPsapTx,
    MsgPsapRx,
    MsgPcmData,
    MsgError,
    MsgIdCount
} MsgId;

typedef struct {
    Ord8  codec;
    Ord8  codecMode;
    Ord8  vad;
    Int32 delay1;
    Int32 delay2;
    char  errorPattern[ERROR_PATTERN_MAX_LENGTH+1];
    Int32 errorPatternIndex;
} DataChReset;

typedef struct {
    Ord32 n;                    /* The number of bytes in the MSD */
    Ord8  msd[MSD_MAX_LENGTH];  /* The bytes of the MSD */
} DataIvsReset;

typedef struct {
    Ord8 dummy;
} DataPsapReset;

typedef struct {
    Ord8 dummy;
} DataPsapTx;

typedef struct {
    Ord32 n;                    /* The number of bytes in the MSD */
    Ord8  msd[MSD_MAX_LENGTH];  /* The bytes of the MSD */
} DataPsapRx;

typedef struct {
    Int16 pcm[PCM_LENGTH];
} DataPcmData;

typedef struct {
    char msg[ERROR_MAX_LENGTH+1];  /* +1 for '\0' string termination */
} DataError;

/* Order must correspond to MsgId enum */
static const int MsgDataSize[MsgIdCount] = {
    sizeof(DataChReset),
    sizeof(DataIvsReset),
    sizeof(DataPsapReset),
    0,
    sizeof(DataPsapTx),
    sizeof(DataPsapRx),
    sizeof(DataPcmData),
    sizeof(DataError)
};

typedef struct {
    Ord8 id;
    union {
        DataChReset   chReset;
        DataIvsReset  ivsReset;
        DataPsapReset psapReset;
        DataPsapTx    psapTx;
        DataPsapRx    psapRx;
        DataPcmData   pcmData;
        DataError     error;
    } u;
} Msg;

#endif

