static int s3c_mfc_release(struct inode *inode, struct file *file) { s3c_mfc_handle_t *handle = NULL; mutex_lock(s3c_mfc_mutex); handle = (s3c_mfc_handle_t *)file->private_data; if (handle->mfc_inst == NULL) { mutex_unlock(s3c_mfc_mutex); return -EPERM; }; mfc_debug("deleting instance number = %d\n", handle->mfc_inst->inst_no); s3c_mfc_inst_del(handle->mfc_inst); kfree(handle); s3c_mfc_openhandle_count--; if (s3c_mfc_openhandle_count == 0) { #if defined(CONFIG_S3C6400_KDPMD) || defined(CONFIG_S3C6400_KDPMD_MODULE) s3c_mfc_pmdev.state = DEV_IDLE; kdpmd_set_event(s3c_mfc_pmdev.devid, KDPMD_DRVCLOSE); kdpmd_wakeup(); kdpmd_wait(s3c_mfc_pmdev.devid); #endif clk_disable(s3c_mfc_hclk); clk_disable(s3c_mfc_sclk); clk_disable(s3c_mfc_pclk); } mutex_unlock(s3c_mfc_mutex); return 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; }
static int s3c_mfc_open(struct inode *inode, struct file *file) { MFC_HANDLE *handle; int ret; ////////////////// // Mutex Lock // ////////////////// MFC_Mutex_Lock(); #ifdef USE_MFC_DOMAIN_GATING if(_openhandle_count == 0) { DOMAIN_POWER_ON; } #endif /* USE_MFC_DOMAIN_GATING */ _openhandle_count++; #ifdef USE_MFC_DOMAIN_GATING CLOCK_ENABLE; #endif /* USE_MFC_DOMAIN_GATING */ if(_openhandle_count == 1) { #if defined(CONFIG_S3C6400_KDPMD) || defined(CONFIG_S3C6400_KDPMD_MODULE) kdpmd_set_event(mfc_pmdev.devid, KDPMD_DRVOPEN); kdpmd_wakeup(); kdpmd_wait(mfc_pmdev.devid); mfc_pmdev.state = DEV_RUNNING; printk("mfc_open woke up\n"); #endif ////////////////////////////////////// // 3. MFC Hardware Initialization // ////////////////////////////////////// if (MFC_HW_Init() == FALSE) { ret = -ENODEV; goto err_MFC_HW_Init; } } handle = (MFC_HANDLE *)kzalloc(sizeof(MFC_HANDLE), GFP_KERNEL); if(!handle) { LOG_MSG(LOG_ERROR, "s3c_mfc_open", "MFC open error\n"); ret = -1; goto err_kzmalloc; } ////////////////////////////// // MFC Instance creation // ////////////////////////////// handle->mfc_inst = MFCInst_Create(); if (handle->mfc_inst == NULL) { LOG_MSG(LOG_ERROR, "s3c_mfc_open", "MFC Instance allocation was failed!\r\n"); ret = -1; goto err_MFCInst_Create; } /* * MFC supports multi-instance. so each instance have own data structure * It saves file->private_data */ file->private_data = (MFC_HANDLE *)handle; #ifdef CONFIG_CPU_FREQ set_dvfs_level(0); #endif /* CONFIG_CPU_FREQ */ LOG_MSG(LOG_TRACE, "mfc_open", "MFC open success! \r\n"); ret = 0; goto no_err; err_MFCInst_Create: kfree (handle); err_kzmalloc: err_MFC_HW_Init: #ifdef USE_MFC_DOMAIN_GATING CLOCK_DISABLE; #endif /* USE_MFC_DOMAIN_GATING */ _openhandle_count --; #ifdef USE_MFC_DOMAIN_GATING if(_openhandle_count == 0) DOMAIN_POWER_OFF; #endif /* USE_MFC_DOMAIN_GATING */ no_err: MFC_Mutex_Release(); return ret; }
static int s3c_mfc_open(struct inode *inode, struct file *file) { s3c_mfc_handle_t *handle; unsigned char *pDataBuf; /* * Mutex Lock */ mutex_lock(s3c_mfc_mutex); clk_enable(s3c_mfc_hclk); clk_enable(s3c_mfc_sclk); clk_enable(s3c_mfc_pclk); s3c_mfc_openhandle_count++; if (s3c_mfc_openhandle_count == 1) { #if defined(CONFIG_S3C6400_KDPMD) || defined(CONFIG_S3C6400_KDPMD_MODULE) kdpmd_set_event(s3c_mfc_pmdev.devid, KDPMD_DRVOPEN); kdpmd_wakeup(); kdpmd_wait(s3c_mfc_pmdev.devid); s3c_mfc_pmdev.state = DEV_RUNNING; mfc_debug("mfc_open woke up\n"); #endif /* FramBufMgr Module Re-initialization */ s3c_mfc_yuv_buffer_mgr_final(); pDataBuf = (unsigned char *)s3c_mfc_get_databuf_virt_addr(); s3c_mfc_init_yuvbuf_mgr(pDataBuf + S3C_MFC_STREAM_BUF_SIZE, S3C_MFC_YUV_BUF_SIZE); /* * 3. MFC Hardware Initialization */ if (s3c_mfc_init_hw() == FALSE) return -ENODEV; } handle = (s3c_mfc_handle_t *)kmalloc(sizeof(s3c_mfc_handle_t), GFP_KERNEL); if (!handle) { mfc_debug("mfc open error\n"); mutex_unlock(s3c_mfc_mutex); return -ENOMEM; } memset(handle, 0, sizeof(s3c_mfc_handle_t)); /* * MFC Instance creation */ handle->mfc_inst = s3c_mfc_inst_create(); if (handle->mfc_inst == NULL) { mfc_err("fail to mfc instance allocation\n"); kfree(handle); mutex_unlock(s3c_mfc_mutex); return -EPERM; } /* * MFC supports multi-instance. so each instance have own data structure * It saves file->private_data */ file->private_data = (s3c_mfc_handle_t *)handle; mutex_unlock(s3c_mfc_mutex); mfc_debug("mfc open success\n"); return 0; }