Ejemplo n.º 1
0
static int check_debug_data(struct melfas_ts_data *ts)
{
	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int gpio = ts->pdata->gpio_int;
	int count = 0;

	disable_irq(ts->client->irq);
	/* enter the debug mode */
	write_buffer[0] = 0xB0;
	write_buffer[1] = 0x1A;
	write_buffer[2] = 0x0;
	write_buffer[3] = 0x0;
	write_buffer[4] = 0x0;
	write_buffer[5] = 0x01;
	melfas_i2c_write(ts->client, (char *)write_buffer, 6);

	/* wating for the interrupt */
	while (gpio_get_value(gpio)) {
		pr_info(".");
		udelay(100);
		count++;
		if (count == 100000) {
			enable_irq(ts->client->irq);
			return -1;
		}
	}

	if (debug_print)
		pr_info("[TSP] read dummy\n");

	/* read the dummy data */
	melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);

	if (debug_print)
		pr_info("[TSP] read inspenction data\n");
	write_buffer[5] = 0x02;
	for (sensing_line = 0; sensing_line < X_LINE; sensing_line++) {
		for (exciting_line = 0; exciting_line < Y_LINE;\
			exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);
			reference_data[exciting_line + sensing_line * Y_LINE] =
			    (read_buffer[1] & 0xf) << 8 | read_buffer[0];
		}
	}
	pr_info("[TSP] Reading data end.\n");

	msleep(200);
	melfas_ts_suspend(ts->client, PMSG_SUSPEND);

	msleep(200);
	melfas_ts_resume(ts->client);

	enable_irq(ts->client->irq);
	return 0;
}
Ejemplo n.º 2
0
static ssize_t set_debug_data2(struct device *dev,
					struct device_attribute *attr,
					const char *buf,
					size_t count)
{

	struct melfas_ts_data *ts = dev_get_drvdata(dev);

	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int gpio = ts->pdata->gpio_int;

/*	if (!ts->tsp_status) {
		pr_info("[TSP] call set_debug_data2 but TSP status OFF!");
		return count;
	}
*/
	disable_irq(ts->client->irq);

	/* enter the debug mode */
	write_buffer[0] = 0xB0;
	write_buffer[1] = 0x1A;
	write_buffer[2] = 0x0;
	write_buffer[3] = 0x0;
	write_buffer[4] = 0x0;
	write_buffer[5] = 0x01;
	melfas_i2c_write(ts->client, (char *)write_buffer, 6);

	/* wating for the interrupt*/
	while (gpio_get_value(gpio)) {
		pr_info(".");
		udelay(100);
	}

	/* read the dummy data */
	melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);

	pr_info("[TSP] read Inspection data\n");
	write_buffer[5] = 0x02;
	for (sensing_line = 0; sensing_line < X_LINE; sensing_line++) {
		for (exciting_line = 0; exciting_line < Y_LINE;
							exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);
			inspection_data[exciting_line +
						sensing_line * Y_LINE] =
				(read_buffer[1] & 0xf) << 8 | read_buffer[0];
		}
	}
	ts->power(0);
	mdelay(200);
	ts->power(1);

	msleep(200);
	enable_irq(ts->client->irq);
	return count;
}
Ejemplo n.º 3
0
static ssize_t set_tsp_threshold_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct melfas_ts_data *ts = dev_get_drvdata(dev);
	u8 threshold;

	melfas_i2c_read(ts->client, P5_THRESHOLD, 1, &threshold);

	return sprintf(buf, "%d\n", threshold);
}
Ejemplo n.º 4
0
static ssize_t
show_threshold(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct melfas_ts_data *ts = dev_get_drvdata(dev);
	u8 threshold;

	if (!tsp_enabled)
		return 0;

	melfas_i2c_read(ts->client, TS_THRESHOLD, 1, &threshold);

	return sprintf(buf, "%d\n", threshold);
}
Ejemplo n.º 5
0
static int check_debug_data(struct melfas_ts_data *ts)
{
	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int ret = 0;
	int gpio = ts->client->irq - NR_MSM_IRQS;

	disable_irq(ts->client->irq);

	/* enter the debug mode */

	write_buffer[0] = 0xA0;
	write_buffer[1] = 0x1A;
	write_buffer[2] = 0x0;
	write_buffer[3] = 0x0;
	write_buffer[4] = 0x0;

	if (debug_print)
		pr_info("[TSP] read inspenction data\n");
	write_buffer[5] = 0x03;
	for (sensing_line = 0; sensing_line < 14; sensing_line++) {
		printk("sensing_line %02d ==> ", sensing_line);
		for (exciting_line =0; exciting_line < 26; exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);
			lntensity_data[exciting_line + sensing_line * 26] =
				(read_buffer[1] & 0xf) << 8 | read_buffer[0];
			printk("%d.", lntensity_data[exciting_line + sensing_line * 26]);
			if(inspection_data[exciting_line + sensing_line * 26] < 900 
			|| inspection_data[exciting_line + sensing_line * 26] > 3000)
				ret = -1;
		}
		printk(" \n");
	}
	pr_info("[TSP] Reading data end.\n");

	enable_irq(ts->client->irq);

	return ret;
}
Ejemplo n.º 6
0
static void check_intensity_data(struct melfas_ts_data *ts, int num)
{
	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int gpio = ts->pdata->gpio_int;
	int i = 0, ret;

	if (0 == reference_data[0]) {
		disable_irq(ts->client->irq);

		/* enter the debug mode */
		write_buffer[0] = 0xB0;
		write_buffer[1] = 0x1A;
		write_buffer[2] = 0x0;
		write_buffer[3] = 0x0;
		write_buffer[4] = 0x0;
		write_buffer[5] = 0x01;
		melfas_i2c_write(ts->client, (char *)write_buffer, 6);

		/* wating for the interrupt*/
		while (gpio_get_value(gpio)) {
			pr_info(".");
			udelay(100);
		}

		/* read the dummy data */
		melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);

		if (debug_print)
			pr_info("[TSP] read the dummy data\n");

		write_buffer[5] = 0x07;
		for (sensing_line = 0; sensing_line < X_LINE; sensing_line++) {
			for (exciting_line = 0; exciting_line < Y_LINE;
							exciting_line++) {
				write_buffer[2] = exciting_line;
				write_buffer[3] = sensing_line;
				melfas_i2c_write(ts->client,
						(char *)write_buffer, 6);
				melfas_i2c_read(ts->client, 0xBF, 2,
								read_buffer);
				reference_data[exciting_line +
						sensing_line * Y_LINE] =
					(read_buffer[1] & 0xf) << 8
						| read_buffer[0];
			}
		}
		msleep(200);
		melfas_ts_suspend(ts->client, PMSG_SUSPEND);

		msleep(200);
		melfas_ts_resume(ts->client);

		msleep(100);
		enable_irq(ts->client->irq);
		msleep(100);
	}

	disable_irq(ts->client->irq);
	release_all_fingers(ts);

	write_buffer[0] = 0xB0;
	write_buffer[1] = 0x1A;
	write_buffer[2] = 0x0;
	write_buffer[3] = 0x0;
	write_buffer[4] = 0x0;
	write_buffer[5] = 0x04;
	for (sensing_line = 0; sensing_line < X_LINE; sensing_line++) {
		for (exciting_line = 0; exciting_line < Y_LINE;\
			exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xBF, 2, read_buffer);
			intensity_data[exciting_line + sensing_line * Y_LINE] =
			    (read_buffer[1] & 0xf) << 8 | read_buffer[0];
		}
	}
	enable_irq(ts->client->irq);
}
Ejemplo n.º 7
0
static void melfas_ts_get_data(struct work_struct *work)
{
	struct melfas_ts_data *ts =
	    container_of(work, struct melfas_ts_data, work);
	int ret = 0, i;
	int _touch_is_pressed;
	u8 read_num = 0, FingerID = 0;
	u8 buf[TS_READ_REGS_LEN];
	int pre_status = 0;

	ret = melfas_i2c_read(ts->client,
		TS_READ_START_ADDR, 1, &read_num);
	if (ret < 0) {
		pr_err("%s: i2c failed(%d)\n", __func__, __LINE__);
		return ;
	}

	if (read_num > 0) {
		ret = melfas_i2c_read(ts->client,
			TS_READ_START_ADDR2, read_num, buf);
		if (ret < 0) {
			pr_err("%s: i2c failed(%d)\n", \
				__func__, __LINE__);
			return ;
		}

		switch (buf[0]) {
		case TSP_STATUS_ESD:
			printk(KERN_DEBUG "[TSP] ESD protection.\n");
			disable_irq_nosync(ts->client->irq);
			ts->power(0);
			TSP_force_released();
			mdelay(200);
			ts->power(1);
			mdelay(200);
			enable_irq(ts->client->irq);
			return ;

		default:
			break;
		}

		if (read_num % 8 != 0) {
			pr_err("[TSP] incorrect read_num  %d\n", read_num);
			read_num = (read_num / 8) * 8;
		}

		for (i = 0; i < read_num; i = i + 8) {
			FingerID = (buf[i] & 0x0F) - 1;
			g_Mtouch_info[FingerID].posX =
			    (uint16_t) (buf[i + 1] & 0x0F) << 8 | buf[i + 2];
			g_Mtouch_info[FingerID].posY =
			    (uint16_t) (buf[i + 1] & 0xF0) << 4 | buf[i + 3];
#if !defined(CONFIG_MACH_C1) && !defined(CONFIG_MACH_C1VZW) && \
			!defined(CONFIG_MACH_M0) && \
			!defined(CONFIG_MACH_SLP_PQ) && \
			!defined(CONFIG_MACH_SLP_PQ_LTE) && \
			!defined(CONFIG_MACH_M3)
			g_Mtouch_info[FingerID].posX =
			    720 - g_Mtouch_info[FingerID].posX;
			g_Mtouch_info[FingerID].posY =
			    1280 - g_Mtouch_info[FingerID].posY;
#endif
			g_Mtouch_info[FingerID].width = buf[i + 4];
			g_Mtouch_info[FingerID].angle =
			    (buf[i + 5] >=
			     127) ? (-(256 - buf[i + 5])) : buf[i + 5];
			g_Mtouch_info[FingerID].major = buf[i + 6];
			g_Mtouch_info[FingerID].minor = buf[i + 7];
			g_Mtouch_info[FingerID].palm = (buf[i] & 0x10) >> 4;
			pre_status = g_Mtouch_info[FingerID].status;
			if ((buf[i] & 0x80) == 0) {
				g_Mtouch_info[FingerID].strength = 0;
				g_Mtouch_info[FingerID].status =
					TSP_STATE_RELEASE;
			} else {
				g_Mtouch_info[FingerID].strength = buf[i + 4];

				if (TSP_STATE_PRESS == \
					g_Mtouch_info[FingerID].status)
					g_Mtouch_info[FingerID].status =
						TSP_STATE_MOVE;
				else
					g_Mtouch_info[FingerID].status =
						TSP_STATE_PRESS;
			}
			/*g_Mtouch_info[FingerID].width = buf[i + 5];*/
		}

	}
Ejemplo n.º 8
0
static void check_intensity_data(struct melfas_ts_data *ts)
{

	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int gpio = ts->client->irq - NR_MSM_IRQS;

	disable_irq(ts->client->irq);
	if (0 == inspection_data[0]) {
		/* enter the debug mode */
		write_buffer[0] = 0xA0;
		write_buffer[1] = 0x1A;
		write_buffer[2] = 0x0;
		write_buffer[3] = 0x0;
		write_buffer[4] = 0x0;
		write_buffer[5] = 0x01;
		melfas_i2c_write(ts->client, (char *)write_buffer, 6);

		/* wating for the interrupt*/
		while (gpio_get_value(gpio)) {
			printk(".");
			udelay(100);
		}

		/* read the dummy data */
		melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);

		write_buffer[5] = 0x02;
		for (sensing_line = 0; sensing_line < 14; sensing_line++) {
			for (exciting_line =0; exciting_line < 26; exciting_line++) {
				write_buffer[2] = exciting_line;
				write_buffer[3] = sensing_line;
				melfas_i2c_write(ts->client, (char *)write_buffer, 6);
				melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);
				inspection_data[exciting_line + sensing_line * 26] =
					(read_buffer[1] & 0xf) << 8 | read_buffer[0];
			}
		}
		melfas_ts_suspend(ts->client, PMSG_SUSPEND);
		msleep(200);
		melfas_ts_resume(ts->client);
	}

	write_buffer[0] = 0xA0;
	write_buffer[1] = 0x1A;
	write_buffer[4] = 0x0;
	write_buffer[5] = 0x04;
	for (sensing_line = 0; sensing_line < 14; sensing_line++) {
		for (exciting_line =0; exciting_line < 26; exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);
			lntensity_data[exciting_line + sensing_line * 26] =
				(read_buffer[1] & 0xf) << 8 | read_buffer[0];
		}
	}
	enable_irq(ts->client->irq);
/*
	pr_info("[TSP] lntensity data");
	int i;
	for (i = 0; i < 14*16; i++) {
		if (0 == i % 26)
			printk("\n");
		printk("%2u, ", lntensity_data[i]);
	}
*/
}
Ejemplo n.º 9
0
static int check_delta_data(struct melfas_ts_data *ts)
{
	u8 write_buffer[6];
	u8 read_buffer[2];
	int sensing_line, exciting_line;
	int gpio = ts->client->irq - NR_MSM_IRQS;
	int ret = 0;
	disable_irq(ts->client->irq);
	/* enter the debug mode */
	write_buffer[0] = 0xA0;
	write_buffer[1] = 0x1A;
	write_buffer[2] = 0x0;
	write_buffer[3] = 0x0;
	write_buffer[4] = 0x0;
	write_buffer[5] = 0x01;
	melfas_i2c_write(ts->client, (char *)write_buffer, 6);

	/* wating for the interrupt*/
	while (gpio_get_value(gpio)) {
		printk(".");
		udelay(100);
	}

	if (debug_print)
		pr_info("[TSP] read dummy\n");

	/* read the dummy data */
	melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);

	if (debug_print)
		pr_info("[TSP] read inspenction data\n");
	write_buffer[5] = 0x02;
	for (sensing_line = 0; sensing_line < 14; sensing_line++) {
		for (exciting_line =0; exciting_line < 26; exciting_line++) {
			write_buffer[2] = exciting_line;
			write_buffer[3] = sensing_line;
			melfas_i2c_write(ts->client, (char *)write_buffer, 6);
			melfas_i2c_read(ts->client, 0xA8, 2, read_buffer);
			inspection_data[exciting_line + sensing_line * 26] =
				(read_buffer[1] & 0xf) << 8 | read_buffer[0];
			printk("%d.", inspection_data[exciting_line + sensing_line * 26]);
			if(inspection_data[exciting_line + sensing_line * 26] < 100 
			|| inspection_data[exciting_line + sensing_line * 26] > 900)
				ret = -1;
		}
		printk(" \n");
	}
	pr_info("[TSP] Reading data end.\n");

//	release_all_fingers(ts);

	msleep(200);
	release_all_fingers(ts);
	ts->gpio();
	ts->power(false);

	msleep(200);
	ts->power(true);

	enable_irq(ts->client->irq);

	return ret;
}