Ejemplo n.º 1
0
/* read xy_data for all current touches */
static int cyttsp4_xy_worker(struct cyttsp4_proximity_data *pd)
{
	struct device *dev = &pd->ttsp->dev;
	struct cyttsp4_sysinfo *si = pd->si;
	u8 num_cur_rec;
	u8 rep_len;
	u8 rep_stat;
	u8 tt_stat;
	int rc = 0;

	/*
	 * Get event data from cyttsp4 device.
	 * The event data includes all data
	 * for all active touches.
	 * Event data also includes button data
	 */
	rep_len = si->xy_mode[si->si_ofs.rep_ofs];
	rep_stat = si->xy_mode[si->si_ofs.rep_ofs + 1];
	tt_stat = si->xy_mode[si->si_ofs.tt_stat_ofs];

	num_cur_rec = GET_NUM_TOUCH_RECORDS(tt_stat);

	if (rep_len == 0 && num_cur_rec > 0) {
		tp_log_err("%s: report length error rep_len=%d num_rec=%d\n",
			   __func__, rep_len, num_cur_rec);
		goto cyttsp4_xy_worker_exit;
	}

	/* check any error conditions */
	if (IS_BAD_PKT(rep_stat)) {
		tp_log_debug("%s: Invalid buffer detected\n", __func__);
		rc = 0;
		goto cyttsp4_xy_worker_exit;
	}

	if (IS_LARGE_AREA(tt_stat))
		tp_log_debug("%s: Large area detected\n", __func__);

	if (num_cur_rec > si->si_ofs.max_tchs) {
		tp_log_err("%s: %s (n=%d c=%d)\n", __func__,
			   "too many tch; set to max tch",
			   num_cur_rec, si->si_ofs.max_tchs);
		num_cur_rec = si->si_ofs.max_tchs;
	}

	/* extract xy_data for all currently reported touches */
	tp_log_debug("%s: extract data num_cur_rec=%d\n", __func__,
		     num_cur_rec);
	if (num_cur_rec)
		cyttsp4_get_proximity_touch(pd, num_cur_rec);
	else
		cyttsp4_report_proximity(pd, false);

	tp_log_debug("%s: done\n", __func__);
	rc = 0;

cyttsp4_xy_worker_exit:
	return rc;
}
/* read xy_data for all current touches */
static int cyttsp4_xy_worker(struct cyttsp4_mt_data *md)
{
	struct device *dev = md->dev;
	struct cyttsp4_sysinfo *si = md->si;
	u8 num_cur_rec;
	u8 rep_len;
	u8 rep_stat;
	u8 tt_stat;
	int rc = 0;

	/*
	 * Get event data from cyttsp4 device.
	 * The event data includes all data
	 * for all active touches.
	 * Event data also includes button data
	 */
	rep_len = si->xy_mode[si->si_ofs.rep_ofs];
	rep_stat = si->xy_mode[si->si_ofs.rep_ofs + 1];
	tt_stat = si->xy_mode[si->si_ofs.tt_stat_ofs];

	num_cur_rec = GET_NUM_TOUCH_RECORDS(tt_stat);

	if (rep_len == 0 && num_cur_rec > 0) {
		dev_err(dev, "%s: report length error rep_len=%d num_tch=%d\n",
			__func__, rep_len, num_cur_rec);
		goto cyttsp4_xy_worker_exit;
	}

	/* check any error conditions */
	if (IS_BAD_PKT(rep_stat)) {
		dev_dbg(dev, "%s: Invalid buffer detected\n", __func__);
		rc = 0;
		goto cyttsp4_xy_worker_exit;
	}

	if (IS_LARGE_AREA(tt_stat)) {
		dev_dbg(dev, "%s: Large area detected\n", __func__);
		/* Do not report touch if configured so */
		if (md->pdata->flags & CY_MT_FLAG_NO_TOUCH_ON_LO)
			num_cur_rec = 0;
	}

	if (num_cur_rec > si->si_ofs.max_tchs) {
		dev_err(dev, "%s: %s (n=%d c=%d)\n", __func__,
			"too many tch; set to max tch",
			num_cur_rec, si->si_ofs.max_tchs);
		num_cur_rec = si->si_ofs.max_tchs;
	}

	/* extract xy_data for all currently reported touches */
	dev_vdbg(dev, "%s: extract data num_cur_rec=%d\n", __func__,
		num_cur_rec);
	if (num_cur_rec)
		cyttsp4_get_mt_touches(md, num_cur_rec);
	else
		cyttsp4_lift_all(md);

	dev_vdbg(dev, "%s: done\n", __func__);
	rc = 0;

cyttsp4_xy_worker_exit:
	return rc;
}
/* read xy_data for all touches for debug */
static int cyttsp4_xy_worker(struct cyttsp4_debug_data *dd)
{
	struct device *dev = &dd->ttsp->dev;
	struct cyttsp4_sysinfo *si = dd->si;
	u8 tt_stat = si->xy_mode[si->si_ofs.tt_stat_ofs];
	u8 num_cur_rec = GET_NUM_TOUCH_RECORDS(tt_stat);
	uint32_t formated_output;
	int rc;

	mutex_lock(&dd->sysfs_lock);
	dd->interrupt_count++;
	formated_output = dd->formated_output;
	mutex_unlock(&dd->sysfs_lock);

	/* Read command parameters */
	rc = cyttsp4_read(dd->ttsp, CY_MODE_OPERATIONAL,
			si->si_ofs.cmd_ofs + 1,
			&si->xy_mode[si->si_ofs.cmd_ofs + 1],
			si->si_ofs.rep_ofs - si->si_ofs.cmd_ofs - 1);
	if (rc < 0) {
		tp_log_err( "%s: read fail on command parameter regs r=%d\n",
				__func__, rc);
	}

	if (si->si_ofs.num_btns > 0) {
		/* read button diff data */
		rc = cyttsp4_read(dd->ttsp, CY_MODE_OPERATIONAL,
				/*  replace with btn_diff_ofs when that field
				 *  becomes supported in the firmware */
				si->si_ofs.tt_stat_ofs + 1 +
				si->si_ofs.max_tchs * si->si_ofs.tch_rec_size,
				si->btn_rec_data,
				si->si_ofs.num_btns * si->si_ofs.btn_rec_size);
		if (rc < 0) {
			tp_log_err( "%s: read fail on button regs r=%d\n",
					__func__, rc);
		}
	}

	/* Interrupt */
#if 0//huawei 0701
	tp_log_info("Interrupt(%u)\n", dd->interrupt_count);
#endif //huawei 0701
	if (formated_output)
		cyttsp4_debug_formated(dev, dd->pr_buf, si, num_cur_rec);
	else
		/* print data for TTHE */
		cyttsp4_pr_buf_op_mode(dev, dd->pr_buf, si, num_cur_rec);

	if (dd->monitor.mntr_status == CY_MNTR_ENABLED) {
		int offset = (si->si_ofs.max_tchs * si->si_ofs.tch_rec_size)
				+ (si->si_ofs.num_btns
					* si->si_ofs.btn_rec_size)
				+ (si->si_ofs.tt_stat_ofs + 1);
		rc = cyttsp4_read(dd->ttsp, CY_MODE_OPERATIONAL,
				offset, &(dd->monitor.sensor_data[0]), 150);
		if (rc < 0)
			tp_log_err( "%s: read fail on sensor monitor regs r=%d\n",
					__func__, rc);
		/* print data for the sensor monitor */
		cyttsp4_debug_print(dev, dd->pr_buf, dd->monitor.sensor_data,
				150, "cyttsp4_sensor_monitor");
	}

#if 0//huawei 0701
	tp_log_info("\n");
#endif //huawei 0701
	tp_log_debug( "%s: done\n", __func__);

	return 0;
}
/* read xy_data for all current touches */
static int cyttsp4_xy_worker(struct cyttsp4_mt_data *md)
{
	struct device *dev = &md->ttsp->dev;
	struct cyttsp4_sysinfo *si = md->si;
	u8 num_cur_rec;
	u8 rep_len;
	u8 rep_stat;
	u8 tt_stat;
	int rc = 0;
#if ZTEMT_CYPRESS_WAKEUP_GESTURE_DEBUG
#else
    unsigned long ids = 0;  //Added by luochangyang, 2013/09/25
#endif
	/*
	 * Get event data from cyttsp4 device.
	 * The event data includes all data
	 * for all active touches.
	 * Event data also includes button data
	 */
	rep_len = si->xy_mode[si->si_ofs.rep_ofs];
	rep_stat = si->xy_mode[si->si_ofs.rep_ofs + 1];
	tt_stat = si->xy_mode[si->si_ofs.tt_stat_ofs];

	num_cur_rec = GET_NUM_TOUCH_RECORDS(tt_stat);

	if (rep_len == 0 && num_cur_rec > 0) {
		dev_err(dev, "%s: report length error rep_len=%d num_tch=%d\n",
			__func__, rep_len, num_cur_rec);
		goto cyttsp4_xy_worker_exit;
	}

	/* check any error conditions */
	if (IS_BAD_PKT(rep_stat)) {
		dev_dbg(dev, "%s: Invalid buffer detected\n", __func__);
		rc = 0;
		goto cyttsp4_xy_worker_exit;
	}

	if (IS_LARGE_AREA(tt_stat)) {
        dev_dbg(dev, "%s: Large area detected\n", __func__);

        /*** ZTEMT Added by luochangyang, 2013/09/25 ***/
    	/* For large area event */
#if ZTEMT_CYPRESS_WAKEUP_GESTURE_DEBUG
		input_report_key(md->input, KEY_POWER, 1);
		input_sync(md->input);

		input_report_key(md->input, KEY_POWER, 0);
		input_sync(md->input);
#else
    	if (md->mt_function.input_report)
    		md->mt_function.input_report(md->input, ABS_MT_TRACKING_ID,
    			0, CY_OBJ_STANDARD_FINGER);

    	input_report_abs(md->input, ABS_MT_PRESSURE, 1000);

    	if (md->mt_function.input_sync)
    		md->mt_function.input_sync(md->input);
    	if (md->mt_function.final_sync)
    		md->mt_function.final_sync(md->input, 0, 1, &ids);
    	if (md->mt_function.report_slot_liftoff)
    		md->mt_function.report_slot_liftoff(md, 1);
    	if (md->mt_function.final_sync)
    		md->mt_function.final_sync(md->input, 1, 1, &ids);
#endif

        cyttsp4_lift_all(md);
        /***ZTEMT END***/

		/* Do not report touch if configured so */
		if (md->pdata->flags & CY_MT_FLAG_NO_TOUCH_ON_LO)
			num_cur_rec = 0;
	}

	if (num_cur_rec > si->si_ofs.max_tchs) {
		dev_err(dev, "%s: %s (n=%d c=%d)\n", __func__,
			"too many tch; set to max tch",
			num_cur_rec, si->si_ofs.max_tchs);
		num_cur_rec = si->si_ofs.max_tchs;
	}

	/* extract xy_data for all currently reported touches */
	dev_vdbg(dev, "%s: extract data num_cur_rec=%d\n", __func__,
		num_cur_rec);
	if (num_cur_rec)
		cyttsp4_get_mt_touches(md, num_cur_rec);
	else
		cyttsp4_lift_all(md);

	dev_vdbg(dev, "%s: done\n", __func__);
	rc = 0;

cyttsp4_xy_worker_exit:
	return rc;
}