static int mfc_release(struct inode *inode, struct file *file) { mfc_inst_ctx *mfc_ctx; int ret; #if ENABLE_MONITORING_MFC_DD mfc_info("MFC Release..\n"); #endif mutex_lock(&mfc_mutex); #if Frame_Base_Power_CTR_ON clk_enable(mfc_clk); #endif mfc_ctx = (mfc_inst_ctx *)file->private_data; if (mfc_ctx == NULL) { mfc_err("MFCINST_ERR_INVALID_PARAM\n"); ret = -EIO; goto out_release; } mfc_release_all_buffer(mfc_ctx->mem_inst_no); mfc_merge_fragment(mfc_ctx->mem_inst_no); mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); /* In case of no instance, we should not release codec instance */ if (mfc_ctx->InstNo >= 0) mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType); kfree(mfc_ctx); ret = 0; out_release: if (!mfc_is_running()) { #ifdef CONFIG_CPU_FREQ s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_1); #endif #ifdef CONFIG_PM_PWR_GATING s5pc110_unlock_power_domain(MFC_DOMAIN_LOCK_TOKEN); #endif #ifdef CONFIG_S5PC11X_LPAUDIO s5pc110_set_lpaudio_lock(0); #endif /* CONFIG_S5PC11X_LPAUDIO */ } clk_disable(mfc_clk); mutex_unlock(&mfc_mutex); return ret; }
static int mfc_release(struct inode *inode, struct file *file) { struct mfc_inst_ctx *mfc_ctx; int ret; mutex_lock(&mfc_mutex); mfc_ctx = (struct mfc_inst_ctx *)file->private_data; if (mfc_ctx == NULL) { mfc_err("MFCINST_ERR_INVALID_PARAM\n"); ret = -EIO; goto out_release; } mfc_release_all_buffer(mfc_ctx->mem_inst_no); mfc_merge_fragment(mfc_ctx->mem_inst_no); mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); /* In case of no instance, we should not release codec instance */ if (mfc_ctx->InstNo >= 0) { clk_enable(mfc_sclk); mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType); clk_disable(mfc_sclk); } kfree(mfc_ctx); ret = 0; if (!mfc_is_running()) { #ifdef CONFIG_DVFS_LIMIT s5pv210_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_1); #endif /* Turn off mfc power domain regulator */ ret = regulator_disable(mfc_pd_regulator); if (ret < 0) { mfc_err("MFC_RET_POWER_DISABLE_FAIL\n"); goto out_release; } s5p_release_media_memory_bank(S5P_MDEV_MFC, 0); s5p_release_media_memory_bank(S5P_MDEV_MFC, 1); } out_release: mutex_unlock(&mfc_mutex); return ret; }
static int mfc_release(struct inode *inode, struct file *file) { struct mfc_inst_ctx *mfc_ctx; int ret; mutex_lock(&mfc_mutex); mfc_ctx = (struct mfc_inst_ctx *)file->private_data; if (mfc_ctx == NULL) { mfc_err("MFCINST_ERR_INVALID_PARAM\n"); ret = -EIO; goto out_release; } mfc_release_all_buffer(mfc_ctx->mem_inst_no); mfc_merge_fragment(mfc_ctx->mem_inst_no); mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); /* In case of no instance, we should not release codec instance */ if (mfc_ctx->InstNo >= 0) { clk_enable(mfc_sclk); mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType); clk_disable(mfc_sclk); } kfree(mfc_ctx); ret = 0; if (!mfc_is_running()) { /* Turn off mfc power domain regulator */ ret = regulator_disable(mfc_pd_regulator); if (ret < 0) { mfc_err("MFC_RET_POWER_DISABLE_FAIL\n"); goto out_release; } } out_release: mutex_unlock(&mfc_mutex); return ret; }
static int mfc_open(struct inode *inode, struct file *file) { struct mfc_inst_ctx *mfc_ctx; int ret; mutex_lock(&mfc_mutex); if (!mfc_is_running()) { /* Request CMA allocation */ ret = s5p_alloc_media_memory_bank(S5P_MDEV_MFC, 0); if (ret < 0) { ret = -ENOMEM; goto err_open; } ret = s5p_alloc_media_memory_bank(S5P_MDEV_MFC, 1); if (ret < 0) { ret = -ENOMEM; goto err_alloc0; } /* Turn on mfc power domain regulator */ ret = regulator_enable(mfc_pd_regulator); if (ret < 0) { mfc_err("MFC_RET_POWER_ENABLE_FAIL\n"); ret = -EINVAL; goto err_alloc1; } #ifdef CONFIG_DVFS_LIMIT s5pv210_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, L2); #endif clk_enable(mfc_sclk); mfc_load_firmware(mfc_fw_info->data, mfc_fw_info->size); if (mfc_init_hw() != true) { clk_disable(mfc_sclk); ret = -ENODEV; goto err_regulator; } clk_disable(mfc_sclk); } mfc_ctx = (struct mfc_inst_ctx *)kmalloc(sizeof(struct mfc_inst_ctx), GFP_KERNEL); if (mfc_ctx == NULL) { mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n"); ret = -ENOMEM; goto err_regulator; } memset(mfc_ctx, 0, sizeof(struct mfc_inst_ctx)); /* get the inst no allocating some part of memory among reserved memory */ mfc_ctx->mem_inst_no = mfc_get_mem_inst_no(); mfc_ctx->InstNo = -1; if (mfc_ctx->mem_inst_no < 0) { mfc_err("MFCINST_INST_NUM_EXCEEDED\n"); ret = -EPERM; goto err_mem_inst; } if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0) { mfc_err("MFCINST_ERR_STATE_INVALID\n"); ret = -ENODEV; goto err_set_state; } /* Decoder only */ mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB; mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET; file->private_data = mfc_ctx; mutex_unlock(&mfc_mutex); return 0; err_set_state: mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); err_mem_inst: kfree(mfc_ctx); err_regulator: if (!mfc_is_running()) { #ifdef CONFIG_DVFS_LIMIT s5pv210_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_1); #endif /* Turn off mfc power domain regulator */ ret = regulator_disable(mfc_pd_regulator); if (ret < 0) mfc_err("MFC_RET_POWER_DISABLE_FAIL\n"); } err_alloc1: if (!mfc_is_running()) s5p_release_media_memory_bank(S5P_MDEV_MFC, 1); err_alloc0: if (!mfc_is_running()) s5p_release_media_memory_bank(S5P_MDEV_MFC, 0); err_open: mutex_unlock(&mfc_mutex); return ret; }
static int mfc_open(struct inode *inode, struct file *file) { struct mfc_inst_ctx *mfc_ctx; int ret; mutex_lock(&mfc_mutex); if (!mfc_is_running()) { /* Turn on mfc power domain regulator */ ret = regulator_enable(mfc_pd_regulator); if (ret < 0) { mfc_err("MFC_RET_POWER_ENABLE_FAIL\n"); ret = -EINVAL; goto err_open; } clk_enable(mfc_sclk); mfc_load_firmware(mfc_fw_info->data, mfc_fw_info->size); if (mfc_init_hw() != MFCINST_RET_OK) { clk_disable(mfc_sclk); ret = -ENODEV; goto err_regulator; } clk_disable(mfc_sclk); } mfc_ctx = (struct mfc_inst_ctx *)kmalloc(sizeof(struct mfc_inst_ctx), GFP_KERNEL); if (mfc_ctx == NULL) { mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n"); ret = -ENOMEM; goto err_regulator; } memset(mfc_ctx, 0, sizeof(struct mfc_inst_ctx)); /* get the inst no allocating some part of memory among reserved memory */ mfc_ctx->mem_inst_no = mfc_get_mem_inst_no(); mfc_ctx->InstNo = -1; if (mfc_ctx->mem_inst_no < 0) { mfc_err("MFCINST_INST_NUM_EXCEEDED\n"); ret = -EPERM; goto err_mem_inst; } if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0) { mfc_err("MFCINST_ERR_STATE_INVALID\n"); ret = -ENODEV; goto err_set_state; } /* Decoder only */ mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB; mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET; file->private_data = mfc_ctx; mutex_unlock(&mfc_mutex); return 0; err_set_state: mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); err_mem_inst: kfree(mfc_ctx); err_regulator: if (!mfc_is_running()) { /* Turn off mfc power domain regulator */ ret = regulator_disable(mfc_pd_regulator); if (ret < 0) mfc_err("MFC_RET_POWER_DISABLE_FAIL\n"); } err_open: mutex_unlock(&mfc_mutex); return ret; }
static int mfc_release(struct inode *inode, struct file *file) { mfc_inst_ctx *mfc_ctx; int ret; #if ENABLE_MONITORING_MFC_DD mfc_info("MFC Release..\n"); #endif mutex_lock(&mfc_mutex); #if Frame_Base_Power_CTR_ON /*if (s5pv210_pd_enable("mfc_pd") < 0) { printk(KERN_ERR "[Error]The power is not on for mfc\n"); return -1; }*/ clk_enable(mfc_clk); #endif mfc_ctx = (mfc_inst_ctx *)file->private_data; if (mfc_ctx == NULL) { mfc_err("MFCINST_ERR_INVALID_PARAM\n"); ret = -EIO; goto out_release; } mfc_release_all_buffer(mfc_ctx->mem_inst_no); mfc_merge_fragment(mfc_ctx->mem_inst_no); mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); /* In case of no instance, we should not release codec instance */ if (mfc_ctx->InstNo >= 0) mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType); kfree(mfc_ctx); ret = 0; out_release: if (!mfc_is_running()) { #ifdef CONFIG_CPU_FREQ_S5PV210 s5pv210_set_cpufreq_level(NORMAL_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ #ifdef CONFIG_PM_PWR_GATING s5pc110_unlock_power_domain(MFC_DOMAIN_LOCK_TOKEN); #endif #ifdef CONFIG_S5P_LPAUDIO s5p_set_lpaudio_lock(0); #endif /* CONFIG_S5P_LPAUDIO */ } clk_disable(mfc_clk); if (s5pv210_pd_disable("mfc_pd") < 0) { printk(KERN_ERR "[Error]The power is not off for mfc\n"); return -1; } mutex_unlock(&mfc_mutex); return ret; }