summaryrefslogtreecommitdiff
path: root/src/common.h
blob: 7f3ecf23e510af054bc9d5d440b84841f2d56eee (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
#ifndef COMMON_H
#define COMMON_H

#include <xf86drm.h>
#include <xf86drmMode.h>
#include <epoxy/egl.h>
#include <gbm.h>

/**
 * https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html
 */
struct render_node {
	int fd;
	drmModeRes *res;
	drmModeConnector *conn;
};

/**
 * ..
 */
struct drm_fb {
	struct drm_fb *next;

	uint32_t width, height; /** w,h of our buffer object */
	uint32_t stride; /** stride value of our buffer object */
	uint32_t size; /** size o fthe memory mapped buffer */
	uint32_t handle; /** a DRM handle to the buffer object that we can draw into */

	/* Used by gbm fbs */
	struct gbm_bo *bo;
	struct gbm_device *gbm_dev;
	struct gbm_surface *gbm_surface;
	/* Used by dumb fbs */
	uint32_t *map; /** pointer to the memory mapped buffer */

	drmModeModeInfo mode; /** display mode that we want to use */
	uint32_t fb; /** framebuffer handle with our buffer object as scanout buffer */
	uint32_t conn; /** the connector ID that we want to use with this buffer */
	uint32_t crtc; /** the crtc ID that we want to use with this connector */
	drmModeCrtc *saved_crtc; /** the conf of the crtc before we changed it as to restore on exit */
};

struct egl {
	EGLDisplay display;
	EGLConfig config;
	EGLContext context;
	EGLSurface surface;
};

/**
 * struct drm_output {}
 * drmModeCrtc *saved_crtc;
 * drmModeConnector *connector;
 * struct gbm_surface *gbm_surface;
 * struct drm_fb *current, *next;
 */
struct display {
	struct render_node rnode;
	struct drm_fb * dev;
	struct egl egl;
};

#endif /* COMMON_H */