summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drmsetup.c20
-rw-r--r--rototiller.c2
2 files changed, 14 insertions, 8 deletions
diff --git a/drmsetup.c b/drmsetup.c
index 3ed435a..5ec832b 100644
--- a/drmsetup.c
+++ b/drmsetup.c
@@ -76,7 +76,7 @@ static const char * connection_type_name(int type) {
/* interactively setup the drm device, store the selections */
void drm_setup(int *res_drm_fd, uint32_t *res_crtc_id, uint32_t *res_connector_id, drmModeModeInfoPtr *res_mode)
{
- int drm_fd, i;
+ int drm_fd, i, connected;
drmVersionPtr drm_ver;
drmModeResPtr drm_res;
drmModeConnectorPtr drm_con;
@@ -107,21 +107,24 @@ void drm_setup(int *res_drm_fd, uint32_t *res_crtc_id, uint32_t *res_connector_i
drm_ver->desc_len,
drm_ver->desc);
- exit_if(!(drm_res = drmModeGetResources(drm_fd)),
+ pexit_if(!(drm_res = drmModeGetResources(drm_fd)),
"unable to get drm resources");
+ connected = 0;
for (i = 0; i < drm_res->count_connectors; i++) {
- exit_if(!(drm_con = drmModeGetConnector(drm_fd, drm_res->connectors[i])),
+ pexit_if(!(drm_con = drmModeGetConnector(drm_fd, drm_res->connectors[i])),
"unable to get connector %x", (int)drm_res->connectors[i]);
if (!drm_con->encoder_id) {
continue;
}
- exit_if(!(drm_enc = drmModeGetEncoder(drm_fd, drm_con->encoder_id)),
+ pexit_if(!(drm_enc = drmModeGetEncoder(drm_fd, drm_con->encoder_id)),
"unable to get encoder %x", (int)drm_con->encoder_id);
+ connected++;
+
printf("%i: Connector [%x]: %s [%s%s%s]\n",
i, (int)drm_res->connectors[i],
connector_type_name(drm_con->connector_type),
@@ -130,14 +133,17 @@ void drm_setup(int *res_drm_fd, uint32_t *res_crtc_id, uint32_t *res_connector_i
drm_con->encoder_id ? encoder_type_name(drm_enc->encoder_type) : "");
/* TODO show mmWidth/mmHeight? */
}
+
+ exit_if(!connected,
+ "No connectors available, try different card or my bug?");
ask_num(&connector_num, drm_res->count_connectors, "Connector", 0); // TODO default?
- exit_if(!(drm_con = drmModeGetConnector(drm_fd, drm_res->connectors[connector_num])),
+ pexit_if(!(drm_con = drmModeGetConnector(drm_fd, drm_res->connectors[connector_num])),
"unable to get connector %x", (int)drm_res->connectors[connector_num]);
- exit_if(!(drm_enc = drmModeGetEncoder(drm_fd, drm_con->encoder_id)),
+ pexit_if(!(drm_enc = drmModeGetEncoder(drm_fd, drm_con->encoder_id)),
"unable to get encoder %x", (int)drm_con->encoder_id);
- exit_if(!(drm_crtc = drmModeGetCrtc(drm_fd, drm_enc->crtc_id)),
+ pexit_if(!(drm_crtc = drmModeGetCrtc(drm_fd, drm_enc->crtc_id)),
"unable to get crtc %x", (int)drm_enc->crtc_id);
*res_drm_fd = drm_fd;
diff --git a/rototiller.c b/rototiller.c
index b1c8c36..7d53afe 100644
--- a/rototiller.c
+++ b/rototiller.c
@@ -62,7 +62,7 @@ int main(int argc, const char *argv[])
drm_setup(&drm_fd, &drm_crtc_id, &drm_connector_id, &drm_mode);
renderer_select(&renderer);
- exit_if(!(fb = fb_new(drm_fd, drm_crtc_id, &drm_connector_id, 1, drm_mode, NUM_FB_PAGES)),
+ pexit_if(!(fb = fb_new(drm_fd, drm_crtc_id, &drm_connector_id, 1, drm_mode, NUM_FB_PAGES)),
"unable to create fb");
pexit_if(!fps_setup(),
© All Rights Reserved