How i2c touchscreen driver work in qnx

Hi
I have written a mtouch driver for one of i2c touchscreens. My driver init and fini are getting called, also from logs I can see mtouch callbacks are getting called too.

But if I touch the screen I see no activity. What could be the missing piece.

Below is my progress

mtouch.conf is able to get parsed and all options are printed for my driver,
Driver is able to attach to libinputevents successfully.
Driver is able to generate interrupts which after processing I can see get_coords() getting called,
No touch device like /dev/mtouch0
Do I need to use io-hid to load mtouch driver? (Most of the io-hid examples are for usb type touch screens), what would be the command to use it.

https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.inputevents/topic/manual/cmtouch_writing_driver.html

Hopefully it’s just a few calls you are missing.

Tim

P.S. You didn’t mention which version of QNX you are using so that might make some difference.

Hi Tim,

Thanks for quick response,

QNX sdp7/8 from license page.

I have written my driver according to this page itself,

cmtouch_writing_driver

I have rougly implemented
get_contact_id(),
get_coords(), and
is_contact_down() as below

int get_contact_id(void* packet, uint8_t digit_idx, uint32_t* contact_id, void* arg)
{
    *contact_id = digit_idx;
	printf("get_contact_id()\n");
    return EOK;
}

int is_contact_down(void* packet, uint8_t digit_idx, int* valid, void* arg)
{
	printf("is_contact_down()\n");
	*valid = 1;
    return EOK;
}
int  get_coords(void* packet, uint8_t digit_idx, int32_t* x, int32_t* y, void* arg)
{
	printf("get_coords()\n");
    *x = target.x;
    *y = target.y;
	return 0;
}

x and y coordinates I have parsed before calling mtouch_driver_process_packet().

logwise my driver works, and all of the above functions gets called after attach driver log, but no /dev/mtouch0 , no screen events etc.
So I have doubt about io-hid utility.

I have also seen there are other devi-xxx commands too, are those required?

Can you tell what is use of io-hid utility, is it for all hid devices or just usb.

Regards
Mrigendra

HID is for HID (human interface devices) class devices. Devices that implement HID communicate through the HID driver rather than directly and they don’t have to be USB devices (A P/S2 mouse is a HID device).

I am not sure whether mtouch requires the touch screen driver to be HID class compliant or not (the doc’s don’t clarify but all the QNX drivers are written that way (see the config file link below).

Since you don’t see /dev/mtouch0 that means:

  1. You didn’t start mtouch
  2. You didn’t setup the config file for mtouch

https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.screen/topic/manual/mtouch_config.html

How are you starting mtouch and what does your config file look like?

Tim

P.S. QNX has an input DDK (device driver kit) with sample code for things like this. You might want to consider getting it.

my mtouch.conf

begin mtouch
    driver = axiom_drv
    options = height=1080,width=720,max_touchpoints=1,priority=21,poll=1,i2c_devname=/dev/i2c2,slave_addr=0x66,irq=0,irq_gpio=44,irq_trigger=2
    display = 1
    scaling = /etc/system/config/scaling.conf
end mtouch

I start mtouch as below
mtouch -c /etc/system/config/mtouch_Touchnetix_1280p_Axiom.conf

Once I issue above commands, I see my driver libmtouch-axiom_drv.so gets loaded and interrupts are getting called as per logs as below,

Dec 20 02:05:48.547                  mtouch.987178                 slog*   200  mtouch[INFO]: Parsing config file: /etc/system/config/mtouch_Touchnetix_1280p_Axiom.conf
Dec 20 02:05:48.547                  mtouch.987178                 slog    200  touch_display[INFO]: loading mtouch module axiom_drv...
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: mtouch_driver_init: Initialize axiom_drv
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: set_option: set_option called
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: print_options:
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: thread_priority: 21
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: max_touchpoints: 1
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: height: 1080
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: width: 720
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: i2c_devname: /dev/i2c2
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: slave.addr: 0x66
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: gpioirq_num: 44
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: irq_trigger: 2
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: poll 1
Dec 20 02:05:48.552                  mtouch.987178                 slog    100  libinputevents[INFO]: Attaching mtouch driver
Dec 20 02:05:48.552                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: mtouch_driver_init: Using Polling mode
Dec 20 02:05:48.553                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: tp_poll_thread()
Dec 20 02:05:48.553                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: axiom_init
Dec 20 02:05:48.568                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: Wakeup setup successfully completed  and now wait for interrupt
Dec 20 02:05:48.568                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: Got GPIO44 interrupt
Dec 20 02:05:48.574                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: len 46
Dec 20 02:05:48.574                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: aXiom-rep: Got Heartbeat report! (46 bytes)
Dec 20 02:05:48.574                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: is_contact_down()
Dec 20 02:05:48.574                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: get_contact_id()
Dec 20 02:05:48.574                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: get_coords()
Dec 20 02:05:48.668                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: Got GPIO44 interrupt
Dec 20 02:05:53.344                  mtouch.987178                 slog    200  mtouch-axiom[INFO]: aXiom-rep: Got touch report! (58 bytes)
Dec 20 02:05:53.344                  mtouch.987178                 slog    200  mtouch-axiom[INFO]:  x 31948, y 31296

From the logs it looks like everything is fine with your driver as the 3 call back functions are being called from mtouch.

When you say you touch the screen and nothing is happening, what are you expecting to happen/see? Is there some program running that would be processing screen touch events (ie a GUI of some kind) or did you run screen?

Tim

Hi,

We have GUI at qnx side and I suppose when mtouch driver starts working that means screen is aware of a touch device. So screen should be able to process get_coords() function and show any kind of touch activity on the display.

Looking back again at your code

int  get_coords(void* packet, uint8_t digit_idx, int32_t* x, int32_t* y, void* arg)
{
	printf("get_coords()\n");
    *x = target.x;
    *y = target.y;
	return 0;
}

I see you fill out the X and Y but nothing else. You get a pointer to a packet but don’t do anything with it. I can’t figure out what’s supposed to go there (no code samples anywhere) but it wouldn’t be passed to you if it wasn’t important. I’m wondering if you have to fill out something there for mtouch.

The fact you don’t see /dev/mtouch says something didn’t go right when mtouch was started and tried to use your driver.

https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.screen/topic/manual/mtouch.html
If you run with the ‘d’ option for debug do you see anything more in slog? Or have you tried the ‘rd’ option they detail here so you don’t need screen at all? I am assuming you started things in the order shown (your driver, then screen, then mtouch)?

Tim

I am not sure who calls get_coords() libinputevents or screen but basically mtouch structure’s x,y values gets filled with this call.
For screen I didn’t do anything. I am assuming writing mtouch driver and get it attached is the only thing to be done.

mtouch -rd I had tried no /dev/mtouch gets created.
Option -d also I have tried no extra logs i saw. But I’ll try again and check if anything stands out.

Do we need to write something for screen?

Hi,

On QNX6.6, there is a mtouch section in screen configuration.

It seems this section has disappeared in QNX7.1 However, in screen configuration there are parameters of interest. input is one of them. Try to enable mouse and be sure to start io-hid before screen as noted in the documentation. There is also a touch-logsize parameter which is set to 0 by default. Setting it to non 0 might help you understand what’s going on.

Nicolas

I think you need the -v option on mtouch when using the -d option because it says you need to be running in verbose mode to get output into the slog.

The point of using the -d is for testing without needing screen running and configured (along with an eventual GUI program on top of that). I suspect if you aren’t running screen then there are no clients for mtouch and thus nothing would happen when you touch the screen (other than your driver being called which you are seeing in the printf) because mtouch has no one to inform about the touch so it ignores it and to you it would look like nothing happens.

Tim