css.c
来自「这是一个SIGMA方案的PMP播放器的UCLINUX程序,可播放DVD,VCD,」· C语言 代码 · 共 324 行
C
324 行
/********************************************************************************************//* pQ->c : Implementation of CSS for EM84xx* REALmagic Quasar Hardware Library* Created by Aurelia Popa-Radu* Copyright Sigma Designs Inc* Sigma Designs Proprietary and confidential* Created on 8/27/99* Description:/********************************************************************************************/#include "pch.h"#include "cquasar.h"#define CHECK_100TIMES 100#define CHECK_PERIOD_1MS 1000/****f* HwLib/IDecoder_GetMpegChgKey * USAGE * QRESULT IDecoder_GetMpegChgKey(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__GetMpegChgKey(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_GetMpegChgKey is called by IDecoderBoard_VideoGetAttribute + MpegAttrChgKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 10 bytes array to read from decoder * SEE ALSO * IDecoder_SetMpegKey1, IDecoder_GetMpegKey2, IDecoder_SendMpegDiscKey, * IDecoder_SendMpegTitleKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************/QRESULT CQuasar__GetMpegChgKey(IDecoder* pIDecoder, BYTE* p){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; QRESULT qr = Q_OK; int i; CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,1); CHECK_SLEEP_CONDITION( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), CHECK_100TIMES, CHECK_PERIOD_1MS) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) { QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("GetMpegChgKey TIMEOUT !"))); qr = Q_FAIL; } QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("GetMpegChgKey read 10 bytes = "))); for(i=0;i<10; i++) { *p = (BYTE)CQuasar__ReadDM(pIDecoder, pQ->AUTH_Challenge.addr+i); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } return qr;}/****f* HwLib/IDecoder_SetMpegKey1 * USAGE * QRESULT IDecoder_SetMpegKey1(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__SetMpegKey1(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_GetMpegChgKey is called by IDecoderBoard_VideoSetAttribute + MpegAttrKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 5 bytes array to write to decoder * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_GetMpegKey2, IDecoder_SendMpegDiscKey, * IDecoder_SendMpegTitleKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************/QRESULT CQuasar__SetMpegKey1(IDecoder* pIDecoder, BYTE* p) { CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; QRESULT qr = Q_OK; DWORD i; QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("SetMpegKey1 = "))); for(i=0;i<5;i++) { CQuasar__WriteDM(pIDecoder, pQ->AUTH_Response.addr+i,*p); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,2); CHECK_SLEEP_CONDITION( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), CHECK_100TIMES, CHECK_PERIOD_1MS) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) { QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("SetMpegKey1 TIMEOUT !"))); qr = Q_FAIL; } if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Acc.addr) == 0x80 ) { QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("SetMpegKey1 failure"))); qr = Q_FAIL; } return qr;}/****f* HwLib/IDecoder_GetMpegKey2 * USAGE * QRESULT IDecoder_GetMpegKey2(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__GetMpegKey2(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_GetMpegKey2 is called by IDecoderBoard_VideoSetAttribute + MpegAttrChgKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 10 bytes array to write to decoder and to read back 5 bytes * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_SetMpegKey1, IDecoder_SendMpegDiscKey, * IDecoder_SendMpegTitleKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************/QRESULT CQuasar__GetMpegKey2(IDecoder* pIDecoder, BYTE* p){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; QRESULT qr = Q_OK; DWORD i; QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("GetMpegKey2 write 10 bytes = "))); for(i=0;i<10; i++) { CQuasar__WriteDM(pIDecoder, pQ->AUTH_Challenge.addr+i,*p); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } p -= 10; CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,3); CHECK_SLEEP_CONDITION( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), CHECK_100TIMES, CHECK_PERIOD_1MS) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) { qr = Q_FAIL; QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("GetMpegKey2 TIMEOUT !"))); } QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("GetMpegKey2 read 5 bytes = "))); for(i=0;i<5;i++) { *p=(BYTE)CQuasar__ReadDM(pIDecoder, pQ->AUTH_Response.addr+i); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } return qr;}/****f* HwLib/IDecoder_GetResponse * USAGE * QRESULT IDecoder_GetResponce(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__GetResponse(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_GetResponse is called by IDecoderBoard_VideoGetAttribute + MpegAttrKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to array to read 5 bytes * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_SetMpegKey1, IDecoder_SendMpegDiscKey, * IDecoder_SendMpegTitleKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************///VG (6/13/2002 11:52:23 AM) - addedQRESULT CQuasar__GetResponse(IDecoder* pIDecoder, BYTE* p){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; DWORD i; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("GetMpegKey2 read 5 bytes = "))); for(i=0;i<5;i++) { *p=(BYTE)CQuasar__ReadDM(pIDecoder, pQ->AUTH_Response.addr+i); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } return Q_OK;}/****f* HwLib/IDecoder_SendMpegDiscKey * USAGE * BOOL IDecoder_SendMpegDiscKey(IDecoder* pIDecoder, BYTE* p) * BOOL CQuasar__SendMpegDiscKey(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_SendMpegDiscKey is called by IDecoderBoard_VideoSetAttribute + MpegAttrDiscKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 2048 bytes array to write to decoder * RETURN VALUE * FALSE if timeout * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_SetMpegKey1, IDecoder_GetMpegKey2, * IDecoder_SendMpegTitleKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************/#define BUSYPOLL_WITHTIMEOUTMS(cond,timeout_ms)\{\ DWORD beginning_ms=OSTimeGetTime();\ while (1)\ { \ if (cond) \ break; \ if (OSTimeGetTime()-beginning_ms > timeout_ms)\ break;\ }\}\BOOL CQuasar__SendMpegDiscKey(IDecoder* pIDecoder, BYTE* p) { CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; DWORD i, j, KeyOk; for(j=0;j<204;j++) { for(i=0;i<10;i++) { CQuasar__WriteDM(pIDecoder, pQ->AUTH_Challenge.addr+i,*p); p++; } CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,4); // actual duration is 85 microseconds BUSYPOLL_WITHTIMEOUTMS( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), 1) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("SendMpegDiscKey %d TIMEOUT !"),j)); } for(i=0;i<8;i++) { CQuasar__WriteDM(pIDecoder, pQ->AUTH_Challenge.addr+i,*p); p++; } CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,4); CHECK_SLEEP_CONDITION( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), CHECK_100TIMES, CHECK_PERIOD_1MS) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("SendMpegDiscKey TIMEOUT end !"))); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("SendMpegDiscKey read 5 bytes Response = "))); for(i=0;i<5;i++) QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("%x "),CQuasar__ReadDM(pIDecoder, pQ->AUTH_Response.addr+i))); KeyOk = CQuasar__ReadDM(pIDecoder, pQ->AUTH_Challenge.addr); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("---->>>>DiscKeyOK = %x"), KeyOk)); return (BYTE)KeyOk; // 0 if incorrect}/****f* HwLib/IDecoder_SendMpegTitleKey * USAGE * QRESULT IDecoder_SendMpegTitleKey(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__SendMpegTitleKey(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_SendMpegTitleKey is called by IDecoderBoard_VideoSetAttribute + MpegAttrTitleKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 5 bytes array to write to decoder * RETURN VALUE * FALSE if timeout * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_SetMpegKey1, IDecoder_GetMpegKey2, * IDecoder_SendMpegDiscKey, IDecoder_GetEncryptedTitleKey/********************************************************************************************/QRESULT CQuasar__SendMpegTitleKey(IDecoder* pIDecoder, BYTE* p){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; QRESULT qr = Q_OK; DWORD i; QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("SendMpegTitleKey write 5 bytes = "))); for(i=0;i<5;i++) { CQuasar__WriteDM(pIDecoder, pQ->AUTH_Response.addr+i,*p); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } CQuasar__WriteDM(pIDecoder, pQ->AUTH_Command.addr,5); CHECK_SLEEP_CONDITION( (CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) == 0), CHECK_100TIMES, CHECK_PERIOD_1MS) if( CQuasar__ReadDM(pIDecoder, pQ->AUTH_Command.addr) ) { QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("SendMpegTitleKey TIMEOUT !"))); qr = Q_FAIL; } QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("TK="))); for(i=0;i<5;i++) QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),CQuasar__ReadDM(pIDecoder, pQ->AUTH_Response.addr+i))); return qr;}/****f* HwLib/IDecoder_GetEncryptedTitleKey * USAGE * QRESULT IDecoder_GetEncryptedTitleKey(IDecoder* pIDecoder, BYTE* p) * QRESULT CQuasar__GetEncryptedTitleKey(IDecoder* pIDecoder, BYTE* p) * DESCRIPTION * IDecoder_GetEncryptedTitleKey is called by IDecoderBoard_VideoGetAttribute + MpegAttrTitleKey. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN BYTE* p - pointer to 8 bytes array to read from decoder * RETURN VALUE * FALSE if timeout * SEE ALSO * IDecoder_GetMpegChgKey, IDecoder_SetMpegKey1, IDecoder_GetMpegKey2, * IDecoder_SendMpegDiscKey, IDecoder_SendMpegTitleKey/********************************************************************************************/QRESULT CQuasar__GetEncryptedTitleKey(IDecoder* pIDecoder, BYTE* p){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; int i; QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("GetEncryptedTitleKey read 8 bytes = "))); for(i=0;i<8;i++) { *p = (BYTE)CQuasar__ReadDM(pIDecoder, pQ->AUTH_Challenge.addr+i); QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("%x "),*p)); p++; } return Q_OK;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?