Igalia / cog

WPE launcher and webapp container
MIT License
241 stars 61 forks source link

Cog + DRM Lease #613

Open woutervanh opened 1 year ago

woutervanh commented 1 year ago

I'm trying to get cog working with drm lease in stead of drm directly. For that I adapted cog-platform-drm.c, to work together with drm-lease-manager (https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/drm-lease-manager.git):

#if 0
drmDevice *devices[64];
memset(devices, 0, sizeof(*devices) * 64);

int num_devices = drmGetDevices2(0, devices, 64);
if (num_devices < 0)
    return FALSE;

for (int i = 0; i < num_devices; ++i) {
    drmDevice* device = devices[i];
    g_debug ("init_drm: enumerated device %p, available_nodes %d",
             device, device->available_nodes);

    if (device->available_nodes & (1 << DRM_NODE_PRIMARY))
        g_debug ("init_drm:   DRM_NODE_PRIMARY: %s", device->nodes[DRM_NODE_PRIMARY]);
    if (device->available_nodes & (1 << DRM_NODE_CONTROL))
        g_debug ("init_drm:   DRM_NODE_CONTROL: %s", device->nodes[DRM_NODE_CONTROL]);
    if (device->available_nodes & (1 << DRM_NODE_RENDER))
        g_debug ("init_drm:   DRM_NODE_RENDER: %s", device->nodes[DRM_NODE_RENDER]);
}

for (int i = 0; i < num_devices; ++i) {
    drmDevice* device = devices[i];
    if (!(device->available_nodes & (1 << DRM_NODE_PRIMARY)))
        continue;

    drm_data.fd = open (device->nodes[DRM_NODE_PRIMARY], O_RDWR);
    if (drm_data.fd < 0)
        continue;

    drm_data.base_resources = drmModeGetResources (drm_data.fd);
    if (drm_data.base_resources) {
        g_debug ("init_drm: using device %p, DRM_NODE_PRIMARY %s",
                 device, device->nodes[DRM_NODE_PRIMARY]);
        break;
    }

    close (drm_data.fd);
    drm_data.fd = -1;
}

drmFreeDevices(devices, num_devices);
#else
struct dlm_lease *lease = dlm_get_lease("card1-DPI-1");
drm_data.fd = dlm_lease_fd(lease);
drm_data.base_resources = drmModeGetResources (drm_data.fd);
#endif
if (!drm_data.base_resources)
return FALSE;

It works well, in a sense that it gets the drm device, detects resolution, modesettings etc. But at some point, it tries to authenticate wl_display, which fails. I find this strange as I'm running it from console with platform -P drm, so don't know where this wl_display is coming from, why it's trying to authenticate, and why it is failing. If I run it via drm directly, it succeeds.

This is with drm: [3083033.269] wl_drm@5.authenticate(1) [3083033.520] -> wl_drm@5.authenticated() This is with a lease: [2887550.595] wl_drm@5.authenticate(1) [2887550.866] -> wl_display@1.error(wl_drm@5, 0, "authenticate failed")

Any help or pointer?

woutervanh commented 1 year ago

What I'm trying to accomplish, is there a way to have video played on it's own hw plane? Without going through the gpu? and maybe without using punch hole approach too? And if using punch hole, what's the best proven approach?