blob: 6fbbe82dad5725a16a3465cef2dcb8876d03954b [file] [log] [blame]
Marius Vlade41c1bf2019-07-16 23:11:25 +03001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
3 * Copyright © 2017, 2018 General Electric Company
4 * Copyright © 2012, 2017-2019 Collabora, Ltd.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
Pekka Paalanene48bfc72019-07-17 00:09:06 +030028/*
29 * This header contains the libweston ABI exported only for internal backends.
30 */
31
Marius Vlade41c1bf2019-07-16 23:11:25 +030032#ifndef LIBWESTON_BACKEND_INTERNAL_H
33#define LIBWESTON_BACKEND_INTERNAL_H
34
Pekka Paalanene48bfc72019-07-17 00:09:06 +030035struct weston_backend {
36 void (*destroy)(struct weston_compositor *compositor);
37
38 /** Begin a repaint sequence
39 *
40 * Provides the backend with explicit markers around repaint
41 * sequences, which may allow the backend to aggregate state
42 * application. This call will be bracketed by the repaint_flush (on
43 * success), or repaint_cancel (when any output in the grouping fails
44 * repaint).
45 *
46 * Returns an opaque pointer, which the backend may use as private
47 * data referring to the repaint cycle.
48 */
49 void * (*repaint_begin)(struct weston_compositor *compositor);
50
51 /** Cancel a repaint sequence
52 *
53 * Cancels a repaint sequence, when an error has occurred during
54 * one output's repaint; see repaint_begin.
55 *
56 * @param repaint_data Data returned by repaint_begin
57 */
58 void (*repaint_cancel)(struct weston_compositor *compositor,
59 void *repaint_data);
60
61 /** Conclude a repaint sequence
62 *
63 * Called on successful completion of a repaint sequence; see
64 * repaint_begin.
65 *
66 * @param repaint_data Data returned by repaint_begin
67 */
68 int (*repaint_flush)(struct weston_compositor *compositor,
69 void *repaint_data);
70
71 /** Allocate a new output
72 *
73 * @param compositor The compositor.
74 * @param name Name for the new output.
75 *
76 * Allocates a new output structure that embeds a weston_output,
77 * initializes it, and returns the pointer to the weston_output
78 * member.
79 *
80 * Must set weston_output members @c destroy, @c enable and @c disable.
81 */
82 struct weston_output *
83 (*create_output)(struct weston_compositor *compositor,
84 const char *name);
85
86 /** Notify of device addition/removal
87 *
88 * @param compositor The compositor.
89 * @param device The device that has changed.
90 * @param added Where it was added (or removed)
91 *
92 * Called when a device has been added/removed from the session.
93 * The backend can decide what to do based on whether it is a
94 * device that it is controlling or not.
95 */
96 void (*device_changed)(struct weston_compositor *compositor,
97 dev_t device, bool added);
Marius Vlad5a701542019-11-16 20:26:52 +020098
99 /** Verifies if the dmabuf can be used directly/scanned-out by the HW.
100 *
101 * @param compositor The compositor.
102 * @param buffer The dmabuf to verify.
103 *
104 * Determines if the buffer can be imported directly by the display
105 * controller/HW. Back-ends can use this to check if the supplied
106 * buffer can be scanned-out, as to void importing it into the GPU.
107 */
108 bool (*can_scanout_dmabuf)(struct weston_compositor *compositor,
109 struct linux_dmabuf_buffer *buffer);
leng.fang32af9fc2024-06-13 11:22:15 +0800110
111 int (*print_output_status)(struct weston_compositor *compositor,
112 void *repaint_data, FILE* fp);
113
114 int (*get_frame_time)(struct weston_output *output_base, uint64_t*frametime, uint64_t* refresh_interval);
115 void (*update_frame_rate)(struct weston_compositor *compositor, int frame_rate_value, int frame_rate_scale);
116 int (*close_video_plane)(struct weston_compositor *ec, struct weston_plane* plane);
chen.wang1d9c36b12024-08-05 11:45:27 +0000117 void (*set_plane_mute)(struct weston_compositor *compositor, unsigned int plane_mute);
limin.tiana0140a72024-10-12 07:28:49 +0000118 void (*set_appstate_for_output)(struct weston_output *output, const char *name, int state);
Pekka Paalanene48bfc72019-07-17 00:09:06 +0300119};
120
Marius Vlade41c1bf2019-07-16 23:11:25 +0300121/* weston_head */
122
123void
124weston_head_init(struct weston_head *head, const char *name);
125
126void
127weston_head_release(struct weston_head *head);
128
129void
130weston_head_set_connection_status(struct weston_head *head, bool connected);
131
132void
133weston_head_set_internal(struct weston_head *head);
134
135void
136weston_head_set_monitor_strings(struct weston_head *head,
137 const char *make,
138 const char *model,
139 const char *serialno);
140void
141weston_head_set_non_desktop(struct weston_head *head, bool non_desktop);
142
143void
144weston_head_set_physical_size(struct weston_head *head,
145 int32_t mm_width, int32_t mm_height);
146
147void
148weston_head_set_subpixel(struct weston_head *head,
149 enum wl_output_subpixel sp);
Lucas Stacha69cb712019-11-25 23:29:31 +0000150
151void
152weston_head_set_transform(struct weston_head *head, uint32_t transform);
153
Marius Vlad63ef0782019-07-16 23:34:14 +0300154/* weston_output */
155
156void
157weston_output_init(struct weston_output *output,
158 struct weston_compositor *compositor,
159 const char *name);
160void
161weston_output_damage(struct weston_output *output);
162
163void
Marius Vlad63ef0782019-07-16 23:34:14 +0300164weston_output_release(struct weston_output *output);
165
166void
167weston_output_init_zoom(struct weston_output *output);
168
169void
170weston_output_finish_frame(struct weston_output *output,
171 const struct timespec *stamp,
172 uint32_t presented_flags);
nerdopolisd2a320d2021-08-23 21:29:42 -0400173
174void
175weston_output_repaint_failed(struct weston_output *output);
176
Marius Vlad63ef0782019-07-16 23:34:14 +0300177int
178weston_output_mode_set_native(struct weston_output *output,
179 struct weston_mode *mode,
180 int32_t scale);
181void
182weston_output_transform_coordinate(struct weston_output *output,
183 double device_x, double device_y,
184 double *x, double *y);
185
Pekka Paalanen06920792020-12-08 15:22:36 +0200186void
187weston_output_region_from_global(struct weston_output *output,
188 pixman_region32_t *region);
189
Marius Vlad5d649b62019-07-16 23:44:21 +0300190/* weston_seat */
191
192void
193notify_axis(struct weston_seat *seat, const struct timespec *time,
194 struct weston_pointer_axis_event *event);
195void
196notify_axis_source(struct weston_seat *seat, uint32_t source);
197
198void
199notify_button(struct weston_seat *seat, const struct timespec *time,
200 int32_t button, enum wl_pointer_button_state state);
201
202void
203notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
204 enum wl_keyboard_key_state state,
205 enum weston_key_state_update update_state);
206void
207notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
208 enum weston_key_state_update update_state);
209void
210notify_keyboard_focus_out(struct weston_seat *seat);
211
212void
213notify_motion(struct weston_seat *seat, const struct timespec *time,
214 struct weston_pointer_motion_event *event);
215void
216notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
217 double x, double y);
218void
219notify_modifiers(struct weston_seat *seat, uint32_t serial);
220
221void
222notify_pointer_frame(struct weston_seat *seat);
223
224void
225notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
226 double x, double y);
227
228/* weston_touch_device */
229
230void
231notify_touch_normalized(struct weston_touch_device *device,
232 const struct timespec *time,
233 int touch_id,
234 double x, double y,
235 const struct weston_point2d_device_normalized *norm,
236 int touch_type);
237
238/** Feed in touch down, motion, and up events, non-calibratable device.
239 *
240 * @sa notify_touch_cal
241 */
242static inline void
243notify_touch(struct weston_touch_device *device, const struct timespec *time,
244 int touch_id, double x, double y, int touch_type)
245{
246 notify_touch_normalized(device, time, touch_id, x, y, NULL, touch_type);
247}
248
249void
250notify_touch_frame(struct weston_touch_device *device);
251
252void
253notify_touch_cancel(struct weston_touch_device *device);
254
255void
256notify_touch_calibrator(struct weston_touch_device *device,
257 const struct timespec *time, int32_t slot,
258 const struct weston_point2d_device_normalized *norm,
259 int touch_type);
260void
261notify_touch_calibrator_cancel(struct weston_touch_device *device);
262void
263notify_touch_calibrator_frame(struct weston_touch_device *device);
Marius Vlade41c1bf2019-07-16 23:11:25 +0300264
leng.fang32af9fc2024-06-13 11:22:15 +0800265void weston_debug_write_buffer_to_file(void* buffer, int buffer_size, char* name_in, FILE *msg_fp );
266
Marius Vlade41c1bf2019-07-16 23:11:25 +0300267#endif