commit fc84dad

Michael Forney  ·  2020-02-20 19:49:45 +0000 UTC
parent fe0a062
drm: Use the CRTC index as the screen ID

This is simpler and avoids a dependency on the non-standard ffsl.
1 files changed,  +1, -25
+1, -25
 1@@ -52,8 +52,6 @@ struct swc_drm swc_drm;
 2 static struct {
 3 	char *path;
 4 
 5-	uint32_t taken_ids;
 6-
 7 	struct wl_global *global;
 8 	struct wl_global *dmabuf;
 9 	struct wl_event_source *event_source;
10@@ -196,18 +194,6 @@ find_available_crtc(drmModeRes *resources, drmModeConnector *connector, uint32_t
11 	return false;
12 }
13 
14-static bool
15-find_available_id(uint32_t *id)
16-{
17-	int index = ffsl(~drm.taken_ids);
18-
19-	if (index == 0)
20-		return false;
21-
22-	*id = index - 1;
23-	return true;
24-}
25-
26 static void
27 handle_vblank(int fd, unsigned int sequence, unsigned int sec, unsigned int usec, void *data)
28 {
29@@ -265,7 +251,6 @@ drm_initialize(void)
30 		goto error0;
31 	}
32 
33-	drm.taken_ids = 0;
34 	swc.drm->fd = launch_open_device(primary, O_RDWR | O_CLOEXEC);
35 	if (swc.drm->fd == -1) {
36 		ERROR("Could not open DRM device at %s\n", primary);
37@@ -378,7 +363,6 @@ drm_create_screens(struct wl_list *screens)
38 
39 		if (connector->connection == DRM_MODE_CONNECTED) {
40 			int crtc_index;
41-			uint32_t id;
42 
43 			if (!find_available_crtc(resources, connector, taken_crtcs, &crtc_index)) {
44 				WARNING("Could not find CRTC for connector %d\n", i);
45@@ -397,20 +381,12 @@ drm_create_screens(struct wl_list *screens)
46 				WARNING("Could not find cursor plane for CRTC %d\n", crtc_index);
47 			}
48 
49-			if (!find_available_id(&id)) {
50-				WARNING("No more available output IDs\n");
51-				drmModeFreeConnector(connector);
52-				break;
53-			}
54-
55 			if (!(output = output_new(connector)))
56 				continue;
57 
58 			output->screen = screen_new(resources->crtcs[crtc_index], output, cursor_plane);
59-			output->screen->id = id;
60-
61+			output->screen->id = crtc_index;
62 			taken_crtcs |= 1 << crtc_index;
63-			drm.taken_ids |= 1 << id;
64 
65 			wl_list_insert(screens, &output->screen->link);
66 		}