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.

AM5728 video display query

Hi,

In GLSDK 6.04.00.02, the drm_mode_setplane was asynchronous (non-blocking call), hence simultaneous drm_mode_setplane calls (in case of dual display or video composition) would get fair chance for utilizing the DRM resources and it works in real-time.  But in PSDK 02.00.00.00, the drm_mode_setplane call is configured as synchronous (Blocking), hence set plane calls initiated simultaneously are not executing in real-time.

We would like to know why the drm_mode_setplane is configured as synchronous in PSDK 02.00.00.00? And why is this configurability not exposed to user space application?. Will there be any issues if we use drm_mode_setplane in asynchronous mode in PSDK 02.00.00.00?

Thanks,
Prasad.

  • Hi,

    I will ask the software team to help on this.
  • drmModeSetPlane() was implemented wrong in v3.14 kernel, and was fixed with the more recent kernel. drmModeSetPlane() must be synchronous so that it can be used reliably. It has no callback, so if it's async, the caller can not know when the work is done.

    It's true that in v3.14 kernel you could call drmModeSetPlane() and sometimes achieve full fps, but it was mostly working by luck. Often using drmModeSetPlane() with other modesetting would result in halved fps, or tearing as the app can't know when drmModeSetPlane() is finished.

    The new kernel supports atomic modesetting API, which allows the user to achieve full fps with multiple plane/display use cases. Unfortunately the libdrm wasn't updated, so it cannot be used out of the box. Either libdrm has to be updated, or the app has to use the kernel ioctls directly, without using libdrm.

  • Hi Tomi,

    Thanks for the reply.

    With kernel v3.14, though drmModeSetPlane() call was async, using the ioctl DRM_IOCTL_WAIT_VBLANK, we were able to know when a VBLANK interrupt has occurred, hence we were able to know when the work is done. Thus, we have achieved full fps with multiple plane/display use cases without any screen tearing with this mechanism.

    Is the libdrm provided as part of PSDK V02.00.01 up to date or else when can we expect a release with the updated libdrm? Can you provide us the list of changes to be done in the libdrm?
    To use the IOCTLs directly, is there any reference, which we can refer, to understand how the ioctl DRM_IOCTL_MODE_SETPLANE has to be used?

    Our understanding from browsing through the kernel source code of PSDK 02.00.00.00 ( linux kernel 4.1.6 gittag: 52c4aa7cdb-g52c4aa7) is that setplane_internal which is called by drm_mode_setplane() function locks the drm device and then submits and waits for a set plane request to complete. Since this lock is holding the entire drm resource, will it be possible to use drmModeSetPlane() call in synchronous mode and still achieve full fps with multiple plane/display use cases?

    Regards,
    Prasad.
  • Prasad Mallya said:

    With kernel v3.14, though drmModeSetPlane() call was async, using the ioctl DRM_IOCTL_WAIT_VBLANK, we were able to know when a VBLANK interrupt has occurred, hence we were able to know when the work is done. Thus, we have achieved full fps with multiple plane/display use cases without any screen tearing with this mechanism.

    That works sometimes, but is not guaranteed to work. When the call to drmModeSetPlane() returns, you don't know if the new configuration has been committed to the HW. The next vblank can happen before the new configuration is written to the HW. Or, if you've called drmModePageFlip() before drmModeSetPlane(), most likely the work for SetPlane will be delayed until after the next vblank, and, again, waiting for vblank will return too early.

    Prasad Mallya said:

    Is the libdrm provided as part of PSDK V02.00.01 up to date or else when can we expect a release with the updated libdrm? Can you provide us the list of changes to be done in the libdrm?
    To use the IOCTLs directly, is there any reference, which we can refer, to understand how the ioctl DRM_IOCTL_MODE_SETPLANE has to be used?

    I'm not that familiar with the PSDK versions, but we're just about to update the libdrm for our next internal release, so anything out there at the moment does not have updated libdrm.

    libdrm needs to have support for atomic modesetting. I think that support was added in libdrm v2.4.62.

    If you want to use the ioctls directly, I think the best reference is to look at a more recent libdrm, and how it deals with it.

    With atomic modesetting, DRM_IOCTL_MODE_SETPLANE is no longer used. Instead, the page flipping and configuring is done via atomic modesetting ioctls. The related libdrm functions are drmModeAtomicAlloc, drmModeAtomicFree, drmModeAtomicAddProperty and drmModeAtomicCommit.

    Prasad Mallya said:

    Our understanding from browsing through the kernel source code of PSDK 02.00.00.00 ( linux kernel 4.1.6 gittag: 52c4aa7cdb-g52c4aa7) is that setplane_internal which is called by drm_mode_setplane() function locks the drm device and then submits and waits for a set plane request to complete. Since this lock is holding the entire drm resource, will it be possible to use drmModeSetPlane() call in synchronous mode and still achieve full fps with multiple plane/display use cases?

    No, but that's not possible with 3.14 either. It's true that with 3.14, if carefully timed, you can get full fps in some cases. But even then the app can't be sure if the framebuffers are currently being shown on the screen or not, so even with full fps you may get tearing.

    Without atomic modesetting, I'd recommend only using drmModePageFlip(), i.e. not using the planes at all. The drmModeSetPlane() API is, in my opinion, "broken".

    Atomic modesetting API fixes all these issues, and all planes can be used on multiple displays with full fps.

    Now, as discussed, unfortunately we couldn't get the libdrm updated, so until a PSDK release comes out that contains updated libdrm, so extra work is needed by the user to use atomic modesetting.

    I think there are a few options for that:

    • Update the libdrm yourself to a more recent version. I believe this will make SGX not to work, so this is not an option if SGX is required.
    • Copy the atomic modesetting code from more recent libdrm to your app, which will call the ioctls. It'll be easy to drop that code later and use libdrm, when libdrm is updated.
    • Call the ioctls yourself.

  • Hi Tomi,

    As per your suggestion, we have copied the atomic modesetting code from libdrm v2.4.66 to our application. With this change we are able to get the display up, but we are facing the following issues,
    1) The display frame rate drops after some time (after ~4000 frames for 1080p @ 60fps) and it continues.
    2) The CPU load monotonically increases after the display application is launched (no other application is running in parallel).

    Can you please help us to figure out why the frame rate is dropping and the load is increasing after doing the atomic mode-setting changes?

    Best Regards,
    Prasad.
  • Hi,


    I had a look at the kernel in PSDK 02.00.00.00, and looks like it's missing the patch to enable support for atomic modesetting API (just setting a flag). This tells that your changes in the userspace are not correct, as the kernel refuses to use atomic modesetting, and thus your userspace cannot be using atomic modesetting.

    How is your application doing page flipping now?

    I have attached the kernel patch to enable atomic modesetting.

    omapdrm-atomic-modeset.tar.gz

  • Hi Tomi,

    Thanks for the reply.
    We are already setting the flag to enable the support for atomic APIs in the omap display driver.

    We are using drmModeAtomicAddProperty - to update the next buffer
    and drmModeAtomicCommit - for pageflip, in our application.

    Regards,
    Prasad.
  • Ok, and are you doing drmModeAtomicAlloc() and drmModeAtomicFree() for each pageflip? If you constantly add to the same atomic-request, it'll grow and grow (I presume).

    Not sure if it's any help, but I have written some DRM test libs and tools: https://github.com/tomba/kmsxx
    There's "db" test application there, which I used to test. I can't see any slow down or cpu usage increase when running that.
  • Hi Tomi,

    Thanks for the reply.

    We were not calling drmModeAtomicFree() on each page flip, we were adding to the same atomic-request. With this correction, we are able achieve the desired frame rate with minimal CPU load.

    Thanks for helping us in resolving the issue.

    Regards,
    Prasad.