//a@nzy static irqreturn_t rk28_AD_irq_handler(s32 irq, void *dev_id) { rk28printk("\n =================================rk28_AD_irq_handler===================================\n"); rk28printk("========= pm_sleep_status=%d PA0=%d\n", pm_sleep_status, GPIOGetPinLevel(WAKEUP_KEY_PORT)); if( pm_sleep_status == 1) { g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT); rk28printk("========== in sleep: g_wakeup_key_enable=%d g_wake_press=%d\n", g_wakeup_key_enable, g_wake_press); if(g_wakeup_key_enable) { input_report_key(prockAD_button->input_dev,AD1KEY5,1); input_sync(prockAD_button->input_dev); input_report_key(prockAD_button->input_dev,AD1KEY5,0); input_sync(prockAD_button->input_dev); printk("\n%s^^level 2^^Wake Up ^^^^^!!\n",__FUNCTION__); g_wakeup_key_enable = 0; // cmy@20100326: 只有在5S后,或者系统被唤醒后(pm_sleep_status == 1),才能再处理唤醒IRQ setup_timer(&g_wakeup_key_timer, rk28_enable_wakeup_key, (unsigned long)0); g_wakeup_key_timer.expires = jiffies + (5*HZ); add_timer(&g_wakeup_key_timer); } } return IRQ_HANDLED; }
static void rk30_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip) { //#if 0 int i; for (i = 0; i < chip->ngpio; i++) { unsigned pin = chip->base + i; struct gpio_chip *chip = pin_to_gpio_chip(pin); u32 bit = gpio_to_bit(pin); //pin_to_bit const char *gpio_label; if(!chip ||!bit) return; gpio_label = gpiochip_is_requested(chip, i); if (gpio_label) { //seq_printf(s, "[%s] GPIO%s%d: ",gpio_label, chip->label, i); printk("[%s] GPIO%s%d: ", gpio_label, chip->label, i); if (!chip || !bit) { //seq_printf(s, "!chip || !bit\t"); printk("!chip || !bit\t"); return; } GPIOSetPinDirection(chip,bit,GPIO_IN); //seq_printf(s, "pin=%d,level=%d\t", pin,GPIOGetPinLevel(chip,bit)); //seq_printf(s, "\t"); printk("pin=%d,level=%d\t", pin, GPIOGetPinLevel(chip,bit)); printk("\t"); } } //#endif }
void rk28_power_off(void) { local_irq_enable(); /* open for some logs */ rockchip_mux_api_set((char *)PLAY_ON_IOMUX_PINNAME,(unsigned int)PLAY_ON_IOMUX_PINDIR); GPIOPullUpDown(PLAY_ON_IOPIN,GPIOPullDown); rockchip_mux_api_set((char *)PWR_ON_IOMUX_PINNAME,PWR_ON_IOMUX_PINDIR); GPIOSetPinDirection(PWR_ON_IOPIN,GPIO_OUT); GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_LOW); while( 1 ) { rockchip_mux_api_set((char *)PWR_ON_IOMUX_PINNAME,(unsigned int)PWR_ON_IOMUX_PINDIR); GPIOSetPinDirection(PWR_ON_IOPIN,GPIO_OUT); if(GPIOGetPinLevel(PWR_ON_IOPIN) == GPIO_HIGH) GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_LOW); if(GPIOGetPinLevel(PLAY_ON_IOPIN) == GPIO_HIGH) break; } rk28_restart( 0 ); }
static void vol_down_key_handle(struct work_struct *work) { if(GPIOGetPinLevel(VOL_DOWN_IOPIN)){ request_gpio_irq(VOL_DOWN_IOPIN,(pFunc)rk28_key_vol_down_irq_handler,GPIOEdgelFalling,NULL); input_report_key(gMatrixKey->input_dev,KEY_VOLUMEDOWN,0); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] up\n",KEY_VOLUMEDOWN); } else{ request_gpio_irq(VOL_DOWN_IOPIN,(pFunc)rk28_key_vol_down_irq_handler,GPIOEdgelRising,NULL); input_report_key(gMatrixKey->input_dev,KEY_VOLUMEDOWN,1); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] down\n",KEY_VOLUMEDOWN); } }
static void page_up_key_handle(struct work_struct *work) { if(GPIOGetPinLevel(PAGE_UP_IOPIN)){ request_gpio_irq(PAGE_UP_IOPIN,(pFunc)rk28_key_up_irq_handler,GPIOEdgelFalling,NULL); input_report_key(gMatrixKey->input_dev,KEY_LEFTBRACE,0); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] up\n",KEY_LEFTBRACE); } else{ request_gpio_irq(PAGE_UP_IOPIN,(pFunc)rk28_key_up_irq_handler,GPIOEdgelRising,NULL); input_report_key(gMatrixKey->input_dev,KEY_LEFTBRACE,1); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] down\n",KEY_LEFTBRACE); } }
static void rk28_matrix_scan(struct work_struct *work) { tcc_gpiokey_poll_callback(); if(!GPIOGetPinLevel(PLAY_ON_IOPIN)) { pwrScanTimes ++; if(pwrScanTimes == (NUMSEC*ONESEC)) {//surpport long press down input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,1); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] down\n",KEY_WAKEUP); endCallTimes = 100; } if(pwrScanTimes == ((NUMSEC+1)*ONESEC)) {//idendify 1s as long press input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,0); input_sync(gMatrixKey->input_dev); printk_d("keycode[%d] up\n",KEY_WAKEUP); endCallTimes = 100; pwrScanTimes = 0; } return ; } else { if(endCallTimes > 0) endCallTimes--;//delay for decrease jitter } if( pwrScanTimes > SLEEPTIME ) { pwrScanTimes = 0; if(rk2818_get_suspend_flags() != PM_AWAKE) { if(rk2818_get_suspend_flags() == PM_TWOLEVEL_SLEEP) { printk_d("Wake Up\n"); return; } if(endCallTimes == 0) { input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,1); input_sync(gMatrixKey->input_dev); input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,0); input_sync(gMatrixKey->input_dev); printk_d("system to be awake\n"); } } else { if(endCallTimes == 0) { input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,1); input_sync(gMatrixKey->input_dev); input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,0); input_sync(gMatrixKey->input_dev); printk_d("system to be sleep\n"); } } } }
static enum hrtimer_restart xpt2046_dostimer(struct hrtimer *handle) { struct XPT2046_TS_EVENT *ts_dev = container_of(handle, struct XPT2046_TS_EVENT, timer); struct input_dev *xpt2046_ts_dev; int ts_io_pin_status; rk28printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__); rk28printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__); spin_lock_irq(&ts_dev->lock); ts_io_pin_status = GPIOGetPinLevel(PT2046_PENIRQ); rk28printk("************>%s....PE7status=%d\n",__FUNCTION__,ts_io_pin_status); rk28printk("--------<%s>--- ts_dev->pendown = %d, PE7status = %d \n", __FUNCTION__, ts_dev->pendown, ts_io_pin_status); if(unlikely(ts_dev->pendown && ts_io_pin_status)) { xpt2046_ts_dev = ts_dev->input; rk28printk("The touchscreen up!!\n"); //printk("-------------------------------------------The touchscreen up!!\n"); input_report_key(xpt2046_ts_dev,BTN_TOUCH,0); input_sync(xpt2046_ts_dev); ts_dev->pendown = 0; gpio_irq_enable(PT2046_PENIRQ); ClearBuff(); gLastZvalue[0] = 4095; gLastZvalue[1] = 4095; } else { /*still down ,continue with the measurement*/ xpt2046_read_values(ts_dev); xpt2046_send_values(ts_dev); } spin_unlock_irq(&ts_dev->lock); #ifdef CONFIG_ANDROID_POWER if(rk2818_get_suspend_flags() != PM_AWAKE) { rk28_send_wakeup_key(); printk("touch screen wake up\n"); } #endif return HRTIMER_NORESTART; }
static void rk28_adkeyscan_timer(unsigned long data) { unsigned int ADKEY1,code = 0,i; /*Enable AD controller to sample */ prockAD_button->timer.expires = jiffies+msecs_to_jiffies(10); add_timer(&prockAD_button->timer); RockAdcScanning(); if (ADSampleTimes < 4) { ADSampleTimes ++; goto scan_io_key; /* scan gpio button event*/ } ADSampleTimes = 0; #if 0 rockchip_mux_api_set(GPIOF5_APWM3_DPWM3_NAME, IOMUXB_GPIO1_B5); GPIOSetPinDirection(GPIOPortF_Pin5, GPIO_OUT); if (gpioflag) { GPIOSetPinLevel(GPIOPortF_Pin5, GPIO_HIGH); gpioflag = 0; } else { GPIOSetPinLevel(GPIOPortF_Pin5, GPIO_LOW); gpioflag = 1; } #endif /*Get button value*/ ADKEY1=get_rock_adc1(); if(ADKEY1<EmptyADValue) printk("\n ADC1 value=%d \n",ADKEY1); #if 1 //ffhh if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue)) goto scan_io_key1; #endif valuecount++; if(valuecount < 2) goto scan_code; code=find_rock_adkeycode(ADKEY1,ad2valuetab); valuecount = 2; goto scan_code; ///scan_code; scan_io_key1: valuecount = 0; scan_code: if((g_code == 0) && (code == 0)){ goto scan_io_key; } ///DBG("\n key button PE2 == %d \n",GPIOGetPinLevel(GPIOPortE_Pin2)); if(code != 0){ if(valuecount<2) goto scan_io_key; if(g_code == 0){ g_code = code; DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,1); input_sync(prockAD_button->input_dev); goto scan_io_key; }else{ if(g_code != code){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,code); input_report_key(prockAD_button->input_dev,code,1); input_sync(prockAD_button->input_dev); g_code = code; goto scan_io_key; } } } if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); valuecount = 0; g_code = 0; goto scan_io_key; } scan_io_key : // if(!GPIOGetPinLevel(GPIOPortF_Pin0)) if(g_wake_press) { pwrscantimes = 0; g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT); if(g_wake_press) return; } if(!GPIOGetPinLevel(GPIOPortE_Pin2)) { pwrscantimes += 1; if(pwrscantimes == (SEC_NUM * ONESEC_TIMES)) { input_report_key(prockAD_button->input_dev,ENDCALL,1); input_sync(prockAD_button->input_dev); DBG("the kernel come to power down!!!\n"); } if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES)) { pwrscantimes = 0; input_report_key(prockAD_button->input_dev,ENDCALL,0); input_sync(prockAD_button->input_dev); DBG("the kernel come to power up!!!\n"); } return ; } if( pwrscantimes > SLEEP_TIME) { pwrscantimes = 0; printk("========== %s: g_enable_sleep=%d\n", __FUNCTION__, g_enable_sleep); if(g_enable_sleep) { input_report_key(prockAD_button->input_dev,AD1KEY5,1); input_sync(prockAD_button->input_dev); input_report_key(prockAD_button->input_dev,AD1KEY5,0); input_sync(prockAD_button->input_dev); printk("\n%s^^level 1^^Wake or sleep ^^^^^!!\n",__FUNCTION__); } } }
static inline int tcc_gpio_ison(int gpio) { int val = GPIOGetPinLevel(gpio); return (MATRIX_IN_ON == val) ? KEY_STATE_ON : KEY_STATE_OFF; }
static int rk30_gpiolib_get(struct gpio_chip *chip, unsigned offset) { return GPIOGetPinLevel(to_rk30_gpio_bank(chip)->regbase, offset_to_bit(offset)); }
static void rk28_adkeyscan_timer(unsigned long data) { unsigned int ADKEY1,code = 0,i; /*Enable AD controller to sample */ prockAD_button->timer.expires = jiffies+msecs_to_jiffies(10); add_timer(&prockAD_button->timer); RockAdcScanning(); if (ADSampleTimes < 4) { ADSampleTimes ++; goto scan_io_key; /* scan gpio button event*/ } ADSampleTimes = 0; /*Get button value*/ ADKEY1=get_rock_adc1(); if(ADKEY1<EmptyADValue) printk("\n ADC1 value=%d \n",ADKEY1); #if 1 //ffhh if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue)) goto scan_io_key1; #endif valuecount++; if(valuecount < 2) goto scan_code; code=find_rock_adkeycode(ADKEY1,ad2valuetab); valuecount = 2; goto scan_code; ///scan_code; scan_io_key1: valuecount = 0; scan_code: if((g_code == 0) && (code == 0)){ goto scan_io_key; } ///DBG("\n key button PE2 == %d \n",GPIOGetPinLevel(GPIOPortE_Pin2)); if(code != 0){ if(valuecount<2) goto scan_io_key; if(g_code == 0){ g_code = code; DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,1); input_sync(prockAD_button->input_dev); goto scan_io_key; }else{ if(g_code != code){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,code); input_report_key(prockAD_button->input_dev,code,1); input_sync(prockAD_button->input_dev); g_code = code; goto scan_io_key; } } } if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); valuecount = 0; g_code = 0; goto scan_io_key; } scan_io_key : // if(!GPIOGetPinLevel(GPIOPortF_Pin0)) if(!GPIOGetPinLevel(GPIOPortE_Pin2)) { pwrscantimes += 1; if(pwrscantimes == (SEC_NUM * ONESEC_TIMES)) { input_report_key(prockAD_button->input_dev,ENDCALL,1); input_sync(prockAD_button->input_dev); DBG("the kernel come to power down!!!\n"); } if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES)) { pwrscantimes = 0; input_report_key(prockAD_button->input_dev,ENDCALL,0); input_sync(prockAD_button->input_dev); DBG("the kernel come to power up!!!\n"); } return ; } if( pwrscantimes > SLEEP_TIME) { pwrscantimes = 0; if(rk28_pm_status == 0) { if(g_wake == 1) /*already wake up*/ { g_wake = 0; return; } input_report_key(prockAD_button->input_dev,AD1KEY5,1); input_sync(prockAD_button->input_dev); input_report_key(prockAD_button->input_dev,AD1KEY5,0); input_sync(prockAD_button->input_dev); } rk28printk("\n%s^^^^Wake Up ^^^^^!!\n",__FUNCTION__); } }
static void rk28_adkeyscan_timer(unsigned long data) { unsigned int ADKEY1,code = 0; /*Enable AD controller to sample */ prockAD_button->timer.expires = jiffies+msecs_to_jiffies(10); add_timer(&prockAD_button->timer); RockAdcScanning(); if (ADSampleTimes < 4) { ADSampleTimes ++; goto scan_io_key; /* scan gpio button event*/ } ADSampleTimes = 0; /*Get button value*/ ADKEY1=get_rock_adc1(); #ifdef CONFIG_MACH_RK2808SDK if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue)) goto scan_io_key1; valuecount++; if(valuecount < 2) goto scan_code; code=find_rock_adkeycode(ADKEY1,ad2valuetab); valuecount = 2; goto scan_code; ///scan_code; scan_io_key1: valuecount = 0; scan_code: if((g_code == 0) && (code == 0)){ goto scan_io_key; } ///DBG("\n key button PE2 == %d \n",GPIOGetPinLevel(GPIOPortE_Pin2)); if(code != 0){ if(valuecount<2) goto scan_io_key; if(g_code == 0){ g_code = code; DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,1); input_sync(prockAD_button->input_dev); goto scan_io_key; }else{ if(g_code != code){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,code); input_report_key(prockAD_button->input_dev,code,1); input_sync(prockAD_button->input_dev); g_code = code; goto scan_io_key; } } } if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); #ifdef CONFIG_MACH_RK2808SDK input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); #endif valuecount = 0; g_code = 0; goto scan_io_key; } #endif scan_io_key : #ifdef CONFIG_MACH_PWS700AA if(GPIOGetPinLevel(GPIOPortE_Pin3)) #else if(g_wake_press) { pwrscantimes = 0; g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT); if(g_wake_press) return; } if(!GPIOGetPinLevel(WAKEUP_KEY_PORT)) #endif { pwrscantimes += 1; if(pwrscantimes == (SEC_NUM * ONESEC_TIMES)) { input_report_key(prockAD_button->input_dev,ENDCALL,1); input_sync(prockAD_button->input_dev); printk("the kernel come to power down!!!\n"); } if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES)) { pwrscantimes = 0; input_report_key(prockAD_button->input_dev,ENDCALL,0); input_sync(prockAD_button->input_dev); printk("the kernel come to power up!!!\n"); } return ; } if( pwrscantimes > SLEEP_TIME) { pwrscantimes = 0; printk("========== %s: g_enable_sleep=%d\n", __FUNCTION__, g_enable_sleep); if(g_enable_sleep) { input_report_key(prockAD_button->input_dev,AD1KEY5,1); input_sync(prockAD_button->input_dev); input_report_key(prockAD_button->input_dev,AD1KEY5,0); input_sync(prockAD_button->input_dev); printk("\n%s^^level 1^^Wake or sleep ^^^^^!!\n",__FUNCTION__); } } }
static void rk28_adkeyscan_timer(unsigned long data) { unsigned int ADKEY1,ADKEY2,code = 0,i; /*Enable AD controller to sample */ prockAD_button->timer.expires = jiffies+msecs_to_jiffies(20); add_timer(&prockAD_button->timer); // printk("\n LED_Delay_Counter=%d \n",LED_Delay_Counter); if(timercount) { timercount --; if(!timercount) pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW); } RockAdcScanning(); if (ADSampleTimes < 4) { ADSampleTimes ++; goto scan_io_key; /* scan gpio button event*/ } ADSampleTimes = 0; /*Get button value*/ ADKEY1=get_rock_adc1(); //ADKEY2=get_rock_adc2(); if(ADKEY1<EmptyADValue) printk("\n ADC1 value=%d \n",ADKEY1); //printk("\n ADC2 value=%d \n",ADKEY2); /* if(backligh_back_vallue!=ADKEY2){ backligh_back_vallue=ADKEY2; backligh_just_vallue=ADKEY2/3; if(backligh_just_vallue>255) backligh_just_vallue=255; //printk("\n backligh_just_vallue value=%d \n",backligh_just_vallue); //rk28_bl_update_status_for_Test(255-backligh_just_vallue); } */ #if 1 //ffhh if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue)) goto scan_io_key1; #endif valuecount++; if(valuecount < 2) goto scan_code; if(ADKEY1<50) code=AD1KEY3; else code=find_rock_adkeycode(ADKEY1,ad2valuetab); valuecount = 2; goto scan_code; ///scan_code; scan_io_key1: valuecount = 0; scan_code: if((g_code == 0) && (code == 0)){ goto scan_io_key; } ///DBG("\n key button PE2 == %d \n",GPIOGetPinLevel(GPIOPortE_Pin2)); if(code != 0){ if(valuecount<2) goto scan_io_key; if(g_code == 0){ g_code = code; DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,1); input_sync(prockAD_button->input_dev); pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_HIGH); timercount = 20; // mdelay(500); // pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW); goto scan_io_key; }else{ if(g_code != code){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d \n",__func__,__LINE__,code); input_report_key(prockAD_button->input_dev,code,1); input_sync(prockAD_button->input_dev); g_code = code; goto scan_io_key; } } } if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){ DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d \n",__func__,__LINE__,g_code); input_report_key(prockAD_button->input_dev,g_code,0); input_sync(prockAD_button->input_dev); valuecount = 0; g_code = 0; goto scan_io_key; } scan_io_key : // rockchip_mux_api_set(GPIOF5_APWM3_DPWM3_NAME, IOMUXB_GPIO1_B5); //GPIOSetPinDirection(GPIOPortF_Pin5,GPIO_IN); #if 0 if(needfirstonwifi){ if(GPIOGetPinLevel(GPIOPortF_Pin5)){ if(!Wifi_turn_on_flag) { if(firstonwifi!=1){ wifi_turn_on_card(); wifi_power_up_wifi(); printk("GPIOPortF_Pin5 HIGH \n"); Wifi_turn_on_flag=1; Wifi_turn_off_flag=0; } } } else { if(!Wifi_turn_off_flag) { if(firstonwifi!=2){ wifi_turn_off_card(); wifi_power_up_wifi(); printk("GPIOPortF_Pin5 LOW \n"); Wifi_turn_on_flag=0; Wifi_turn_off_flag=1; } } } } #endif for(i=0;i<4;i++){ GPIOSetPinDirection(IoCode[i][0],GPIO_IN); #if 1 if(GPIOGetPinLevel(IoCode[i][0])){ if((IOkeyback!=IoCode[i][1])&&(IOkeyback)){ input_report_key(prockAD_button->input_dev,IOkeyback,0); input_sync(prockAD_button->input_dev); DBG("Key Pb%d up code=%d!!!\n",i,IOkeyback); } IOkeyback=IoCode[i][1]; input_report_key(prockAD_button->input_dev,IoCode[i][1],1); input_sync(prockAD_button->input_dev); DBG("Key Pb%d down code=%d!!!\n",i,IoCode[i][1]); pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_HIGH); timercount = 20; // mdelay(500); // pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW); break; }else if(IOkeyback==IoCode[i][1]){ IOkeyback=0; input_report_key(prockAD_button->input_dev,IoCode[i][1],0); input_sync(prockAD_button->input_dev); DBG("Key Pb%d up code=%d!!!\n",i,IoCode[i][1]); break; } #endif } if(g_wake_press) { pwrscantimes = 0; g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT); if(g_wake_press) return; } // if(!GPIOGetPinLevel(GPIOPortF_Pin0)) if(!GPIOGetPinLevel(WAKEUP_KEY_PORT)) { pwrscantimes += 1; if(pwrscantimes == (SEC_NUM * ONESEC_TIMES)) { input_report_key(prockAD_button->input_dev,ENDCALL,1); input_sync(prockAD_button->input_dev); DBG("the kernel come to power down!!!\n"); LED_Delay_Counter=LED_LIGHT_TIME; } if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES)) { pwrscantimes = 0; input_report_key(prockAD_button->input_dev,ENDCALL,0); input_sync(prockAD_button->input_dev); DBG("the kernel come to power up!!!\n"); } return ; } if( pwrscantimes > SLEEP_TIME) { pwrscantimes = 0; DBG("========== %s: g_enable_sleep=%d\n", __FUNCTION__, g_enable_sleep); if(g_enable_sleep) { input_report_key(prockAD_button->input_dev,AD1KEY5,1); input_sync(prockAD_button->input_dev); input_report_key(prockAD_button->input_dev,AD1KEY5,0); input_sync(prockAD_button->input_dev); rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0); rockchip_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1); } DBG("\n%s^^^^Wake Up ^^^^^!!\n",__FUNCTION__); } }
void ak4183_delay_work(struct work_struct *work) { struct AK4183_TS_EVENT *ts_dev = g_ts_dev; int ak4183_irq_pin_level = 0; int ak4183_input_report_flag = 0; int raw_x[SAMPLE_TIMES] = {0}; /* x raw adc data */ int raw_y[SAMPLE_TIMES] = {0}; /* y raw adc data */ int filtered_x = 0; int filtered_y = 0; int xpos; int ypos; int ret = 0; int i; D("enter!\n"); ak4183_irq_pin_level = GPIOGetPinLevel(GPIOPortE_Pin3); /* touch */ if(ak4183_irq_pin_level == 0){ /* get raw data of x and y */ for(i = 0; i < SAMPLE_TIMES; i++){ ret |= ak4183_read_x(&raw_x[i]); ret |= ak4183_read_y(&raw_y[i]); if(ret != 0){ E("an4183_read xpos or ypos err!\n"); goto fake_touch; } } /* check raw data whether valid */ for (i = 0; i < SAMPLE_TIMES; i++) { if (raw_x[i] == 4095 || raw_x[i] == 0 || raw_y[i] == 4095 || raw_y[i] == 0){ I("raw data invalid\n"); goto fake_touch; } } /* filter raw data */ ret = tp_average_filter(raw_x, &filtered_x); if(ret < 0){ I("x fake touch\n"); goto fake_touch; } ret = tp_average_filter(raw_y, &filtered_y); if (ret < 0){ I("y fake touch\n"); goto fake_touch; } TouchPanelCalibrateAPoint(filtered_x, filtered_y, &xpos, &ypos); xpos = xpos / 4; ypos = ypos / 4; if(tp_state == TP_STATE_IDLE){ input_report_key(ts_dev->input, BTN_TOUCH, 1); ak4183_input_report_flag = 1; tp_state = TP_STATE_DOWN; } if(tp_state == TP_STATE_DOWN){ I("xpos=%d, ypos=%d\n", xpos, ypos); I("gADPoint.x=%d, gADPoint.y=%d\n", gADPoint.x, gADPoint.y); gADPoint.x = filtered_x; gADPoint.y = filtered_y; input_report_abs(ts_dev->input, ABS_X, xpos); input_report_abs(ts_dev->input, ABS_Y, ypos); ak4183_input_report_flag = 1; } } fake_touch: if(ak4183_irq_pin_level == 1 && tp_state == TP_STATE_DOWN){ input_report_key(ts_dev->input, BTN_TOUCH, 0); ak4183_input_report_flag = 1; tp_state = TP_STATE_IDLE; } if(ak4183_input_report_flag != 0){ input_sync(ts_dev->input); } /* still on touch */ if(ak4183_irq_pin_level == 0){ schedule_delayed_work(&ts_dev->work, TP_POLL_PERIOD); } /* untouch, open ts irq */ else{ gpio_irq_enable(GPIOPortE_Pin3); } }