Esempio n. 1
0
static int mfc_open(struct inode *inode, struct file *file)
{
	mfc_inst_ctx *mfc_ctx;
	int ret;
	//struct sched_param param = { .sched_priority = 1 };

#if	ENABLE_MONITORING_MFC_DD
	mfc_info("MFC mfc_open..\n");
#endif

	mutex_lock(&mfc_mutex);


	if (!mfc_is_running())
	{
#ifdef CONFIG_CPU_FREQ_S5PV210
		s5pv210_set_cpufreq_level(RESTRICT_TABLE);
#endif /* CONFIG_CPU_FREQ_S5PV210 */
#ifdef CONFIG_S5P_LPAUDIO
		s5p_set_lpaudio_lock(1);
#endif /* CONFIG_S5P_LPAUDIO */

		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);
#ifdef CONFIG_PM_PWR_GATING
		s5pc110_lock_power_domain(MFC_DOMAIN_LOCK_TOKEN);
#endif

		if (mfc_init_hw() != TRUE)
		{
#if	Frame_Base_Power_CTR_ON
			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;
			}
#endif
			ret =  -ENODEV;
			goto out_open;
		}
#if	Frame_Base_Power_CTR_ON
			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;
			}*/
#endif
	}

	mfc_ctx = (mfc_inst_ctx *)kmalloc(sizeof(mfc_inst_ctx), GFP_KERNEL);
	if (mfc_ctx == NULL)
	{
		mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n");
		ret = -ENOMEM;
		goto out_open;
	}

	memset(mfc_ctx, 0, sizeof(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");
		kfree(mfc_ctx);
		ret = -EPERM;
		goto out_open;
	}

	if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0)
	{
		mfc_err("MFCINST_ERR_STATE_INVALID\n");
		kfree(mfc_ctx);
		ret = -ENODEV;
		goto out_open;
	}

	/* Decoder only */
	mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB;
	mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET;

	file->private_data = (mfc_inst_ctx *)mfc_ctx;

	//sched_setscheduler(current, SCHED_FIFO, &param);

	ret = 0;

out_open:
	mutex_unlock(&mfc_mutex);

	if(ret != 0)
	{
		mfc_err("MFC_OEPN_FAIL..... ret(%d) \n", ret);
		return ret;
	}

#if	ENABLE_MONITORING_MFC_DD
		mfc_info("MFC_OEPN_OK..... ret(%d) \n", ret);
#endif


	return ret;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
static int mfc_open(struct inode *inode, struct file *file)
{
	mfc_inst_ctx *mfc_ctx;
	int ret;
	//struct sched_param param = { .sched_priority = 1 };

	printk("%s(%d)\n", __func__, __LINE__);
	
	mutex_lock(&mfc_mutex);

	
	if (!mfc_is_running())
	{
#ifdef CONFIG_CPU_FREQ
#if defined(CONFIG_MACH_S5PC110_P1)
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, 2); // DVFS Limit 200Mhz when mfc is running
#endif
#if defined(CONFIG_MACH_S5PC110_ARIES)
		#if MAXIMUM_FREQ == 1200000
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, LEV_400MHZ);
		#else
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, LEV_416MHZ);
		#endif
#endif // CONFIG_MACH_S5PC110_P1
#endif
#ifdef CONFIG_S5PC11X_LPAUDIO
		s5pc110_set_lpaudio_lock(1);
#endif /* CONFIG_S5PC11X_LPAUDIO */

		clk_enable(mfc_clk);
#ifdef CONFIG_PM_PWR_GATING
		s5pc110_lock_power_domain(MFC_DOMAIN_LOCK_TOKEN);
#endif

		if (mfc_init_hw() != TRUE)
		{
#if	Frame_Base_Power_CTR_ON			
			clk_disable(mfc_clk);
#endif
			ret =  -ENODEV;
			goto out_open;
		}
#if	Frame_Base_Power_CTR_ON			
			clk_disable(mfc_clk);
#endif
	}

	mfc_ctx = (mfc_inst_ctx *)kmalloc(sizeof(mfc_inst_ctx), GFP_KERNEL);
	if (mfc_ctx == NULL)
	{
		mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n");
		ret = -ENOMEM;
		goto out_open;
	}

	memset(mfc_ctx, 0, sizeof(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");
		kfree(mfc_ctx);
		ret = -EPERM;
		goto out_open;
	}

	if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0)
	{
		mfc_err("MFCINST_ERR_STATE_INVALID\n");
		kfree(mfc_ctx);
		ret = -ENODEV;
		goto out_open;
	}

	/* Decoder only */
	mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB;
	mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET;

	file->private_data = (mfc_inst_ctx *)mfc_ctx;

	//sched_setscheduler(current, SCHED_FIFO, &param);

	ret = 0;
	
out_open:
	mutex_unlock(&mfc_mutex);

	if(ret != 0)
	{
		mfc_err("MFC_OEPN_FAIL..... ret(%d) \n", ret);	
		return ret;
	}

#if	ENABLE_MFC_DD_MONITOR
		mfc_info("MFC_OEPN_OK..... ret(%d) \n", ret);
#endif		


	return ret;
}