summaryrefslogtreecommitdiffstats
path: root/meta-agl-profile-graphical/recipes-graphics/wayland/weston/0002-compositor-add-output-type-to-weston_output.patch
blob: 187bea5020a362ff3ada4f553dc5d8f0578a0307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
From e31e63976aab7616319c10ad21c998c3b4c634e6 Mon Sep 17 00:00:00 2001
From: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
Date: Tue, 30 Jul 2019 20:22:15 +0900
Subject: [PATCH 1/2] compositor: add output type to weston_output

This enables weston to use multiple types of backend
Each backends have own output structure for each functions
To avoid invalid member access, type identifier is needed

Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
---
 libweston/compositor-drm.c      | 12 +++++++++++-
 libweston/compositor-fbdev.c    |  2 +-
 libweston/compositor-headless.c |  2 +-
 libweston/compositor-rdp.c      |  2 +-
 libweston/compositor-wayland.c  |  2 +-
 libweston/compositor-x11.c      |  2 +-
 libweston/compositor.h          | 12 ++++++++++++
 7 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index c110110..b83459a 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -923,6 +923,7 @@ drm_output_find_by_crtc(struct drm_backend *b, uint32_t crtc_id)
 	struct drm_output *output;
 
 	wl_list_for_each(output, &b->compositor->output_list, base.link) {
+                if(output->base.output_type == OUTPUT_DRM)
 		if (output->crtc_id == crtc_id)
 			return output;
 	}
@@ -939,6 +940,7 @@ drm_head_find_by_connector(struct drm_backend *backend, uint32_t connector_id)
 	wl_list_for_each(base,
 			 &backend->compositor->head_list, compositor_link) {
 		head = to_drm_head(base);
+		if(base->output->output_type == OUTPUT_DRM)
 		if (head->connector_id == connector_id)
 			return head;
 	}
@@ -6159,6 +6161,7 @@ drm_output_enable(struct weston_output *base)
 
 	assert(!output->virtual);
 
+        output->base.output_type = OUTPUT_DRM;
 	resources = drmModeGetResources(b->drm.fd);
 	if (!resources) {
 		weston_log("drmModeGetResources failed\n");
@@ -6628,6 +6631,7 @@ drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
 	/* Remove connectors that have disappeared. */
 	wl_list_for_each_safe(base, next,
 			      &b->compositor->head_list, compositor_link) {
+                if (base->output->output_type == OUTPUT_DRM) {
 		bool removed = true;
 
 		head = to_drm_head(base);
@@ -6646,6 +6650,7 @@ drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
 			   head->base.name, head->connector_id);
 		drm_head_destroy(head);
 	}
+	}
 
 	drm_backend_update_unused_outputs(b, resources);
 
@@ -6751,12 +6756,14 @@ session_notify(struct wl_listener *listener, void *data)
 		 * pending frame callbacks. */
 
 		wl_list_for_each(output, &compositor->output_list, base.link) {
+		        if(output->base.output_type == OUTPUT_DRM) {
 			output->base.repaint_needed = false;
 			if (output->cursor_plane)
 				drmModeSetCursor(b->drm.fd, output->crtc_id,
 						 0, 0, 0);
 		}
-
+		}
+                if(output->base.output_type == OUTPUT_DRM) {
 		output = container_of(compositor->output_list.next,
 				      struct drm_output, base.link);
 
@@ -6768,6 +6775,7 @@ session_notify(struct wl_listener *listener, void *data)
 					plane->plane_id,
 					output->crtc_id, 0, 0,
 					0, 0, 0, 0, 0, 0, 0, 0);
+	                }
 		}
 	}
 }
@@ -7094,6 +7102,7 @@ switch_to_gl_renderer(struct drm_backend *b)
 	}
 
 	wl_list_for_each(output, &b->compositor->output_list, base.link)
+	        if(output->base.output_type == OUTPUT_DRM)
 		pixman_renderer_output_destroy(&output->base);
 
 	b->compositor->renderer->destroy(b->compositor);
@@ -7106,6 +7115,7 @@ switch_to_gl_renderer(struct drm_backend *b)
 	}
 
 	wl_list_for_each(output, &b->compositor->output_list, base.link)
+		if(output->base.output_type == OUTPUT_DRM)
 		drm_output_init_egl(output, b);
 
 	b->use_pixman = 0;
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 6031be5..97002e6 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -526,7 +526,7 @@ fbdev_output_enable(struct weston_output *base)
 	struct fbdev_head *head;
 	int fb_fd;
 	struct wl_event_loop *loop;
-
+        output->base.output_type = OUTPUT_FBDEV;
 	head = fbdev_output_get_head(output);
 
 	/* Create the frame buffer. */
diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index 5a0e46c..20b78b2 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -160,7 +160,7 @@ headless_output_enable(struct weston_output *base)
 	loop = wl_display_get_event_loop(b->compositor->wl_display);
 	output->finish_frame_timer =
 		wl_event_loop_add_timer(loop, finish_frame_handler, output);
-
+        output->base.output_type = OUTPUT_HEADLESS;
 	if (b->use_pixman) {
 		output->image_buf = malloc(output->base.current_mode->width *
 					   output->base.current_mode->height * 4);
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 871a0a3..b3064dd 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -554,7 +554,7 @@ rdp_output_enable(struct weston_output *base)
 	struct rdp_output *output = to_rdp_output(base);
 	struct rdp_backend *b = to_rdp_backend(base->compositor);
 	struct wl_event_loop *loop;
-
+        output->base.output_type = OUTPUT_RDP;
 	output->shadow_surface = pixman_image_create_bits(PIXMAN_x8r8g8b8,
 							  output->base.current_mode->width,
 							  output->base.current_mode->height,
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index e1485ca..75140b2 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1221,7 +1221,7 @@ wayland_output_enable(struct weston_output *base)
 	struct wayland_backend *b = to_wayland_backend(base->compositor);
 	enum mode_status mode_status;
 	int ret = 0;
-
+        output->base.output_type = OUTPUT_WAYLAND;
 	weston_log("Creating %dx%d wayland output at (%d, %d)\n",
 		   output->base.current_mode->width,
 		   output->base.current_mode->height,
diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 922e3c8..8c20626 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -934,7 +934,7 @@ x11_output_enable(struct weston_output *base)
 		XCB_EVENT_MASK_STRUCTURE_NOTIFY,
 		0
 	};
-
+        output->base.output_type = OUTPUT_X11;
 	if (!b->no_input)
 		values[0] |=
 			XCB_EVENT_MASK_KEY_PRESS |
diff --git a/libweston/compositor.h b/libweston/compositor.h
index a5223c2..040917b 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -169,6 +169,17 @@ enum dpms_enum {
 	WESTON_DPMS_OFF
 };
 
+/* bit compatible with drm definitions. */
+enum output_type {
+	OUTPUT_DRM,
+	OUTPUT_FBDEV,
+	OUTPUT_HEADLESS,
+	OUTPUT_RDP,
+	OUTPUT_WAYLAND,
+	OUTPUT_X11,
+	OUTPUT_WALTHAM
+};
+
 /** Represents a monitor
  *
  * This object represents a monitor (hardware backends like DRM) or a window
@@ -202,6 +213,7 @@ struct weston_head {
 struct weston_output {
 	uint32_t id;
 	char *name;
+        enum output_type output_type;
 
 	/** Matches the lifetime from the user perspective */
 	struct wl_signal user_destroy_signal;
-- 
2.7.4