forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/vkms/vkms_drv.h
....@@ -3,14 +3,15 @@
33 #ifndef _VKMS_DRV_H_
44 #define _VKMS_DRV_H_
55
6
-#include <drm/drmP.h>
6
+#include <linux/hrtimer.h>
7
+
78 #include <drm/drm.h>
89 #include <drm/drm_gem.h>
910 #include <drm/drm_encoder.h>
10
-#include <linux/hrtimer.h>
11
+#include <drm/drm_writeback.h>
1112
12
-#define XRES_MIN 32
13
-#define YRES_MIN 32
13
+#define XRES_MIN 20
14
+#define YRES_MIN 20
1415
1516 #define XRES_DEF 1024
1617 #define YRES_DEF 768
....@@ -18,17 +19,67 @@
1819 #define XRES_MAX 8192
1920 #define YRES_MAX 8192
2021
21
-static const u32 vkms_formats[] = {
22
- DRM_FORMAT_XRGB8888,
22
+extern bool enable_cursor;
23
+
24
+struct vkms_composer {
25
+ struct drm_framebuffer fb;
26
+ struct drm_rect src, dst;
27
+ unsigned int offset;
28
+ unsigned int pitch;
29
+ unsigned int cpp;
30
+};
31
+
32
+/**
33
+ * vkms_plane_state - Driver specific plane state
34
+ * @base: base plane state
35
+ * @composer: data required for composing computation
36
+ */
37
+struct vkms_plane_state {
38
+ struct drm_plane_state base;
39
+ struct vkms_composer *composer;
40
+};
41
+
42
+/**
43
+ * vkms_crtc_state - Driver specific CRTC state
44
+ * @base: base CRTC state
45
+ * @composer_work: work struct to compose and add CRC entries
46
+ * @n_frame_start: start frame number for computed CRC
47
+ * @n_frame_end: end frame number for computed CRC
48
+ */
49
+struct vkms_crtc_state {
50
+ struct drm_crtc_state base;
51
+ struct work_struct composer_work;
52
+
53
+ int num_active_planes;
54
+ /* stack of active planes for crc computation, should be in z order */
55
+ struct vkms_plane_state **active_planes;
56
+ void *active_writeback;
57
+
58
+ /* below four are protected by vkms_output.composer_lock */
59
+ bool crc_pending;
60
+ bool wb_pending;
61
+ u64 frame_start;
62
+ u64 frame_end;
2363 };
2464
2565 struct vkms_output {
2666 struct drm_crtc crtc;
2767 struct drm_encoder encoder;
2868 struct drm_connector connector;
69
+ struct drm_writeback_connector wb_connector;
2970 struct hrtimer vblank_hrtimer;
3071 ktime_t period_ns;
3172 struct drm_pending_vblank_event *event;
73
+ /* ordered wq for composer_work */
74
+ struct workqueue_struct *composer_workq;
75
+ /* protects concurrent access to composer */
76
+ spinlock_t lock;
77
+
78
+ /* protected by @lock */
79
+ bool composer_enabled;
80
+ struct vkms_crtc_state *composer_state;
81
+
82
+ spinlock_t composer_lock;
3283 };
3384
3485 struct vkms_device {
....@@ -41,6 +92,8 @@
4192 struct drm_gem_object gem;
4293 struct mutex pages_lock; /* Page lock used in page fault handler */
4394 struct page **pages;
95
+ unsigned int vmap_count;
96
+ void *vaddr;
4497 };
4598
4699 #define drm_crtc_to_vkms_output(target) \
....@@ -49,27 +102,54 @@
49102 #define drm_device_to_vkms_device(target) \
50103 container_of(target, struct vkms_device, drm)
51104
105
+#define drm_gem_to_vkms_gem(target)\
106
+ container_of(target, struct vkms_gem_object, gem)
107
+
108
+#define to_vkms_crtc_state(target)\
109
+ container_of(target, struct vkms_crtc_state, base)
110
+
111
+#define to_vkms_plane_state(target)\
112
+ container_of(target, struct vkms_plane_state, base)
113
+
52114 /* CRTC */
53115 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
54116 struct drm_plane *primary, struct drm_plane *cursor);
55117
56
-bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
57
- int *max_error, ktime_t *vblank_time,
58
- bool in_vblank_irq);
118
+int vkms_output_init(struct vkms_device *vkmsdev, int index);
59119
60
-int vkms_output_init(struct vkms_device *vkmsdev);
61
-
62
-struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev);
120
+struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
121
+ enum drm_plane_type type, int index);
63122
64123 /* Gem stuff */
65
-int vkms_gem_fault(struct vm_fault *vmf);
124
+vm_fault_t vkms_gem_fault(struct vm_fault *vmf);
66125
67126 int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
68127 struct drm_mode_create_dumb *args);
69128
70
-int vkms_dumb_map(struct drm_file *file, struct drm_device *dev,
71
- u32 handle, u64 *offset);
72
-
73129 void vkms_gem_free_object(struct drm_gem_object *obj);
74130
131
+int vkms_gem_vmap(struct drm_gem_object *obj);
132
+
133
+void vkms_gem_vunmap(struct drm_gem_object *obj);
134
+
135
+/* Prime */
136
+struct drm_gem_object *
137
+vkms_prime_import_sg_table(struct drm_device *dev,
138
+ struct dma_buf_attachment *attach,
139
+ struct sg_table *sg);
140
+
141
+/* CRC Support */
142
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
143
+ size_t *count);
144
+int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
145
+int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
146
+ size_t *values_cnt);
147
+
148
+/* Composer Support */
149
+void vkms_composer_worker(struct work_struct *work);
150
+void vkms_set_composer(struct vkms_output *out, bool enabled);
151
+
152
+/* Writeback */
153
+int vkms_enable_writeback_connector(struct vkms_device *vkmsdev);
154
+
75155 #endif /* _VKMS_DRV_H_ */