static void getIMSI_work_func(struct work_struct *work)
{
	SIMLOCK_SIM_DATA_t* simdata = GetSIMData();
	
	if(simdata == NULL)
	{
		//printk("%s: IMSI NULL\n", __func__);
		FactoryMode = DISABLE;
	}
	else
	{
		//printk("%s: IMSI %s\n", __func__, simdata->imsi_string);
		FactoryMode = strncmp(simdata->imsi_string, "999999999999999", IMSI_DIGITS) == 0 ?  ENABLE : DISABLE;
	}
	
	printk("%s: Factorymode %d\n", __func__, FactoryMode);

	if(FactoryMode == ENABLE)
	{
		if(mic.headset_state)
		{
			if(mic.hsbst == ENABLE && mic.headset_state == HEADSET_4_POLE)
				board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
		}
	}
}
Ejemplo n.º 2
0
/* 	1 : SIM_DUAL_FIRST,
	2 : SIM_DUAL_SECOND */
static void getIMSI_work_func(struct work_struct *work)
{
	SIMLOCK_SIM_DATA_t* simdata = GetSIMData();
	
	if(simdata == NULL)
	{
		FactoryMode = DISABLE;
	}
	else
	{
		FactoryMode = strncmp(simdata->imsi_string, TEST_SIM_IMSI, IMSI_DIGITS) == 0 ?  ENABLE : DISABLE;
	}
	
	if(FactoryMode == ENABLE)
	{
		if(mic.headset_state == HEADSET_4_POLE)
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
	}
}
Ejemplo n.º 3
0
static void input_work_func(struct work_struct *work)
{
	int adc_value = -1;
	int val = 0;
	ktime_t temptime;

	adc_value = auxadc_access(2);
	val = readl(io_p2v(REG_ANACR12));
//	printk("%s: REG_ANACR2=%d, REG_ANACR12=%d\n", __func__,adc_value , val);

#ifdef USE_SERVICEMODE
	if(val >= KEY_PRESS_THRESHOLD && adc_value >= Min_threshold && adc_value < Max_threshold)
	{
#else
	if(val >= KEY_PRESS_THRESHOLD && adc_value >= KEY1_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U)
	{
#endif
		temptime = ktime_get();
		temptime = ktime_sub(temptime, mic.hsbtime);

		if(temptime.tv.nsec < VALID_RELEASE_REF_TIME && mic.keypressing == PRESS)
		{
			if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
			{
				mic.key_count[0]++;
				printk ("KEY_BCM_HEADSET_BUTTON \n");
			}
			else if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
			{
				mic.key_count[1]++;
				printk ("KEY_VOLUMEUP \n");
			}
			else if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
			{
				mic.key_count[2]++;
				printk ("KEY_VOLUMEDOWN \n");
			}
		}
		else
		{
			if(mic.keypressing == PRESS && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
			{
				input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), PRESS);
				input_sync(mic.headset_button_idev);

				set_button(1); 
				mic.keypressing = RELEASE;
			}
		}

		cancel_delayed_work(&(mic.input_work));
		queue_delayed_work(mic.headset_workqueue, &(mic.input_work), KEY_PRESS_REF_TIME);
	}
	else
	{
		if(mic.keypressing == RELEASE && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
		{			
			printk ("%s: RELEASE key_count [%d, %d, %d] \n", __func__,  mic.key_count[0], mic.key_count[1], mic.key_count[2]);
			input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else
		{
			printk("%s: NO PRESS\n",  __func__);
		}

		if(FactoryMode == DISABLE)
		{
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE | SYSCFG_DISABLE);
			sync_use_mic = DISABLE;		
		}
		
		set_button(0); 
		mic.keypressing = NONE;
	}
}

/*------------------------------------------------------------------------------
Function name   : hs_buttonisr
Description     : interrupt handler

Return type     : irqreturn_t
------------------------------------------------------------------------------*/
irqreturn_t hs_buttonisr(int irq, void *dev_id)
{
	struct mic_t *p = &mic;
	int val = 0;
	ktime_t temptime;
	
#ifdef USE_SERVICEMODE
	if(TestMode == ENABLE)
	{
		if(p->headset_state == HEADSET_4_POLE)
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
		
		return IRQ_NONE;
	}
#endif
	
	if(mic.keypressing == INIT)
	{
		temptime = ktime_get();
		temptime = ktime_sub(temptime, mic.hsbtime);
		if(temptime.tv.sec >= 1 || temptime.tv.nsec >= KEY_INTERRUPT_REF_TIME)
			mic.keypressing = NONE;
		else
		{
		 	printk("%s: Initializing HSB ISR\n", __func__ );
			return IRQ_NONE;
		}
	}	

	if(p->pluging ==  ENABLE || p->keypressing != NONE)
	{
		printk("%s: Headset pluging OR keypressing\n", __func__ );
		return IRQ_NONE;
	}

	val = readl(io_p2v(REG_ANACR12));
	if(val < KEY_PRESS_THRESHOLD)
	{
		printk("%s: False button interrupt\n", __func__ );
		return IRQ_NONE;	
	}
	
	if (p->headset_state == HEADSET_4_POLE)
	{	
		p->hsbtime = ktime_get();
		
		board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
		
		memset(mic.key_count, 0, sizeof(mic.key_count));
		p->keypressing = PRESS;
		sync_use_mic = ENABLE;

		cancel_delayed_work(&(mic.input_work));
		queue_delayed_work(mic.headset_workqueue, &(p->input_work), KEY_BEFORE_PRESS_REF_TIME);
	}

	 return IRQ_HANDLED;
}

/* 	1 : SIM_DUAL_FIRST,
	2 : SIM_DUAL_SECOND */
static void getIMSI_work_func(struct work_struct *work)
{
	SIMLOCK_SIM_DATA_t* simdata = NULL; 
	int first = DISABLE;
	int second = DISABLE;

	simdata = GetSIMData(SIM_DUAL_FIRST);
	first = ((simdata == NULL) || (strncmp(simdata->imsi_string, TEST_SIM_IMSI, IMSI_DIGITS) != 0)) ?  DISABLE : ENABLE;
	simdata = GetSIMData(SIM_DUAL_SECOND);
	second = ((simdata == NULL) || (strncmp(simdata->imsi_string, TEST_SIM_IMSI, IMSI_DIGITS) != 0)) ?  DISABLE : ENABLE;

	FactoryMode = (first == ENABLE || second == ENABLE) ? ENABLE : DISABLE;
	printk("%s: Factorymode %d\n", __func__, FactoryMode);

	if(FactoryMode == ENABLE)
	{
		if(mic.headset_state == HEADSET_4_POLE)
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
	}
}