예제 #1
0
/*
** Function Name : MFC_Close
**
** Function Description : This function close MFC instance.
**                        The instance handle and memory block free here.
*/
BOOL
MFC_Close(
    DWORD OpenHandle
    )
{
    MFC_HANDLE *handle;
    BOOL        ret;

    handle = (MFC_HANDLE *) OpenHandle;
    if (handle == NULL)
        return FALSE;

    if(handle->pStrmBuf)
    {
        ret = VirtualFreeEx(handle->hUsrProc,    // HANDLE hProcess
                          handle->pStrmBuf,
                          0,
                          MEM_RELEASE);
        if (ret == FALSE)
            RETAILMSG(1, (L"\n[MFC_Close] VirtualFreeEx(STRM_BUF) returns FALSE.\n"));
    }

    if(handle->pFramBuf)
    {
        ret = VirtualFreeEx(handle->hUsrProc,    // HANDLE hProcess
                              handle->pFramBuf,
                              0,
                              MEM_RELEASE);
        if (ret == FALSE)
            RETAILMSG(1, (L"\n[MFC_Close] VirtualFreeEx(FRAM_BUF) returns FALSE.\n"));
    }

    if (handle->mfc_inst)
    {
        MFCInst_Delete(handle->mfc_inst);
    }

    free(handle);

    // Decrement OpenHandle Count
    InterlockedDecrement(&_openhandle_count);

    if (_openhandle_count == 1)
    {   // Remain Power Control handle only.
        // MFC is now sw-reset.
        Mfc_Clk_On();
        MfcReset();
        Mfc_Clk_Off();

        // MFC Power Off
        Mfc_Pwr_Off();
    }
    else if (_openhandle_count == 0)
    {
        RETAILMSG(1, (L"\n[MFC_Close] Power Manager Handle closed...\n"));
        gMfcHandlePower = NULL;
    }

    return TRUE;
}
예제 #2
0
/*
** Function Name : MFC_Open
**
** Function Description : This function open MFC instace and return instance handle.
*/
DWORD
MFC_Open(
    DWORD InitHandle,
    DWORD dwAccess,
    DWORD dwShareMode
    )
{
    MFC_HANDLE   *handle;

    // Mutex Lock
    MFC_Mutex_Lock();

    // Allocate & Clear MFC Handle
    handle = (MFC_HANDLE *) malloc(sizeof(MFC_HANDLE));
    if (!handle)
    {
        RETAILMSG(1, (L"\n[MFC_Open Error] Momory Allocation Fail.\n"));
        MFC_Mutex_Release();
        return 0;
    }
    memset(handle, 0, sizeof(MFC_HANDLE));

    // Increment OpenHandle Count
    InterlockedIncrement(&_openhandle_count);

    //
    if (_openhandle_count == 1) // Handle for Power Control
    {
        // Save Specific Handle for Power Control
        gMfcHandlePower = handle;
        RETAILMSG(1, (L"\n[MFC_Open] Power Manager Handle Opened...\n"));
    }
    else if (_openhandle_count >= 2) // Handle for User Application
    {
        // Create MFC Instance
        handle->mfc_inst = MFCInst_Create();
        if (!handle->mfc_inst)
        {
            RETAILMSG(1, (L"\n[MFC_Open Error] MFC Instance Creattion Fail.\n"));
            InterlockedDecrement(&_openhandle_count);
            free(handle);
            MFC_Mutex_Release();
            return 0;
        }

        if (_openhandle_count == 2) // First Handle for User Application
        {
            // MFC HW Init
            Mfc_Pwr_On();
            Mfc_Clk_On();

            if (MFC_HW_Init() == FALSE)
            {
                Mfc_Clk_Off();
                Mfc_Pwr_Off();
                MFCInst_Delete(handle->mfc_inst);
                InterlockedDecrement(&_openhandle_count);
                MFC_Mutex_Release();
                return 0;
            }
            Mfc_Clk_Off();
        }
    }

    // Mutex Release
    MFC_Mutex_Release();

    return (DWORD) handle;
}
예제 #3
0
static int s3c_mfc_release(struct inode *inode, struct file *file)
{
	MFC_HANDLE		*handle = NULL;
	MFCINST_DEC_INBUF_TYPE	inbuf_type;
	int			ret;

	MFC_Mutex_Lock();
#ifdef CONFIG_MACH_SATURN
	lcd_gamma_change(LCD_IDLE); // when finishing playing video, AMOLED gamma change to idle mode
#endif

    #if 1 //mfc.error.recovery
    // If the last issued command is timed out, reset the MFC for error recovery
    // When MFC doesn't respond with DEC_INIT command (timeout)
    // It seems that it doesn't operate normally. It doesn't even respond
    // to swfi command and locks up the cpu when going to sleep. 
    // (SWFI instruction waits for the response from the DOMAIN-V)
    // 
    if(mfc_critial_error) {
        printk(KERN_ERR "\x1b[1;31m" "@#@#@# Reset mfc for error recovery" "\x1b[0m \n");
        MFC_HW_Init();
    }
    #endif
	handle = (MFC_HANDLE *)file->private_data;
	if (handle->mfc_inst == NULL) {
		ret = -1;
		goto err_handle;
	};
	
	//printk("Exit MFC Linux Driver\n");

	inbuf_type = handle->mfc_inst->inbuf_type;
	
	LOG_MSG(LOG_TRACE, "mfc_release", "delete inst no : %d\n", handle->mfc_inst->inst_no);

#if (MFC_LINE_RING_SHARE == 1)
	// In case of (MFC_LINE_RING_SHARE == 1), all the instances were reserved.
	// Therefore the instances need to be released.
	if (inbuf_type == DEC_INBUF_RING_BUF) {
		MfcInstPool_ReleaseAll();
	}
#endif

	MFCInst_Delete(handle->mfc_inst);

	kfree(handle);

#ifdef USE_MFC_DOMAIN_GATING
	CLOCK_DISABLE;
#endif /* USE_MFC_DOMAIN_GATING */

	_openhandle_count--;

	if(_openhandle_count == 0) {

#if defined(CONFIG_S3C6400_KDPMD) || defined(CONFIG_S3C6400_KDPMD_MODULE)
		mfc_pmdev.state = DEV_IDLE;
		kdpmd_set_event(mfc_pmdev.devid, KDPMD_DRVCLOSE);
		kdpmd_wakeup();
		kdpmd_wait(mfc_pmdev.devid);
#endif
#ifdef CONFIG_CPU_FREQ
		set_dvfs_level(1);
#endif /* CONFIG_CPU_FREQ */

#ifdef USE_MFC_DOMAIN_GATING
		DOMAIN_POWER_OFF;
#endif /* USE_MFC_DOMAIN_GATING */
	}

	ret = 0;

err_handle:
	MFC_Mutex_Release();
	return ret;
}