Пример #1
0
//20101005 [email protected] STAR_COUNTRY_KR Add [END_LGE_LAB1]
static void hook_det_work(struct work_struct *work)
{
    int hok_adc_value =0;
    if (headset_off) return;
    if(headset_type != STAR_HEADSET)
        return;
	
    if(is_hook_test == false){
        hok_adc_value = 20;
    }
    else{
        lprintk(D_AUDIO, KERN_ERR "##(hook_det)## IS FACTORYMODE\n");
        hok_adc_value = 65;
    }
    
	if(hook_status == HOOK_RELEASED){
		#if HOOK_USE_ADC
        hookkey_gpio_status = headset_get_hook_adc_average(5);
		if( hookkey_gpio_status <= hok_adc_value )
		{
		    hook_status = HOOK_PRESSED; 
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);
			input_sync(headset_sw_data->ip_dev);
			lprintk(D_AUDIO, KERN_ERR "##(hook_det_work)## HOOK PRESSED ADC %d\n", hookkey_gpio_status);
		}
		#else
		NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, &hookkey_gpio_status);	//[email protected] 20100419 for nVidia headset driver
		if(hookkey_gpio_status == 0){ 
		    hook_status = HOOK_PRESSED; 
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);
			input_sync(headset_sw_data->ip_dev);
			lprintk(D_AUDIO, KERN_ERR "##(hook_det_work)## HOOK PRESSED\n");
		}
		#endif
    }
	else{
		#if HOOK_USE_ADC
        hookkey_gpio_status = headset_get_hook_adc_value();
		if(hookkey_gpio_status > hok_adc_value)
		{ 
		    hook_status = HOOK_RELEASED; 
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 0);
			input_sync(headset_sw_data->ip_dev);
			lprintk(D_AUDIO, KERN_ERR "##(hook_det_work)## HOOK RELEASED ADC %d\n", hookkey_gpio_status);
		}
		#else
		NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, &hookkey_gpio_status);	//[email protected] 20100419 for nVidia headset driver
		if(hookkey_gpio_status == 1){ 
		    hook_status = HOOK_RELEASED; 
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 0);
			input_sync(headset_sw_data->ip_dev);
			lprintk(D_AUDIO, KERN_ERR "##(hook_det_work)## HOOK RELEASED\n");
		}
		#endif
	}
    
}
Пример #2
0
//101106, [email protected], FOTA update [START]
int fota_ebl_download(void)
{
    static NvOdmServicesGpioHandle hCprom = NULL;
    static NvOdmGpioPinHandle hIFX_Reset = NULL;
    int ret;

    if(hCprom == NULL)
    {
	hCprom = NvOdmGpioOpen();
	if (!hCprom)
	{
	    lprintk(D_MUIC, "%s: NvOdmGpioOpen Error \n", __func__);
	    goto error_open_gpio_fail;
	}
    }
    if(hIFX_Reset == NULL)
    {
	hIFX_Reset = NvOdmGpioAcquirePinHandle(hCprom, 'v' - 'a', 0);
	if (!hIFX_Reset)
	{
	    lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
	    goto error_open_gpio_pin_acquire_fail;
	}
    }
    NvOdmGpioConfig(hCprom, hIFX_Reset, NvOdmGpioPinMode_Output);

#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E)
    NvOdmGpioSetState(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN, DISABLE);
#endif

    NvOdmGpioSetState(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW, 0x0);
    NvOdmGpioSetState(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW, 0x0);

    //change USB path from AP to CP
    //Set_MAX14526_CP_USB_Mode();

    NvOdmOsSleepMS(5000);

    //change TEST_GPIO state from low to high (GPIO_PV0)
    NvOdmGpioSetState(hCprom, hIFX_Reset, 0);
    NvOdmGpioGetState(hCprom, hIFX_Reset, &ret);
    lprintk(D_MUIC, "%s: hIFX_Reset is %d \n", __func__, ret);
    NvOdmOsSleepMS(10);
    NvOdmGpioSetState(hCprom, hIFX_Reset, 1);
    NvOdmGpioGetState(hCprom, hIFX_Reset, &ret);    
    lprintk(D_MUIC, "%s: hIFX_Reset is %d \n", __func__, ret);

    return 0;

error_open_gpio_pin_acquire_fail:
    NvOdmGpioClose(hCprom);
error_open_gpio_fail:
    return -ENOSYS;
}
Пример #3
0
int mdm_reset(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;
    NvOdmGpioPinHandle h_uart1_rtspin;

    printk("%s \n", __func__);    
    h_gpio = NvOdmGpioOpen();
    if (!h_gpio)
	{
		printk("%s: NvOdmGpioOpen Error\n", __func__);
		goto error_open_gpio_fail;
	}

    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 0);
    if (!h_gpiopin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    h_uart1_rtspin = NvOdmGpioAcquirePinHandle(h_gpio, 'o' - 'a', 3);
    if (!h_uart1_rtspin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    NvOdmGpioSetState( h_gpio, h_uart1_rtspin, 0x1);
    NvOdmGpioConfig( h_gpio, h_uart1_rtspin, NvOdmGpioPinMode_Output);
    NvOdmGpioGetState( h_gpio, h_uart1_rtspin, &pin_val);
    printk("ifx_reset_high - [CP RTS]: pin %d\n", pin_val);         

	//reset Communication Processor (GPIO_PV0: high -> 1000ms -> low -> 3000ms -> high)
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);
    msleep(1000);
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x0);
    msleep(3000);
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_reset_high - [CP RESET]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_uart1_rtspin);
    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
    return 0;

error_open_gpio_pin_acquire_fail:
	NvOdmGpioClose(h_gpio);
error_open_gpio_fail:
	return -ENOSYS;
}
Пример #4
0
static void powerkey_handle(struct work_struct *wq)
{
    NvU32   pinValue;

#ifdef AP20_A03_POWERKEY_WAR
    unsigned long reg;

    reg = readl(pmc_base + PMC_WAKE_STATUS);

    // Clear power key wakeup pad bit.
    // Because powerkey interrupt might be called before powerkey_resume() is called.
    // In this case, clear bit not to call power key press at powerkey_resume() function.
    if (key_wakeup_ISR == 0 || LP1_key_wake == 1)
    {
        if( reg & WAKEUP_POWERKEY_MASK){
            printk("[PWR_KEY] wakeup pad clear\n");
            //clear wakeuppad status
            writel(WAKEUP_POWERKEY_MASK, pmc_base + PMC_WAKE_STATUS);
        }
        printk("[PWR_KEY] wakeup by powerkey POWERKEY press\n");
        input_report_key(s_powerkey.inputDev, KEY_POWER, 1);
        input_sync(s_powerkey.inputDev);
        
        NvOdmGpioGetState(s_powerkey.gpioHandle, s_powerkey.pinHandle, &pinValue);
        if(pinValue){
            printk("[PWR_KEY] wakeup by powerkey POWERKEY release\n");
            input_report_key(s_powerkey.inputDev, KEY_POWER, 0);
            input_sync(s_powerkey.inputDev);
        }
        key_wakeup_ISR = 1;
//20110324, , LP1 powerkey skip issue [START]
        LP1_key_wake = 0;
//20110324, , LP1 powerkey skip issue [END]
        return;
    }
#endif

    if(!s_powerkey.gpioHandle || !s_powerkey.pinHandle || !s_powerkey.inputDev)
        printk("POWERKEY handler error\n");
    
    NvOdmGpioGetState(s_powerkey.gpioHandle, s_powerkey.pinHandle, &pinValue);
    
    if(pinValue){
        printk("POWERKEY release\n");
        input_report_key(s_powerkey.inputDev, KEY_POWER, 0);
    }else{
        printk("POWERKEY press\n");
        input_report_key(s_powerkey.inputDev, KEY_POWER, 1);
    }
    input_sync(s_powerkey.inputDev);
}
Пример #5
0
static void headset_int_handler(void *dev_id)
{
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset_int_handler()!!\n");

	struct headset_switch_data *switch_data =
		(struct headset_switch_data *)dev_id;
	headset_detecting = 1;
	cancel_delayed_work_sync(&switch_data->hook_delayed_work);
	//schedule_work(&switch_data->work);
	NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, &headset_gpio_status);	
	headset_status = headset_gpio_status;

	if(headset_status == 0)
   	{
        schedule_work(&headset_sw_data->delayed_work);
		  #if defined(STAR_COUNTRY_KR) && !defined(CONFIG_MACH_STAR_SKT_REV_A)  
			headset_Mic_Bias(0);
		  #endif
   	}
	else
	{
	    schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_time));	
//P990_IFX_GB_PORTING_LGSI_START
#if !defined (STAR_OPERATOR_FIDO)
	    wake_lock_timeout(&headset_wake_lock, msecs_to_jiffies(type_detection_time + 50));	 //20111017 [email protected] Problem that no wake up when disconn headset in calling
#endif
//P990_IFX_GB_PORTING_LGSI_END
    }
	NvOdmGpioInterruptDone(s_hHeadsetHandle.hheadsetInterrupt);	//20100420 [email protected] for next interrupt (nVidia Interrupt Spec.) [LGE]
//FIDO - GB Porting [09/08/2011] - Start
#if defined (STAR_OPERATOR_FIDO)
	wake_lock_timeout(&headset_wake_lock, msecs_to_jiffies(1500));		 //20110427 [email protected] headset wake lock timeout
#endif
//FIDO - GB Porting [09/08/2011] - End
}
Пример #6
0
static void headset_int_handler(void *dev_id)
{
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset_int_handler()!!\n");

	struct headset_switch_data *switch_data =
		(struct headset_switch_data *)dev_id;
	headset_detecting = 1;
	cancel_delayed_work_sync(&switch_data->hook_delayed_work);
	//schedule_work(&switch_data->work);
	NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, &headset_gpio_status);	
	headset_status = headset_gpio_status;

	if(headset_status == 0)
   	{
        schedule_work(&headset_sw_data->delayed_work);
		  #if defined(STAR_COUNTRY_KR) && !defined(CONFIG_MACH_STAR_SKT_REV_A)  
			headset_Mic_Bias(0);
		  #endif
   	}
	else
	{
	    schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_time));	
    }
	NvOdmGpioInterruptDone(s_hHeadsetHandle.hheadsetInterrupt);	//20100420  for next interrupt (nVidia Interrupt Spec.) [LGE]
}
Пример #7
0
int mdm_rts_low(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_uart1_rtspin;

    printk("%s \n", __func__);    
    h_gpio = NvOdmGpioOpen();
    if (!h_gpio)
	{
		printk("%s: NvOdmGpioOpen Error\n", __func__);
		goto error_open_gpio_fail;
	}

    h_uart1_rtspin = NvOdmGpioAcquirePinHandle(h_gpio, 'o' - 'a', 3);
    if (!h_uart1_rtspin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    NvOdmGpioSetState( h_gpio, h_uart1_rtspin, 0x1);
    NvOdmGpioConfig( h_gpio, h_uart1_rtspin, NvOdmGpioPinMode_Output);
    NvOdmGpioGetState( h_gpio, h_uart1_rtspin, &pin_val);
    printk("ifx_reset_high - [CP RTS]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_uart1_rtspin);
    NvOdmGpioClose(h_gpio);
    return 0;

error_open_gpio_pin_acquire_fail:
	NvOdmGpioClose(h_gpio);
error_open_gpio_fail:
	return -ENOSYS;
}
Пример #8
0
static void headset_irq_handler(void* arg)
{
    NvU32 states;

    //printk("===============================> headset_irq_handler\n");

    NvOdmGpioGetState(s_hGpio,s_hHeadphoneGpioPin,&states);
    if( !states )
    {     
        gHeadsetInsertStatus = HEADSET_STATUS_REMOVE;
        NvOdmGpioConfig(s_hGpio,s_hHeadphoneGpioPin,NvOdmGpioPinMode_InputInterruptHigh );
    }
    else
    {        
        gHeadsetInsertStatus = HEADSET_STATUS_INSERT;
        NvOdmGpioConfig(s_hGpio,s_hHeadphoneGpioPin,NvOdmGpioPinMode_InputInterruptLow );
    }


	//schedule_work(&switch_data->work);
    if ( g_hDetectEventSema )
        NvOdmOsSemaphoreSignal( g_hDetectEventSema );


    if (s_hGpioIntr_Headphone)
        NvOdmGpioInterruptDone(s_hGpioIntr_Headphone);

	return;
}
Пример #9
0
static void
GpioInterruptHandler(void *arg)
{
	NvOdmGpioPinMode mode;

	NvU32 pinValue = 0;
	NvOdmGyroAccelHandle hDevice =  (NvOdmGyroAccelHandle)arg;
	printk(" ## MPU3050 : 5 \n") ;

	NvOdmGpioGetState(hDevice->hGpioINT, hDevice->hPinINT, &pinValue);

	if (pinValue == 1) {
		mode = NvOdmGpioPinMode_InputInterruptLow;
	} else {
		mode = NvOdmGpioPinMode_InputInterruptHigh;
	}

	NvOdmGpioConfig(hDevice->hGpioINT, hDevice->hPinINT, mode);

	if (pinValue == 1) {
		NvOdmOsSemaphoreSignal(hDevice->SemaphoreForINT);
	}
	NvOdmGpioInterruptDone(hDevice->hGpioInterrupt);

	return;
}
Пример #10
0
int powerkey_resume(struct platform_device *dev)
{
    NvU32   pinValue;
    unsigned long reg;

#ifdef AP_SUSPEND_STATUS
    NvOdmGpioSetState(s_modemCheck.gpioHandle, s_modemCheck.pinHandle, 1);
#endif

    reg = readl(pmc_base + PMC_WAKE_STATUS);

    if (key_wakeup_ISR == 0)
    {
        if (reg & WAKEUP_POWERKEY_MASK) {
            //clear wakeuppad status
            writel(WAKEUP_POWERKEY_MASK, pmc_base + PMC_WAKE_STATUS);
            printk("[PWR_KEY] resume func POWERKEY press\n");
            input_report_key(s_powerkey.inputDev, KEY_POWER, 1);
            input_sync(s_powerkey.inputDev);

            NvOdmGpioGetState(s_powerkey.gpioHandle, s_powerkey.pinHandle, &pinValue);
            if(pinValue){
                printk("[PWR_KEY] resume func POWERKEY release\n");
                input_report_key(s_powerkey.inputDev, KEY_POWER, 0);
                input_sync(s_powerkey.inputDev);
            }
        }
        key_wakeup_ISR = 1;
    }

    return 0;
}
static ssize_t als_control_show(struct device *dev, 
		struct device_attribute *attr, char *buf)
{
	NvU32 pinValue;
	NvOdmGpioGetState(s_hALSHandle.hGpio, s_hALSHandle.s_hResetALSGpioPin, &pinValue); 

	return sprintf(buf, "%d\n", pinValue);
}
Пример #12
0
static void h2w_switch_work(struct work_struct *work)
{
	int state, state2;
	struct h2w_switch_dev *hsdev;

	//logd("h2w_switch_work() IN");

	hsdev = container_of(work, struct h2w_switch_dev, work);
#ifdef CONFIG_SWITCH_DOCK_H2W
	#if !TIMER_DEALER
	NvOdmGpioGetState(hsdev->gpio, hsdev->hp_det_pin, &state);
	NvOdmGpioGetState(hsdev->gpio, hsdev->dock_hp_det_pin, &state2);
	if(!desktop_dock_inserted()) state2=0;
	
	if (!state || state2) {
		logd("on");
		switch_set_state(&hsdev->sdev, 1);
	} else {
		logd("off");
		switch_set_state(&hsdev->sdev, 0);
	}
	#else
	if(!hsdev->hp_det_pinstate||hsdev->dock_hp_det_pinstate)
	{
		switch_set_state(&hsdev->sdev, 1);
	}
	else
	{
		switch_set_state(&hsdev->sdev, 0);
	}
	
	#endif
	
#else
	#if !TIMER_DEALER
	NvOdmGpioGetState(hsdev->gpio, hsdev->hp_det_pin, &state);
	switch_set_state(&hsdev->sdev, !state);
	#else
	switch_set_state(&hsdev->sdev, !hsdev->hp_det_pinstate);
	#endif
#endif

	//logd("h2w_switch_work() OUT");
}
Пример #13
0
static void h2w_switch_work(struct work_struct *work)
{
	int state, state2;
	struct h2w_switch_dev *hsdev;

	hsdev = container_of(work, struct h2w_switch_dev, work); 
	NvOdmGpioGetState(hsdev->gpio, hsdev->hp_det_pin, &state);
	logd("hp pin state=%d,active_low=%d\n",state,hsdev->hp_det_active_low);
	state = hsdev->hp_det_active_low ? !state : state;
	if (hsdev->have_dock_hp&&desktop_dock_inserted()) {
		NvOdmGpioGetState(hsdev->gpio, hsdev->dock_hp_det_pin, &state2);
		logd("dock hp pin state2=%d,active_low=%d\n\n",state2,hsdev->dock_hp_det_active_low);
		state2 = hsdev->dock_hp_det_active_low ? !state2 : state2;
	} else {
		state2 = 0;
	}
	logd("hp state %s\n", state ? "on" : "off");
	logd("dock hp state %s\n", state2 ? "on" : "off");
	switch_set_state(&hsdev->sdev, ((state==1) || (state2==1)));
}
Пример #14
0
static void star_hall_work_func( struct work_struct* work )
{
	NvU32 gpio_status;

	printk("Enter the %s\n", __func__);

	NvOdmGpioGetState(g_hall->h_hall_gpio, g_hall->h_hall_gpio_pin, &gpio_status );
	
	printk("+++++++++++++++++++++++++Sensing Value = %d\n",   gpio_status );
	
	 schedule_delayed_work(&g_hall->delayed_work_hall, 100 ); 
}
Пример #15
0
NvBool EETI_HandleInterrupt(NvOdmTouchDeviceHandle hDevice) {
    EETI_TouchDevice* hTouch = (EETI_TouchDevice*)hDevice;
    NvU32 pinValue;

    NvOdmGpioGetState(hTouch->hGpio, hTouch->hPin, &pinValue);
    if (!pinValue) {
        //interrupt pin is still LOW, read data until interrupt pin is released.
        return NV_FALSE;
    } else
        NvOdmGpioInterruptDone(hTouch->hGpioIntr);

    return NV_TRUE;
}
static void GpioInterruptHandler(void *arg)
{
    NvU32 pinValue;
    NvOdmEcompassHandle hDevice =  (NvOdmEcompassHandle)arg;
	
    NvOdmGpioGetState(hDevice->hGpioINT, hDevice->hPinINT, &pinValue);
    if (pinValue == 1)
    {
		NvOdmEcompasspioInterruptMask(hDevice);				/* Daniel 20101122 <<< */
		NvOdmOsSemaphoreSignal(hDevice->SemaphoreForINT);
    }
    NvOdmGpioInterruptDone(hDevice->hGpioInterrupt);
    return;
}
Пример #17
0
void ifx_power_low(void)
{
    unsigned int pin_val = 0;
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;

    printk("%s LOW\n", __func__);
    h_gpio = NvOdmGpioOpen();
    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 1);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);

    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x0);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_power_low - [CP POWER]: pin %d\n", pin_val);

    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
}
Пример #18
0
/* get GPIO_PU3 status and set it into global variable gUsbCurrLimitC */
static void UsbCurLimitGpioInterruptHandler(void *arg)
{
	NvU32 CurrSelectPinState = 0;
	
	

	
	NvOdmGpioGetState(s_hGpio, s_hOvrrCurPin, &CurrSelectPinState);

	NvOsDebugNprintf ("###INterrupt#####\n");
	//gUsbCurrLimitC = ( CurrSelectPinState ) ? 1 : 0;
	gUsbCurrLimitC = CurrSelectPinState;
	
	NvOsDebugNprintf ("CurrSelectPinState = %d\n",CurrSelectPinState);
	NvOsDebugNprintf("======>i=%d, gUsbCurrLimitC=%d\n", i, gUsbCurrLimitC);
	i = i++;
	NvOdmGpioInterruptDone(IntrHandle);
}
Пример #19
0
static void star_hall_intr_handler( void *arg )
{
	NvU32 gpio_status;
	//NvOdmGpioInterruptMask(g_hall->h_hall_intr, NV_TRUE );// NV_FALSE --> enable intr , NV_TRUE --> disable
	NvOdmGpioGetState(g_hall->h_hall_gpio, g_hall->h_hall_gpio_pin, &gpio_status );
	printk("--------------------------------------------------detecting value = %d\n", gpio_status);
	if( gpio_status == 0 )
		{atomic_set( &sensing_hall, 0 );input_report_abs(g_hall->input_device, ABS_HAT2X, 0);input_sync(g_hall->input_device);}
	else if( gpio_status == 1 )
		{atomic_set( &sensing_hall, 1 );input_report_abs(g_hall->input_device, ABS_HAT2X, 1);input_sync(g_hall->input_device);}

	//NvOdmGpioInterruptMask(g_hall->h_hall_intr, NV_FALSE);// NV_FALSE --> enable intr , NV_TRUE --> disable

	/* 2 == CAR */
	switch_set_state(&g_hall->sdev, gpio_status ? 0 : 2);

	NvOdmGpioInterruptDone(g_hall->h_hall_intr);
}
Пример #20
0
void ifx_reset_high(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;

    printk("%s HIGH\n", __func__);    
    h_gpio = NvOdmGpioOpen();
    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 0);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);

    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_reset_high - [CP RESET]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
}
Пример #21
0
static void GpioInterruptHandler(void *arg)
{
    NvU32 pinValue;
    NvU8 ret;
    NvU8 buffer[SENSOR_DATA_SIZE];
    NvU8 i;
    NvOdmEcompassHandle hDevice =  (NvOdmEcompassHandle)arg;
    NvOdmGpioGetState(hDevice->hGpioINT, hDevice->hPinINT, &pinValue);

    if (pinValue == 1)
    {
        ret=ReadReg(hDevice, AK8975_REG_ST1, buffer, SENSOR_DATA_SIZE);
        if (ret<0) {
            NVODMECOMPASS_PRINTF(("AKM8975 compass driver: I2C failed\n"));
            return;
        }
        /* Check ST bit */
        if ((buffer[0] & 0x01) != 0x01)
        {
            NVODMECOMPASS_PRINTF(("AKM8975 akm8975_work_func: ST is not set\n"));
            return;
        }
        /* Check ST2 bit */
        if (((buffer[7]&0x04)==0x04)||((buffer[7]&0x08)==0x08))
        {
            NVODMECOMPASS_PRINTF(("AKM8975 akm8975_work_func: Data is Fail\n"));
            return;
        }
        NvOdmOsMemcpy(ecompass_buffer,buffer,SENSOR_DATA_SIZE);
#if 0
        NVODMECOMPASS_PRINTF(("\n"));
        NVODMECOMPASS_PRINTF((" GPIO handle :\n"));
        for (i=0; i<SENSOR_DATA_SIZE; i++) {
            NVODMECOMPASS_PRINTF((" Reg %d : [%02x]\n",i,ecompass_buffer[i]));
        }
#endif
        NvOdmOsSemaphoreSignal(hDevice->SemaphoreForINT);
    }
    NvOdmGpioInterruptDone(hDevice->hGpioInterrupt);
    return;
}
Пример #22
0
static NvU8 star_read_vo_bit(ProximityDevice *data)
{
    NvU8 vo = 0;
	NvU32 pinvalue;
    star_proxi_read_reg(&s_proximity, 0x00, &vo);

//    vo = (vo & 0x01) ? 0 : 1;
	
	if(vo & 0x01)
		vo = 1;
	else
		vo = 0;
		
	
	#if STAR_PROX_DEBUG
    lprintk(D_PROXI, "star proxi out [%d]\n", vo);
 	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("pin value = %d\n", pinvalue);
	#endif
    return vo;
}
Пример #23
0
static void headset_det_work(struct work_struct *work)
{
    if (headset_off) return;
	NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, &headset_gpio_status);	//20100419 [email protected] for nVidia headset driver [LGE]
	headset_status = headset_gpio_status;

	lprintk(D_AUDIO, KERN_ERR "@@(Headset_det.c)@@ headset_det_work(), headset_status = %d\n",headset_status);

   if(headset_status == 0)
   {
        schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(remove_detection_time));
	#if defined(STAR_COUNTRY_KR) && !defined(CONFIG_MACH_STAR_SKT_REV_A)	  
		 headset_Mic_Bias(0);
	#endif

   }
	else
	{
	     schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_time));
		  
	}
}
Пример #24
0
static void headset_hook_int_handler(void *dev_id)
{
    
	//lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset_hook_int_handler()!! detecting %d headset type %d\n", headset_detecting, headset_type );
    NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, &hook_gpio);

    if( block_hook_int ){
		NvOdmGpioInterruptDone(s_hHeadsetHandle.hhookInterrupt);
        return;
	}
	
	struct headset_switch_data	*switch_data =
	    (struct headset_switch_data *)dev_id;

	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset_hook_int_handler()!! detecting %d headset type %d\n", headset_detecting, headset_type );
    
	if( (headset_detecting == 1) || (headset_type != STAR_HEADSET)){
		NvOdmGpioInterruptDone(s_hHeadsetHandle.hhookInterrupt);
	}
	else{
		//lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset_hook_int_handler()!!\n");
		//20101125, [email protected], hookkey press is skipped When wakeup from LP1 [START]
        if(suspend_status){
            schedule_work(&switch_data->hook_delayed_work);
        }else{
        //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [END]
        
            if(hook_gpio){
                schedule_delayed_work(&switch_data->hook_delayed_work,	msecs_to_jiffies(hook_release_time));
            }
            else{
		        schedule_delayed_work(&switch_data->hook_delayed_work,	msecs_to_jiffies(hook_press_time));
            }
        
        }
        NvOdmGpioInterruptDone(s_hHeadsetHandle.hhookInterrupt);	
	}
}
Пример #25
0
static void star_vib_work_func(struct work_struct *work)
{
	u32 gpio_state = 0;	
	#if VIB_DEBUG 
	printk("vibrator test... value = %d\n", toggle);
	#endif

	NvOdmGpioConfig( g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, NvOdmGpioPinMode_Output);
	
	NvOdmGpioSetState( g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, toggle );
	if( toggle == 0 )
		toggle++;
	else	
		toggle = 0;

	NvOdmGpioGetState(g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, &gpio_state); 	
	#if VIB_DEBUG
	printk("[skhwang] VIB_EN = %d\n", gpio_state);
	#endif

	NvOdmOsSleepMS(1000);
	schedule_delayed_work(&g_vib->delayed_work_vib,150);
}
Пример #26
0
static int __init proximity_probe(struct platform_device *pdev)
{
    int i, ret = 0;
    NvU32 I2cInstance = 0;
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;
    NvU32 port = 0, pin = 0;
    struct device *dev = &pdev->dev;
	unsigned int pinvalue;

	atomic_set(&proxi_status, 1);
    pConnectivity = NvOdmPeripheralGetGuid(PROXIMITY_GUID);

    for (i = 0; i < pConnectivity->NumAddress; i++)
    {
        switch (pConnectivity->AddressList[i].Interface)
        {
            case NvOdmIoModule_I2c:
                s_proximity.i2c_address = (pConnectivity->AddressList[i].Address << 1);
                I2cInstance = pConnectivity->AddressList[i].Instance;
                break;
            case NvOdmIoModule_Gpio:
                port = pConnectivity->AddressList[i].Instance;
                pin = pConnectivity->AddressList[i].Address;
                break;
            case NvOdmIoModule_Vdd:
                s_proximity.vddId = pConnectivity->AddressList[i].Address;
                break;
            default:
                break;
        }
    }

	s_proximity.MVO = 0;
	#if defined(CONFIG_MACH_STAR_MDM_C)
	port = 'r' - 'a';//'a' - 'a';
	pin = 2;//0;
	#elif defined (CONFIG_MACH_STAR_REV_F) || defined (CONFIG_MACH_STAR_TMUS)
	port = 'w'-'a';
	pin = 2;
	#else
	#error PROXI_OUT PIN not assigned
	#endif

    lprintk(D_PROXI, "[star Proximity] start!!!--------------------------------------------------------------------------\n");

    s_proximity.proxi_out_gpio = NvOdmGpioOpen();
    if (!s_proximity.proxi_out_gpio)
    {
        lprintk(D_PROXI, "[star Proximity] gpio open fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        ret = -ENOSYS;
        goto err_open_gpio_fail;
    }

    s_proximity.proxi_out_gpio_pin = NvOdmGpioAcquirePinHandle(s_proximity.proxi_out_gpio, port, pin);
    if (!s_proximity.proxi_out_gpio_pin)
    {
        lprintk(D_PROXI, "[star Proximity] gpio pin acquire fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        ret = -ENOSYS;
        goto err_open_gpio_pin_acquire_fail;
    }

//    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1);
//    NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputData);
	#if 1

    INIT_WORK(&s_proximity.work, star_proxi_workqueue_func);

    s_proximity.gen2_i2c = NvOdmI2cPinMuxOpen(NvOdmIoModule_I2c, 1, NvOdmI2cPinMap_Config2);
    if (!s_proximity.gen2_i2c)
    {
        lprintk(D_PROXI, "[star Proximity] i2c open fail!\n");
        ret = -ENOSYS;
        goto err_open_i2c_handle_fail;
    }


    s_proximity.use_int_mode = true;
	#if 0
    NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_Output);
    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1);
		NvOdmOsWaitUS(100000);//100ms
   	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("interrupt pin level = %d\n----------------", pinvalue );
    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0);
		NvOdmOsWaitUS(100000);//100ms
   	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("interrupt pin level = %d\n----------------", pinvalue );
    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1);
		NvOdmOsWaitUS(100000);//100ms
   	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("interrupt pin level = %d\n----------------", pinvalue );
    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0);
		NvOdmOsWaitUS(100000);//100ms
   	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("interrupt pin level = %d\n----------------", pinvalue );
    NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1);
		NvOdmOsWaitUS(100000);//100ms
   	NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue);
	printk("interrupt pin level = %d\n----------------", pinvalue );
	#endif	

	#if 0 
	while(1)
	{
    	NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1);
		NvOdmOsWaitUS(100000);//100ms
    	NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0);
		NvOdmOsWaitUS(100000);//100ms
	}
	#endif

    NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputData);

    if (s_proximity.use_int_mode == true) {
        if (NvOdmGpioInterruptRegister(s_proximity.proxi_out_gpio, &s_proximity.proxi_out_intr,
            s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputInterruptLow, star_proxi_interrupt_handler, (void*)&s_proximity, 0) == NV_FALSE)
        {
            lprintk(D_PROXI, "[star Proximity] interrupt register fail!\n");
            ret = -ENOSYS;
            goto err_open_irq_handle_fail;
        }
    } else {
        if (NvOdmGpioInterruptRegister(s_proximity.proxi_out_gpio, &s_proximity.proxi_out_intr,
            s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputInterruptFallingEdge, star_proxi_sleep_handler, (void*)&s_proximity, 0) == NV_FALSE)
        {
            lprintk(D_PROXI, "[star Proximity] interrupt register fail!\n");
            ret = -ENOSYS;
            goto err_open_irq_handle_fail;
        }

        hrtimer_init(&s_proximity.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        s_proximity.timer.function = star_proxi_timer_func;
        s_proximity.delay = PROXI_DEFAULT_DELAY_NS;
    }


    NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_TRUE);

    s_proximity.input_dev = input_allocate_device();
    if (!s_proximity.input_dev) {
        lprintk(D_PROXI, "[star Proximity] input device alloc fail!\n");
        ret = -ENOMEM;
        goto err_alloc_input_device_fail;
    }

    set_bit(EV_KEY, s_proximity.input_dev->evbit);
    set_bit(KEY_POWER, s_proximity.input_dev->keybit);
    set_bit(EV_ABS, s_proximity.input_dev->evbit);
    input_set_abs_params(s_proximity.input_dev, ABS_DISTANCE, 0, 1, 0, 0);
    s_proximity.input_dev->name = "proximity";
    ret = input_register_device(s_proximity.input_dev);
    if (ret) {
        lprintk(D_PROXI, "[star Proximity] input device register fail!\n");
        ret = -ENOMEM;
        goto err_alloc_input_device_fail;
    }

    if ((ret = sysfs_create_group(&dev->kobj, &star_proxi_group))) {
        lprintk(D_PROXI, "[star Proximity] sysfs_create_group fail!\n");
        ret = -ENOMEM;
        goto err_sysfs_group_fail;
    }

//    star_proxi_power_onoff(&s_proximity, true);

    return 0;

err_sysfs_group_fail:
    input_unregister_device(s_proximity.input_dev);
err_alloc_input_device_fail:
    NvOdmGpioInterruptUnregister(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin,
        s_proximity.proxi_out_intr);
err_open_irq_handle_fail:
    NvOdmI2cClose(s_proximity.gen2_i2c); 
err_open_i2c_handle_fail:
    NvOdmGpioReleasePinHandle(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin);
err_open_gpio_pin_acquire_fail:
    NvOdmGpioClose(s_proximity.proxi_out_gpio);
err_open_gpio_fail:

    return ret;

#endif
}
Пример #27
0
static int h2w_switch_probe(struct platform_device *pdev)
{
	struct h2w_switch_dev *hsdev;

	logd("h2w_switch_probe() IN\r\n");

	hsdev = kzalloc(sizeof(struct h2w_switch_dev), GFP_KERNEL);
	if (!hsdev) {
		loge("err_alloc_hsdev\r\n");
		goto err_alloc_hsdev;
	}
	
	hsdev->gpio = NvOdmGpioOpen();
	if (!hsdev->gpio) {
		loge("err open gpio\r\n");
		goto err_open_gpio;
	}
	hsdev->hp_det_pin = NvOdmGpioAcquirePinHandle(hsdev->gpio, HP_DET_GPIO_PORT, HP_DET_GPIO_PIN);
	if (!hsdev->hp_det_pin) {
		loge("err acquire detect pin handle\r\n");
		goto err_acquire_det_pin;
	}
	NvOdmGpioConfig(hsdev->gpio, hsdev->hp_det_pin, NvOdmGpioPinMode_InputData);

#ifdef CONFIG_SWITCH_DOCK_H2W
	hsdev->dock_hp_det_pin = NvOdmGpioAcquirePinHandle(hsdev->gpio, DOCK_HP_DET_GPIO_PORT, DOCK_HP_DET_GPIO_PIN);
	if (!hsdev->dock_hp_det_pin) {
		loge("err acquire dock headphone detect pin handle");
		goto err_acquire_dock_det_pin;
	}
	NvOdmGpioConfig(hsdev->gpio, hsdev->dock_hp_det_pin, NvOdmGpioPinMode_InputData);
#endif

	hsdev->sdev.name = "h2w";
	hsdev->sdev.print_name = h2w_switch_print_name;
	hsdev->sdev.print_state = h2w_switch_print_state;
	if (switch_dev_register(&hsdev->sdev)) {
		loge("err register switch device\r\n");
		goto err_register_sdev;
	}
	
	hsdev->workqueue = create_singlethread_workqueue("h2w_switch");
	if (!hsdev->workqueue) {
		goto err_create_workqueue;
	}
	
	INIT_WORK(&hsdev->work, h2w_switch_work);
	
	

	#if !TIMER_DEALER
	/* Enable the interrupt at last */
	if ((NvOdmGpioInterruptRegister(hsdev->gpio, &hsdev->hp_det_irq, hsdev->hp_det_pin,
			NvOdmGpioPinMode_InputInterruptAny, h2w_switch_irq_isr, hsdev, IRQ_DEBOUNCE) 
			== NV_FALSE) || (hsdev->hp_det_irq == NULL)) {
		logd("err register irq\r\n");
		goto err_register_irq;
	}
	#endif

#ifdef CONFIG_SWITCH_DOCK_H2W
	#if !TIMER_DEALER
	/* Enable the dock hp detect interrupt */
	if ((NvOdmGpioInterruptRegister(hsdev->gpio, &hsdev->dock_hp_det_irq, hsdev->dock_hp_det_pin,
			NvOdmGpioPinMode_InputInterruptAny, dock_h2w_switch_irq_isr, hsdev, IRQ_DEBOUNCE)
			== NV_FALSE) || (hsdev->dock_hp_det_irq == NULL)) {
		loge("err register dock hp irq\r\n");
		goto err_register_dock_hp_irq;
	}
	#endif
#endif

	platform_set_drvdata(pdev, hsdev);
	p_switch_dev=hsdev;
	#if !TIMER_DEALER
	/* After all we simulate a isr */
	queue_work(hsdev->workqueue, &hsdev->work);
	#endif
	
	#if TIMER_DEALER
	init_timer(&hsdev->timer);
	hsdev->timer.function = h2w_switch_timer_func;
	hsdev->timer.data = hsdev;
	mod_timer(&hsdev->timer, jiffies + msecs_to_jiffies(2000));
	
	{
	hsdev->hp_det_ups=0;
	hsdev->hp_det_downs=0;
	hsdev->hp_det_pinstate=0;
	int state;
	int counts=80;
	while(counts)
	{
		NvOdmGpioGetState(hsdev->gpio, hsdev->hp_det_pin, &state);
		if(state){hsdev->hp_det_ups++;hsdev->hp_det_downs=0;}
		else {hsdev->hp_det_downs++;hsdev->hp_det_ups=0;}
		msleep(10);
		
		if(hsdev->hp_det_downs>=5)
		{
			hsdev->hp_det_pinstate=0;
			switch_set_state(&hsdev->sdev, !hsdev->hp_det_pinstate);
			logd("h2w_switch_timer_func headphone detect low~ \n");
			break;
		}
		else if(hsdev->hp_det_ups>=5)
		{
			hsdev->hp_det_pinstate=1;
			switch_set_state(&hsdev->sdev, !hsdev->hp_det_pinstate);
			logd("h2w_switch_timer_func headphone detect high~ \n");
			break;
		}
		counts--;
	}
	if(counts==0){logd("h2w_switch_timer_func headphone detect failed \n");};
	hsdev->hp_det_ups=0;
	hsdev->hp_det_downs=0;
	
	#ifdef CONFIG_SWITCH_DOCK_H2W
	hsdev->dock_hp_det_ups=0;
	hsdev->dock_hp_det_downs=0;
	hsdev->dock_hp_det_pinstate=0;
	counts=80;
	while(counts)
	{
		NvOdmGpioGetState(hsdev->gpio, hsdev->dock_hp_det_pin, &state);
		if(state){hsdev->dock_hp_det_ups++;hsdev->dock_hp_det_downs=0;}
		else {hsdev->dock_hp_det_downs++;hsdev->dock_hp_det_ups=0;}
		msleep(10);
		
		if(hsdev->dock_hp_det_downs>=5)
		{
			hsdev->dock_hp_det_pinstate=0;
			switch_set_state(&hsdev->sdev, hsdev->dock_hp_det_pinstate);
			logd("h2w_switch_timer_func dock headphone detect low~ \n");
			break;
		}
		else if(hsdev->dock_hp_det_ups>=5)
		{
			hsdev->dock_hp_det_pinstate=1;
			switch_set_state(&hsdev->sdev, hsdev->dock_hp_det_pinstate);
			logd("h2w_switch_timer_func dock headphone detect high~ \n");
			break;
		}
		counts--;
	}
	if(counts==0){logd("h2w_switch_timer_func dock headphone detect failed \n");};
	hsdev->dock_hp_det_ups=0;
	hsdev->dock_hp_det_downs=0;
	#endif
	}
	#endif
	
	logd("h2w_switch_probe() OUT\r\n");
	return 0;

#ifdef CONFIG_SWITCH_DOCK_H2W
err_register_dock_hp_irq:
	NvOdmGpioInterruptUnregister(hsdev->gpio, hsdev->hp_det_pin, hsdev->hp_det_irq);
#endif
err_register_irq:
	destroy_workqueue(hsdev->workqueue);
err_create_workqueue:
	switch_dev_unregister(&hsdev->sdev);
err_register_sdev:
#ifdef CONFIG_SWITCH_DOCK_H2W
	NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->dock_hp_det_pin);
err_acquire_dock_det_pin:
#endif
	NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->hp_det_pin);
err_acquire_det_pin:
	NvOdmGpioClose(hsdev->gpio);
err_open_gpio:
	kfree(hsdev);
err_alloc_hsdev:
	
	logd("h2w_switch_probe failed\r\n");
	return -1;
}
Пример #28
0
static void h2w_switch_timer_func(unsigned long __dev) 
{
	int state;
	struct h2w_switch_dev *hsdev;
	
	hsdev = (struct h2w_switch_dev *)__dev;

	NvOdmGpioGetState(hsdev->gpio, hsdev->hp_det_pin, &state);
	if(state){hsdev->hp_det_ups++;hsdev->hp_det_downs=0;}
	else {hsdev->hp_det_downs++;hsdev->hp_det_ups=0;}
	
	if(hsdev->hp_det_downs>=5)
	{
		if(hsdev->hp_det_pinstate!=0)
		{
			hsdev->hp_det_pinstate=0;
			//switch_set_state(&hsdev->sdev, !hsdev->pinstate);
			queue_work(hsdev->workqueue, &hsdev->work);
			logd("h2w_switch_timer_func headphone detect low \n");
		}
		hsdev->hp_det_downs=0;
		hsdev->hp_det_ups=0;
	}
	else if(hsdev->hp_det_ups>=5)
	{
		if(hsdev->hp_det_pinstate==0)
		{
			hsdev->hp_det_pinstate=1;
			//switch_set_state(&hsdev->sdev, !hsdev->pinstate);
			queue_work(hsdev->workqueue, &hsdev->work);
			logd("h2w_switch_timer_func headphone detect high \n");
		}
		hsdev->hp_det_downs=0;
		hsdev->hp_det_ups=0;
	}
	
	#ifdef CONFIG_SWITCH_DOCK_H2W
	NvOdmGpioGetState(hsdev->gpio, hsdev->dock_hp_det_pin, &state);
	if(state){hsdev->dock_hp_det_ups++;hsdev->dock_hp_det_downs=0;}
	else {hsdev->dock_hp_det_downs++;hsdev->dock_hp_det_ups=0;}
	
	if(hsdev->dock_hp_det_downs>=5)
	{
		if(hsdev->dock_hp_det_pinstate!=0)
		{
			hsdev->dock_hp_det_pinstate=0;
			//switch_set_state(&hsdev->sdev, !hsdev->pinstate);
			queue_work(hsdev->workqueue, &hsdev->work);
			logd("h2w_switch_timer_func dock headphone detect low \n");
		}
		hsdev->dock_hp_det_downs=0;
		hsdev->dock_hp_det_ups=0;
	}
	else if(hsdev->dock_hp_det_ups>=5)
	{
		if(hsdev->dock_hp_det_pinstate==0)
		{
			hsdev->dock_hp_det_pinstate=1;
			//switch_set_state(&hsdev->sdev, !hsdev->pinstate);
			queue_work(hsdev->workqueue, &hsdev->work);
			logd("h2w_switch_timer_func dock headphone detect high \n");
		}
		hsdev->dock_hp_det_downs=0;
		hsdev->dock_hp_det_ups=0;
	}
	#endif
	
	mod_timer(&hsdev->timer, jiffies + msecs_to_jiffies(80));
	//logd("h2w_switch_timer_func out \n");
}
Пример #29
0
static int headset_switch_probe(struct platform_device *pdev)
{
	struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;
	struct gpio_switch_data *switch_data;
	int ret = 0;
    NvU32 states;


	if (!pdata)
		return -EBUSY;

	switch_data = kzalloc(sizeof(struct gpio_switch_data), GFP_KERNEL);
	if (!switch_data)
		return -ENOMEM;

	switch_data->sdev.name = pdata->name;
	switch_data->gpio = pdata->gpio;
    //switch_data->pin = pdata->pin;
	switch_data->name_on = pdata->name_on;
	switch_data->name_off = pdata->name_off;
	switch_data->state_on = pdata->state_on;
	switch_data->state_off = pdata->state_off;
	switch_data->sdev.print_state = switch_headset_print_state;


    ret = switch_dev_register(&switch_data->sdev);
	if (ret < 0)
		goto err_switch_dev_register;


    if( !s_hGpio )
    {
        s_hGpio = NvOdmGpioOpen();
        if( !s_hGpio )
        {
            goto err_request_gpio;
        }
    }    

    s_hHeadphoneGpioPin = NvOdmGpioAcquirePinHandle(s_hGpio, 'w'-'a', 2);
            //switch_data->gpio, switch_data->pin);

    NvOdmGpioConfig( s_hGpio, s_hHeadphoneGpioPin, NvOdmGpioPinMode_InputData);


	INIT_WORK(&switch_data->work, headset_switch_work);

    //create thread
    if( !g_hDetectEventSema )
        g_hDetectEventSema  = NvOdmOsSemaphoreCreate(0);
    g_DetectThread_exit = 0;
    if( !g_hDetectThread )
        g_hDetectThread = NvOdmOsThreadCreate( (NvOdmOsThreadFunction)DetectThreadFun,
                            (void*)switch_data);

    // headphone ISR      
    if (!NvOdmGpioInterruptRegister(
        s_hGpio, &s_hGpioIntr_Headphone, s_hHeadphoneGpioPin,
        NvOdmGpioPinMode_InputInterruptLow, headset_irq_handler, (void*)switch_data, 0))
    {
        return NV_FALSE;
    }
  

    //detect headphone right now
    NvOdmGpioGetState(s_hGpio,s_hHeadphoneGpioPin,&states);
    if( !states )
    {
            gHeadsetInsertStatus = HEADSET_STATUS_REMOVE;
            NvOdmGpioConfig(s_hGpio,s_hHeadphoneGpioPin,NvOdmGpioPinMode_InputInterruptHigh );
    }
    else
    {
            gHeadsetInsertStatus = HEADSET_STATUS_INSERT;
            NvOdmGpioConfig(s_hGpio,s_hHeadphoneGpioPin,NvOdmGpioPinMode_InputInterruptLow );               
    } 

	/* Perform initial detection */
	//headset_switch_work(&switch_data->work);


	return 0;


err_request_gpio:
    switch_dev_unregister(&switch_data->sdev);
err_switch_dev_register:
	kfree(switch_data);

	return ret;
}
Пример #30
0
static void type_det_work(struct work_struct *work)
{
    NvU32 hook_value =0;
	if (headset_off) return;

    NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, &headset_gpio_status);	
	headset_status = headset_gpio_status;
    
	if( (headset_status == 1) && (headset_type == STAR_NONE))	
	{
#if defined(CONFIG_MACH_STAR_SKT_REV_A)  
		 if(star_get_i2c_busy())
		 {
			  schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_time));	
			lprintk(D_AUDIO, KERN_ERR "@@(Headset_det.c)@@ type_det_work(), i2c is busy\n");
			return;
		 }
		 star_set_i2c_busy();
		star_headsetdet_bias(1);
#else
		headset_Mic_Bias(1);
#endif

	#if HOOK_USE_ADC
		hook_value = headset_get_hook_adc_value();	

		if(hook_value > 350) //20101127 [email protected] detect adc 1200==>350[LGE_LAB1]
			headset_type = STAR_HEADSET;	
		else
			headset_type = STAR_HEADPHONE;
	#else
		NvOdmGpioGetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, &hookkey_gpio_status);	//[email protected] 20100419 for nVidia headset driver
		if(hookkey_gpio_status == 0){ 
		   headset_type = STAR_HEADPHONE;
			hook_value = 1111;
		}
		else{
		   headset_type = STAR_HEADSET;
			hook_value = 2222;
		}
	#endif
	}
	else if(headset_status == 0){
		headset_type = STAR_NONE;
        hook_status = HOOK_RELEASED; 
		input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 0);
		input_sync(headset_sw_data->ip_dev);
    }

	lprintk(D_AUDIO, KERN_ERR "@@(Headset_det.c)@@ type_det_work(), HOOKVALUE %d headset_type = %d\n", hook_value, headset_type);
#if defined(CONFIG_MACH_STAR_SKT_REV_A)  
	if(headset_type != STAR_HEADSET){
		block_hook_int =1;
		star_headsetdet_bias(0);	//20100419 [email protected]  for Headset MIC Bias  ==> framwork function used in kernel ==> error [LGE]
	}
	else{
        block_hook_int =0;
	}
	star_unset_i2c_busy();
#else
	if(headset_type != STAR_HEADSET){
        block_hook_int =1;
		headset_Mic_Bias(0);
	}
    else{
        block_hook_int =0;
	}
#endif
	headset_detecting = 0;

	switch_set_state(&headset_sw_data->sdev, headset_type); 
}