diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2018-10-15 13:35:10 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-10-15 13:35:10 +0200 |
commit | b682cc8ce12204a94891c5efc3265ee3c15ec966 (patch) | |
tree | 631155c7cdfaf2c9d1f970daf19e0d6db12bb434 /drmtest.c | |
parent | cb0ab87935c13c6d3e642b7ce0dc8d9a1f739b8e (diff) | |
download | drminfo-b682cc8ce12204a94891c5efc3265ee3c15ec966.tar.gz |
move code to drmtools.c
Diffstat (limited to 'drmtest.c')
-rw-r--r-- | drmtest.c | 139 |
1 files changed, 0 insertions, 139 deletions
@@ -31,14 +31,6 @@ /* ------------------------------------------------------------------ */ -/* device */ -static int fd; -static drmModeConnector *conn = NULL; -static drmModeEncoder *enc = NULL; -static drmModeModeInfo *mode = NULL; -static drmModeCrtc *scrtc = NULL; -static uint32_t fb_id; - /* dumb fb */ static struct drm_mode_create_dumb creq; static const struct fbformat *fmt = NULL; @@ -54,137 +46,6 @@ cairo_surface_t *image; /* ------------------------------------------------------------------ */ -static void drm_init_dev(int devnr, const char *output, - const char *modename, bool need_dumb) -{ - drmModeRes *res; - char dev[64]; - char name[64]; - char m[64]; - int i, rc; - uint64_t has_dumb; - - /* open device */ - snprintf(dev, sizeof(dev), DRM_DEV_NAME, DRM_DIR_NAME, devnr); - fd = open(dev, O_RDWR); - if (fd < 0) { - fprintf(stderr, "open %s: %s\n", dev, strerror(errno)); - exit(1); - } - - if (need_dumb) { - rc = drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &has_dumb); - if (rc < 0 || !has_dumb) { - fprintf(stderr, "no dumb buffer support\n"); - exit(1); - } - } -#if 0 - if (need_master) { - rc = drmSetMaster(fd); - if (rc < 0) { - fprintf(stderr, "drmSetMaster() failed: %s\n", - strerror(errno)); - exit(1); - } - } -#endif - - /* find connector */ - res = drmModeGetResources(fd); - if (res == NULL) { - fprintf(stderr, "drmModeGetResources() failed\n"); - exit(1); - } - for (i = 0; i < res->count_connectors; i++) { - conn = drmModeGetConnector(fd, res->connectors[i]); - if (conn && - (conn->connection == DRM_MODE_CONNECTED) && - 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) { - if (output) { - fprintf(stderr, "drm: output %s not found or disconnected\n", - output); - } else { - fprintf(stderr, "drm: no usable output found\n"); - } - exit(1); - } - - for (i = 0; i < res->count_connectors; i++) { - conn = drmModeGetConnector(fd, res->connectors[i]); - if (conn && - (conn->connection == DRM_MODE_CONNECTED) && - conn->count_modes) - break; - drmModeFreeConnector(conn); - conn = NULL; - } - if (!conn) { - fprintf(stderr, "no usable connector found\n"); - exit(1); - } - - if (modename) { - for (i = 0; i < conn->count_modes; i++) { - snprintf(m, sizeof(m), "%dx%d", - conn->modes[i].hdisplay, - conn->modes[i].vdisplay); - if (strcmp(m, modename) == 0) { - fprintf(stderr, "Using mode %s\n", modename); - mode = &conn->modes[i]; - break; - } - } - } - if (!mode) { - mode = &conn->modes[0]; - } - - enc = drmModeGetEncoder(fd, conn->encoder_id); - if (enc == NULL) { - fprintf(stderr, "drmModeGetEncoder() failed\n"); - exit(1); - } - - /* save crtc */ - scrtc = drmModeGetCrtc(fd, enc->crtc_id); -} - -static void drm_fini_dev(void) -{ - /* restore crtc */ - if (scrtc) { - drmModeSetCrtc(fd, scrtc->crtc_id, scrtc->buffer_id, scrtc->x, scrtc->y, - &conn->connector_id, 1, &scrtc->mode); - } -} - -static void drm_show_fb(void) -{ - int rc; - - rc = drmModeSetCrtc(fd, enc->crtc_id, fb_id, 0, 0, - &conn->connector_id, 1, - mode); - if (rc < 0) { - fprintf(stderr, "drmModeSetCrtc() failed\n"); - exit (1); - } -} - static void drm_draw(const char *text) { char name[64]; |