Android12 occasional touch failure

       When the production line is burning firmware, it will occasionally appear that the screen touch cannot be used after a while. In the early stage, I thought it was because the programming was not done properly, but it happened again later, so I suspected it was related to the product.

        First, capture and analyze the logs: first confirm the dmesg information of the device in question.

adb连接设备进行日志抓取:
logcat > /sdcard/logcat.log
dmesg  > /sdcard/dmesg.log

        Confirm the problem log information is as follows:

[    6.224059] ___touch_compatible_probe() start____ 
[    6.225273] \x0avfs_read return ret=12
[    6.225292] touch_compatible:Not first Start the system,Already read touch\xef\xbc\x9aUSB_touch
[    6.225297] LOUHN in touch_module_init:USB_touch
[    6.225514] pwm-backlight backlight1: backlight1 supply power not found, using dummy regulator
[    6.225780] pwm-backlight backlight1: Linked as a consumer to regulator.0
[    6.225837] pwm-backlight backlight1: Dropping the link to regulator.0
[    6.249039] usb 1-1: new high-speed USB device number 3 using ehci-platform
[    6.400229] usb 1-1: New USB device found, idVendor=a69c, idProduct=8801, bcdDevice= 1.00
[    6.400245] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

Based on identifying the problematic log fragments, we can perform detailed analysis:

  1. touch_compatible_probe() start: Indicates that touch matching has just started.

  2. touch_compatible: Not first Start the system, Already read touch\xef\xbc\x9aUSB_touch: This message indicates that this is not the first time the system is started. The touch input device has been read before and is connected through the USB interface.

  3. LOUHN in touch_module_init:USB_touch: Indicates that the touch module being initialized is connected through the USB interface.

But our touch is I2C touch, what will be recognized as USB touch? So we have to go to the driver to see the implementation of this touch_compatible_probe() function.

Touch driver path:

Android12.0/kernel-4.19/drivers/input/touchscreen/touch_adapter_driver/touch_adapter.c

 touch_compatible_probe implementation:

static int touch_compatible_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    int ret = 0,i = 0;
     struct device_node *np = client->dev.of_node;
    printk("___%s() start____ \n", __func__);

    ret = read_touch_type(TOUCH_TYPE_FILE,touch_type,31);
    if(ret) {
        printk("touch_compatible:read %s faild ret=%d!",TOUCH_TYPE_FILE,ret);
        return -ENOMEM;
    } else {
        if( strlen(touch_type) ) {//touch_type不为空,则说明不是第一次启动
             printk("touch_compatible:Not first Start the system,Already read touch:%s\n",touch_type);
             touch_module_init(touch_type);
             return 0;
        }
    }
    comp_irq_gpio = of_get_named_gpio(np, "compatible,riq-gpio",0);
    comp_reset_gpio = of_get_named_gpio(np, "compatible,reset-gpio", 0);
    //gtp_request_io_port
    ret = gpio_request(comp_reset_gpio, "touch_gpio_reset");
    ret += gpio_request(comp_irq_gpio, "touch_gpio_irq");
    if(!ret) {
            for (i = 0; i < (sizeof(ts_list) / sizeof(touchscreen)); i++) {
            if (ts_list[i].check_i2c_func) {
                if((ts_list[i].check_i2c_func)(client, ts_list[i].i2c_addr)) {
                    printk("Found Touch I2C IC: %s\n",ts_list[i].touch_name);
                    if (save_data_to_file(TOUCH_TYPE_FILE,ts_list[i].touch_name,strlen(ts_list[i].touch_name)) ) {
                        printk("touch_compatible:save %s faild!",TOUCH_TYPE_FILE);
                        return -ENOMEM;
                    }
                    touch_module_init(ts_list[i].touch_name);
                    break;
                }
            } else {
printk("Touch[%s] Handle function is NULL\n", ts_list[i].touch_name);
            }
            if (i == ((sizeof(ts_list) / sizeof(touchscreen) -1)) ) {
                save_data_to_file(TOUCH_TYPE_FILE,USB_TOUCH,strlen(ts_list[i].touch_name));//没有匹配到I2C触摸,默认为USB触摸
                return 0;
            }
            }

    }

    return 0;
}

 From the above information we can know:

         gpio_requestFunctions are requested via the GPIO pins of comp_reset_gpioand . comp_irq_gpioIf the request is successful, loop through ts_listthe elements in the array and check whether there is an I2C touch device one by one. If there is an I2C touch device, print the information and write the name of the touch device into TOUCH_TYPE_FILEthe file, then call touch_module_initto initialize the touch module, and finally break out of the loop. If no matching I2C touch device is found after the loop ends, the touch device type will be written to TOUCH_TYPE_FILEthe file by default.

        The main function of this function is to obtain information related to the touch device through I2C, and select different touch modules for initialization based on the configuration information. If no matching touch device is found, the USB touch device will be selected by default for initialization.

        Obviously, the device with the problem must be recognized as USB touch, but we are using I2C touch, so the touch cannot be used. Let’s first find the file TOUCH_TYPE_FILE, delete it, and locate the cause.

        File location lookup:

Android12.0/kernel-4.19/drivers/input/touchscreen/touch_adapter_driver/touch_compatible.h

         It can be seen that the file path of TOUCH_TYPE_FILE is in /data/hardware_status/touch_type

       Delete touch_type and recreate it, and touch can be used normally. The initial consideration is that there is no need to connect to the I2C touch when burning the firmware, and assembly is done only after the burning is completed. Therefore, the I2C touch screen is not recognized for the first time. If no matching I2C touch screen device is found, the save_data_to_file function will be called to set the touch screen type to USB touch. This is indeed the case later in the implementation of the production line. Code logic optimization will be carried out later to optimize the above situation.

Guess you like

Origin blog.csdn.net/qq_53676406/article/details/132336632