1 /*-------------------------------------------------------------
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
25 3. This notice may not be removed or altered from any source
28 -------------------------------------------------------------*/
36 * \brief DVD subsystem
41 #include <ogc/lwp_queue.h>
42 #include <ogc/disc_io.h>
45 * \addtogroup dvd_statecodes DVD state codes
49 #define DVD_STATE_FATAL_ERROR -1
50 #define DVD_STATE_END 0
51 #define DVD_STATE_BUSY 1
52 #define DVD_STATE_WAITING 2
53 #define DVD_STATE_COVER_CLOSED 3
54 #define DVD_STATE_NO_DISK 4
55 #define DVD_STATE_COVER_OPEN 5
56 #define DVD_STATE_WRONG_DISK 6
57 #define DVD_STATE_MOTOR_STOPPED 7
58 #define DVD_STATE_IGNORED 8
59 #define DVD_STATE_CANCELED 10
60 #define DVD_STATE_RETRY 11
62 #define DVD_ERROR_OK 0
63 #define DVD_ERROR_FATAL -1
64 #define DVD_ERROR_IGNORED -2
65 #define DVD_ERROR_CANCELED -3
66 #define DVD_ERROR_COVER_CLOSED -4
74 * \addtogroup dvd_resetmode DVD reset modes
78 #define DVD_RESETHARD 0 /*!< Performs a hard reset. Complete new boot of FW. */
79 #define DVD_RESETSOFT 1 /*!< Performs a soft reset. FW restart and drive spinup */
80 #define DVD_RESETNONE 2 /*!< Only initiate DI registers */
88 * \addtogroup dvd_motorctrlmode DVD motor control modes
92 #define DVD_SPINMOTOR_DOWN 0x00000000 /*!< Stop DVD drive */
93 #define DVD_SPINMOTOR_UP 0x00000100 /*!< Start DVD drive */
94 #define DVD_SPINMOTOR_ACCEPT 0x00004000 /*!< Force DVD to accept the disk */
95 #define DVD_SPINMOTOR_CHECKDISK 0x00008000 /*!< Force DVD to perform a disc check */
104 #endif /* __cplusplus */
108 * \typedef struct _dvddiskid dvddiskid
109 * \brief forward typedef for struct _dvddiskid
111 typedef struct _dvddiskid dvddiskid
;
114 * \typedef struct _dvddiskid dvddiskid
116 * This structure holds the game vendors copyright informations.<br>
117 * Additionally it holds certain parameters for audiocontrol and<br>
120 * \param gamename[4] vendors game key
121 * \param company[2] vendors company key
122 * \param disknum number of disc when multidisc support is used.
123 * \param gamever version of game
124 * \param streaming flag to control audio streaming
125 * \param streambufsize size of buffer used for audio streaming
126 * \param pad[22] padding
139 * \typedef struct _dvdcmdblk dvdcmdblk
140 * \brief forward typedef for struct _dvdcmdblk
142 typedef struct _dvdcmdblk dvdcmdblk
;
146 * \typedef void (*dvdcbcallback)(s32 result,dvdcmdblk *block)
147 * \brief function pointer typedef for the user's operations callback
149 typedef void (*dvdcbcallback
)(s32 result
,dvdcmdblk
*block
);
153 * \typedef struct _dvdcmdblk dvdcmdblk
155 * This structure is used internally to control the requested operation.
173 * \typedef struct _dvddrvinfo dvddrvinfo
174 * \brief forward typedef for struct _dvddrvinfo
176 typedef struct _dvddrvinfo dvddrvinfo
;
180 * \typedef struct _dvddrvinfo dvddrvinfo
182 * This structure structure holds the drive version infromation.<br>
183 * Use DVD_Inquiry() to retrieve this information.
185 * \param rev_leve revision level
186 * \param dev_code device code
187 * \param rel_date release date
188 * \param pad[24] padding
199 * \typedef struct _dvdfileinfo dvdfileinfo
200 * \brief forward typedef for struct _dvdfileinfo
202 typedef struct _dvdfileinfo dvdfileinfo
;
206 * \typedef void (*dvdcallback)(s32 result,dvdfileinfo *info)
207 * \brief function pointer typedef for the user's DVD operation callback
209 * \param[in] result error code of last operation
210 * \param[in] info pointer to user's file info strucutre
212 typedef void (*dvdcallback
)(s32 result
,dvdfileinfo
*info
);
216 * \typedef struct _dvdfileinfo dvdfileinfo
218 * This structure is used internally to control the requested file operation.
220 struct _dvdfileinfo
{
229 * \fn void DVD_Init()
230 * \brief Initializes the DVD subsystem
232 * You must call this function before calling any other DVD function
241 * \fn void DVD_Reset(u32 reset_mode)
242 * \brief Performs a reset of the drive and FW respectively.
244 * \param[in] reset_mode \ref dvd_resetmode "type" of reset
248 void DVD_Reset(u32 reset_mode
);
252 * \fn s32 DVD_Mount()
253 * \brief Mounts the DVD drive.
255 * This is a synchronous version of DVD_MountAsync().
260 s32
DVD_GetDriveStatus();
264 * \fn s32 DVD_MountAsync(dvdcmdblk *block,dvdcbcallback cb)
265 * \brief Mounts the DVD drive.
267 * You <b>must</b> call this function in order to access the DVD.
269 * Following tasks are performed:
270 * - Issue a hard reset to the drive.
271 * - Turn on drive's debug mode.
272 * - Patch drive's FW.
273 * - Enable extensions.
276 * The patch code and procedure was taken from the gc-linux DVD device driver.
278 * \param[in] block pointer to a dvdcmdblk structure used to process the operation
279 * \param[in] cb callback to be invoked upon completion of operation
283 s32
DVD_MountAsync(dvdcmdblk
*block
,dvdcbcallback cb
);
287 * \fn s32 DVD_ControlDrive(dvdcmdblk *block,u32 cmd)
288 * \brief Controls the drive's motor and behavior.
290 * This is a synchronous version of DVD_ControlDriveAsync().
292 * \param[in] block pointer to a dvdcmdblk structure used to process the operation
293 * \param[in] cmd \ref dvd_motorctrlmode "command" to control the drive.
297 s32
DVD_ControlDrive(dvdcmdblk
*block
,u32 cmd
);
301 * \fn s32 DVD_ControlDriveAsync(dvdcmdblk *block,u32 cmd,dvdcbcallback cb)
302 * \brief Controls the drive's motor and behavior.
304 * \param[in] block pointer to a dvdcmdblk structure used to process the operation
305 * \param[in] cmd \ref dvd_motorctrlmode "command" to control the drive.
306 * \param[in] cb callback to be invoked upon completion of operation.
310 s32
DVD_ControlDriveAsync(dvdcmdblk
*block
,u32 cmd
,dvdcbcallback cb
);
314 * \fn s32 DVD_SetGCMOffset(dvdcmdblk *block,u32 offset)
315 * \brief Sets the offset to the GCM. Used for multigame discs.
317 * This is a synchronous version of DVD_SetGCMOffsetAsync().
319 * \param[in] block pointer to a dvdcmdblk structure used to process the operation
320 * \param[in] offset offset to the GCM on disc.
322 * \return \ref dvd_errorcodes "dvd error code"
324 s32
DVD_SetGCMOffset(dvdcmdblk
*block
,s64 offset
);
328 * \fn s32 DVD_SetGCMOffsetAsync(dvdcmdblk *block,u32 offset,dvdcbcallback cb)
329 * \brief Sets the offset to the GCM. Used for multigame discs.
331 * This is a synchronous version of DVD_SetGCMOffsetAsync().
333 * \param[in] block pointer to a dvdcmdblk structure used to process the operation
334 * \param[in] offset offset to the GCM on disc.
335 * \param[in] cb callback to be invoked upon completion of operation.
337 * \return \ref dvd_errorcodes "dvd error code"
339 s32
DVD_SetGCMOffsetAsync(dvdcmdblk
*block
,s64 offset
,dvdcbcallback cb
);
341 s32
DVD_GetCmdBlockStatus(dvdcmdblk
*block
);
342 s32
DVD_SpinUpDrive(dvdcmdblk
*block
);
343 s32
DVD_SpinUpDriveAsync(dvdcmdblk
*block
,dvdcbcallback cb
);
344 s32
DVD_Inquiry(dvdcmdblk
*block
,dvddrvinfo
*info
);
345 s32
DVD_InquiryAsync(dvdcmdblk
*block
,dvddrvinfo
*info
,dvdcbcallback cb
);
346 s32
DVD_ReadPrio(dvdcmdblk
*block
,void *buf
,u32 len
,s64 offset
,s32 prio
);
347 s32
DVD_ReadAbsAsyncPrio(dvdcmdblk
*block
,void *buf
,u32 len
,s64 offset
,dvdcbcallback cb
,s32 prio
);
348 s32
DVD_ReadAbsAsyncForBS(dvdcmdblk
*block
,void *buf
,u32 len
,s64 offset
,dvdcbcallback cb
);
349 s32
DVD_SeekPrio(dvdcmdblk
*block
,s64 offset
,s32 prio
);
350 s32
DVD_SeekAbsAsyncPrio(dvdcmdblk
*block
,s64 offset
,dvdcbcallback cb
,s32 prio
);
351 s32
DVD_CancelAllAsync(dvdcbcallback cb
);
352 s32
DVD_StopStreamAtEndAsync(dvdcmdblk
*block
,dvdcbcallback cb
);
353 s32
DVD_StopStreamAtEnd(dvdcmdblk
*block
);
354 s32
DVD_ReadDiskID(dvdcmdblk
*block
,dvddiskid
*id
,dvdcbcallback cb
);
355 u32
DVD_SetAutoInvalidation(u32 auto_inv
);
356 dvddiskid
* DVD_GetCurrentDiskID();
357 dvddrvinfo
* DVD_GetDriveInfo();
359 #define DVD_SetUserData(block, data) ((block)->usrdata = (data))
360 #define DVD_GetUserData(block) ((block)->usrdata)
362 #define DEVICE_TYPE_GAMECUBE_DVD (('G'<<24)|('D'<<16)|('V'<<8)|'D')
363 extern const DISC_INTERFACE __io_gcdvd
;
367 #endif /* __cplusplus */