Wednesday, 18 December 2019

No cursor in your embedded Qt-App on iMX-6?


This one is a continuation of (meanwhile) a series of bughunting/bugfixing posts*.  As I already wrote once:
"You'll maybe complain that this site is degenerating into a mingle-mangle of bug descriptions, but if you've ever had a pesky problem and couldn't find anything about it on the web, you'll understand my urge to document such things for the fellow hackers."**
So I'll just document this one gotcha to help the googling programmer, because on that way I received help from others multiple times. I hope it'll make someone's life easier.

1. The Problem

In the current project for one of my customers I'm writing a Qt UI for an application running on embedded Linux. We are using the open source version of Qt, so we build the system image with yocto using standard Qt5 recipies. We are also using the tried and tested iMX-6 board, that was used in iPhones time and ago.

This board has a GPU and we are using Qt's EGLFS platform plugin which enables standard OpenGL graphics. Everything should hunky-dory, no surprizes, this configuration is well-tested, and it should just work. And it worked, a demo Qt application showed on the attached VGG screen. But then we plugged in a mouse, whisked it to and fro, but nothing happened. No mouse cursor on the screen!

2. The Solution

I tried to google the problem away, but no ready-made solution could be found. But then a small hint set the ball rolling, namely this one:
"... very likely the hardware or the drivers doen't support a hardware-accelerated mouse cursor."
Wait, wait... And what does the "i.MX Graphics User’s Guide" say about this exaclty? Let have a look:
"10.1.5 Cursor
  Hardware IPU does not provide a hardware cursor."
In no uncertain terms! 

Problem solved: Qt will by default try to use the hardware cursor to speed things up, but in such a case it will fail in name of performance. A very honourable end - dulce et decorum est pro performancem mori, as the ancient Romans used to say! 

After we clearified that question the fix "follows trivially" 😉 - we only have to turn on Qt's software cursor option. How to do that? As Qt's documentation says:
"The KMS/DRM backend also supports custom configurations via a JSON file."
This is our way. We habe to create a JSON config file and point to it with the QT_QPA_EGLFS_KMS_CONFIG environment variable. The contents should be looking roughly like that:

  {
    "device": "/dev/dri/card0",
    "hwcursor": false,
    "pbuffers": true,
    "outputs": [
      {
        "name": "LVDS0",
        "mode": "800x480"
      }
    ]
  }
with "device" set to your device name and "pbuffers" enabling usage of standard EGL pbuffer surfaces.

3. The Moral

There isn't one this time 😕. I you can think about one that could fit in here, say it in the comments.

--
* like this, thisthis, this and even this one for Python!
** in one of the above posts here.

No comments: