This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3358: TSC PEN_UP interrupt issue

Part Number: AM3358
Other Parts Discussed in Thread: TSC2005

Tool/software: Linux

hi:     

CPU:am3358

SDK:ti-processor-sdk-linux-am335x-evm-03.02.00.05

filesystem:arago-base-tisdk-image-am335x-evm or tisdk-rootfs-image-am335x-evm

lib:tslib

app:qt

       I found a bug when i touch the touchscreen on a button,the button is pressed ,but if i raise pen,the button still pressed,not change the state.

       I debug the touchscreen driver,find when I raise the pen,the touchscreen can not reciever the PEN_UP interrupt.follow is the debug.,irq_status is the value of IRQSTATUS_RAW(offset=0x24)

No PEN_UP interrupt(after this operation,i read the IRQSTATUS_RAW(devmem2 0x44e0d024),the value is 0x600,so the PEN_UP[9] flag is set,why the irq function can not receive this interrupt? )

[huzz]titsc_irq:irq_status=0x605
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:IRQENB_PENUP
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x402
[huzz]titsc_irq:irq_status=0x404
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x403
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:irq_status=0x404
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x403
[huzz]titsc_irq:IRQENB_HW_PEN

a Normal touch message (after this operation,the IRQSTATUS_RAW=0x400)

[huzz]titsc_irq:irq_status=0x605
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:IRQENB_PENUP
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x402
[huzz]titsc_irq:irq_status=0x404
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x403
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:irq_status=0x404
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x403
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:irq_status=0x404
[huzz]titsc_irq:IRQENB_FIFO0THRES
[huzz]titsc_irq:irq_status=0x603
[huzz]titsc_irq:IRQENB_HW_PEN
[huzz]titsc_irq:IRQENB_PENUP

  • Hi,

    Is this a custom board or an AM335x EVM?
  • Reference EVM design 。
    I find the reason.
    ti_am335x_tsc.c file
    the titsc_probe function,when it init the IRQ, the PEN_UP and PEN_DOWN interrupt are not enabled,why do this?

    ps:

    in my test,the irq function get the interrupt,but sometimes it can not report the PENUP event .I find when get the PENUP event,the fsm value is 0x50 not 0x10,why this happen?

    if (status & IRQENB_PENUP) {
    fsm = titsc_readl(ts_dev, REG_ADCFSM);
    printk("[huzz]%s:fsm=0x%x\n",__func__,fsm);
    if (fsm == ADCFSM_STEPID) {
    ts_dev->pen_down = false;
    input_report_key(input_dev, BTN_TOUCH, 0);
    input_report_abs(input_dev, ABS_PRESSURE, 0);
    input_sync(input_dev);
    pm_relax(ts_dev->mfd_tscadc->dev);
    } else {
    ts_dev->pen_down = true;
    }
    irqclr |= IRQENB_PENUP;
    }

  • I will ask the software team to comment. They will respond here.
  • Hi,

    the titsc_probe function,when it init the IRQ, the PEN_UP and PEN_DOWN interrupt are not enabled,why do this?

    The driver actually uses the IRQSTATUS_RAW register to determine if there is a pen_up or pen_down event, see titsc_irq():
    status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
    ........
    if (status & IRQENB_PENUP) {
    fsm = titsc_readl(ts_dev, REG_ADCFSM);
    if (fsm == ADCFSM_STEPID) {
    ts_dev->pen_down = false;
    input_report_key(input_dev, BTN_TOUCH, 0);
    input_report_abs(input_dev, ABS_PRESSURE, 0);
    input_sync(input_dev);
    pm_relax(ts_dev->mfd_tscadc->dev);
    } else {
    ts_dev->pen_down = true;
    }
    irqclr |= IRQENB_PENUP;
    }

    So there is no need to set the irq in IRQENABLE_SET register in titsc_probe().

    As for the problem you have:
    1. I understand this is a custom board, so try lowering the x-plate-resistance to lower the pressure needed for pendown & penup interrupts.
    2. As far as I know the latest sdk does NOT use tslib.. It uses the weston libraries... Try rebuilding your qt app with wayland-egl support.

    Best Regards,
    Yordan
  • hi yordan:
    when I raise the pen,the titsc_irq can not get an interrupt,but when i read the IRQSTATUS_RAW REG,the pen up event is set.
    when i change the x-plate-resistance 200 to 50,it still can not get the pen up irq.
    our customer use the tslib,so we use the tslib.
    PS:use the IT SDK touchscreen,there is a error when i use the touch.
    I use the QT example fingerpaint to test the touch.this app can Draw a green spot where i touch the scree.but sometimes when i touch one place on the screen,and the other place also draw a spot.I debug the touchscree driver,i find the other place also get a adc value .the x-plate-resistance set to lower or lager is not change to good.
  • Part Number: AM3358

    Tool/software: Linux

    hi:

    our SDK is ti-processor-sdk-linux-am335x-evm-03.02.00.05.

    we used the 4 wires touchscreen.the touchscreen driver is 

    linux-4.4.32+gitAUTOINC+adde2ca9f8-gadde2ca9f8/drivers/input/touchscreen/ti_am335x_tsc.c

    sometimes,when we touch the button of a QT APP, the button Pressed,when we Lift touch pen,the button still pressed,it not raised up.

    we debug the touchscreen driver,when it happed,the interrupt function can not receive the pen up interrupt.so the function can not report the pen up event.

    when i see the driver,in probe function,the drivers does not enable pen up interrupt,why driver do not need the pen up interrupt,if not enable it ,how could the driver knew the pen up event happend?

    when pen up happed,the driver does not get the interrupt,but when i do "devmem2 0x44e0d024",the pen_up_event[9] value is 1

    can some one tell me how the touchscreen driver work with the interrupt?

    the dts file:


    &tscadc {
    status = "okay";
    tsc {
    ti,wires = <4>;
    ti,x-plate-resistance = <200>;
    ti,coordinate-readouts = <5>;
    ti,wire-config = <0x01 0x10 0x22 0x33>;
    ti,charge-delay = <0x400>;
    };

    adc {
    ti,adc-channels = <4 5 6 7>;
    };
    };

  • can anyone supported me this issue.

    in the code,the z may be the pressure,but how it work?   first ,z2 is bigger than z1,and z1,z2,z is defined unsigned int.secord the formula is different.

    /*
    * Calculate pressure using formula
    * Resistance(touch) = x plate resistance *
    * x postion/4096 * ((z2 / z1) - 1)
    */
    z = z1 - z2;
    z *= x;
    z *= ts_dev->x_plate_resistance;
    z /= z2;
    z = (z + 2047) >> 12;

  • Hi,

    Bellow information is strictly general info from my experience with TI TSC controllers. 

    z1 & z2 are two additional cross panel measurements (The END result Z = (Z+2047) >>12; is the actual pressure):

    "To determine pen or finger touch, the pressure of the touch must be determined. Generally, it is not necessary to have very high performance for this test; therefore, 10-bit resolution mode is recommended (however, data sheet calculations are shown using 12-bit resolution mode). There are several different ways of performing this measurement. The TSC2005 supports two methods. The first method requires knowing the X-plate resistance, the measurement of the X-Position, and two additional cross panel measurements (Z2 and Z1) of the touch screen"

    The reference block diagram of the above is usually as follows:

      

    There are two equations, that can be used to calculate the pressure. One is the most commonly used (implemented in ti_am335x_tsc.c):
        

    The SECOND is as follows: 
       

    Again from my experience with some resistive displays, when the touch screen behaved strange (random behavior when touching the screen, when there were some spikes & offsets with the touch point), the SECOND equation sowed better performance. Again this was a strictly trial and error finding, and in my opinion is use case dependent. 

    Now as far as your pen up interrupt not being processed. See Section 12.3.5 Interrupts of AM335x TRM: 
     "A Pen-up event interrupt, also known as the Pen-up interrupt, can only be generated when using HW steps with the charge steps enabled. If a Pen-down event caused the HW steps to be scheduled and no Pen-down is present after the sequencer finished servicing the charge step, then a Pen-up interrupt is generated. To detect Pen-up interrupts, the charge step must share the same configuration as the idle step." 

    Check the code within if (status & IRQENB_PENUP) of the ti_am335x_tsc.c driver. Print the values of status & IRQENB_PENUP, to see if these have been updated. Make sure the sequence described in Section 12.3.5 is implemented correctly. 

    Best Regards, 
    Yordan

  • hi youda:

    thanks for your reply, I will test for z.

    but the code follow is not one of the equations you tell me,why the code use this code?

    z = z1 - z2;
    z *= x;
    z *= ts_dev->x_plate_resistance;
    z /= z2;
    z = (z + 2047) >> 12;

    in my test ,i use the x-plat =300,and i use the first equation,but still has a error point .follow is my one touch,the fourth is the error point,but the is still the right value (if (z <= MAX_12BIT)

    [ 575.006265] [huzz]titsc_read_coordinates:z1=1393,z2=3634[huzz]titsc_irq:calc:x=1873,y=2285,z=137
    [ 575.017267] [huzz]titsc_read_coordinates:z1=1385,z2=3648[huzz]titsc_irq:calc:x=1867,y=2292,z=136
    [ 575.028162] [huzz]titsc_read_coordinates:z1=1303,z2=3680[huzz]titsc_irq:calc:x=1864,y=2279,z=136
    [ 575.039134] [huzz]titsc_read_coordinates:z1=115,z2=4054[huzz]titsc_irq:calc:x=1251,y=2275,z=3094
    [ 575.048193] [huzz]titsc_irq:report pen_up

    about the pen_up question.see the first floor,my question is the intrtitsc_irq can not receive the pen_up event.so the driver do not know the static is pen up.

  • Hi,

    I am seeing the same issue with the PEN_UP, was there any resolution to this problem?

    Todd

  • I add the pen_up interrupt,it can work good