embear-engineering / drm-framebuffer

A simple application which can be used to test a Linux DRM device
GNU General Public License v3.0
55 stars 21 forks source link

could not find referred resolution #6

Closed Jomy10 closed 10 months ago

Jomy10 commented 10 months ago
$ ./drm-framebuffer -d /dev/dri/by-path/platform-gpu-card -c HMDI-A-1
Could not find preferred resolution

when I use -r:

$ ./drm-framebuffer -d /dev/dri/by-path/platform-gpu-card -c HMDI-A-1 -r
1280x720
eichenberger commented 10 months ago

Hi @Jomy10 I had a look at it and there is a bug in there. Currently the display has to announce it has a default resolution if it does not then "-r" option just shows the last resolution it found while the the filling will abort. For you maybe the following patch would work:

diff --git a/framebuffer.c b/framebuffer.c
index 260ebfa..389f611 100644
--- a/framebuffer.c
+++ b/framebuffer.c
@@ -116,10 +116,9 @@ int get_framebuffer(const char *dri_device, const char *connector_name, struct f
     /* Get the preferred resolution */
     drmModeModeInfoPtr resolution = 0;
     for (int i = 0; i < connector->count_modes; i++) {
-            drmModeModeInfoPtr res = 0;
-            res = &connector->modes[i];
-            if (res->type & DRM_MODE_TYPE_PREFERRED)
-                    resolution = res;
+            resolution = &connector->modes[i];
+            if (resolution->type & DRM_MODE_TYPE_PREFERRED)
+                break;
     }

     if (!resolution) {

But I think I need to cleanup that stuff and make it possible to select a specific resolution

eichenberger commented 10 months ago

Commit https://github.com/embear-engineering/drm-framebuffer/commit/77fc4b5571e04160b348843bcedf8939c1e6d529 should solve this issue by using the first possible resolution when no resolution is specified.

Jomy10 commented 10 months ago

Commit 77fc4b5 should solve this issue by using the first possible resolution when no resolution is specified.

Awesome!