1
2
3 #ifndef _VKMS_DRV_H_
4 #define _VKMS_DRV_H_
5
6 #include <linux/hrtimer.h>
7
8 #include <drm/drm.h>
9 #include <drm/drm_gem.h>
10 #include <drm/drm_encoder.h>
11
12 #define XRES_MIN 20
13 #define YRES_MIN 20
14
15 #define XRES_DEF 1024
16 #define YRES_DEF 768
17
18 #define XRES_MAX 8192
19 #define YRES_MAX 8192
20
21 extern bool enable_cursor;
22
23 struct vkms_composer {
24 struct drm_framebuffer fb;
25 struct drm_rect src, dst;
26 unsigned int offset;
27 unsigned int pitch;
28 unsigned int cpp;
29 };
30
31
32
33
34
35
36 struct vkms_plane_state {
37 struct drm_plane_state base;
38 struct vkms_composer *composer;
39 };
40
41
42
43
44
45
46
47
48 struct vkms_crtc_state {
49 struct drm_crtc_state base;
50 struct work_struct composer_work;
51
52 int num_active_planes;
53
54 struct vkms_plane_state **active_planes;
55
56
57 bool crc_pending;
58 u64 frame_start;
59 u64 frame_end;
60 };
61
62 struct vkms_output {
63 struct drm_crtc crtc;
64 struct drm_encoder encoder;
65 struct drm_connector connector;
66 struct hrtimer vblank_hrtimer;
67 ktime_t period_ns;
68 struct drm_pending_vblank_event *event;
69
70 struct workqueue_struct *composer_workq;
71
72 spinlock_t lock;
73
74
75 bool composer_enabled;
76 struct vkms_crtc_state *composer_state;
77
78 spinlock_t composer_lock;
79 };
80
81 struct vkms_device {
82 struct drm_device drm;
83 struct platform_device *platform;
84 struct vkms_output output;
85 };
86
87 struct vkms_gem_object {
88 struct drm_gem_object gem;
89 struct mutex pages_lock;
90 struct page **pages;
91 unsigned int vmap_count;
92 void *vaddr;
93 };
94
95 #define drm_crtc_to_vkms_output(target) \
96 container_of(target, struct vkms_output, crtc)
97
98 #define drm_device_to_vkms_device(target) \
99 container_of(target, struct vkms_device, drm)
100
101 #define drm_gem_to_vkms_gem(target)\
102 container_of(target, struct vkms_gem_object, gem)
103
104 #define to_vkms_crtc_state(target)\
105 container_of(target, struct vkms_crtc_state, base)
106
107 #define to_vkms_plane_state(target)\
108 container_of(target, struct vkms_plane_state, base)
109
110
111 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
112 struct drm_plane *primary, struct drm_plane *cursor);
113
114 bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
115 int *max_error, ktime_t *vblank_time,
116 bool in_vblank_irq);
117
118 int vkms_output_init(struct vkms_device *vkmsdev, int index);
119
120 struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
121 enum drm_plane_type type, int index);
122
123
124 vm_fault_t vkms_gem_fault(struct vm_fault *vmf);
125
126 int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
127 struct drm_mode_create_dumb *args);
128
129 void vkms_gem_free_object(struct drm_gem_object *obj);
130
131 int vkms_gem_vmap(struct drm_gem_object *obj);
132
133 void vkms_gem_vunmap(struct drm_gem_object *obj);
134
135
136 const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
137 size_t *count);
138 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
139 int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
140 size_t *values_cnt);
141
142
143 void vkms_composer_worker(struct work_struct *work);
144
145 #endif