Exemplo n.º 1
0
static int mt_freqhopping_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	//Get the structure of ioctl
	int ret = 0;

	struct freqhopping_ioctl *freqhopping_ctl = (struct freqhopping_ioctl *)arg;

	FH_MSG("EN:CMD:%d pll id:%d",cmd,freqhopping_ctl->pll_id);

	if(FH_CMD_ENABLE == cmd) {
		ret = mt_fh_hal_ctrl_lock(freqhopping_ctl,true);
	}else if(FH_CMD_DISABLE == cmd) {
		ret = mt_fh_hal_ctrl_lock(freqhopping_ctl,false);
	}
	else if(FH_CMD_ENABLE_USR_DEFINED == cmd) {
		ret = mt_fh_enable_usrdef(freqhopping_ctl);
	}
	else if(FH_CMD_DISABLE_USR_DEFINED == cmd) {
		ret = mt_fh_disable_usrdef(freqhopping_ctl);
	}else {
		//Invalid command is not acceptable!!
		WARN_ON(1);
	}

	//FH_MSG("Exit");

	return ret;
}
static ssize_t freqhopping_userdefine_proc_write(struct file *file, const char *buffer, size_t count, loff_t *data)
{
	int 		ret;
	char 		kbuf[256];
	size_t 	len = 0;
	unsigned int 	p1,p2,p3,p4,p5,p6,p7;
	struct 		freqhopping_ioctl fh_ctl;

 	p1 = p2 = p3 = p4 = p5 = p6 = p7 = 0;

	FH_MSG("EN: %s",__func__);

	len = min(count, (sizeof(kbuf)-1));

	if (count == 0)return -1;
	if(count > 255)count = 255;

	ret = copy_from_user(kbuf, buffer, count);
	if (ret < 0)return -1;

	kbuf[count] = '\0';

	sscanf(kbuf, "%x %x %x %x %x %x %x", &p1, &p2, &p3, &p4, &p5, &p6, &p7);

	fh_ctl.pll_id  			= p2;
	fh_ctl.ssc_setting.df		= p3;
	fh_ctl.ssc_setting.dt		= p4;
	fh_ctl.ssc_setting.upbnd	= p5;
	fh_ctl.ssc_setting.lowbnd	= p6;
	fh_ctl.ssc_setting.dds 		= p7;
	fh_ctl.ssc_setting.freq		= 0;


	if( p1 == FH_CMD_ENABLE){
		ret = mt_fh_enable_usrdef(&fh_ctl);
		if(ret){
			FH_MSG("__EnableUsrSetting() fail!");
		}
	}
	else{
		ret = mt_fh_disable_usrdef(&fh_ctl);
		if(ret){
			FH_MSG("__DisableUsrSetting() fail!");
		}
	}

    FH_MSG("Exit: %s",__func__);
	return count;
}