📄 discinfo.c
字号:
// _bFirstTNo = 1 means DVD-RW , Lead-In Area is 0x2E400
// _bFirstTNo = 0 means DVD-ROM,DVD-R,DVD+RW,DVD-RAM, Lead-In Area is 0x2F200
if (_fgSkipSrvStart)
{
#ifdef SUPPORT_DVDRAM_FAMILY
_bFirstTNo = (((_bMediaType== 0x52) || (_bMediaType == 0x33)) ? 1 : 0);
#else
_bFirstTNo = ((_bMediaType == 0x33) ? 1 : 0);
#endif
}
else
{
#ifdef SUPPORT_DVDRAM_FAMILY
_bFirstTNo = (!_fgDiskIsDVDRAM ? 1 : 0);
#else
_bFirstTNo = 1;
#endif
}
lbDVDLeadInRetry:
if (_bTotalSen == 1)
{
_dStartAddr = (_bFirstTNo ? 0x2E440 : 0x2F200);
}
#ifdef READ_MULTI_BORDER
else
{
_bFirstTNo = 0;
}
#endif
#ifdef READ_MULTI_BORDER
bCnt = ((_bTotalSen == 1) ? 0 : 3); // _bAPMState is temporary variable
#else
bCnt = 0;
#endif
#ifdef RS232_LOG_DVDTOC
DBGLogS("Read LeadIn :");
DBGLogB(0, bLoByte(wHiWord(_dStartAddr)), bHiByte(wLoWord(_dStartAddr)), bLoByte(wLoWord(_dStartAddr)));
DBGLogS("\n");
#endif
#ifdef READ_MULTI_BORDER
while (!fgReadLTData(((_bTotalSen == 1) ? AREA_LEADIN : AREA_DATA), 3))
#else
while (!fgReadLTData(AREA_LEADIN, 3))
#endif
{
if (_fgAbort)
{
goto lbDVDExitToc;
}
if (++bCnt == 4)
{
// Mabybe DVDROM,DVDR with DVDRW misjudge
if ((!_fgSkipSrvStart) && _bFirstTNo && (_bTotalSen == 1))
{
_bFirstTNo = 0;
goto lbDVDLeadInRetry;
}
#ifdef READ_MULTI_BORDER
if (_bTotalSen > 1)
{
_bTotalSen--;
goto lbDVDContinue;
}
#endif
_bTotalSen = 0;
return (FALSE); // Invalid data of lead in area
}
_dStartAddr += 0x40;
}
// Get CPS_TY of CPR_MAI for Content provider information.
DescrambleBlk(5, 20);
wBAddr = 5 * DVD_BLK_SIZE;
bCnt = bReadDRAML(0, wBAddr + 6);
WriteTOCMem(2, bCnt);
#ifdef RS232_LOG_DVDTOC
DBGLogS("CPS_TY :");
DBGLogB(0, 0, 0, bCnt);
DBGLogS("\n");
#endif
#ifdef READ_MULTI_BORDER
DescrambleBlk((_bFirstTNo?2:0), 270); // descramble Lead-in block
#else
DescrambleBlk((_bFirstTNo?2:0), 40); // descramble Lead-in block
#endif
wBAddr = pwDiscKeyAddr[9] + 1;
if (wBAddr < 24)
{
wBAddr = 24;
}
#ifdef SUPPORT_DVD_AUDIO
if (wBAddr < (pwCPPMKeyAddr[7] + 1))
{
wBAddr = pwCPPMKeyAddr[7] + 1;
}
else
#endif
DescrambleBlk((_bFirstTNo?0:2), wBAddr); // descramble Disc key
if (_bFirstTNo)
{
wBAddr = 2 * DVD_BLK_SIZE;
}
else
{
wBAddr = 0;
}
// Check this control area is for sure or not
_dMaxLBA = dReadDRAML4(0, wBAddr + 16);
#ifdef RS232_LOG_DVDTOC
DBGLogS("Start PSN :");
DBGLogB(0, bLoByte(wHiWord(_dMaxLBA)), bHiByte(wLoWord(_dMaxLBA)), bLoByte(wLoWord(_dMaxLBA)));
DBGLogS("\n");
#endif
if ((_dMaxLBA != 0x030000) && (_dMaxLBA != 0x031000)) // Start Address
{
#ifdef READ_MULTI_BORDER
if (_bTotalSen > 1)
{
_bTotalSen--;
goto lbDVDContinue;
}
#endif
// The second time to read control data
if (_bFirstTNo)
{
_bFirstTNo = 0;
goto lbDVDLeadInRetry;
}
#ifdef RS232_LOG_DVDTOC
DBGLogS("LeadIn Data(Start PSN) Error\n");
#endif
#if 0 /* Jacob: bypass the reading fails retry, under checking */
_bTotalSen = 0;
return (FALSE); // Invalid data of lead in area
#endif /*0*/
}
else
{
_dMaxLBA = dReadDRAML4(0, wBAddr + 20);
#ifdef RS232_LOG_DVDTOC
DBGLogS("Max PSN (Layer 0):");
DBGLogB(0, bLoByte(wHiWord(_dMaxLBA)), bHiByte(wLoWord(_dMaxLBA)), bLoByte(wLoWord(_dMaxLBA)));
DBGLogS("\n");
#endif
if (_dMaxLBA == 0x30000)
{
_bVRDiscFlag = TRUE;
_dMaxLBA = 0x300000;
}
if(_dMaxLBA <= 0x30000) // Last Recorded Address
{
// 050628: YH (Lily): set to a large value
_dMaxLBA = 0x300000;
#ifdef READ_MULTI_BORDER
if (_bTotalSen > 1)
{
_bTotalSen--;
goto lbDVDContinue;
}
#endif
#ifdef RS232_LOG_DVDTOC
DBGLogS("LeadIn Data(End PSN) Error\n");
#endif
// 050628: YH (Lily): Don't return here.
//_bTotalSen = 0;
//return (FALSE); // Invalid data of lead in area
}
}
if (_bEmptyFlag)
{
_bEmptyFlag = FALSE;
goto lbDVDContinue;
}
// Disc Key offset 11
if (_bFirstTNo)
{
wLoWord(_dMaxLBA) = 11;
}
else
{
wLoWord(_dMaxLBA) = DVD_BLK_SIZE * 2 + 11;
}
///////// layer0 ////////////////
if (_bTotalSen == 1)
{
// copy Region Information of DVD
// bCnt is temparary variable here
bCnt = bReadDRAML(0, wLoWord(_dMaxLBA));
WriteTOCMem(1, bCnt);
}
wLoWord(_dMaxLBA)++; // Disc Key offset 12
// copy Disc Key
for(bCnt=0; bCnt<10;bCnt++)
{
WriteTOCMem(bCnt + DISC_KEY_OFFSET,
bReadDRAML(0, wLoWord(_dMaxLBA) + pwDiscKeyAddr[bCnt]));
}
#ifdef SUPPORT_DVD_AUDIO
for(bCnt=0; bCnt<8;bCnt++)
{
WriteTOCMem(bCnt + CPPM_KEY_OFFSET,
bReadDRAML(0, wLoWord(_dMaxLBA) + pwCPPMKeyAddr[bCnt]));
}
#endif
bCnt = 0; // No Need to read BCA
if ((!_fgSkipSrvStart) && (_bTotalSen == 1))
{
// decide layer number and layer track path
_fgTwoLayer = FALSE; // Init : treat as one layer
_fgPTP = TRUE; // Init : treat as Parallel Track Path
// Check the _fgDiskIsDVDRW , _fgDiskIsDVDR compatibale with disc or not
bHiByte(wHiWord(_dMaxLBA)) = bReadDRAML(0, wBAddr + 12 + 0);
_fg8CMDisk = bReadDRAML(0, wBAddr + 12 + 1) >> 4;
if ( ((bHiByte(wHiWord(_dMaxLBA)) >> 4) != 0x03) && _bVRDiscFlag)
{
_bTotalSen = 0;
#ifdef RS232_LOG_DVDTOC
DBGLogS("ERROR : End PSN = 0x30000 & not DVD-RW\n");
#endif
return (FALSE);
}
#ifdef RS232_LOG_DVDTOC
DBGLogS("DiscType:");
DBGLogB(0, 0, 0, (bHiByte(wHiWord(_dMaxLBA)) >> 4));
DBGLogS("\n");
#endif
#if 1 // VCPS_SUPPORT
vSetSharedInfo(SI_VCPS_STATUS, 0);
#endif
switch (bHiByte(wHiWord(_dMaxLBA)) >> 4) // DVD DiscType
{
case 0:
case 0x0A: // DVD+R Single Layer
case 0x0E: // DVD+R Dual Layer
#if 1 // VCPS_SUPPORT
bVcpsDisc = (bReadDRAML(0, wBAddr + 12 + 16)) >> 6;
vSetSharedInfo(SI_VCPS_STATUS, bVcpsDisc);
#endif
bLoByte(_wPauseTimer) = bReadDRAML(0, wBAddr + 12 + 2);
if (bLoByte(_wPauseTimer) & 0x60) // LeadIn Disc Information : Two Layer
{
_fgTwoLayer = TRUE;
if (bLoByte(_wPauseTimer) & 0x10)
{
_fgPTP = FALSE; // Opposite Track Path
SRVSetDVDBookType(0x13); // Dual and Opposite
}
else
{
SRVSetDVDBookType(0x11); // Dual and Parallel
}
}
else
{
SRVSetDVDBookType(0x10); // DVD-ROM
}
break;
#ifdef SUPPORT_DVDRAM_FAMILY
case 1:
if ((bHiByte(wHiWord(_dMaxLBA)) & 0x0F) == 1) // DVDRAM 1.0
{
WriteBIM(BIM_CFG, DVDRAM + DVDRAMVER1);
SRVSetDVDBookType(0x90);
}
else // DVDRAM 2.0
{
WriteBIM(BIM_CFG, DVDRAM + DVDRAMVER2);
SRVSetDVDBookType(0x91);
}
break;
#endif
case 0x02: // DVD-R
if ((bHiByte(wHiWord(_dMaxLBA)) & 0x0F) == 1) // DVD-R 1.0
{
SRVSetDVDBookType(0x30);
}
else // DVD-R 2.0
{
bCnt = 1;
SRVSetDVDBookType(_bFirstTNo ? 0x33 : 0x31);
}
break;
case 0x03: // DVD-RW
if ((bHiByte(wHiWord(_dMaxLBA)) & 0x0F) == 1) // DVD-RW 1.0
{
}
else // DVD-RW 2.0
{
bCnt = 1;
}
SRVSetDVDBookType(0x52);
_bMediaType = 0x52 ;
break;
case 0x09:
#if 1 // VCPS_SUPPORT
bVcpsDisc = (bReadDRAML(0, wBAddr + 12 + 16)) >> 6;
vSetSharedInfo(SI_VCPS_STATUS, bVcpsDisc);
#endif
if ((bHiByte(wHiWord(_dMaxLBA)) & 0x0F) == 2) // DVD-R 2.0
{
SRVSetDVDBookType(0x50);
}
else
{
_bTotalSen = 0;
return (FALSE);
}
break;
#if 0
case 0x0A: // DVD+R 4.7G
_bMaxSpeed = MAX_DVDR_SPEED;
SRVSetDVDBookType(0x10); // DVD-ROM
break;
#endif
default:
_bTotalSen = 0;
return (FALSE);
}
}
#ifdef SUPPORT_BCA
#ifdef RS232_LOG_DVDTOC
DRS232LogS("Check if BCA exist\n");
#endif
if ((bReadDRAML(0, wBAddr + 12 + 16) & 0x80) && bCnt)
{
vSetSharedInfo(SI_BCA_READY, 0);
vNotifySharedInfo(SI_BCA_READY, 0, 0);
if (fgReadBCAData()) // if BCA flag == 1 then Read BCA
{
#ifdef RS232_LOG_DVDTOC
DRS232LogS("BCAOK\n");
#endif
vSetSharedInfo(SI_BCA_READY, 1);
vNotifySharedInfo(SI_BCA_READY, 0, 0);
}
}
#endif // BCA
#ifdef RS232_LOG_DVDTOC
DBGLogS("MediaType:");
DBGLogB(0, 0, 0, _bMediaType);
DBGLogS("\n");
#endif
#ifdef READ_MULTI_BORDER
// DVD-R v1.0 & for Authoring v2.0, DVD-RW
if (_fgDiskIsDVDR || (_fgDiskIsDVDRW && _fgDiskIsDVDMRW))
{
_dMaxLBA = dReadDRAML4(0, wBAddr + 12 + 32);
_dStartAddr = dReadDRAML4(0, wBAddr + 12 + 36);
if (_dStartAddr) // if zero, next border doesn't exist
{
MDVDSeek(bLoByte(wHiWord(_dStartAddr)),
bHiByte(wLoWord(_dStartAddr)),
bLoByte(wLoWord(_dStartAddr))); // Read 1st Next Border Marker
if (_bPlayerStatus == PLAYER_READY) // 1st Next Border Marker Exist!!
{
_bTotalSen++;
goto lbDVDLeadInRetry; // Read Next Border In
}
}
}
#else
if (_fgDiskIsDVDR || (_fgDiskIsDVDRW && _fgDiskIsDVDMRW))
{
_dMaxLBA = dReadDRAML4(0, wBAddr + 12 + 32); // Read Start PSN of the current border out
// Use _dEndPSN1 as next session start address
_dEndPSN1 = dReadDRAML4(0, wBAddr + 12 + 36);
_dStartAddr = _dEndPSN1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -