#ident "$Id: dvd_low.h,v 1.8 2006/07/28 21:26:04 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.
 *
 */

#ifndef DVD_LOW_H
#define DVD_LOW_H


#include "dvd.h"
#include "dvd_command.h"

enum dvdDiscEventMesgType{DVD_EVENT_BOGUS, DVD_EVENT_BREAK,
                          DVD_EVENT_TRANS_DONE,
                          DVD_EVENT_ERROR, DVD_EVENT_COVER,
                          DVD_EVENT_TIMEOUT};

u32      handleDiCommand(const diCommand_t* const command,
                         volatile void *outputPtr,
                         const u32      outputLen);
void     enableTransferCompleteIntr(void);
void     enableErrorIntr(void);
void     doWaitForCoverClose(void);

bool     isTransCompInterruptSet(void);
bool     isErrorInterruptSet(void);
bool     isCoverInterruptSet(void);

void     diClearTransCompStatus(void);
u32      clearDriveErrorInterrupt();
void     diClearCoverIntr(void);
void     initializeDriveRegisters();

extern u32 driverLengthReg;

extern u32 doRawDiskRead(volatile u8* const destAddr,
                         const u32          length,
                         const u32          wordOffset,
                         const bool         DCacheInvalidate);

void setDvdVideoReadDisableFlag(const bool disableDvdVideo);

static inline void
disableDvdVideoAccess(void)
{
   IOS_SetDvdReadDisable(1);
}

static inline void
enableDvdVideoAccess(void)
{
   IOS_SetDvdReadDisable(0);
}

void                    initSleep();
void                    startSleep(const IOSTime value);
extern IOSTimerId       commandTimeoutId;
extern diOtherMesg_t    timeoutMesg;

/* Timeout is 10 seconds */
/* #define DI_COMMAND_TIMEOUT      (10 * 1000) */
/*
 * FIXME - longer timeout is needed for hudson emu.  Change 
 * it back to 10 seconds for production.
 */
#define DI_COMMAND_TIMEOUT      (15 * 1000000)


#endif
