swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 0c3f36c5ac561cd2adcc9fc09fc8ad0abe6f371a
parent f5f7b0704c1f8f93c03bd09d449296f318817a3e
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Thu, 13 May 2021 12:27:03 -0500

drm: primary card needs universal planes support

Diffstat:
Mlibswc/drm.c | 23+++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/libswc/drm.c b/libswc/drm.c @@ -129,7 +129,7 @@ static bool find_primary_drm_device(char *path, size_t size) { struct dirent **cards, *card = NULL; - int num_cards, ret; + int num_cards, ret, fd; unsigned index; FILE *file; unsigned char boot_vga; @@ -154,6 +154,24 @@ find_primary_drm_device(char *path, size_t size) } } + if (snprintf(path, size, "/dev/dri/%s", cards[index]->d_name) >= size) + return false; + + fd = open(path, O_RDWR | O_CLOEXEC); + if (fd == -1) + continue; + + /* If the card doesn't support universal planes, we can't use it. + * On many ARM devices, the device that performs hardware accelerated + * rendering is different from the device composites framebuffers. + * The one that composites framebuffers should have universal planes + * support (if I understand correctly) */ + if (drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0) { + close(fd); + continue; + } + close(fd); + if (!card) card = cards[index]; else @@ -277,9 +295,10 @@ drm_initialize(void) { uint64_t val; char primary[PATH_MAX]; + char render[PATH_MAX]; if (!find_primary_drm_device(primary, sizeof(primary))) { - ERROR("Could not find DRM device\n"); + ERROR("Could not find valid DRM device\n"); goto error0; }