1 /*---------------------------------------------------------------------------* 2 Project: Dolphin OS 3 File: dvd.h 4 5 Copyright 1998-2004 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: dvd.h,v $ 14 Revision 1.10.30.1 2009/01/16 01:19:42 ooizumi 15 Added DVDIsDiskIdentified(). 16 17 Revision 1.10 2006/09/28 04:50:20 shirakae 18 Added DVDEntrynumIsDir 19 20 Revision 1.9 2006/06/07 02:21:23 ooizumi 21 Deleted DVDCheckDisk. 22 23 Revision 1.8 2006/06/05 00:21:27 ooizumi 24 Enabled DVDCheckDiskAsync for RVL0 target. 25 26 Revision 1.7 2006/05/17 22:16:20 ooizumi 27 Added DVD_STATE_NO_INPUT state. 28 29 Revision 1.6 2006/04/24 05:23:16 ooizumi 30 Changed a header file for WIN32 target. 31 32 Revision 1.5 2006/03/20 10:24:33 ooizumi 33 Deleted APIs for hardware streaming. 34 35 Revision 1.4 2006/03/12 03:03:29 craig 36 Added GC and RVL magic number locations to disk id structure. 37 38 Revision 1.3 2006/03/10 22:44:58 ooizumi 39 Changed DVDGetStartAddr's return value u32 to u64. 40 41 Revision 1.2 2006/02/04 11:56:44 hashida 42 (none) 43 44 Revision 1.1.1.1 2005/12/29 06:53:27 hiratsu 45 Initial import. 46 47 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to 48 Ported from dolphin sheath tree 49 50 51 54 2004/03/31 20:27 Hashida 52 Updated copyright info. 53 54 53 2003/09/10 14:37 Ooshima 55 Modified DVDDirEntry and DVDRewindDir to remove DVDETH definition. 56 57 51 2003/04/22 11:29 Hashida 58 Modified DVDGetFileInfoStatus to refer fileinfo's member instead of 59 just casting to DVDCommandBlock structure. 60 61 50 2003/02/28 5:30p Ooshima 62 Changed DVDCommandBlock and DVDDirEntry structure for DVDETH again 63 64 49 2003/01/09 10:34a Ooshima 65 Changed DVDCommandBlock and DVDDirEntry structure for DVDETH 66 67 47 2002/08/30 12:00 Shiki 68 Clean up. 69 70 46 2002/08/29 21:38 Shiki 71 Added DVDSetAutoFatalMessaging(). 72 73 45 2002/08/05 16:19 Shiki 74 Added const keywords to relevant function prototypes. 75 76 44 2002/02/07 16:04 Hashida 77 Changed the return value of DVDGenerateDiskID from void to DVDDiskID* 78 79 43 2002/01/02 5:00p Hashida 80 Added DVDCompareDiskID and DVDGenerateDiskID. 81 82 42 2001/08/10 3:04p Hashida 83 Added DVDFastOpenDir 84 85 41 2001/07/06 1:20a Hashida 86 Resurrected function version of DVDGetFileInfoStatus(). 87 88 40 2001/06/29 11:43a Hashida 89 Added DVDCheckDisk(). 90 91 39 2001/06/26 9:18a Hashida 92 Modified so that DVDGetFileInfoStatus is properly prototype'd for MAC 93 build. 94 95 38 2001/06/15 10:35p Hashida 96 Deleted obsolete result codes. 97 98 37 2001/06/15 9:01p Hashida 99 Changed DVDGetFileInfoStatus to a macro. 100 101 36 2001/05/29 11:52a Hashida 102 Removed duplicated DVDPause and DVDResume prototypes. 103 104 35 2001/05/10 2:24p Hashida 105 Added DVDDumpWaitingQueue. 106 107 34 2001/05/01 2:49p Hashida 108 Removed DVDGetStreamStartAddr & DVDGetStreamLength. 109 110 33 2001/04/19 5:40p Hashida 111 Added DVDGetCurrentDiskID 112 113 32 2001/03/22 6:10p Hashida 114 Added DVDCancelAll and DVDCancelAllAsync. 115 Moved DVDCommandBlock structure in DVDFileInfo to the first member. 116 117 31 2001/03/02 5:48p Hashida 118 Modified error code handling (fatal error, internal retry and retry) 119 120 30 2001/03/02 11:35a Hashida 121 Added DVDCancel, DVDPause, DVDResume, DVDGetTransferredSize. 122 123 29 2001/02/08 3:46p Hashida 124 Added DVDPause and DVDResume prototypes. 125 126 28 2001/01/08 7:02p Hashida 127 Added DVDSet/GetUserData macros. 128 129 27 2000/11/13 5:30p Hashida 130 Added streamingBufSize member to diskid. 131 132 133 26 2000/10/27 2:24p Hashida 134 Added a check code so that audio streaming command will not be issued 135 while a track is auto finishing. 136 137 25 2000/10/10 11:28a Hashida 138 Fixed a problem that MAC target won't be built. 139 140 24 2000/10/09 6:53p Hashida 141 Added prioritized queuing. 142 143 23 2000/09/29 9:51p Hirose 144 Replaced "MAC" flag by better alternatives 145 146 22 2000/09/26 3:38p Hashida 147 Added DVDChangeDisk (synchronous version) 148 149 21 2000/09/25 3:32p Hashida 150 Changed API names that don't follow the convention (sync, async) 151 152 20 2000/07/21 11:15a Hashida 153 Added DVD_STATE_PAUSING. 154 155 19 2000/07/20 12:32p Hashida 156 Removed DVDConvertEntrynumToPath 157 158 18 2000/07/20 9:46a Hashida 159 Added DVDFastOpen(), DVDConvertPathToEntrynum and 160 DVDConvertEntrynumToPath. 161 162 17 2000/07/07 6:00p Dante 163 PC Compatibility 164 165 16 2000/05/14 8:06p Hashida 166 Added DVDGetCurrentDir 167 168 15 2000/05/10 5:24p Hashida 169 Removed relocate FST function. 170 171 14 2000/04/13 5:21p Hashida 172 Added DVD_RESULT_* definitions for streaming commands. 173 Added more streaming APIs' prototypes. 174 175 13 4/12/00 3:58p Hashida 176 Added audio streaming stuffs. 177 178 12 4/12/00 1:31p Hashida 179 Misc. changes. 180 181 11 3/29/00 2:29p Hashida 182 Added DVDGetDirEntryName and DVDDirEntryIsDir 183 184 10 2000/03/28 3:42p Hashida 185 Added directory accessing functions to MAC build. 186 187 9 3/13/00 2:46p Hashida 188 Added DVDGetFSTLocation. 189 190 8 3/10/00 2:38p Hashida 191 Added DVDRelocateFST 192 193 7 2000/03/02 3:00p Ryan 194 Added DVDChangeDir to MAC build 195 196 6 2000/03/01 1:13p Hashida 197 Renamed DVDDirEntry->filename to name. 198 199 5 2/29/00 7:57p Hashida 200 Added directory access support. 201 202 4 2000/02/02 6:28p Tian 203 Halved size of DVD_FST_MAX_SIZE 204 205 3 1/13/00 12:14p Hashida 206 Added directory access functions for future use. 207 208 21 1999/10/06 10:33a Hashida 209 Changed the filename length limit to 200 chars. 210 211 20 1999/09/09 5:55p Hashida 212 Removed warnings. 213 214 19 1999/08/26 5:37p Hashida 215 Added DVDSetAutoInvalidation 216 217 18 1999/07/21 11:52p Hashida 218 Added DVD_MIN_TRANSFER_SIZE 219 220 17 1999/07/21 9:47p Hashida 221 Added DVDSeek(), DVDChangeDir(), DVDChangeDisk() 222 223 16 1999/07/20 2:37p Hashida 224 Changed DVDFileInfo structure for EPPC 225 Removed DVD_RESULT_GOOD 226 227 15 1999/07/19 11:45p Hashida 228 Changed the value for fatal error to -1 229 230 14 1999/07/19 4:29p Hashida 231 Added DVDCommandBlockStatus and DVDDriveStatus. 232 233 13 1999/07/19 2:58p Hashida 234 Added DVD_FST_MAX_SIZE, DVD_STATE*, DVD_RESULT* and DVDCommandBlock. 235 236 12 1999/07/09 9:59p Hashida 237 Added DVDDiskID structure 238 239 9 1999/06/12 12:11a Hashida 240 Added DVDSetRoot() 241 242 8 1999/06/11 3:04p Shiki 243 Added DVDGetFileInfoStatus(). 244 245 7 1999/06/04 3:14p Hashida 246 Fixed small mistakes 247 248 6 1999/05/28 1:34p Shiki 249 Fixed DVDReadAll() and DVDReadAllAsync() macros. 250 251 5 1999/05/11 4:42p Shiki 252 Refreshed include tree. 253 254 3 1999/04/30 4:22p Shiki 255 Added DVDInit() declaration. 256 257 2 1999/04/30 4:02p Shiki 258 Supported DVDReadAsync(). 259 260 1 1999/04/29 2:51p Shiki 261 262 $NoKeywords: $ 263 *---------------------------------------------------------------------------*/ 264 265 #ifndef __DVD_H__ 266 #define __DVD_H__ 267 268 #ifdef MACOS 269 #include <OSUtils.h> 270 #include <Gestalt.h> 271 #include <Files.h> 272 #endif // MACOS 273 274 #ifdef WIN32 275 #include <windows.h> 276 #endif 277 278 #include <revolution/types.h> 279 280 #ifdef __cplusplus 281 extern "C" { 282 #endif 283 284 #ifdef MACOS 285 // The following is a restriction that only exists on Mac emulator 286 #define DVD_PATH_MAX 200 // The number of bytes in an absolute pathname 287 // Excluding terminating '\0'. 288 #endif 289 290 typedef struct DVDDiskID DVDDiskID; 291 292 struct DVDDiskID 293 { 294 char gameName[4]; 295 char company[2]; 296 u8 diskNumber; 297 u8 gameVersion; 298 u8 streaming; 299 u8 streamingBufSize; // 0 = default 300 u8 padding[14]; // 0's are stored 301 u32 rvlMagic; // Revolution disk magic number 302 u32 gcMagic; // GC magic number is here 303 }; 304 305 typedef struct DVDCommandBlock DVDCommandBlock; 306 307 typedef void (*DVDCBCallback)(s32 result, DVDCommandBlock* block); 308 309 struct DVDCommandBlock 310 { 311 DVDCommandBlock* next; 312 DVDCommandBlock* prev; 313 u32 command; 314 s32 state; 315 u32 offset; 316 u32 length; 317 void* addr; 318 u32 currTransferSize; 319 u32 transferredSize; 320 DVDDiskID* id; 321 DVDCBCallback callback; 322 void* userData; 323 }; 324 325 typedef struct DVDFileInfo DVDFileInfo; 326 327 /*---------------------------------------------------------------------------* 328 Name: DVDCallback 329 330 Description: DVD callback function 331 332 Arguments: result If the function that set the callback succeeds, 333 it is the number of bytes transferred. If that 334 function fails, it is -1. 335 336 Returns: None. 337 *---------------------------------------------------------------------------*/ 338 typedef void (*DVDCallback)(s32 result, DVDFileInfo* fileInfo); 339 340 struct DVDFileInfo 341 { 342 #ifndef MACOS 343 DVDCommandBlock cb; 344 #endif 345 346 u32 startAddr; // Disk address of file 347 u32 length; // File size in bytes 348 349 #ifdef MACOS 350 DVDFileInfo* next; 351 #endif // MACOS 352 DVDCallback callback; 353 354 #ifdef WIN32 355 FILE * file; 356 #endif 357 358 #ifdef MACOS 359 IOParam pb; 360 #endif // MACOS 361 362 }; 363 364 typedef struct 365 { 366 u32 entryNum; 367 u32 location; 368 u32 next; 369 } DVDDir; 370 371 typedef struct 372 { 373 u32 entryNum; 374 BOOL isDir; 375 char* name; 376 } DVDDirEntry; 377 378 379 // FST maximum size 380 #ifndef MINNOW 381 #define DVD_FST_MAX_SIZE 0x00100000 382 #else // MINNOW 383 #define DVD_FST_MAX_SIZE 0x00080000 384 #endif 385 386 #define DVD_MIN_TRANSFER_SIZE 32 387 388 #define DVD_STATE_FATAL_ERROR -1 389 #define DVD_STATE_END 0 390 #define DVD_STATE_BUSY 1 391 #define DVD_STATE_WAITING 2 392 #define DVD_STATE_COVER_CLOSED 3 // Internal state. never returns. 393 #define DVD_STATE_NO_DISK 4 394 #define DVD_STATE_COVER_OPEN 5 395 #define DVD_STATE_WRONG_DISK 6 396 #define DVD_STATE_MOTOR_STOPPED 7 397 #define DVD_STATE_PAUSING 8 398 #define DVD_STATE_IGNORED 9 399 #define DVD_STATE_CANCELED 10 400 #define DVD_STATE_RETRY 11 401 #define DVD_STATE_NO_INPUT 12 402 403 #define DVD_FILEINFO_READY 0 404 #define DVD_FILEINFO_BUSY 1 405 406 #define DVD_RESULT_GOOD 0 407 #define DVD_RESULT_FATAL_ERROR -1 408 #define DVD_RESULT_IGNORED -2 409 #define DVD_RESULT_CANCELED -3 410 411 #define DVD_AIS_SUCCESS 0x0 412 413 #define DVDGetStartAddr(fileInfo) \ 414 ((u64)((u64)(fileInfo)->startAddr) << 2) 415 416 #define DVDGetLength(fileInfo) \ 417 ((fileInfo)->length) 418 419 void DVDInit ( void ); 420 421 BOOL DVDOpen ( const char* fileName, DVDFileInfo* fileInfo ); 422 BOOL DVDFastOpen ( s32 entrynum, DVDFileInfo* fileInfo ); 423 424 #ifndef MACOS 425 s32 DVDReadPrio ( DVDFileInfo* fileInfo, void* addr, s32 length, 426 s32 offset, s32 prio ); 427 428 BOOL DVDReadAsyncPrio ( DVDFileInfo* fileInfo, void* addr, s32 length, 429 s32 offset, 430 DVDCallback callback, s32 prio ); 431 432 #define DVDRead(fileInfo, addr, length, offset) \ 433 DVDReadPrio((fileInfo), (addr), (length), (offset), 2) 434 #define DVDReadAsync(fileInfo, addr, length, offset, callback) \ 435 DVDReadAsyncPrio((fileInfo), (addr), (length), (offset), (callback), 2) 436 #else 437 s32 DVDRead ( DVDFileInfo* fileInfo, void* addr, s32 length, 438 s32 offset ); 439 440 BOOL DVDReadAsync ( DVDFileInfo* fileInfo, void* addr, s32 length, 441 s32 offset, 442 DVDCallback callback ); 443 #endif 444 445 BOOL DVDClose ( DVDFileInfo* fileInfo ); 446 447 #ifndef MACOS 448 BOOL DVDGetCurrentDir ( char* path, u32 maxlen ); 449 #endif 450 451 BOOL DVDChangeDir ( const char* dirName ); 452 453 #ifdef MACOS 454 BOOL DVDMovePickup ( DVDFileInfo* fileInfo, 455 s32 offset, 456 DVDCallback callback ); 457 #else // EPPC 458 s32 DVDSeekPrio ( DVDFileInfo* fileInfo, 459 s32 offset, s32 prio ); 460 461 BOOL DVDSeekAsyncPrio ( DVDFileInfo* fileInfo, 462 s32 offset, 463 DVDCallback callback, s32 prio ); 464 465 #define DVDSeek(fileInfo, offset) \ 466 DVDSeekPrio((fileInfo), (offset), 2) 467 #define DVDSeekAsync(fileInfo, offset, callback) \ 468 DVDSeekAsyncPrio((fileInfo), (offset), (callback), 2) 469 470 s32 DVDChangeDisk ( DVDCommandBlock* block, DVDDiskID* id ); 471 472 BOOL DVDChangeDiskAsync ( DVDCommandBlock* block, DVDDiskID* id, 473 DVDCBCallback callback ); 474 #endif 475 476 s32 DVDGetCommandBlockStatus 477 ( const DVDCommandBlock* block ); 478 479 s32 DVDGetFileInfoStatus( const DVDFileInfo* fileInfo ); 480 481 #define DVDGetFileInfoStatus(fileinfo) \ 482 DVDGetCommandBlockStatus(&(fileinfo)->cb) 483 484 s32 DVDGetDriveStatus ( void ); 485 486 BOOL DVDSetAutoInvalidation 487 ( BOOL autoInval ); 488 489 void* DVDGetFSTLocation ( void ); 490 491 #ifdef MACOS 492 void DVDSetRoot ( const char *rootPath ); 493 #endif 494 #ifdef WIN32 495 void DVDSetRoot ( const char *rootPath ); 496 #endif 497 498 s32 DVDConvertPathToEntrynum 499 ( const char* pathPtr ); 500 501 BOOL DVDEntrynumIsDir ( s32 entrynum ); 502 503 // Directory access functions 504 BOOL DVDOpenDir ( const char* dirName, DVDDir* dir ); 505 BOOL DVDFastOpenDir ( s32 entrynum, DVDDir* dir ); 506 BOOL DVDReadDir ( DVDDir* dir, DVDDirEntry* dirent ); 507 BOOL DVDCloseDir ( DVDDir* dir ); 508 509 void DVDPause ( void ); 510 void DVDResume ( void ); 511 512 /*---------------------------------------------------------------------------* 513 Name: DVDTellDir 514 515 Description: Returns the current location associated with the directory 516 517 Arguments: dir Pre-opened DVDDir* structure 518 519 Returns: Current location 520 *---------------------------------------------------------------------------*/ 521 #define DVDTellDir(dir) ((dir)->location) 522 523 /*---------------------------------------------------------------------------* 524 Name: DVDSeekDir 525 526 Description: Sets the position of the next DVDReadDir on the directory 527 528 Arguments: dir Pre-opened DVDDir* structure 529 loc Location to set 530 531 Returns: None. 532 *---------------------------------------------------------------------------*/ 533 #define DVDSeekDir(dir, loc) ((dir)->location = loc) 534 535 /*---------------------------------------------------------------------------* 536 Name: DVDRewindDir 537 538 Description: Resets the position of the directory to the beginning 539 540 Arguments: dir Pre-opened DVDDir* structure 541 542 Returns: None. 543 *---------------------------------------------------------------------------*/ 544 void DVDRewindDir(DVDDir* dir); 545 546 #define DVDGetDirEntryName(dirent) ((dirent)->name) 547 #define DVDDirEntryIsDir(dirent) ((dirent)->isDir) 548 549 /*---------------------------------------------------------------------------* 550 Name: DVDSetUserData 551 552 Description: Set user data in command block 553 554 Arguments: block Command block 555 data Data to set 556 557 Returns: None. 558 *---------------------------------------------------------------------------*/ 559 #define DVDSetUserData(block, data) ((block)->userData = (data)) 560 561 /*---------------------------------------------------------------------------* 562 Name: DVDGetUserData 563 564 Description: Get user data in command block 565 566 Arguments: block Command block 567 568 Returns: data (void * type) 569 *---------------------------------------------------------------------------*/ 570 #define DVDGetUserData(block) ((block)->userData) 571 572 #ifndef EMU 573 574 BOOL DVDCancelAsync(DVDCommandBlock* block, DVDCBCallback callback); 575 s32 DVDCancel(DVDCommandBlock* block); 576 BOOL DVDCancelAllAsync(DVDCBCallback callback); 577 s32 DVDCancelAll(void); 578 579 s32 DVDGetTransferredSize(DVDFileInfo* fileinfo); 580 581 DVDDiskID* DVDGetCurrentDiskID(void); 582 583 void DVDDumpWaitingQueue(void); 584 585 BOOL DVDCheckDiskAsync(DVDCommandBlock* block, DVDCBCallback callback); 586 587 BOOL DVDCompareDiskID(const DVDDiskID* id1, const DVDDiskID* id2); 588 589 DVDDiskID* DVDGenerateDiskID(DVDDiskID* id, const char* game, const char* company, 590 u8 diskNum, u8 version); 591 592 BOOL DVDSetAutoFatalMessaging(BOOL enable); 593 594 BOOL DVDIsDiskIdentified(void); 595 596 #endif 597 598 #ifdef __cplusplus 599 } 600 #endif 601 602 #endif // __DVD_H__ 603