Exemplo n.º 1
0
static void mcs6000_work(struct work_struct *work)
{
	int x1=0, y1 = 0;
#ifdef LG_FW_MULTI_TOUCH
	int x2=0, y2 = 0;
	static int pre_x1, pre_x2, pre_y1, pre_y2;
	static unsigned int s_input_type = NON_TOUCHED_STATE;
#endif
	unsigned int input_type;
	unsigned int key_touch;	
	unsigned char read_buf[READ_NUM];

	static int key_pressed = 0;
	static int touch_pressed = 0;

	struct mcs6000_ts_device *dev 
		= container_of(to_delayed_work(work), struct mcs6000_ts_device, work);

	dev->pendown = !gpio_get_value(dev->intr_gpio);

	/* read the registers of MCS6000 IC */
	if ( i2c_smbus_read_i2c_block_data(dev->client, MCS6000_TS_INPUT_INFO, READ_NUM, read_buf) < 0) {
		printk(KERN_ERR "%s touch ic read error\n", __FUNCTION__);
		goto touch_retry;
	}

	input_type = read_buf[0] & 0x0f;
	key_touch = (read_buf[0] & 0xf0) >> 4;

	x1 = y1 =0;
#ifdef LG_FW_MULTI_TOUCH
	x2 = y2 = 0;
#endif
	x1 = (read_buf[1] & 0xf0) << 4;
	y1 = (read_buf[1] & 0x0f) << 8;

	x1 |= read_buf[2];	
	y1 |= read_buf[3];		

#ifdef LG_FW_MULTI_TOUCH
	if(input_type == MULTI_POINT_TOUCH) {
		s_input_type = input_type;
		x2 = (read_buf[5] & 0xf0) << 4;
		y2 = (read_buf[5] & 0x0f) << 8;
		x2 |= read_buf[6];
		y2 |= read_buf[7];
	}
#endif

	if (dev->pendown) { /* touch pressed case */
#ifdef LG_FW_HARDKEY_BLOCK
		if(dev->hardkey_block == 0)
#endif
		if(key_touch && key_pressed != key_touch) {
			if(key_pressed)
				mcs6000_key_event_touch(key_pressed, RELEASED, dev);
			mcs6000_key_event_touch(key_touch, PRESSED, dev);
			key_pressed = key_touch;
		}

		if(input_type) {
			touch_pressed = 1;

#ifdef LG_FW_MULTI_TOUCH
			if(input_type == MULTI_POINT_TOUCH) {
				mcs6000_multi_ts_event_touch(x1, y1, x2, y2, PRESSED, dev);
				pre_x1 = x1;
				pre_y1 = y1;
				pre_x2 = x2;
				pre_y2 = y2;
			}
			else if(input_type == SINGLE_POINT_TOUCH) {
				mcs6000_multi_ts_event_touch(x1, y1, -1, -1, PRESSED, dev);
				s_input_type = SINGLE_POINT_TOUCH;				
			}
#else
			if(input_type == SINGLE_POINT_TOUCH) {
				mcs6000_single_ts_event_touch(x1, y1, PRESSED, dev);
			}
#endif
#ifdef LG_FW_HARDKEY_BLOCK
			dev->hardkey_block = 1;
#endif
		}
	} 
	else { /* touch released case */
		if(key_pressed) {
			mcs6000_key_event_touch(key_pressed, RELEASED, dev);
			key_pressed = 0;
		}

		if(touch_pressed) {
#ifdef LG_FW_MULTI_TOUCH
			if(s_input_type == MULTI_POINT_TOUCH) {
				DMSG("%s: multi touch release...(%d, %d), (%d, %d)\n", __FUNCTION__,pre_x1,pre_y1,pre_x2,pre_y2);
				mcs6000_multi_ts_event_touch(pre_x1, pre_y1, pre_x2, pre_y2, RELEASED, dev);
				s_input_type = NON_TOUCHED_STATE; 
				pre_x1 = -1; pre_y1 = -1; pre_x2 = -1; pre_y2 = -1;
			} else {
				DMSG("%s: single touch release... %d, %d\n", __FUNCTION__, x1, y1);
				mcs6000_multi_ts_event_touch(x1, y1, -1, -1, RELEASED, dev);
			}
#else
			DMSG("%s: single release... %d, %d\n", __FUNCTION__, x1, y1);
			mcs6000_single_ts_event_touch (x1, y1, RELEASED, dev);
			touch_pressed = 0;
#endif
#ifdef LG_FW_HARDKEY_BLOCK
			hrtimer_cancel(&dev->touch_timer);
			hrtimer_start(&dev->touch_timer, ktime_set(0, 800),
			HRTIMER_MODE_REL);
#endif
		}
	}

touch_retry:
	if (dev->pendown) {
		//ret = schedule_delayed_work(&dev->work, msecs_to_jiffies(TS_POLLING_TIME));
		queue_delayed_work(dev->ts_wq, &dev->work,msecs_to_jiffies(TS_POLLING_TIME));
	} else {
		enable_irq(dev->num_irq);
		DMSG("%s: irq enable\n", __FUNCTION__);
	}
}
static void mcs6000_work(struct work_struct *work)
{
	int x1=0, y1 = 0;
#ifdef LG_FW_MULTI_TOUCH
	int x2=0, y2 = 0;
	static int pre_x1, pre_x2, pre_y1, pre_y2;
	static unsigned int s_input_type = NON_TOUCHED_STATE;
#endif
	unsigned int input_type;
	// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
	//unsigned int key_touch;	
	unsigned char read_buf[READ_NUM];

	// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
	//static int key_pressed = 0;
	static int touch_pressed = 0;

	struct mcs6000_ts_device *dev 
		= container_of(to_delayed_work(work), struct mcs6000_ts_device, work);

	DMSG("[sub]%s\n", __FUNCTION__);

#ifdef SLIDE_SUPPORT
	if(is_touch_suspend == 1)
	{
		DMSG("[sub]%s is_touch_suspend true! pendown forced '0' \n", __FUNCTION__);
		dev->pendown = 0;
	}
	else
#endif
	{
		dev->pendown = !gpio_get_value(dev->intr_gpio);
	}

	// LGE_CHANGE [[email protected]] 2010-08-12, new event
	if (dev->pendown && (saved_count != dev->count)) {
		// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
		/*
		if(key_pressed) {
			mcs6000_key_event_touch(key_pressed, RELEASED, dev);
			key_pressed = 0;
		}
		*/

		if (touch_pressed) {
#ifdef LG_FW_MULTI_TOUCH
			if(s_input_type == MULTI_POINT_TOUCH) {
				DMSG("[sub]%s: multi touch release...(%d, %d), (%d, %d)\n", 
						__FUNCTION__,pre_x1,pre_y1,pre_x2,pre_y2);
				mcs6000_multi_ts_event_touch(pre_x1, pre_y1, pre_x2, pre_y2, 
						RELEASED, dev);
				s_input_type = NON_TOUCHED_STATE; 
				pre_x1 = -1; pre_y1 = -1; pre_x2 = -1; pre_y2 = -1;
			} else {
				DMSG("[sub]%s: single touch release... %d, %d\n", __FUNCTION__, 
						pre_x1, pre_y1);
				mcs6000_multi_ts_event_touch(pre_x1, pre_y1, -1, -1, 
						RELEASED, dev);
				pre_x1 = -1; pre_y1 = -1;
			}
			touch_pressed = 0;
#else
			DMSG("[sub]%s: single release... %d, %d\n", __FUNCTION__, pre_x1, pre_y1);
			mcs6000_single_ts_event_touch (pre_x1, pre_y1, RELEASED, dev);
			pre_x1 = -1; pre_y1 = -1;
			touch_pressed = 0;
#endif
		}
		saved_count = dev->count;
	}

#ifdef SLIDE_SUPPORT
	if(is_touch_suspend == 1)
	{
		DMSG("[sub]%s is_touch_suspend true! pendown assign to parameter \n", __FUNCTION__);
		input_type = NON_TOUCHED_STATE;
		x1 = ts_sub_pdata->ts_x_scrn_max - x1_orig;
		y1 = ts_sub_pdata->ts_y_start + y1_orig;
	}
	else
#endif
	{
		/* read the registers of MCS6000 IC */
		if ( i2c_smbus_read_i2c_block_data(dev->client, MCS6000_TS_INPUT_INFO, READ_NUM, read_buf) < 0) {
			printk(KERN_ERR "[sub]%s touch ic read error\n", __FUNCTION__);
			goto touch_retry;
		}

		input_type = read_buf[0] & 0x0f;
		// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
		//key_touch = (read_buf[0] & 0xf0) >> 4;

		// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
		/*
		x1 = y1 =0;
#ifdef LG_FW_MULTI_TOUCH
		x2 = y2 = 0;
#endif
		*/

/*
		y1 = (read_buf[1] & 0xf0) << 4;
		x1 = (read_buf[1] & 0x0f) << 8;

		y1 |= read_buf[2];	
		x1 |= read_buf[3];
		
		
		

	   	x1_orig = y1;
	    	y1_orig = x1;

	        x1 = ts_sub_pdata->ts_x_scrn_max - x1;
		y1 = ts_sub_pdata->ts_y_start + y1;
*/ 
		
		x1 = (read_buf[1] & 0xf0) << 4;
		y1 = (read_buf[1] & 0x0f) << 8;

		x1 |= read_buf[2];	
		y1 |= read_buf[3];
		
		x1_orig = x1;
	    	y1_orig = y1;

	        //x1 = ts_sub_pdata->ts_x_scrn_max - x1;
		y1 = ts_sub_pdata->ts_y_start + y1;
		
		
#ifdef LG_FW_MULTI_TOUCH
		if(input_type == MULTI_POINT_TOUCH) {
			s_input_type = input_type;
			y2 = (read_buf[5] & 0xf0) << 4;
			x2 = (read_buf[5] & 0x0f) << 8;
			y2 |= read_buf[6];
			x2 |= read_buf[7];
		    x2 = ts_sub_pdata->ts_x_scrn_max - x2;
			y2 = ts_sub_pdata->ts_y_start + y2;
		}
#endif
	}

	if (dev->pendown) { /* touch pressed case */
		// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
		/*
		if(key_touch) {
			mcs6000_key_event_touch(key_touch, PRESSED, dev);
			key_pressed = key_touch;
		}
		*/

		if(input_type) {
			touch_pressed = 1;

			/* exceptional routine for the touch case moving from key area to touch area of touch screen */

			// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
			/*
			if(key_pressed) {
				mcs6000_key_event_touch(key_pressed, RELEASED, dev);
				key_pressed = 0;
			}
			*/
#ifdef LG_FW_MULTI_TOUCH
			if(input_type == MULTI_POINT_TOUCH) {
				mcs6000_multi_ts_event_touch(x1, y1, x2, y2, PRESSED, dev);
				pre_x1 = x1;
				pre_y1 = y1;
				pre_x2 = x2;
				pre_y2 = y2;
			}
			else if(input_type == SINGLE_POINT_TOUCH) {
				mcs6000_multi_ts_event_touch(x1, y1, -1, -1, PRESSED, dev);
				s_input_type = SINGLE_POINT_TOUCH;				
				// LGE_CHANGE [[email protected]] 2010-08-12
				pre_x1 = x1;
				pre_y1 = y1;
			}
#else
			if(input_type == SINGLE_POINT_TOUCH) {
				mcs6000_single_ts_event_touch(x1, y1, PRESSED, dev);
				// LGE_CHANGE [[email protected]] 2010-08-12
				pre_x1 = x1;
				pre_y1 = y1;
			}
#endif				
		}
	} 
	else { /* touch released case */
		// LGE_CHANGE [dojip.kim@lgecom] 2010-08-12, not used
		/*
		if(key_pressed) {
			mcs6000_key_event_touch(key_pressed, RELEASED, dev);
			key_pressed = 0;
		}
		*/

		if(touch_pressed) {
#ifdef LG_FW_MULTI_TOUCH
			if(s_input_type == MULTI_POINT_TOUCH) {
				DMSG("[sub]%s: multi touch release...(%d, %d), (%d, %d)\n", __FUNCTION__,pre_x1,pre_y1,pre_x2,pre_y2);
				mcs6000_multi_ts_event_touch(pre_x1, pre_y1, pre_x2, pre_y2, RELEASED, dev);
				s_input_type = NON_TOUCHED_STATE; 
				pre_x1 = -1; pre_y1 = -1; pre_x2 = -1; pre_y2 = -1;
			} else {
				DMSG("[sub]%s: single touch release... %d, %d\n", __FUNCTION__, x1, y1);
				mcs6000_multi_ts_event_touch(x1, y1, -1, -1, RELEASED, dev);
			}
			// LGE_CHANGE [[email protected]] 2010-08-12
			touch_pressed = 0;
#else
			DMSG("[sub]%s: single release... %d, %d\n", __FUNCTION__, x1, y1);
			mcs6000_single_ts_event_touch (x1, y1, RELEASED, dev);
			touch_pressed = 0;
#endif
		}
	}

/* LGE_CHANGE [[email protected]] 2010-06-12, touch event logging */
#if 0 //#if defined (CONFIG_LGE_DIAGTEST)  // Temp on Flip
	ats_eta_mtc_touch_logging(dev->pendown, x1, y1);
	if(input_type == MULTI_POINT_TOUCH)
		ats_eta_mtc_touch_logging(dev->pendown, x2, y2);
#endif
/* -----------------------------------------------------------------------*/

touch_retry:
	if (dev->pendown) 
    {
		// LGE_CHANGE [[email protected]] 2010-08-22, fix the freezing (from VS660)
		//schedule_delayed_work(&dev->work, msecs_to_jiffies(TS_POLLING_TIME));	
		queue_delayed_work(dev->ts_wq, 
				&dev->work,msecs_to_jiffies(TS_POLLING_TIME));
	} 
	// LGE_CHANGE [[email protected]] 2010-08-12
	/*
	else {
		enable_irq(dev->num_irq);
		DMSG("%s: irq enable\n", __FUNCTION__);
	}
	*/
}