aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-09-11 08:10:07 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-09-11 08:10:07 +0200
commit069b8bca0dc60077eba891566f32aa91532e123c (patch)
tree73bcb58b4e0421e97de9316bd0faa2cbfc79ff2e
parente63f7620b6a8cb64a1d47adb789f51802163a8b7 (diff)
downloadfbida-069b8bca0dc60077eba891566f32aa91532e123c.tar.gz
mode switching for drm
-rw-r--r--drmtools-egl.c4
-rw-r--r--drmtools.c27
-rw-r--r--drmtools.h7
-rw-r--r--fbi.c4
-rw-r--r--fbpdf.c8
5 files changed, 34 insertions, 16 deletions
diff --git a/drmtools-egl.c b/drmtools-egl.c
index 49932df..50a3408 100644
--- a/drmtools-egl.c
+++ b/drmtools-egl.c
@@ -163,7 +163,7 @@ static void drm_egl_flush_display(bool second)
bo = newbo;
}
-gfxstate *drm_init_egl(const char *device, const char *output)
+gfxstate *drm_init_egl(const char *device, const char *output, const char *mode)
{
gfxstate *gfx;
char dev[64];
@@ -175,7 +175,7 @@ gfxstate *drm_init_egl(const char *device, const char *output)
}
fprintf(stderr, "trying drm/egl: %s ...\n", dev);
- if (drm_init_dev(dev, output) < 0)
+ if (drm_init_dev(dev, output, mode) < 0)
return NULL;
if (drm_setup_egl() < 0)
return NULL;
diff --git a/drmtools.c b/drmtools.c
index df95468..86662cb 100644
--- a/drmtools.c
+++ b/drmtools.c
@@ -75,10 +75,10 @@ void drm_cleanup_display(void)
}
}
-int drm_init_dev(const char *dev, const char *output)
+int drm_init_dev(const char *dev, const char *output, const char *mode)
{
drmModeRes *res;
- char name[64];
+ char name[64], m[64];
uint64_t has_dumb;
int i, rc;
@@ -127,7 +127,23 @@ int drm_init_dev(const char *dev, const char *output)
}
return -1;
}
- drm_mode = &drm_conn->modes[0];
+
+ if (mode) {
+ for (i = 0; i < drm_conn->count_modes; i++) {
+ snprintf(m, sizeof(m), "%dx%d",
+ drm_conn->modes[i].hdisplay,
+ drm_conn->modes[i].vdisplay);
+ if (strcmp(m, mode) == 0) {
+ fprintf(stderr, "Using mode %s\n", mode);
+ drm_mode = &drm_conn->modes[i];
+ break;
+ }
+ }
+ }
+ if (!drm_mode) {
+ drm_mode = &drm_conn->modes[0];
+ }
+
drm_enc = drmModeGetEncoder(drm_fd, drm_conn->encoder_id);
if (drm_enc == NULL) {
fprintf(stderr, "drm: drmModeGetEncoder() failed\n");
@@ -207,7 +223,8 @@ static void drm_flush_display(bool second)
drmModeDirtyFB(drm_fd, fbc->id, 0, 0);
}
-gfxstate *drm_init(const char *device, const char *output, bool pageflip)
+gfxstate *drm_init(const char *device, const char *output,
+ const char *mode, bool pageflip)
{
gfxstate *gfx;
char dev[64];
@@ -219,7 +236,7 @@ gfxstate *drm_init(const char *device, const char *output, bool pageflip)
}
fprintf(stderr, "trying drm: %s ...\n", dev);
- if (drm_init_dev(dev, output) < 0)
+ if (drm_init_dev(dev, output, mode) < 0)
return NULL;
if (drm_init_fb(&fb1) < 0)
return NULL;
diff --git a/drmtools.h b/drmtools.h
index 0def894..169157e 100644
--- a/drmtools.h
+++ b/drmtools.h
@@ -7,11 +7,12 @@ extern drmModeEncoder *drm_enc;
extern drmModeModeInfo *drm_mode;
extern drmModeConnector *drm_conn;
void drm_cleanup_display(void);
-int drm_init_dev(const char *dev, const char *output);
+int drm_init_dev(const char *dev, const char *output, const char *mode);
/* drmtools.c */
-gfxstate *drm_init(const char *device, const char *output, bool pageflip);
+gfxstate *drm_init(const char *device, const char *output,
+ const char *mode, bool pageflip);
void drm_info(const char *device);
/* drmtools-egl.c */
-gfxstate *drm_init_egl(const char *device, const char *output);
+gfxstate *drm_init_egl(const char *device, const char *output, const char *mode);
diff --git a/fbi.c b/fbi.c
index cfe5f96..b5c79aa 100644
--- a/fbi.c
+++ b/fbi.c
@@ -1405,14 +1405,14 @@ int main(int argc, char *argv[])
if (device) {
/* device specified */
if (strncmp(device, "/dev/d", 6) == 0) {
- gfx = drm_init(device, output, false);
+ gfx = drm_init(device, output, mode, false);
} else {
framebuffer = true;
gfx = fb_init(device, mode, GET_VT());
}
} else {
/* try drm first, failing that fb */
- gfx = drm_init(NULL, output, false);
+ gfx = drm_init(NULL, output, mode, false);
if (!gfx) {
framebuffer = true;
gfx = fb_init(NULL, mode, GET_VT());
diff --git a/fbpdf.c b/fbpdf.c
index 9b4e665..73ce1f9 100644
--- a/fbpdf.c
+++ b/fbpdf.c
@@ -317,10 +317,10 @@ int main(int argc, char *argv[])
/* device specified */
if (strncmp(device, "/dev/d", 6) == 0) {
if (opengl) {
- gfx = drm_init_egl(device, output);
+ gfx = drm_init_egl(device, output, mode);
}
if (!gfx) {
- gfx = drm_init(device, output, pageflip);
+ gfx = drm_init(device, output, mode, pageflip);
}
} else {
framebuffer = true;
@@ -329,10 +329,10 @@ int main(int argc, char *argv[])
} else {
/* try drm first, failing that fb */
if (opengl) {
- gfx = drm_init_egl(NULL, output);
+ gfx = drm_init_egl(NULL, output, mode);
}
if (!gfx) {
- gfx = drm_init(NULL, output, pageflip);
+ gfx = drm_init(NULL, output, mode, pageflip);
}
if (!gfx) {
framebuffer = true;