#ident "$Id: dvd.h,v 1.4 2007/05/03 22:56:10 craig Exp $"
/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

/*
 * Contains definitions used in multiple files and that don't
 * particularly belong anywhere else
 */

#ifndef DVD_H
#define DVD_H

/*
 * Include either iostypes.h or types.h before including this
 * file.
 */

typedef struct dvdState {
    u32    savedDmaAddressRegister;
    u32    savedDmaTransferRegister;
} dvdState_t;

extern dvdState_t       dvdState;

/*
 * The following are the values that struct diOtherMesg.mesgType takes
 */
#define DI_MESG_TIMEOUT                 (MAX_RM_MESG_NUM + 1)
#define DI_MESG_INTR                    (MAX_RM_MESG_NUM + 2)
#define DI_MESG_COMMAND                 (MAX_RM_MESG_NUM + 3)


typedef struct diOtherMesg {
    u32         mesgType;       /* DI_MESG_TIMEOUT, DI_MESG_INTR... */
    bool        inUse;
    /*
     * Used to match timeouts to the command which caused the timeout
     * Starts at 0, then goes to 1, 2, etc.
     */
    u8          commandNum;    
} diOtherMesg_t;

typedef union diInQueueMesg {
    IOSResourceRequest  *resourceMesg;
    diOtherMesg_t       *otherMesg;
} diInQueueMesg_t;

#define MAX_COMMAND_NUM         255
extern u8  currentCommandNum;

#define DVD_RM_QUEUE_LEN        8
#define DVD_TRANSACTION_QUEUE_LEN 8
#define MAX_H3_HASH_SIZE        (96 * 1024)

/* Memory size of an integer padded out to cache line size */
#define PADDED_INT_CACHE_LINE   32

#define CACHE_LINE_SIZE         32
#define MISALIGNED(ptr, size)   ( ((u32) ptr) & (size - 1) )

/* Values returned by the DVDLowGetCoverStatus call */
#define DVD_COVER_UNKNOWN       0x0
#define DVD_COVER_OPEN          0x1
#define DVD_COVER_CLOSED        0x2
/*
 * Assumes:
 *              Clock rate of 243 MHz
 *              128 cycles/tick
 */
#define SYSTEM_TICKS_PER_MILLISEC           1898
/* Time is in microseconds */
#define DUMMY_COVER_INTR_TIME                200
#define COVER_STATUS_UNKNOWN_TIME            100
#define WARM_RESET_HOLD_TIME_MICRO_SEC        12
#define COLD_RESET_HOLD_TIME_MILLI_SEC       200
extern u32              lastResetTime;
extern bool             resetTimeValid;

extern  IOSMessageQueueId      dvdTransactionQueue;

#endif /* DVD_H */
