aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.h
blob: 8744b4400f2dc273f20c5d1d3e4db63aaf41e163 (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
#ifndef DRM_H
#define DRM_H

#include <stdbool.h>
#include <stdint.h>
#include <xf86drmMode.h>
#include <EGL/egl.h>
#include <gbm.h>

enum otd_display_state {
	OTD_DISP_INVALID,
	OTD_DISP_DISCONNECTED,
	OTD_DISP_NEEDS_MODESET,
	OTD_DISP_CONNECTED,
};

struct otd_display {
	struct otd *otd;

	enum otd_display_state state;
	uint32_t connector;
	char name[16];

	size_t num_modes;
	drmModeModeInfo *modes;
	drmModeModeInfo *active_mode;

	uint32_t width;
	uint32_t height;

	uint32_t crtc;
	drmModeCrtc *old_crtc;

	struct gbm_surface *gbm;
	EGLSurface *egl;
	uint32_t fb_id;

	bool pageflip_pending;
	bool cleanup;
};

bool init_renderer(struct otd *otd);
void destroy_renderer(struct otd *otd);

void scan_connectors(struct otd *otd);
bool modeset_str(struct otd *otd, struct otd_display *disp, const char *str);
void destroy_display_renderer(struct otd *otd, struct otd_display *disp);

void get_drm_event(struct otd *otd);

void rendering_begin(struct otd_display *disp);
void rendering_end(struct otd_display *disp);

#endif