Beispiel #1
0
static int cavan_touch_device_probe(struct cavan_touch_device *dev, void *data)
{
	int ret;
	int min, max, diff;
	int fd = dev->input_dev.event_dev->fd;
	struct cavan_input_service *service = data;

	pr_bold_info("LCD: width = %d, height = %d", service->lcd_width, service->lcd_height);

	if (service->lcd_width > 0)
	{
		ret = cavan_event_get_absinfo(fd, dev->xaxis, &min, &max);
		if (ret < 0)
		{
			pr_red_info("cavan_event_get_absinfo");
			return ret;
		}

		pr_bold_info("x-min = %d, x-max = %d", min, max);
		diff = max - min;
		dev->xscale = ((double) service->lcd_width) / diff;
		dev->xoffset = ((double) service->lcd_width) * min / diff;
	}
	else
	{
		dev->xscale = 1;
		dev->xoffset = 0;
	}

	if (service->lcd_height > 0)
	{
		ret = cavan_event_get_absinfo(fd, dev->yaxis, &min, &max);
		if (ret < 0)
		{
			pr_red_info("cavan_event_get_absinfo");
			return ret;
		}

		pr_bold_info("y-min = %d, y-max = %d", min, max);
		diff = max - min;
		dev->yscale = ((double) service->lcd_height) / diff;
		dev->yoffset = ((double) service->lcd_height) * min / diff;
	}
	else
	{
		dev->yscale = 1;
		dev->yoffset = 0;
	}

	pr_bold_info("xscale = %lf, xoffset = %lf", dev->xscale, dev->xoffset);
	pr_bold_info("yscale = %lf, yoffset = %lf", dev->yscale, dev->yoffset);

	return 0;
}
Beispiel #2
0
static int cavan_touchpad_probe(struct cavan_input_device *dev, void *data)
{
	int ret;
	int min, max, diff;
	int width, height;
	int fd = dev->event_dev->fd;
	struct cavan_touchpad_device *touchpad = (struct cavan_touchpad_device *) dev;
	struct cavan_input_service *service = data;

	pr_bold_info("LCD: width = %d, height = %d", service->lcd_width, service->lcd_height);

	ret = cavan_event_get_absinfo(fd, ABS_X, &min, &max);
	if (ret < 0)
	{
		pr_red_info("cavan_event_get_absinfo");
		return ret;
	}

	diff = max - min;
	width = service->lcd_height > 0 ? service->lcd_height : diff;
	pr_bold_info("x-min = %d, x-max = %d, diff = %d, width = %d", min, max, diff, width);

	touchpad->xspeed = ((double) width) / diff;
	touchpad->right = max - (diff >> CAVAN_TOUCHPAD_EDGE_SHIFT);
	pr_bold_info("xspeed = %lf, right = %d", touchpad->xspeed, touchpad->right);

	ret = cavan_event_get_absinfo(fd, ABS_Y, &min, &max);
	if (ret < 0)
	{
		pr_red_info("cavan_event_get_absinfo");
		return ret;
	}

	diff = max - min;
	height = service->lcd_height > 0 ? service->lcd_height : diff;
	pr_bold_info("y-min = %d, y-max = %d, diff = %d, height = %d", min, max, diff, height);

	touchpad->yspeed = ((double) height) / diff;
	touchpad->bottom = max - (diff >> CAVAN_TOUCHPAD_EDGE_SHIFT);
	pr_bold_info("yspeed = %lf, bottom = %d", touchpad->yspeed, touchpad->bottom);

	return 0;
}