static void check_position(Space *s, double *data) {
	if (isnan(data[0]) || isnan(data[1])) {
		if (!isnan(data[0]))
			data[1] = s->axis[1]->settings.source;
		else if (!isnan(data[1]))
			data[0] = s->axis[0]->settings.source;
		else {
			// Cannot check; assume it's ok.
			return;
		}
	}
	for (uint8_t counter = 0; counter < 2; ++counter) {
		bool ok = true;
		for (uint8_t a = 0; a < s->num_axes; ++a)
			ok &= check_delta(s, a, data);
		if (ok)
			break;
	}
}
Beispiel #2
0
static inline int classify(int x1,int y1,int w,int h,int x,int y,int *a,int *b,int *c)
{
	int rv;
	if(y<y1)
		return EOB;
#ifndef AVOID_DELTA
	if((rv=check_delta(x1,y1,w,h,x,y,a,b,c))!=NOPE)
	{
		return rv;
	}
#endif
	if((rv=check_rle(x1,y1,w,h,x,y,a,b,c))!=NOPE)
	{
		return rv;
	}
	if((rv=check_abs(x1,y1,w,h,x,y,a,b,c))!=NOPE)
	{
		return rv;
	}
	return NOPE;
}
static void input_work_func(struct work_struct *work)
{
	int delta;
	unsigned long key_val, bias_val, button_threshold;
	static int key_status = 0;

    /* Set the keypress threshold based on bias voltage*/
    bias_val = readl(io_p2v(REG_MICAUX_EN));
	if (bias_val == 1)
        button_threshold = mic.headset_pd->keypress_threshold_fp;
    else
        button_threshold = mic.headset_pd->keypress_threshold_lp;

    /* If the key_status is 0, send the event for a key press */
	 if(key_status == 0)
	 {
	     delta = check_delta(mic.hsbtime,mic.hstime);
	     if((mic.headset_state== 1) && (delta == 0)){
		 input_report_key(mic.headset_button_idev, KEY_BCM_HEADSET_BUTTON,1);
		 input_sync(mic.headset_button_idev);
	     }
	 }
	 /* Check if the value read from ANACR12 is greater than the
	  * threshold. If so, the key is still pressed and schedule the work
	  * queue till the value is less than the threshold */
	 key_val = readl(io_p2v(REG_ANACR12));
	 if (key_val >= button_threshold)
	 {
	     key_status = 1;
	     schedule_delayed_work(&(mic.input_work), KEY_PRESS_REF_TIME);
	 }
	 /*Once the value read from ANACR12 is lesser than the threshold, send
	  * the event for a button release */
	 else
	 {
	     key_status = 0;
	     input_report_key(mic.headset_button_idev, KEY_BCM_HEADSET_BUTTON, 0);
             input_sync(mic.headset_button_idev);
	 }
}
static void input_work_func(struct work_struct *work)
{
	int delta = 0;
	unsigned long val = 0;
#ifdef REG_DEBUG
	unsigned long val_anacr2, val_cmc, val_auxen;
#endif
	static int key_status = RELEASE;
	int adc_value = auxadc_access(2);	
	printk("%s: input_work adc_value=%d\n", __func__, adc_value);

	/* If the key_status is 0, send the event for a key press */
	if(key_status == RELEASE)
	{
		delta = check_delta(mic.hsbtime,mic.hstime);
		if((mic.headset_state == HEADSET_4_POLE) && (delta == 0))
		{
			if (!key_resolved)
			{
				if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
				{
					key_count[0]++;
					if (key_count[0] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_BCM_HEADSET_BUTTON;
					printk ("KEY_BCM_HEADSET_BUTTON \n");
				}
				if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
				{	
					key_count[1]++;
					if (key_count[1] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_VOLUMEUP;
					printk ("KEY_VOLUMEUP \n");
				}
				if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
				{
					key_count[2]++;
					if (key_count[2] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_VOLUMEDOWN;
					printk ("KEY_VOLUMEDOWN \n");
				}
			}
			else
				input_report_key(mic.headset_button_idev, key_type, PRESS);

			input_sync(mic.headset_button_idev);
			printk("%s: set_button => PRESS\n", __func__);
			set_button(PRESS);
			printk("%s: button pressed : ear_adc=%d\n", __func__, adc_value);
		}
	}

	/* Check if the value read from ANACR12 is greater than the
	* threshold. If so, the key is still pressed and schedule the work
	* queue till the value is less than the threshold */
	val = readl(io_p2v(REG_ANACR12));
	printk("%s: REG_ANACR12=%x\n", __func__,val);

	if (val >= KEY_PRESS_THRESHOLD && (adc_value >= KEY1_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U))
	{
		key_status = PRESS;

		if (!key_resolved)
		{
			if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
			{
				key_count[0]++;
				if (key_count[0] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_BCM_HEADSET_BUTTON;
				printk ("KEY_BCM_HEADSET_BUTTON\n");
			}
			if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
			{	
				key_count[1]++;
				if (key_count[1] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_VOLUMEUP;
				printk ("KEY_VOLUMEUP\n");
			}
			if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
			{
				key_count[2]++;
				if (key_count[2] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_VOLUMEDOWN;
				printk ("KEY_VOLUMEDOWN\n");
			}
		}
		else
			input_report_key(mic.headset_button_idev, key_type, PRESS);

		schedule_delayed_work(&(mic.input_work), KEY_PRESS_REF_TIME);
		printk("%s: set_button => PRESS\n", __func__);
		set_button(PRESS);
	}
	/* Once the value read from ANACR12 is less than the threshold, send
	* the event for a button release */
	else
	{
		key_status = RELEASE;
		printk ("%s: key_count [%d, %d, %d] \n", __func__, key_count[0], key_count[1], key_count[2]);

		if ( key_count[0] >= KEYCOUNT_THRESHOLD )
		{
			printk("SEND/END RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_BCM_HEADSET_BUTTON, RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else if ( key_count[1] >= KEYCOUNT_THRESHOLD )
		{	
			printk("VOLUP RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_VOLUMEUP, RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else if ( key_count[2] >= KEYCOUNT_THRESHOLD )
		{
			printk("VOLDOWN RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_VOLUMEDOWN, RELEASE);
			input_sync(mic.headset_button_idev);
		}

		printk("%s: set_button => RELEASE\n", __func__);
		set_button(RELEASE);	 
		key_resolved = 0;
		key_count[0] = key_count[1] = key_count[2] = 0;

		if(FactoryMode == DISABLE)
		{
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE | SYSCFG_DISABLE);
		sync_use_mic = DISABLE;
		}

#ifdef REG_DEBUG
		val_anacr2 = readl(io_p2v(REG_ANACR2));
		val_cmc = readl(io_p2v(REG_AUXMIC_CMC));
		val_auxen = readl(io_p2v(REG_AUXMIC_AUXEN));
		printk("%s: REG_ANACR2=%x, REG_AUXMIC_CMC=%x, REG_AUXMIC_AUXEN=%x\n", __func__, val_anacr2, val_cmc, val_auxen);
#endif
	}
}
void testcase(int index , int size)
{
	//printf("inside testcase");	
	int checkip=0 , checkdel =0 ,checkd ;
	strcpy(testname,input_arra[index]);
	checkip=check_ip(size);
	checkd=check_d(size);
	checkdel=check_delta(size);
	if(checkdel != -1)
	{
		//strcpy(ip," ");
		delta=0;		
		delta=atof(input_arra[checkdel]);
		//printf("delta is %f  \n",delta);	
	}
	else
	{
		delta=0.10;
		//printf("delta is %f we\n",delta);	
	}	
	if(checkd != -1)
	{
		//strcpy(ip," ");
		d_value=0;		
		d_value=atof(input_arra[checkd]);
		//printf("delta is %f  \n",delta);	
	}
	else
	{
		d_value=2;
		//printf("delta is %f we\n",delta);	
	}	

	if(checkip != 0)
	{
				
		strcpy(ip," ");
		strcpy(ip,input_arra[checkip]);
	}
	//printf("testcase name %s is  checking on ip = %s and ",testname, ip);	
	int checks=-1;
	checks=check_s(index,size);	
	if(checks != -1)
	{
		teststream=atoi(input_arra[checks]);
		//printf("stream number is %d  \n",teststream);	
		checks=teststream;	
		if(checks>node_count)
		{
			printf(" \t stream number entered is out of range ! \n ");
			return;
		}
	}
	
	if( !strcmp(testname,"FR") || !strcmp(testname,"fr"))	
	{
		
		 tc_fr(checks , checkip );

	}
	else if( !strcmp(testname,"RT") || !strcmp(testname,"rt"))
	{
			
				 tc_rt(checks , checkip);
	}
	else
	{

		printf("wrong test case name \n");
	}		

}
Beispiel #6
0
void read_controls(Slider_type* sliders, Calibration_slider_type* cal) {
	uint16_t ADC_value;
	uint8_t slider_number;
	uint16_t ODR_tmp;
	uint16_t tmp;
	uint16_t adc_res;
	uint8_t mux3;
	uint8_t i;

	switch (controls_read_status) {
	case CHECK_VALUE:
		mux3=mux_pin*3;
		for (i=0; i<3; i++)
			ADC_sourse[mux3+i][ADC_channel]= ADC_DMA_buffer[i] & 0x0FFF;
		slider_number = mux3 + ADC_channel;
		adc_res = median(&ADC_sourse[slider_number][0]);
		ADC_value = median_filter(adc_res, &filter_storage[slider_number]); //big window median filter
		switch (sliders_state) { // SLIDERS_WORK is for ordinary work, other values are for calibration only
		case SLIDERS_WORK:
			//Calculate change comparing with old value.
			if (check_integral_delta(&ADC_value, slider_number, cal[slider_number].delta)) { //Change a result only if difference exceeds SLIDERS_DELTA.
				ADC_old_values[slider_number] = ADC_value;
				if (sliders[slider_number].active) //only active sliders work send fifo
					slider_FIFO_send(slider_number, ADC_value,
							&sliders[slider_number], &cal[slider_number]);
			}
			break;
		case SLIDERS_MENU_SEARCH:
			//Calculate change comparing with old value.
			if (check_delta(&ADC_value, slider_number, SLIDERS_DELTA_SEARCH)) { //Change a result only if difference exceeds SLIDERS_DELTA.
				ADC_old_values[slider_number] = ADC_value;
				slider_calibrate_number = slider_number;
				send_message(MES_SLIDER_MENU_FOUND);
			}
			break;
		case SLIDERS_CALIBRATE:
			if (slider_number == slider_calibrate_number) {
				sliders_state = SLIDERS_EDGE;
				slider_calibrate_store = ADC_value;
				send_message(MES_SLIDER_EDGE);
			}
			break;
		default:
			break;
		}
		ADC_channel++;
		if (ADC_channel>=3){
		   ADC_channel=0;
		   controls_read_status = NEXT_MUX;
		}
		break;
	case NEXT_MUX:
		//Switch multiplexors to next state
		mux_pin++;
		if (mux_pin > 7) {
			mux_pin = 0;
		}
		ODR_tmp = GPIOB->ODR & 0xFF8F; //PB4, PB5, PB6
		tmp = ODR_tmp | (mux_pin << 4); //next value to multiplexors PB4, PB5, PB6
		GPIOB->ODR = tmp;
		controls_read_status = WAIT_MUX;
		break;
	case WAIT_MUX:
		controls_read_status = CHECK_VALUE;
		break;
	}
}