eglInitialize fails with DRM KMS

Hi, I’m trying to port an existing application to the Jetson Xavier AGX. It currently works in KMS mode. First I tried using tegra-ugm:

# Stop X xerver
sudo service gdm stop; 
sudo ln -sf /usr/lib/aarch64-linux-gnu/tegra/libnvgbm.so /usr/lib/aarch64-linux-gnu/libgbm.so.1
sudo modprobe tegra-udrm modeset=1

I am able to open the gdm device, but eglInitialize fails. I also tried the method with drmOpen (which is what nvrenderer.cpp uses), but eglInitialize fails on that as well.

Hi,
Please refer to steps in
https://docs.nvidia.com/jetson/l4t/#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/accelerated_gstreamer.html#wwpID0E02P0HA

If you don’t run Westson, the commands are not required:

$ sudo ln -sf /usr/lib/aarch64-linux-gnu/tegra/libnvgbm.so /usr/lib/aarch64-linux-gnu/libgbm.so.1
$ sudo modprobe tegra-udrm modeset=1

I’m unsure if the steps are related. For example I’m trying to run kmscube (Debian -- Details of package kmscube in buster) which fails even with those commands.

Hi,
Please check if you can run

/usr/src/jetson_multimedia_api/samples/08_video_dec_drm

Jetson Linux API Reference: 08_video_dec_drm (Direct Rendering Manager) | NVIDIA Docs

This is the DRM sample we verify in each release. Suggest you give it a try and develop your usecase based on it.

Ok, so it sounds like using EGL+drm just isn’t supported? I’ve seen that sample and it doesn’t address my issue as the sample doesn’t use EGL.

Hi,
Not sure if EGL APIs work, but the following demo code works:

    if (ctx->enable_cuda)
    {
        /* Create EGLImage from dmabuf fd */
        ctx->egl_image = NvEGLImageFromFd(ctx->egl_display, fd);
        if (ctx->egl_image == NULL)
            ERROR_RETURN("Failed to map dmabuf fd (0x%X) to EGLImage",
                    ctx->render_dmabuf_fd);

        /* Pass this buffer hooked on this egl_image to CUDA for
           CUDA processing - draw a rectangle on the frame */
        HandleEGLImage(&ctx->egl_image);

        /* Destroy EGLImage */
        NvDestroyEGLImage(ctx->egl_display, ctx->egl_image);
        ctx->egl_image = NULL;
    }

Doing CUDA post processing should work fine.