예제 #1
0
void rk28_send_wakeup_key( void ) 
{
	if(rk2818_get_suspend_flags() != PM_AWAKE ){
	  	rk2818_set_suspend_flags(PM_AWAKE);
		input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,1);
		input_sync(gMatrixKey->input_dev);
		printk_d("keycode[%d] down\n",KEY_WAKEUP);
		input_report_key(gMatrixKey->input_dev,KEY_WAKEUP,0);
		input_sync(gMatrixKey->input_dev);
		printk_d("keycode[%d] up\n",KEY_WAKEUP);
	}
}
예제 #2
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);
	}
}
예제 #3
0
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);
	}
}
예제 #4
0
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");
			}
		}
	}
}
예제 #5
0
int procfile_create(void)
{
    static struct proc_dir_entry* p_proc_file;

    /* create the /proc file */
	p_proc_file = create_proc_entry(PROCFS_NAME, 0644, NULL);
    /*note: for read ops only, "create_proc_read_entry" could be used as below:*/
    /*p_proc_file = create_proc_read_entry(PROCFS_NAME, 0, NULL, procfile_read, NULL);*/
	
	if (p_proc_file == NULL) {
		remove_proc_entry(PROCFS_NAME, NULL);
		printk_a("Could not initialize /proc/%s\n", PROCFS_NAME);
		return -ENOMEM;
	}
	p_proc_file->read_proc  = procfile_read;
	p_proc_file->write_proc = procfile_write;
	p_proc_file->mode 	  = S_IFREG | S_IRUGO;
	p_proc_file->uid 	  = 0;
	p_proc_file->gid 	  = 0;
	p_proc_file->size 	  = 37;

    v_procfile_initialized = TRUE;

	printk_d("/proc/%s created\n", PROCFS_NAME);	
	return 0;	/*OK*/

}
예제 #6
0
void procfile_remove(void)
{
    if(v_procfile_initialized == FALSE)
        return;
    //remove_proc_entry(PROCFS_NAME, 0); 
    remove_proc_entry(PROCFS_NAME, NULL);
    v_procfile_initialized = FALSE;
	printk_d("/proc/%s removed\n", PROCFS_NAME);
}
예제 #7
0
void rk28_send_rtc_wakeup_key( void ) 
{
	if(rk2818_get_suspend_flags() != PM_AWAKE ){
		printk_d("\n");
		rk2818_set_suspend_flags(PM_AWAKE);
		input_report_key(gMatrixKey->input_dev,KEY_RTC_WAKEUP,1);
		input_sync(gMatrixKey->input_dev);
		input_report_key(gMatrixKey->input_dev,KEY_RTC_WAKEUP,0);
		input_sync(gMatrixKey->input_dev);
	}
}
예제 #8
0
/*This function is called when the /proc file is written */
static int procfile_write(struct file *file, const char *buffer, unsigned long count, void *unused)
{
    char procfs_buffer[PROCFS_WRITE_SIZE];
    u32 procfs_buffer_size = count;

	//procfs_buffer_size = count;
	if (procfs_buffer_size > PROCFS_WRITE_SIZE ) {
		procfs_buffer_size = PROCFS_WRITE_SIZE;
	}
	/* write data to the buffer */
	if(copy_from_user(procfs_buffer, buffer, procfs_buffer_size)) {
        printk_a("copy_from_user failed\n");
        return -EFAULT;
    }
    printk_d("buf0 %d, buf1 %d, count %ld, procfs_buffer_size %d\n", procfs_buffer[0], procfs_buffer[1], count, procfs_buffer_size);
    //return procfs_buffer_size;
    return count; /*acknowledge that everything has been read, to avoid procfile_write to be called again! */
}
예제 #9
0
/*This function is called when the /proc file is read*/
static int procfile_read(  char *buffer, char **buffer_location, off_t offset, int buffer_length, int *eof, void *unused)
{
    int ret;
    if (offset > 0) {
		/* subsequent reads are called with offset > 0 */
        *eof = 1; /*signal end of file*/
		ret = 0; /*return 0 bytes stored in buffer*/
	} else {
    	/*first read triggered by cat from /proc => fill the buffer, return the no of bytes written*/
        ret = sprintf(buffer,"blabla\n");
        *eof = 1; /*signal end of file => still one more read will be performed, no way to avoid?*/
        //ret = 0; //if always returning 0, sprintf has no effect and no proc info is displayed to the user
	}

    printk_d("offset %ld, buffer_length %d, *eof %d, ret %d\n", offset, buffer_length, *eof, ret);
    procfile_context_print();
   
	return ret; /*returns the number of bytes stored in the buffer */
}
예제 #10
0
static void inline procfile_context_print(void)
{
    printk_d("preemptible 0x%x\n", preemptible());
    printk_d("in_atomic_preempt_off 0x%x\n", in_atomic_preempt_off());
    printk_d("in_atomic 0x%x\n", in_atomic());
    printk_d("in_nmi 0x%lx\n", in_nmi());
    printk_d("in_serving_softirq 0x%lx\n", in_serving_softirq());
    printk_d("in_interrupt 0x%lx\n", in_interrupt());
    printk_d("in_softirq 0x%lx\n", in_softirq());
    printk_d("in_irq 0x%lx\n", in_irq());
    printk_d("preempt_count 0x%x\n", preempt_count());
    printk_d("irqs_disabled 0x%x\n", irqs_disabled());
    if(current) {
        printk_d("task->comm %s\n", current->comm);
        printk_d("task->flags 0x%x\n", current->flags);
        printk_d("task->state %lu\n", current->state);
        printk_d("task->usage %d\n", atomic_read(&(current->usage)));
        printk_d("task->prio %d\n", current->prio);
        printk_d("task->static_prio %d\n", current->static_prio);
        printk_d("task->normal_prio %d\n", current->normal_prio);
        printk_d("task->rt_priority %d\n", current->rt_priority);
        printk_d("task->policy %d\n", current->policy);
        printk_d("task->pid %d\n", current->pid);
        printk_d("task->tgid %d\n", current->tgid);
    }
    else
        printk_d("task pointer NULL\n");
}
예제 #11
0
static void tcc_gpiokey_poll_callback(void)
{
	int i,j;
	int value;	
	struct gpio_button v;

	gpio_callback_times++;
	if(gpio_callback_times<4)	{
		return;
	} else {
		gpio_callback_times = 0;
	}

	key_in_gpio_init();

	if(touch_key_scan_flag)	{	
		GPIOSetPinLevel(key_of_old_gpio_out, MATRIX_OUT_TURNON);
		value = tcc_gpio_ison(key_of_old_gpio);
		value = tcc_gpio_ison(key_of_old_gpio);
		value = tcc_gpio_ison(key_of_old_gpio);
		
		if(key_of_debounce)	{
			if(KEY_STATE_OFF == value)	{	//released, active low.
				touch_key_scan_flag = 0;
				key_of_debounce = 0;				
			} else {
				if(jiffies - last_key_time > KEY_REPORT_INTERVAL)	{
					key_of_debounce = 0;
					last_key_time = jiffies;
					input_report_key(gMatrixKey->input_dev,key_of_old_key,1);
					input_sync(gMatrixKey->input_dev);
					printk_d("keycode [%d] pressed\n", key_of_old_key);
				}
			}
		} else {
			if(KEY_STATE_OFF == value) {	//released, active low.
				last_key_time = jiffies;
				input_report_key(gMatrixKey->input_dev,key_of_old_key,0);
				input_sync(gMatrixKey->input_dev);
				printk_d("keycode [%d] released\n", key_of_old_key);
				touch_key_scan_flag = 0;
			} else {
			}
		}
	}else{
		int gpio_hasOneKeyPressed = 0;

		// first  turn off all output gpios 
		for (i=0;i<MAX_GPIO_OUT_CNT;i++) {
			GPIOSetPinLevel(gpio_out[i], MATRIX_OUT_TURNOFF);
		}
		
		// then turn on one by one & turn off the pre one
		for (i=0; i<MAX_GPIO_OUT_CNT; i++) {
			// turn on
			{ 					
				GPIOSetPinLevel(gpio_out[i], MATRIX_OUT_TURNON);
				//value = tcc_gpio_ison(gpio_in[0]);		// just for delay
				value = tcc_gpio_ison(gpio_in[0]);
				value = tcc_gpio_ison(gpio_in[0]);
				value = tcc_gpio_ison(gpio_in[0]);
				value = tcc_gpio_ison(gpio_in[0]);
				value = tcc_gpio_ison(gpio_in[0]);
			}

			for (j=0; j<MAX_GPIO_IN_CNT;j++) {
				value = tcc_gpio_ison(gpio_in[j]);
				if(KEY_STATE_ON == value){//pressed.
					gpio_hasOneKeyPressed = 1;
					v.gpio_out = gpio_out[i];
					v.gpio= gpio_in[j];
					v.key_code = gpio_key_code[i][j];
					printk_d("Find key[%d][%d]\n",i,j );
					break;
				}
			}
			
			if (!gpio_hasOneKeyPressed) {  // turn off
				GPIOSetPinLevel(gpio_out[i], MATRIX_OUT_TURNOFF);
			}else{
				break;
			}
		}

		if(gpio_hasOneKeyPressed) {
			/*
			if(!suspend_finished){
				printk("%s: key press during suspend\n", __func__);
				touch_key_scan_flag_during_suspend = 1;
			}
			*/
			key_of_old_gpio = v.gpio;
			key_of_old_key = v.key_code;
			key_of_old_gpio_out = v.gpio_out;
			
			key_of_debounce = 1;
			touch_key_scan_flag = 1;			

			#if	1
				//
				if( (jiffies - last_key_time) > (KEY_REPORT_INTERVAL - msecs_to_jiffies(40))  )	{
					last_key_time = jiffies -KEY_REPORT_INTERVAL + msecs_to_jiffies(40);
				}
				
			#else
			
			if(jiffies - last_key_time > KEY_REPORT_INTERVAL)
			{
				last_key_time = jiffies;
				last_key_state = 1;
				input_report_key(tcc_private->poll_dev->input, tcc_private->old_key, 1);
				input_report_key(tcc_private->poll_dev->input, tcc_private->old_key, 0);
				input_sync(tcc_private->poll_dev->input);
				last_key_state = !last_key_state;
				printk("%s: 3 new key %d pressed\n", __func__, tcc_private->old_key);
			}
			#endif
		}		
	}

	if(touch_key_scan_flag)	{
		return;
	} else {
		//touch_key(dev);
		return;
	}
	
}