Summarize the Problems and Solutions encountered during the migration of the tslib library.
Question 1: Selected device is not a touchscreen I understand
Solution:
View the principles of the tslib library and find the place where this sentence is located in plugins/input-raw.c
if (! ((ioctl(ts->fd, EVIOCGVERSION, &version) >= 0) && (version == EV_VERSION) && (ioctl(ts->fd, EVIOCGBIT(0, sizeof(bit) * 8), &bit) >= 0) && (bit & (1 << EV_ABS)) && (ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit) * 8), &absbit) >= 0) && (absbit & (1 << ABS_X)) && (absbit & (1 << ABS_Y)) && (absbit & (1 << ABS_PRESSURE)))) { fprintf(stderr, "selected device is not a touchscreen I understand\n"); return -1; }
We can see that the cause of this error is that some of these conditions are insufficient. We need to know which conditions are not met, so we can print them out and view them one by one, to see which is 0, which is not satisfied
printf("EV_VERSION=%p\n", EV_VERSION);printf("version=%p\n", version);printf("EV_ABS_ERRON=%d\n", EV_ABS_ERRON);printf("XY_ABS_ERRON=%d\n", XY_ABS_ERRON);printf("bit & (1 << EV_ABS)=%d\n", (bit & (1 << EV_ABS)));printf("absbit & (1 << ABS_X)=%d\n", (absbit & (1 << ABS_X)));printf("absbit & (1 << ABS_Y)=%d\n", (absbit & (1 << ABS_Y)));printf("absbit & (1 << ABS_PRESSURE)=%d\n",(absbit & (1 << ABS_PRESSURE)));fprintf(stderr, "selected device is not a touchscreen I understand\n");
You only need to find the value 0 in the output, and then you will know which condition is not met. here we will not conduct in-depth debugging on the conditions where errors occur. you need to check the touch screen driver.
This is usually set in this way, in the case of single-touch:
__set_bit(EV_ABS, ts->input_dev->evbit);__set_bit(EV_KEY, ts->input_dev->evbit);__set_bit(EV_SYN, ts->input_dev->evbit);__set_bit(BTN_TOUCH, ts->input_dev->keybit);input_set_abs_params(ts->input_dev, ABS_X, 0, ts->abs_x_max, 0, 0);input_set_abs_params(ts->input_dev, ABS_Y, 0, ts->abs_y_max, 0, 0);input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 1, 0, 0);
You can refer to the touch screen driver that has been transplanted in the Linux kernel.
Problem 2: the touch screen data is not reported to tslib
Symptom:
Clicking the touch screen has data output, but running the ts_calibrate program shows that the cross click does not respond.
Problem Analysis:
This is because the coordinate data collected by the device driver is not successfully reported to tslib, resulting in no response to clicks.
Solution:
Check whether the report data function driven by the touch screen is correct. In addition, the tslib Library supports single-contact and whether it is single-contact or multi-contact.
This is a single-touch reporting function:
input_report_abs(ts->input_dev, ABS_X, x);input_report_abs(ts->input_dev, ABS_Y, y);input_report_abs(ts->input_dev, ABS_PRESSURE, 1);input_sync(ts->input_dev);
This is the reporting function of multi-touch:
input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w);input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id);input_mt_sync(ts->input_dev);
We can see the macro definitions such as abs_x in the include/Linux/input. h file. Their values are different.
Look at the ts_input_read function in the plugins/input-raw.c in the tslib library. Here we won't list it, I know it is abs_x, abs_y...
You can also modify the tslib library, or the touch screen driver, depending on your choice. Here, the analysis is not modified, because the code is different, and the Principle Analysis is OK.
Now the problem has been solved. The biggest feeling of this debugging is to use printf to print the printed value so that we can better analyze the problem.
The problem can be solved only by finding the error information. If you cannot find the error information and have no experience, you can't start with it.
When the tslib library is transplanted, selected device is not a touchscreen I understand appears.