示例#1
0
/* process event data from frontcontroller. An event is
 * defined as something which is _not_ initiated
 * by a command _to_ the frontcontroller.
 */
static int processEvent(unsigned char* data, int count)
{

	if(debug)
		dump("processEvent: ", data, count);

	if(count < 5)
		return 0; // no enough data size

	if (data[0] == 0x01 && data[1] == 0x05 && data[4] == 0xFB)
	{
		int key;

		/* 0. claim semaphore */
		down_interruptible(&receive_sem);
			
		dprintk("command RCU complete. Added %i. item\n", receiveCount+1);

		/* 1. copy data */
			
		if (receiveCount == cMaxReceiveQueue) {
		 	printk("FP: ERR: receive queue full!\n");
			/* 2. free semaphore */
			up(&receive_sem);
			return 1;
		}	
			
		memcpy(receive[receiveCount].buffer, data, 5);
		receiveCount++;
			
		// event subsystem passing
		key = translate_fp_key(data, 5);
		if(key) {
			input_report_key(fp_button_dev, key, 1);
			input_sync(fp_button_dev);
			msleep(100);
			input_report_key(fp_button_dev, key, 0);
			input_sync(fp_button_dev);
			//FIXME: Add delay to not report one key press ducplicated
		}

		/* 2. free semaphore */
		up(&receive_sem);
		
		/* 3. wake up threads */
		wake_up_interruptible(&wq);
		return 1;
	}
	
	return 0;
}
示例#2
0
文件: front.c 项目: Audioniek/driver
void scan_key(void)
{
	int i, j;
	u32 key_data = 0;
	unsigned char key_buf[5];

	memset(key_buf, 0, sizeof(key_buf));

	command(0x42);                  /*command2 read key data to Display increment mode*/

	stpio_set_pin(kfront->data, 1);

	for (i = 0; i < 5; i++)
	{
		for (j = 0; j < 8; j++)
		{
			stpio_set_pin(kfront->clk, 1);
			delay(1);
			stpio_set_pin(kfront->clk, 0);
			delay(1);
			if (stpio_get_pin(kfront->data))
			{
				key_buf[i] |= (1 << j);
			}
		}
	}

#if 0
	for (i = 0; i < 5; i++)
	{
		for (j = 0; j < 8; j++)
		{
			dprintk("%d ", (key_buf[i] >> j) & 0x01);
		}
		dprintk("\n");
	}
	dprintk("\n");
#endif

	stpio_set_pin(kfront->clk, 1);

	/*	parse key	*/
	if (key_buf[0] & 0x01)			/*	exit		*/
		key_data = FRONT_EXIT;
	else if (key_buf[0] & 0x08)		/*	ok		*/
		key_data = FRONT_OK;
	else if (key_buf[1] & 0x01)		/*	vol+		*/
		key_data = FRONT_VolUp;
	else if (key_buf[1] & 0x08)		/*	vol-		*/
		key_data = FRONT_VolDn;
	else if (key_buf[2] & 0x01)		/*	power	*/
		key_data = FRONT_STBY;
	else if (key_buf[2] & 0x08)		/*	ch-		*/
		key_data = FRONT_PgDn;
	else if (key_buf[3] & 0x01)		/*	menu	*/
		key_data = FRONT_Menu;
	else if (key_buf[3] & 0x08)		/*	ch+		*/
		key_data = FRONT_PgUp;

	if (key_data)
	{
		int key;
#ifdef REPEAT_KEY_SUPPORT
#ifdef REPEAT_DEACCEL_SUPPORT
		if (prev_key_data != key_data)
			repeat_key_count = 0;

		repeat_key_count++;
#endif
		if (is_repeat_key(key_data))
		{
#ifdef REPEAT_DEACCEL_SUPPORT
			if (repeat_key_count > 1 && repeat_key_count <= MSEC_TO_LOOP_CNT(500))
				return;
#endif
		}
		else
		{
			if (prev_key_data == key_data)
				return;
		}

		prev_key_data = key_data;
		prev_loop_count = cur_loop_count;
#endif

		// event subsystem passing
		key = translate_fp_key(key_data, 5);
		if (key)
		{
			input_report_key(fp_button_dev, key, 1);
			input_sync(fp_button_dev);
			msleep(100);
			input_report_key(fp_button_dev, key, 0);
			input_sync(fp_button_dev);
			//FIXME: Add delay to not report one key press ducplicated
		}

		DVB_RINGBUFFER_WRITE_BYTE(&ci_rbuffer, key_data);
		wake_up_interruptible(&ci_rbuffer.queue);
	}
	else
	{
#ifdef REPEAT_KEY_SUPPORT
		/*	delete chattering	*/
		if ((prev_loop_count + MSEC_TO_LOOP_CNT(200)) <= cur_loop_count)
		{
			prev_key_data = 0;
#ifdef REPEAT_DEACCEL_SUPPORT
			repeat_key_count = 0;
#endif
		}
#endif
	}
}