1#ifndef _VKMS_DRV_H_
2#define _VKMS_DRV_H_
3
4#include <drm/drmP.h>
5#include <drm/drm.h>
6#include <drm/drm_gem.h>
7#include <drm/drm_encoder.h>
8#include <linux/hrtimer.h>
9
10#define XRES_MIN 32
11#define YRES_MIN 32
12
13#define XRES_DEF 1024
14#define YRES_DEF 768
15
16#define XRES_MAX 8192
17#define YRES_MAX 8192
18
19static const u32 vkms_formats[] = {
20 DRM_FORMAT_XRGB8888,
21};
22
23struct vkms_output {
24 struct drm_crtc crtc;
25 struct drm_encoder encoder;
26 struct drm_connector connector;
27 struct hrtimer vblank_hrtimer;
28 ktime_t period_ns;
29 struct drm_pending_vblank_event *event;
30};
31
32struct vkms_device {
33 struct drm_device drm;
34 struct platform_device *platform;
35 struct vkms_output output;
36};
37
38struct vkms_gem_object {
39 struct drm_gem_object gem;
40 struct mutex pages_lock;
41 struct page **pages;
42};
43
44#define drm_crtc_to_vkms_output(target) \
45 container_of(target, struct vkms_output, crtc)
46
47#define drm_device_to_vkms_device(target) \
48 container_of(target, struct vkms_device, drm)
49
50
51int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
52 struct drm_plane *primary, struct drm_plane *cursor);
53
54bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
55 int *max_error, ktime_t *vblank_time,
56 bool in_vblank_irq);
57
58int vkms_output_init(struct vkms_device *vkmsdev);
59
60struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev);
61
62
63struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
64 struct drm_file *file,
65 u32 *handle,
66 u64 size);
67
68int vkms_gem_fault(struct vm_fault *vmf);
69
70int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
71 struct drm_mode_create_dumb *args);
72
73int vkms_dumb_map(struct drm_file *file, struct drm_device *dev,
74 u32 handle, u64 *offset);
75
76void vkms_gem_free_object(struct drm_gem_object *obj);
77
78#endif
79