/* ** Function Name : process_MFC_PowerDown ** ** Function Description : This function Power down MFC. */ CEDEVICE_POWER_STATE process_MFC_PowerDown(DWORD OpenHandle, PCEDEVICE_POWER_STATE mfc_pwr_state) { unsigned int nNumOfInstance = 0; if ( *mfc_pwr_state == D0) { is_mfc_on = FALSE; // Check if MFC is being used // and change the MFC instance state to PowerOff for (int inst_no = 0; inst_no < MFC_NUM_INSTANCES_MAX; inst_no++) { MFCInstCtx *mfcinst_ctx = MFCInst_GetCtx(inst_no); if (mfcinst_ctx) { nNumOfInstance++; LOG_MSG(LOG_TRACE, "MFC_IOControl", "[MFC IOCTL_POWER_SET] MFC State = 0x%X \r\n",(DWORD) (MFCINST_STATE(mfcinst_ctx))); // On Power Down, the MFC instance is invalidated. // Then the MFC operations (DEC_EXE, ENC_EXE, etc.) will not be performed // until it is validated by entering Power Up state transition. MFCInst_PowerOffState(mfcinst_ctx); if (MFCINST_STATE_CHECK(mfcinst_ctx, MFCINST_STATE_CREATED) || MFCINST_STATE_CHECK(mfcinst_ctx, MFCINST_STATE_DELETED)) { LOG_MSG(LOG_TRACE, "MFC_IOControl", "[MFC IOCTL_POWER_SET] MFC doesn't working!!! MFC State = 0x%X \r\n",(DWORD) (MFCINST_STATE(mfcinst_ctx))); } else { is_mfc_on = TRUE; } } } if (is_mfc_on) { Mfc_Clk_On(); MFC_Sleep(); // Clock & Power off the MFC block if they are on. Mfc_Clk_Off(); LOG_MSG(LOG_TRACE, "MFC_IOControl", "[MFC IOCTL_POWER_SET] POWER DOWN, handle = 0x%X \r\n",(DWORD) OpenHandle); } } *mfc_pwr_state = D4; // MFC power state is now changed to D0(Power On) state. RETAILMSG(1, (L"[MFC] Sleep! (NumOfInstance=%d) \r\n", nNumOfInstance)); return *mfc_pwr_state; }
static int s3c_mfc_suspend(struct platform_device *dev, pm_message_t state) { MFCInstCtx *mfcinst_ctx; int inst_no; int is_mfc_on = 0; int i, index = 0; unsigned int dwMfcBase; MFC_Mutex_Lock(); is_mfc_on = 0; // 1. Power Off state // Invalidate all the MFC Instances for (inst_no = 0; inst_no < MFC_NUM_INSTANCES_MAX; inst_no++) { mfcinst_ctx = MFCInst_GetCtx(inst_no); if (mfcinst_ctx) { is_mfc_on = 1; // On Power Down, the MFC instance is invalidated. // Then the MFC operations (DEC_EXE, ENC_EXE, etc.) will not be performed // until it is validated by entering Power up state transition MFCInst_PowerOffState(mfcinst_ctx); printk(KERN_INFO "MFC_Suspend %d-th instance is invalidated\n", inst_no); } } /* 2. Command MFC sleep and save MFC SFR */ if (is_mfc_on) { dwMfcBase = (unsigned int)GetMfcSfrVirAddr(); for(i=SAVE_START_ADDR; i <= SAVE_END_ADDR; i+=4) { mfc_save[index] = (unsigned int)MFC_READ_REG(dwMfcBase + i); index++; } MFC_Sleep(); } #ifdef USE_MFC_DOMAIN_GATING { /* 3. Disable MFC clock */ int tmp_openhandle_count = _openhandle_count; while (tmp_openhandle_count-- > 0) { CLOCK_DISABLE; } } #endif /* USE_MFC_DOMAIN_GATING */ /* // 4. MFC Power Off(Domain V) mfc_pwr = readl(S3C_NORMAL_CFG); mfc_pwr &= ~(1<<9); printk("mfc_pwr : 0x%X\n", mfc_pwr); __raw_writel(mfc_pwr, S3C_NORMAL_CFG); */ MFC_Mutex_Release(); return 0; }