Ejemplo n.º 1
0
static void ts_timer(unsigned long arg)
{
    struct ts *ts = (struct ts *)arg;
    
    /* Data has been read, OK to clear the data flag */
    writel(TSSC_CTL_STATE, TSSC_REG(CTL));
    
    /*detect pen up status*/
    if(ts->pen_up_count++ >= TS_PENUP_COUNTER)
    {
        if(ts->use_touch_key)
        {
#ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY
            update_pen_and_key_state(ts, 0, 0, 0);
#else
            ts_update_pen_state(ts, 0, 0, 0);
#endif
        }
        else
        {
            ts_update_pen_state(ts, 0, 0, 0);
        }

        ts->is_first_point = true;
    }
    else
    {
        mod_timer(&ts->timer,
            jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));
    }
}
Ejemplo n.º 2
0
static void ts_late_resume(struct early_suspend *h)
{
    struct ts *ts;
    ts = container_of(h, struct ts, early_suspend);

    enable_irq(ts->irq);
    /* Data has been read, OK to clear the data flag */
    writel(TSSC_CTL_STATE, TSSC_REG(CTL));

    TSSC("%s:msm_touch late resume\n!", __FUNCTION__);
}
Ejemplo n.º 3
0
static void ts_early_suspend(struct early_suspend *h)
{
    struct ts *ts;
    ts = container_of(h, struct ts, early_suspend);

    del_timer_sync(&ts->timer);

#ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY
    if(ts->use_touch_key)
    {
        del_timer_sync(&ts->key_timer);
    }
#endif
    
    writel(0, TSSC_REG(CTL));

    disable_irq(ts->irq);

    TSSC("%s:msm_touch early suspend!\n", __FUNCTION__);
}
Ejemplo n.º 4
0
static irqreturn_t ts_interrupt(int irq, void *dev_id)
{
    u32 avgs, x, y, lx, ly;
    u32 num_op, num_samp;
    u32 status;

    struct ts *ts = dev_id;

    status = readl(TSSC_REG(STATUS));
    avgs = readl(TSSC_REG(AVG12));
    x = avgs & 0xFFFF;
    y = avgs >> 16;

    ts->pen_up_count = 0;
    TSSC("ts_interrupt: status=0x%x, avgs=0x%x\n", status, avgs);
    /* For pen down make sure that the data just read is still valid.
     * The DATA bit will still be set if the ARM9 hasn't clobbered
     * the TSSC. If it's not set, then it doesn't need to be cleared
     * here, so just return.
     */
    if (!(readl(TSSC_REG(CTL)) & TSSC_CTL_DATA))
        goto out;

    /* Data has been read, OK to clear the data flag */
    //writel(TSSC_CTL_STATE, TSSC_REG(CTL));

    /* Valid samples are indicated by the sample number in the status
     * register being the number of expected samples and the number of
     * samples collected being zero (this check is due to ADC contention).
     */
    num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT;
    num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT;

    if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) {
        /* TSSC can do Z axis measurment, but driver doesn't support
         * this yet.
         */
         
        /*
         * REMOVE THIS:
         * These x, y co-ordinates adjustments will be removed once
         * Android framework adds calibration framework.
         */
#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS
        lx = ts->x_max - x;
        ly = ts->y_max - y;
#else
        lx = x;
        ly = y;
#endif

        TSSC("%s: x=%d, y=%d\n", __FUNCTION__, lx, ly);
        
        /*get rid of some wrong point*/
        if((lx == 0) || (lx == X_MAX) || (ly == 0) || (ly == Y_MAX))
        {
            TSSC("ts_outscale: x=%d, y=%d\n", lx, ly);
        }
        else
        {
            if(ts->is_first_point)
            {     
                ts->last_x = ts->save_x = lx;
                ts->last_y = ts->save_y = ly;
                ts->move_fast = false;
                ts->is_first_point = false; 
                if(ts->use_touch_key)
                {
#ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY
                    update_pen_and_key_state(ts, lx, ly, 255);
#else
                    ts_update_pen_state(ts, lx, ly, 255);
#endif
                }
                else
                {
                    ts_update_pen_state(ts, lx, ly, 255);
                }
            }
            else
            {
                if(((max(ts->last_x, lx)-min(ts->last_x, lx)) > TOUCH_OFFSET)
                    || ((max(ts->last_y, ly)-min(ts->last_y, ly)) > TOUCH_OFFSET) )
                {
                    ts->last_x = lx;
                    ts->last_y = ly;

                    if(sqr((int)ts->last_y - (int)ts->save_y) > 60)
                    {
                        ts->move_fast = true;
                    }
                    else
                    {
                        ts->move_fast = false;
                    }
                    ts->save_y = ly;
                    ts->save_x = lx;
                    
                    if(ts->use_touch_key)
                    {
#ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY
                        update_pen_and_key_state(ts, lx, ly, 255);
#else
                        ts_update_pen_state(ts, lx, ly, 255);
#endif
                    }
                    else
                    {
                        ts_update_pen_state(ts, lx, ly, 255);
                    }
                }
            }
        }
        //ts_update_pen_state(ts, lx, ly, 255);
        /* kick pen up timer - to make sure it expires again(!) */
        mod_timer(&ts->timer,
            jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));

    } else
        printk(KERN_INFO "Ignored interrupt: {%3d, %3d},"
                " op = %3d samp = %3d\n",
                 x, y, num_op, num_samp);

out:
    return IRQ_HANDLED;
}
static irqreturn_t ts_interrupt(int irq, void *dev_id) {

	u32 avgs, x, y, lx, ly, x_prime, y_prime;
	u32 num_op, num_samp;
	u32 status;

	struct ts *ts = dev_id;
	status = readl(TSSC_REG(STATUS));
	avgs = readl(TSSC_REG(AVG12));
	x = avgs & 0xFFFF;
	y = avgs >> 16;

	/* For pen down make sure that the data just read is still valid.
	 * The DATA bit will still be set if the ARM9 hasn't clobbered
	 * the TSSC. If it's not set, then it doesn't need to be cleared
	 * here, so just return.
	 */
	if (!(readl(TSSC_REG(CTL)) & TSSC_CTL_DATA))
		goto out;

	/* Data has been read, OK to clear the data flag */
	writel(TSSC_CTL_STATE, TSSC_REG(CTL));
	writel(TSSC_SI_STATE, TSSC_REG(SI));

	/* Valid samples are indicated by the sample number in the status
	 * register being the number of expected samples and the number of
	 * samples collected being zero (this check is due to ADC contention).
	 */
	num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT;
	num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT;

	if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) {
		/* TSSC can do Z axis measurment, but driver doesn't support
		 * this yet.
		 */

		/*
		 * REMOVE THIS:
		 * These x, y co-ordinates adjustments will be removed once
		 * Android framework adds calibration framework.
		 */

		x_prime = y;
		y_prime = x;

		lx = x_prime;
		ly = 3300 - y_prime;  /* 10bit : 827  12bit : 3300 */

		if (msm_tsdebug & 1)
			pr_info("++++++++x=%d, y=%d++++++++\n", lx, ly);

		if ((lx  <  left_x) && (ly > left_y)) {

			if (msm_tsdebug & 1)
				pr_info("%s: x=%d, y=%d\n", leftkeyname, lx, ly);

			if (ts->keypad == 0) {
				pr_debug("input report %s\n", leftkeyname);
				input_report_key(ts->input, LEFT_KEY, 1);
				ts->keypad = LEFT_KEY;
			}

		} else if ((lx > right_x) && (ly > right_y)) {
			if (msm_tsdebug & 1)
				pr_info("%s: x=%d, y=%d\n", rightkeyname, lx, ly);

			if (ts->keypad == 0) {
				pr_debug("input report %s\n", rightkeyname);
				input_report_key(ts->input, RIGHT_KEY, 1);
				ts->keypad = RIGHT_KEY;
				ts_key_event = 1;
			}

		} else {
			if (PreRejectTouchCount > preRejectValue) {
				ts_update_pen_state(ts, lx, ly, 255);
			} else {
				PreRejectTouchCount++;
			}
		}

		/* kick pen up timer - to make sure it expires again(!) */
		mod_timer(&ts->timer, jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));

	} else
		pr_info("Ignored interrupt: {%3d, %3d},"
				" op = %3d samp = %3d\n",
				x, y, num_op, num_samp);

out:
		return IRQ_HANDLED;
}
Ejemplo n.º 6
0
static irqreturn_t ts_interrupt(int irq, void *dev_id)
{
	u32 avgs, x, y, lx, ly;
	u32 num_op, num_samp;
	u32 status;

	struct ts *ts = dev_id;

	status = readl(TSSC_REG(STATUS));
	avgs = readl(TSSC_REG(AVG12));
	x = avgs & 0xFFFF;
	y = avgs >> 16;

	/* For pen down make sure that the data just read is still valid.
	 * The DATA bit will still be set if the ARM9 hasn't clobbered
	 * the TSSC. If it's not set, then it doesn't need to be cleared
	 * here, so just return.
	 */

	if (!(readl(TSSC_REG(CTL)) & TSSC_CTL_DATA))
		goto out;

	/* Data has been read, OK to clear the data flag */
	writel(TSSC_CTL_STATE, TSSC_REG(CTL));

	/* Valid samples are indicated by the sample number in the status
	 * register being the number of expected samples and the number of
	 * samples collected being zero (this check is due to ADC contention).
	 */
	num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT;
	num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT;

	if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) {
		/* TSSC can do Z axis measurment, but driver doesn't support
		 * this yet.
		 */

		/*
		 * REMOVE THIS:
		 * These x, y co-ordinates adjustments will be removed once
		 * Android framework adds calibration framework.
		 */
#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS
		lx = ts->x_max - x;
		ly = ts->y_max - y;
#else
		lx = x;
		ly = y;
#endif
		ly = ts->y_max - ly;
		lx -= 100;
		ly -= 50;
		ts_update_pen_state(ts, lx, ly, 255);
		/* kick pen up timer - to make sure it expires again(!) */
		mod_timer(&ts->timer,
			jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));

	} else
		printk(KERN_INFO "Ignored interrupt: {%3d, %3d},"
				" op = %3d samp = %3d\n",
				 x, y, num_op, num_samp);

out:
	return IRQ_HANDLED;
}
Ejemplo n.º 7
0
static irqreturn_t ts_interrupt(int irq, void *dev_id)
{
	u32 avgs, x, y, lx, ly;
	u32 num_op, num_samp;
	u32 status;

#if !defined(CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS)
    int sx, sy;
#endif

	struct ts *ts = dev_id;

	status = readl(TSSC_REG(STATUS));
	avgs = readl(TSSC_REG(AVG12));

#if !HUAWEI_HWID(S70)
	x = avgs & 0xFFFF;
	y = avgs >> 16;
#else
#if HWVERID_HIGHER(S70, T1)
	x = avgs & 0xFFFF;
	y = avgs >> 16;
#else
	x = avgs >> 16;
	y = avgs & 0xFFFF;
#endif
#endif

	/* For pen down make sure that the data just read is still valid.
	 * The DATA bit will still be set if the ARM9 hasn't clobbered
	 * the TSSC. If it's not set, then it doesn't need to be cleared
	 * here, so just return.
	 */
	if (!(readl(TSSC_REG(CTL)) & TSSC_CTL_DATA))
		goto out;

	/* Data has been read, OK to clear the data flag */
	writel(TSSC_CTL_STATE, TSSC_REG(CTL));

	/* Valid samples are indicated by the sample number in the status
	 * register being the number of expected samples and the number of
	 * samples collected being zero (this check is due to ADC contention).
	 */
	num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT;
	num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT;

	if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) {
		/* TSSC can do Z axis measurment, but driver doesn't support
		 * this yet.
		 */

		/*
		 * REMOVE THIS:
		 * These x, y co-ordinates adjustments will be removed once
		 * Android framework adds calibration framework.
		 */
#if !HUAWEI_HWID(S70)
#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS
        lx = 1024 -(ts->x_max + 25 - x);
        ly = (ts->y_max + 25 - y);
#else
        lx = x;
        ly = y;
#endif
#else
#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS
#if HWVERID_HIGHER(S70, T1)
		lx = 1024 - (ts->x_max + 25 - x);
		ly = ts->y_max + 25 - y;
#else
		lx = ts->x_max + 25 - x;
		ly = 1024 - (ts->y_max + 25 - y);
#endif
#else
#if HWVERID_HIGHER(S70, T1)
		lx = (tsp_ul_50x50.x > tsp_dr_50x50.x) ? (ts->x_max - x) : x;
		ly = (tsp_ul_50x50.y > tsp_dr_50x50.y) ? (ts->y_max - y) : y;

		sx = (lx - tsp_origin_convert.x) 
			 * (lcd_size.x - 100)
			 * ts->x_max 
			 	/ ((tsp_dr_50x50_convert.x - tsp_ul_50x50_convert.x) * lcd_size.x);
		sy = (ly - tsp_origin_convert.y) 
			 * (lcd_size.y - 100)
			 * ts->y_max 
			 	/ ((tsp_dr_50x50_convert.y - tsp_ul_50x50_convert.y) * lcd_size.y);

        if (sx < 0) {
            lx = 0;
        } else if (sx > ts->x_max) {
            lx = ts->x_max;
        } else {
        	lx = sx;
        }

        if (sy < 0) {
            ly = 0;
        } else if (sy > ts->y_max) {
            ly = ts->y_max;
        } else {
        	ly = sy;
        }
#else
        lx = x;
        ly = y;
#endif
#endif
#endif

#if 1
		

		if (1 == ts_filter(lx, ly, &lx, &ly)) {
			ts_update_pen_state(ts, lx, ly, 255);	
		} else {
		}
#else
		ts_update_pen_state(ts, lx, ly, 255);
#endif		
		mod_timer(&ts->timer,
			jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));

	} else
		printk(KERN_INFO "Ignored interrupt: {%3d, %3d},"
				" op = %3d samp = %3d\n",
				 x, y, num_op, num_samp);

out:
	return IRQ_HANDLED;
}
static irqreturn_t ts_interrupt(int irq, void *dev_id)
{
	u32 avgs, x, y, lx, ly, x_prime, y_prime;
	u32 num_op, num_samp;
	u32 status;

	struct ts *ts = dev_id;
	status = readl(TSSC_REG(STATUS));
	avgs = readl(TSSC_REG(AVG12));
	x = avgs & 0xFFFF;
	y = avgs >> 16;

	/* For pen down make sure that the data just read is still valid.
	 * The DATA bit will still be set if the ARM9 hasn't clobbered
	 * the TSSC. If it's not set, then it doesn't need to be cleared
	 * here, so just return.
	 */
	if (!(readl(TSSC_REG(CTL)) & TSSC_CTL_DATA))
		goto out;

	/* Data has been read, OK to clear the data flag */
	writel(TSSC_CTL_STATE, TSSC_REG(CTL));
    writel(TSSC_SI_STATE, TSSC_REG(SI));

	/* Valid samples are indicated by the sample number in the status
	 * register being the number of expected samples and the number of
	 * samples collected being zero (this check is due to ADC contention).
	 */
	num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT;
	num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT;

	if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) {
		/* TSSC can do Z axis measurment, but driver doesn't support
		 * this yet.
		 */

		/*
		 * REMOVE THIS:
		 * These x, y co-ordinates adjustments will be removed once
		 * Android framework adds calibration framework.
		 */
		
		x_prime = y;
		y_prime = x;

#if defined(CONFIG_MACH_MSM7X27_SWIFT)
		lx = x_prime;
		ly = 3300 - y_prime;  /* 10bit : 827  12bit : 3300 */
#else
#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS
		lx = ts->x_max + 25 - x;
		ly = ts->y_max + 25 - y;
		if (machine_is_msm7201a_surf()) {
			if (lx > 435) {
				/* Max out x for points lying outside hvga display */
				lx = X_MAX;
			} else {
				/* Scale x for hvga display */
				if (lx < 250)
					lx = lx * 2 - 55;
				else if (lx > 250 && lx < 260)
					lx = lx * 2;
				else
					lx = lx * 2 + 70;
			}
		} else {
			/* manipulate x,y co-ordinates for ffa */
			if (lx > 700 || ly > 820) {
				/* Max out x for points lying outside hvga display */
				lx = X_MAX;
				ly = Y_MAX;
			} else {
				if (ly < 700 && ly > 280) {
					lx = lx * 2 - 250 ;
					ly = ly  + 160;
				} else if (lx > 530)
					lx = lx * 2 + 30;
				else if (ly < 280)
					ly = ly - 50;
				else
					ly = ly + 250;
			}
		}
#else
		lx = x;
		ly = y;
#endif
#endif

		if (msm_tsdebug & 1)
			printk("++++++++x=%d, y=%d++++++++\n", lx, ly);

		if ((lx  <  menu_x) && (ly > menu_y)) {
#if defined(CONFIG_MACH_MSM7X27_SWIFT_REV_1)
			if (msm_tsdebug & 1)
				printk("Menu key : x=%d, y=%d\n", lx, ly);
			
			if (ts->keypad == 0) {
				printk("input report MENU key\n");
				input_report_key(ts->input, KEY_MENU, 1);
				ts->keypad = KEY_MENU;
			}
#else
			if (msm_tsdebug & 1)
				printk("Home key : x=%d, y=%d\n", lx, ly);
			
			if (ts->keypad == 0) {
				printk("input report HOME key\n");
				input_report_key(ts->input, KEY_HOME, 1);
				ts->keypad = KEY_HOME;
			}
#endif 
		} else if ((lx > back_x) && (ly > back_y)) {
			if (msm_tsdebug & 1)
				printk("Back key : x=%d, y=%d\n", lx, ly);

			if (ts->keypad == 0) {
				printk("input report BACK key\n");
				input_report_key(ts->input, KEY_BACK, 1);
				ts->keypad = KEY_BACK;
				ts_key_event = 1;
			}	
		
		} else {
			if (PreRejectTouchCount > preRejectValue) {
				ts_update_pen_state(ts, lx, ly, 255);
			} else {
				PreRejectTouchCount++;
			}
		}
		
		/* kick pen up timer - to make sure it expires again(!) */
		mod_timer(&ts->timer, jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));

	} else
		printk(KERN_INFO "Ignored interrupt: {%3d, %3d},"
				" op = %3d samp = %3d\n",
				x, y, num_op, num_samp);

out:
		return IRQ_HANDLED;
}