Beispiel #1
0
int USB_HcdDeinit()
{
	int i = 0;
	
	if( gHcdInst.pdeviceDesc )
	{
		sxr_Free(gHcdInst.pdeviceDesc);
	}	

	if( gHcdInst.pconfig != NULL)
	{
		sxr_Free(gHcdInst.pconfig);
	}

	for(; i<3; i++)
	{
		if( gHcdInst.pConfigDesc[i] )
		{
			sxr_Free(gHcdInst.pConfigDesc[i]);
		}
	}
	VendorCmdFinish = 1;
	BulkTransFinish = 1;
	gHcdInst.flag = USB_HCD_DEVICE_DETACHED;
	return 0;
}
Beispiel #2
0
VOID xvid_freeAll(VOID)
{
    MALLOC_CHUNK_T* currentChunk;
    MALLOC_CHUNK_T* nextChunk;
    UINT32          i;

    currentChunk = firstChunk;

    while(currentChunk)
    {
        for(i = 0; i <  MALLOC_CHUNK_SIZE; ++i)
        {
            if(currentChunk->addr[i] != 0)
            {
                sxr_Free(currentChunk->addr[i]);
            }
        }

        currentChunk = currentChunk->next;
    }

    currentChunk = firstChunk;

    while(currentChunk)
    {
        nextChunk    = currentChunk->next;
        sxr_Free(currentChunk);
        currentChunk = nextChunk;
    }
}
Beispiel #3
0
PRIVATE VOID
hal_UsbDescriptorCleanEpListDescriptor(HAL_USB_EP_DESCRIPTOR_T** eps)
{
    UINT32 i;

    if(eps)
    {
        for(i = 0; eps[i] != 0; ++i) {
            sxr_Free(eps[i]);
        }
        sxr_Free(eps);
    }
}
Beispiel #4
0
PRIVATE VOID
hal_UsbDescriptorCleanConfigListDescriptor(HAL_USB_CONFIG_DESCRIPTOR_T** configs)
{
    UINT32 i;

    if(configs)
    {
        for(i = 0; configs[i] != 0; ++i)
        {
            hal_UsbDescriptorCleanInterfaceListDescriptor(configs[i]->interfaceList);
            sxr_Free(configs[i]);
        }
        sxr_Free(configs);
    }
}
Beispiel #5
0
PUBLIC VOID
hal_UsbDescriptorCleanInterfaceListDescriptor(HAL_USB_INTERFACE_DESCRIPTOR_T** interfaces)
{
    UINT32 i;

    if(interfaces)
    {
        for(i = 0; interfaces[i] != 0; ++i)
        {
            hal_UsbDescriptorCleanEpListDescriptor(interfaces[i]->epList);
            sxr_Free(interfaces[i]);
            interfaces[i] = 0;
        }
        sxr_Free(interfaces);
    }
}
Beispiel #6
0
VOID xvid_myFree(VOID* buffer)
{
    MALLOC_CHUNK_T* currentChunk;
    UINT32          i;

    currentChunk = firstChunk;

    while(currentChunk)
    {
        for(i = 0; i <  MALLOC_CHUNK_SIZE; ++i)
        {
            if(currentChunk->addr[i] == buffer)
            {
                break;
            }
        }

        if(i != MALLOC_CHUNK_SIZE)
        {
            break;
        }

        currentChunk = currentChunk->next;
    }

    if(currentChunk)
    {
        sxr_Free(buffer);
        currentChunk->addr[i] = 0;
    }
    else
    {
        // Error: double free ??
    }
}
Beispiel #7
0
PUBLIC VOID
hal_UsbDescriptorCleanDeviceDescriptor(HAL_USB_DEVICE_DESCRIPTOR_T* dev)
{
    if(dev)
    {
        hal_UsbDescriptorCleanConfigListDescriptor(dev->configList);
        sxr_Free(dev);
    }
}
PRIVATE VOID mps_closePcm8kmono(MPS_HANDLE_T handle)
{
    avps_Stop(&handle->bufferContext);
    if (handle->audioBuffer != NULL)
    {
        sxr_Free(handle->audioBuffer);
        handle->audioBuffer = NULL;
    }
}
Beispiel #9
0
VOID* xvid_myMalloc(UINT32 size)
{
    VOID*            addr;
    MALLOC_CHUNK_T** currentChunk;
    UINT32           i;

    addr = sxr_Malloc(size);

    if(addr == 0)
    {
        return 0;
    }

    currentChunk = &firstChunk;

    while(*currentChunk)
    {
        for(i = 0; i < MALLOC_CHUNK_SIZE; ++i)
        {
            if((*currentChunk)->addr[i] == 0)
            {
                break;
            }
        }

        if(i != MALLOC_CHUNK_SIZE)
        {
            break;
        }

        currentChunk = &(*currentChunk)->next;
    }

    if(*currentChunk == 0)
    {
        *currentChunk = (MALLOC_CHUNK_T*)sxr_Malloc(sizeof(MALLOC_CHUNK_T));
        if(*currentChunk == 0)
        {
            sxr_Free(addr);
            return 0;
        }
        memset(*currentChunk, 0, sizeof(MALLOC_CHUNK_T));
        i = 0;
    }

    (*currentChunk)->addr[i] = addr;

    return addr;
}
Beispiel #10
0
// =============================================================================
// mrs_AmrClose
// -----------------------------------------------------------------------------
/// Close the AMR codec.
/// This function frees the buffer used to record the data, so ensure everything
/// reliable in the buffer has been saved before. (ie: call #mrs_AmrStop before
/// that function)
/// @todo Assert/Error ensure the correct behaviour ?
/// @param handle Handle of the file to close.
// =============================================================================
PRIVATE VOID mrs_AmrClose(MRS_HANDLE_T handle)
{
    MRS_TRACE(MRS_INFO_TRC, 0,  "mrs_AmrClose called.");

    if (handle->audioBuffer != NULL)
    {
        sxr_Free(handle->audioBuffer);
        handle->audioBuffer = NULL;
    }
    
#ifndef MRS_USES_AVRS
    g_mrsAmrMsgAcked = FALSE;
    g_mrsAmrHandle = NULL;
#endif
}
Beispiel #11
0
// =============================================================================
// mrs_TaskAudio
// -----------------------------------------------------------------------------
/// This task is dedicated to the audio management. The main MRS task (mrs_Task)
/// will forward audio related messages to this task. The reason is 
/// @todo Ask Lilian the reason.
// =============================================================================
PRIVATE VOID mrs_TaskAudio(VOID* param)
{
//    Msg_t           msg;
    UINT32          size;
    UINT32          j;
    AVRS_EVENT_T    avrsEvent;
    while(1)
    {
        if(sxr_Wait((UINT32*)&avrsEvent, g_mrsMbxAudio))
        {
            continue;
        }
        MRS_TRACE(MRS_INFO_TRC, 0, "mrs_TaskAudio: new message");

        // It is obviously an audio (from AVRS) message
        // (It is only a private internal thing.)

        // Write new audio data
        g_mrsBufferWritePos = (UINT8*)avrsEvent.bufferPos;
        if(g_mrsBufferReadPos == 0)
        {
            g_mrsBufferReadPos  = g_mrsCurrentHandle->audioBuffer;
        }
        MRS_TRACE(MRS_INFO_TRC, 0, "mrs_Task: Read pos %#x Write pos %#x",
                  g_mrsBufferReadPos, g_mrsBufferWritePos);

        MRS_ASSERT(g_mrsBufferWritePos == 0 ||
                   ((UINT32)g_mrsBufferWritePos >= (UINT32)g_mrsCurrentHandle->audioBuffer &&
                    (UINT32)g_mrsBufferWritePos < (UINT32)g_mrsCurrentHandle->audioBuffer + g_mrsCurrentHandle->audioLength),
                   "Read pointer out of range");
        size = 0;

// FIXME: In order to test the MP3 recording, 
// we will temporarily not use a stream buffer but
// directly the encoded swap buffer.
// The fact that this swap buffer is used is
// detected a non zero frame size.
// This special case shall be removed in the final
// implementation.
        if (avrsEvent.frameSize != 0)
        {
            // special MP3 case to merge into STD one
            size += g_mrsCurrentHandle->codec->writeAudioData(g_mrsCurrentHandle, (UINT8*)avrsEvent.bufferPos,
                    avrsEvent.frameSize);

        }
        else
        {
            // Normal case unindented on purpose
        if((UINT32)g_mrsBufferWritePos <= (UINT32)g_mrsBufferReadPos)
        {
            size += g_mrsCurrentHandle->codec->writeAudioData(g_mrsCurrentHandle, g_mrsBufferReadPos,
                                                         g_mrsCurrentHandle->audioLength +
                                                         (UINT32)g_mrsCurrentHandle->audioBuffer -
                                                         (UINT32)g_mrsBufferReadPos);
            g_mrsBufferReadPos           += size;

            // Wrap ??
            if((UINT32)g_mrsBufferReadPos ==
               (UINT32)g_mrsCurrentHandle->audioBuffer + g_mrsCurrentHandle->audioLength)
            {
                g_mrsBufferReadPos = g_mrsCurrentHandle->audioBuffer;
            }
        }

        if(size !=  g_mrsCurrentHandle->audioLength &&
           (UINT32)g_mrsBufferWritePos > (UINT32)g_mrsBufferReadPos)
        {
            j = g_mrsCurrentHandle->codec->writeAudioData(g_mrsCurrentHandle, g_mrsBufferReadPos,
                                                     (UINT32)g_mrsBufferWritePos - (UINT32)g_mrsBufferReadPos);
            g_mrsBufferReadPos      += j;
            size                    += j;
        }
        if((UINT32)g_mrsBufferReadPos ==
           (UINT32)g_mrsCurrentHandle->audioBuffer + g_mrsCurrentHandle->audioLength)
        {
            g_mrsBufferReadPos = g_mrsCurrentHandle->audioBuffer;
        }
        }
        if(size == 0)
        {
            // Stop recording
            g_mrsCurrentHandle->codec->stop(g_mrsCurrentHandle);

            MRS_TRACE(MRS_INFO_TRC, 0, "mrs_Task: No more room for data");
            MRS_TRACE(MRS_INFO_TRC, 0, "mrs_Task: End of file");
            
            g_mrsCurrentHandle->bufferContext.audioRemainingSize      = 0;
            g_mrsCurrentHandle->bufferContext.bufferAudioReadPosition = g_mrsCurrentHandle->audioBuffer;


            if(g_mrsCurrentHandle->callback)
            {
                g_mrsCurrentHandle->callback((MRS_HANDLE_T)g_mrsCurrentHandle,
                                                 MRS_STATE_EOF);
            }
            
            // Close the codec.
            g_mrsCurrentHandle->codec->close(g_mrsCurrentHandle);
            
            mrs_MediumClose(&g_mrsCurrentHandle->mediumAudio);
            mrs_MediumClose(&g_mrsCurrentHandle->mediumVideo);
            
            sxr_Free(g_mrsCurrentHandle);
            g_mrsCurrentHandle = 0;

        }
        else
        {
            MRS_TRACE(MRS_INFO_TRC, 0, "mrs_Task: AudioAddedData %i", size);
#ifdef MRS_USES_AVRS
            avrs_ReadData(size);
#else
            ars_ReadData(size);
#endif
        }
    }
}
Beispiel #12
0
// =============================================================================
// calib_StubTaskInit
// -----------------------------------------------------------------------------
/// Calib Stub OS task.
// =============================================================================
PROTECTED VOID calib_StubTaskInit(VOID)
{
    UINT32  evt[4];
    Msg_t   *msg;
#ifdef CES_DISPLAY
    LCDD_SCREEN_INFO_T screenInfo;
    GFX_ROI_T fullScreenRoi;
#endif

    CALIB_PROFILE_FUNCTION_ENTER(calib_StubTestTaskInit);
    
    /// Some initialization.
   
    /// Enable full-speed access to flash and ram.
    memd_FlashOpen(tgt_GetMemdFlashConfig());
    memd_RamOpen(tgt_GetMemdRamConfig());

#if (CHIP_HAS_USB == 1) && (CALIB_WITHOUT_USB != 1)
    uctls_Open(g_calibStubMbx, 0, 0, 0, "USB Calib");
    uctls_SetMode(UCTLS_ID_TRACE);

    // Force usb power cycle
    uctls_ChargerStatus(UCTLS_CHARGER_STATUS_DISCONNECTED);
    sxr_Sleep(8000);

    // Initiate charger status
    calib_ChargerHandler(pmd_GetChargerStatus());
    // Configure PMD to warn the calib when a charger is plugged.
    pmd_SetChargerStatusHandler(calib_ChargerHandler);
#endif // CHIP_HAS_USB  && (CALIB_WITHOUT_USB != 1)

#ifdef CES_DISPLAY
    /// Setup the display.
    lcdd_Open();
    lcdd_SetStandbyMode(FALSE);
    lcdd_GetScreenInfo(&screenInfo);
    
    // Fill the whole screen with white.
    fullScreenRoi.start.x      = 0;
    fullScreenRoi.start.y      = 0;
    fullScreenRoi.width        = screenInfo.width;    
    fullScreenRoi.height       = screenInfo.height;
    while (LCDD_ERR_NO != lcdd_FillRect16(&fullScreenRoi, 0xffff));
    
    /// Draw a cool logo.
    while (lcdd_Blit16(&g_calibLogoFbw, 0, 0) != LCDD_ERR_NO);
    lcdd_SetBrightness(6);

    fmg_PrintfInit(0, 8, screenInfo.width, screenInfo.height);

    SXS_TRACE(TSTDOUT, "Running code: Calib Embedded Stub");

    /// Switch ON/OFF PAL traces. 
    sxs_SetTraceLevel(_PAL, 0x1);
#endif

    // Start the calibration stub
    calib_StubOpen();



    /// Update the display. 
    calib_DispState(TRUE);


    /// Start the display refresh and battery monitoring timers. 
    sxs_StartTimer(DISP_TIME, DISP_TIMER, NULL, FALSE, g_calibStubMbx);
    
    /// Main loop. 
    while (1)
    {
        /// Wait for a timer event or a key message. 
        msg = sxr_Wait(evt, g_calibStubMbx);

        if (msg == 0)
        {
            /// Refresh screen. 
            if (evt[0] == DISP_TIMER)
            {
                CALIB_PROFILE_PULSE(calib_StubTimDisp);
                
                /// Update the display. 
                calib_DispState(FALSE);
                
                /// Wakeup the task to update the display. 
                sxs_StartTimer(DISP_TIME, DISP_TIMER, NULL, FALSE, g_calibStubMbx);
            }

            /// Skip the message handling. 
            continue;
        }
        else
        {
            /// Free the message.
            sxr_Free(msg);
            /// Don't handle the key pressing.
            

        }
    }
}