diff options
-rw-r--r-- | drmtools.c | 28 | ||||
-rw-r--r-- | drmtools.h | 3 | ||||
-rw-r--r-- | fbi.c | 7 | ||||
-rw-r--r-- | fbiconfig.c | 8 | ||||
-rw-r--r-- | fbiconfig.h | 1 |
5 files changed, 34 insertions, 13 deletions
@@ -77,11 +77,12 @@ static void drm_cleanup_display(void) } } -static int drm_init_dev(const char *dev) +static int drm_init_dev(const char *dev, const char *output) { drmModeRes *res; - int i, rc; + char name[64]; uint64_t has_dumb; + int i, rc; /* open device */ fd = open(dev, O_RDWR); @@ -106,13 +107,26 @@ static int drm_init_dev(const char *dev) conn = drmModeGetConnector(fd, res->connectors[i]); if (conn && (conn->connection == DRM_MODE_CONNECTED) && - conn->count_modes) - break; + conn->count_modes) { + if (output) { + drm_conn_name(conn, name, sizeof(name)); + if (strcmp(name, output) == 0) { + break; + } + } else { + break; + } + } drmModeFreeConnector(conn); conn = NULL; } if (!conn) { - fprintf(stderr, "drm: no usable connector found\n"); + if (output) { + fprintf(stderr, "drm: output %s not found or disconnected\n", + output); + } else { + fprintf(stderr, "drm: no usable output found\n"); + } return -1; } mode = &conn->modes[0]; @@ -186,7 +200,7 @@ static void drm_restore_display(void) drm_show_fb(); } -gfxstate *drm_init(const char *device) +gfxstate *drm_init(const char *device, const char *output) { gfxstate *gfx; char dev[64]; @@ -198,7 +212,7 @@ gfxstate *drm_init(const char *device) } fprintf(stderr, "trying drm: %s ...\n", dev); - if (drm_init_dev(dev) < 0) + if (drm_init_dev(dev, output) < 0) return NULL; if (drm_init_fb() < 0) return NULL; @@ -1,3 +1,2 @@ -gfxstate *drm_init(const char *dev); +gfxstate *drm_init(const char *device, const char *output); void drm_info(const char *device); - @@ -1435,7 +1435,7 @@ int main(int argc, char *argv[]) int once; int i, arg, key; bool framebuffer = false; - char *info, *desc, *filelist, *device, *mode; + char *info, *desc, *filelist, *device, *output, *mode; char linebuffer[128]; struct flist *fprev = NULL; @@ -1520,18 +1520,19 @@ int main(int argc, char *argv[]) /* gfx device init */ device = cfg_get_str(O_DEVICE); + output = cfg_get_str(O_OUTPUT); mode = cfg_get_str(O_VIDEO_MODE); if (device) { /* device specified */ if (strncmp(device, "/dev/d", 6) == 0) { - gfx = drm_init(device); + gfx = drm_init(device, output); } else { framebuffer = true; gfx = fb_init(device, mode, GET_VT()); } } else { /* try drm first, failing that fb */ - gfx = drm_init(NULL); + gfx = drm_init(NULL, output); if (!gfx) { framebuffer = true; gfx = fb_init(NULL, mode, GET_VT()); diff --git a/fbiconfig.c b/fbiconfig.c index 8a82331..f67850b 100644 --- a/fbiconfig.c +++ b/fbiconfig.c @@ -163,7 +163,13 @@ struct cfg_cmdline fbi_cfg[] = { .cmdline = "device", .option = { O_DEVICE }, .needsarg = 1, - .desc = "use framebuffer device <arg>", + .desc = "use framebuffer/drm device <arg>", + },{ + .letter = 'o', + .cmdline = "output", + .option = { O_OUTPUT }, + .needsarg = 1, + .desc = "use drm output <arg> (try -info for a list)", },{ .letter = 'm', .cmdline = "mode", diff --git a/fbiconfig.h b/fbiconfig.h index 048735b..9a8c058 100644 --- a/fbiconfig.h +++ b/fbiconfig.h @@ -32,6 +32,7 @@ #define O_PCD_RES O_OPTIONS, "photocd-res" #define O_DEVICE O_OPTIONS, "device" +#define O_OUTPUT O_OPTIONS, "output" #define O_FONT O_OPTIONS, "font" #define O_VIDEO_MODE O_OPTIONS, "video-mode" |