File: private.h

package info (click to toggle)
libliftoff 0.5.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: ansic: 5,432; makefile: 3
file content (169 lines) | stat: -rw-r--r-- 3,871 bytes parent folder | download
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
#ifndef PRIVATE_H
#define PRIVATE_H

#include <libliftoff.h>
#include <sys/types.h>
#include "list.h"
#include "log.h"

/* Layer priority is assigned depending on the number of updates during a
 * given number of page-flips */
#define LIFTOFF_PRIORITY_PERIOD 60

/**
 * List of well-known KMS properties.
 *
 * Keep core_property_index() in sync.
 */
enum liftoff_core_property {
	LIFTOFF_PROP_FB_ID,
	LIFTOFF_PROP_CRTC_ID,
	LIFTOFF_PROP_CRTC_X,
	LIFTOFF_PROP_CRTC_Y,
	LIFTOFF_PROP_CRTC_W,
	LIFTOFF_PROP_CRTC_H,
	LIFTOFF_PROP_SRC_X,
	LIFTOFF_PROP_SRC_Y,
	LIFTOFF_PROP_SRC_W,
	LIFTOFF_PROP_SRC_H,
	LIFTOFF_PROP_ZPOS,
	LIFTOFF_PROP_ALPHA,
	LIFTOFF_PROP_ROTATION,
	LIFTOFF_PROP_LAST, /* keep last */
};

struct liftoff_device {
	int drm_fd;

	struct liftoff_list planes; /* liftoff_plane.link */
	struct liftoff_list outputs; /* liftoff_output.link */

	uint32_t *crtcs;
	size_t crtcs_len;

	size_t planes_cap; /* max number of planes */

	int page_flip_counter;
	int test_commit_counter;
};

struct liftoff_output {
	struct liftoff_device *device;
	uint32_t crtc_id;
	size_t crtc_index;
	struct liftoff_list link; /* liftoff_device.outputs */

	struct liftoff_layer *composition_layer;

	struct liftoff_list layers; /* liftoff_layer.link */
	/* layer added or removed, or composition layer changed */
	bool layers_changed;

	int alloc_reused_counter;
};

struct liftoff_layer {
	struct liftoff_output *output;
	struct liftoff_list link; /* liftoff_output.layers */

	struct liftoff_layer_property *props;
	size_t props_len;
	ssize_t core_props[LIFTOFF_PROP_LAST]; /* indices into the props array */

	bool force_composition; /* FB needs to be composited */

	struct liftoff_plane *plane;

	/* Array of plane IDs with a length of liftoff_device.planes_cap */
	uint32_t *candidate_planes;

	int current_priority, pending_priority;
	/* prop added or force_composition changed */
	bool changed;
	drmModeFB2 fb_info, prev_fb_info; /* cached FB info */
};

struct liftoff_layer_property {
	char name[DRM_PROP_NAME_LEN];
	uint64_t value, prev_value;
	ssize_t core_index;
};

struct liftoff_plane {
	uint32_t id;
	uint32_t possible_crtcs;
	uint32_t type;
	int zpos; /* greater values mean closer to the eye */
	struct liftoff_list link; /* liftoff_device.planes */

	drmModePropertyRes **props;
	size_t props_len;
	drmModePropertyBlobRes *in_formats_blob;
	const drmModePropertyRes *core_props[LIFTOFF_PROP_LAST];

	struct liftoff_layer *layer;
};

struct liftoff_rect {
	int x, y;
	int width, height;
};

int
device_test_commit(struct liftoff_device *device, drmModeAtomicReq *req,
		   uint32_t flags);

struct liftoff_layer_property *
layer_get_property(struct liftoff_layer *layer, const char *name);

struct liftoff_layer_property *
layer_get_core_property(struct liftoff_layer *layer, enum liftoff_core_property prop);

void
layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect);

void
layer_get_prev_rect(struct liftoff_layer *layer, struct liftoff_rect *rect);

bool
rect_intersects(struct liftoff_rect *a, struct liftoff_rect *b);

bool
layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b);

void
layer_mark_clean(struct liftoff_layer *layer);

void
layer_update_priority(struct liftoff_layer *layer, bool make_current);

bool
layer_has_fb(struct liftoff_layer *layer);

void
layer_add_candidate_plane(struct liftoff_layer *layer,
			  struct liftoff_plane *plane);

void
layer_reset_candidate_planes(struct liftoff_layer *layer);

bool
layer_is_visible(struct liftoff_layer *layer);

int
layer_cache_fb_info(struct liftoff_layer *layer);

int
plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer,
	    drmModeAtomicReq *req);

bool
plane_check_layer_fb(struct liftoff_plane *plane, struct liftoff_layer *layer);

void
output_log_layers(struct liftoff_output *output);

ssize_t
core_property_index(const char *name);

#endif