⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbaddi_mgr.c

📁 这是韩国EQUATOR公司提供的DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:

    //
    // Open DS Path(s)
    //

    status = DsOpenPath(&req_PathW2GBi_InputStream, &PathW2GBi_InputStream);
    if ( status != S_OK ) kprintf("ERROR : S_ERROR returned for status of DsOpenPath()...\n");

    status = DsOpenPath(&req_PathGBo2W_OutputStream, &PathGBo2W_OutputStream);
    if ( status != S_OK ) kprintf("ERROR : S_ERROR returned for status of DsOpenPath()...\n");

    status = DsOpenPath(&req_PathV2W_OutputXfer, &PathV2W_OutputXfer);
    if ( status != S_OK ) kprintf("ERROR : S_ERROR returned for status of DsOpenPath()...\n");

    //
    // Setup getBitsData
    //

    // 15 : jpeg consume 0x00
    // 14 : jpeg dct mode
    // 13 : per-byte bit reversal to GB input
    // 12 : per-byte bit reversal from GB output
    gbCtrl   = 0x00; // do bit-reversal on input and output
    bufInIndex  = DsGetBufferIndexFromDS_BUFFER(PathW2GBi_InputStream.buf.id);
    bufOutIndex = DsGetBufferIndexFromDS_BUFFER(PathGBo2W_OutputStream.buf.id);
    getBitsData =  (((gbCtrl & 0xf) << 12) | ((bufInIndex & 0x3f) << 6) | (bufOutIndex & 0x3f));

    //
    //  Write the values into the Vlx binary (pre-load).
    //
   #ifdef _CONFIG_VLX_C
    getBitsOffset = VLXLAB_vmbaddi__gb_config;
   #else
    getBitsOffset = VLXLAB_vmbaddi_D0_GBDATA;
   #endif

    kprintf("\nGetBits configuration data at %d offset (short) in CM1\n", getBitsOffset);
	        
    vlxBin->Binary[ getBitsOffset >> 2 ] = getBitsData; // convert long long to short
    kprintf("\nWrote GetBits configuration data = %x \n", getBitsData);
		  
    //
    // Load the VLx binary into CM1
    //
    status = VlxLoadBinaryByValue(
        vlxBin,                                 // the pointer to the binary
        ((vlxBin->BinaryByteLength + 1) >> 1),  // length to transfer is 16-bit quantities
        VLXLAB_vmbaddi_PCSTART,                  // transfer from the beginning of the binary 
        0,                                      // which is the beginning of CM1 (offset 0)
        VLX_LOAD_PIO                            // using the PIOs for the transfer.
    );

    kprintf("Sema Data @pVlSemaStop(0x%08x) : 0x%08x (after VLx load, before VLx run)\n" 
      , pVlSemaStop, *pVlSemaStop);

    //
    // Kick channels 
    //    ~ Make sure this is done *after* doing the VLx binary load into CM1
    //
    #ifdef VERBOSE_MODE  
    kprintf("verbose: DsKick : PathW2GBi_InputStream.srcCh.id  = 0x%x\n", PathW2GBi_InputStream.srcCh.id);
    kprintf("verbose: DsKick : PathGBo2W_OutputStream.dstCh.id = 0x%x\n", PathGBo2W_OutputStream.dstCh.id);
    #endif

    // Kick InputSteam src. DST is IO, so DsKick not needed
    DsKick(PathW2GBi_InputStream.srcCh.id, &dsSrc_PathW2GBi_InputStream); 

    // Kick OutputStream dst, SRC is IO, so DsKick not needed
    DsKick(PathGBo2W_OutputStream.dstCh.id, &dsDst_PathGBo2W_OutputStream); 

    //
    // Reset and kick the VLx program
    //  
    kprintf("\nVlxKick()...\n");
    VlxResetPC();  // this makes the starting PC for the VLx be 0.
    VlxKick();     // this turns on the VLx clock.
	           
    //
    // Wait for VLx to clear semaphore
    //
    i=0;
    kprintf("\nWaiting for VLx to clear semaphore...\n");
    while( *(volatile unsigned short*)pVlSemaStop != 0 ) {
        for(j=0;j<100;j++); // kill some time to avoid swamping bus
        if( i++ > SEMA_TIMEOUT_CYCLES ) break;
    }
    kprintf("Sema Data @pVlSemaStop(0x%08x) : 0x%08x (after VLx load, before VLx run)\n" ,pVlSemaStop, *pVlSemaStop);
    if (i>SEMA_TIMEOUT_CYCLES) {
        kprintf("ERROR...semaphore timed out, resume.\n");
        succeeded = S_FAIL_SEMA;
    } else {
        kprintf("...semaphore cleared, resume.\n");
    }

    kprintf("\nVlxStop()\n");
    VlxStop();  // turns off the VLx clock

    kprintf("\nDsKick for PathV2W_OutputXfer\n");
    DsKick(PathV2W_OutputXfer.dstCh.id, &dsDst_PathV2W_OutputXfer);
    DsKick(PathV2W_OutputXfer.srcCh.id, &dsSrc_PathV2W_OutputXfer);

    kprintf("\nWaiting for PathV2W_OutputXfer.srcCh to halt...\n");
    DsWaitHalted(PathV2W_OutputXfer.srcCh.id, DS_TIMEOUT_INDEFINITE); 
    kprintf("\t...halt detected; continuing.\n");


#if 0
    kprintf("\nPrintout BufferTmp[]...\n");
    for (i=0;i<10;i++) kprintf("BufferTmp[%d] = 0x%x\n", i, BufferTmp[i] );
#endif

    kprintf("\nPrintout BufferOut[]...\n");
    for (i=0;i<8;i++) kprintf("BufferOut[%d] = 0x%04x\n", i, BufferOut[i] );

    //
    // Check Data
    //
    if ( 
	    (BufferOut[0] != 0x4)
	 || (BufferOut[1] != 0xA)
	 || (BufferOut[2] != 0xF)
       ) 
    {
        succeeded = S_FAIL_DATA;
    }

    if ( succeeded == S_PASS ) {
        kprintf("\nPASSED!! \n");
    } else {
        kprintf("\nFAILED!! \n");
    }
    kprintf("\tBufferOut[0] = 0x%x, ExpectedVal = 0x%x\n", BufferOut[0], 0x4  );
    kprintf("\tBufferOut[1] = 0x%x, ExpectedVal = 0x%x\n", BufferOut[1], 0xA  );
    kprintf("\tBufferOut[2] = 0x%x, ExpectedVal = 0x%x\n", BufferOut[2], 0xF );

    exit();

} // end main end
				      

//-------------------------------------------

//
// Function Defintions
//

//---------------------------------------
//  BEGIN FUNC InitData() 
//
//---------------------------------------

//
// Start Code :
//
// 0x55aa_00ff_0000_011c
//  0101_0101_1010_1010  0000_0000_1111_1111  0000_0000_0000_0000 0000_0001_0001_1100
//  ^                                                                               ^
//  ^-Early bits                                                        Later bits -^
//
//    Data0[0] = 0x55; 
//    Data0[1] = 0xaa; 
//    Data0[2] = 0x00; 
//    Data0[3] = 0xff; 
//    Data0[4] = 0x00; // start code 1 of 3
//    Data0[5] = 0x00; // start code 2 of 3
//    Data0[6] = 0x01; // start code 3 of 3
//    Data0[7] = 0x1c; // start code value
//    
// ---
//
//    macroblock_address_increment (MPEG spec Table B.1):
//
//    vlc : 0011 -> value 0x4
//    vlc : 0000 1011 -> value 0xA
//    vlc : 0000 0110 -> value 0xF
//
//    0011_0000_1011_0000_0110    
//    00110000101100000110       <->  01100000110100001100
//    0011_0000_1011_0000_0110   <->  0110_0000_1101_0000_1100
//    ^                      ^
//    ^-Early bits           ^
//               Later bits -^
//      3 .  0 .  b .  0 .  6    <->    6 .  0 .  d .  0 .  c
//    0x30b04                    <-> 0x20d0c
//
// Expected output :
//    
//     MAP PRINTF: BufferOut[0] = 0x0073
//     MAP PRINTF: BufferOut[1] = 0x0053
//     MAP PRINTF: BufferOut[2] = 0x01a5
//    

void InitData(unsigned char *lArrayIn)
{
    int i=0;

    for (i=0;i<BLOCKSIZE;i++) { 
        lArrayIn[i] = 0; // Init to incrementing zeros
    }  

    // Override these values 
    lArrayIn[0]  = 0x51;  // junk
    lArrayIn[1]  = 0xa1;  // junk
    lArrayIn[2]  = 0xa2;  // junk
    lArrayIn[3]  = 0x52;  // junk
    lArrayIn[4]  = 0x00;  // start code 1 of 4
    lArrayIn[5]  = 0x00;  // start code 2 of 4
    lArrayIn[6]  = 0x01;  // start code 3 of 4
    lArrayIn[7]  = 0x1c;  // start code 4 of 4 (value)
    lArrayIn[8]  = 0x30;  // first vlc
    lArrayIn[9]  = 0xb0;
    lArrayIn[10] = 0x63;
    lArrayIn[11] = 0x0b;
    lArrayIn[12] = 0x06;


} // END FUNC InitData()

void InitDsReqPath(
	DS_PATH_INFO 	*dsPathRequest, 
	BOOL 		isSrcIO, 
	BOOL 		isDstIO, 
	SINT32 		bufferSize, 
	SINT32 		srcSize, 
	SINT32 		dstSize
)
{
    dsPathRequest->srcCh.transferBurstSize 	= DS_DEFAULT;
    dsPathRequest->srcCh.minInterburstDelay 	= DS_DEFAULT;
    dsPathRequest->srcCh.dtsPriority 		= 1;
    dsPathRequest->srcCh.channelPriority 	= DS_DEFAULT;
    dsPathRequest->srcCh.descriptorFetchMode 	= DS_ACCESS_MODE_COHERENT_ALLOCATE;
    dsPathRequest->srcCh.wayMask 		= DS_DEFAULT;
    dsPathRequest->srcCh.base 			= 0;
    dsPathRequest->isSrcIO 			= FALSE;
    dsPathRequest->dstCh.transferBurstSize 	= DS_DEFAULT;
    dsPathRequest->dstCh.minInterburstDelay 	= DS_DEFAULT;
    dsPathRequest->dstCh.dtsPriority 		= 1;
    dsPathRequest->dstCh.channelPriority 	= DS_DEFAULT;
    dsPathRequest->dstCh.descriptorFetchMode 	= DS_ACCESS_MODE_COHERENT_ALLOCATE;
    dsPathRequest->dstCh.wayMask 		= DS_DEFAULT;
    dsPathRequest->dstCh.base 			= 0;
    dsPathRequest->isDstIO 			= FALSE;
    dsPathRequest->buf.bufferSize   		= bufferSize; // in bytes
    dsPathRequest->buf.srcChunkSize 		= 32;
    dsPathRequest->buf.dstChunkSize 		= 32;
    dsPathRequest->isSrcIO          		= isSrcIO;
    dsPathRequest->isDstIO          		= isDstIO;
    dsPathRequest->flags            		= 0;

}
// END PROGRAM FILE end basic.c 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -