1 /* SPDX-License-Identifier: GPL-2.0+ */
6 #include <linux/hrtimer.h>
9 #include <drm/drm_gem.h>
10 #include <drm/drm_encoder.h>
11 #include <drm/drm_writeback.h>
22 struct vkms_composer {
23 struct drm_framebuffer fb;
24 struct drm_rect src, dst;
31 * vkms_plane_state - Driver specific plane state
32 * @base: base plane state
33 * @composer: data required for composing computation
35 struct vkms_plane_state {
36 struct drm_plane_state base;
37 struct vkms_composer *composer;
41 struct drm_plane base;
45 * vkms_crtc_state - Driver specific CRTC state
46 * @base: base CRTC state
47 * @composer_work: work struct to compose and add CRC entries
48 * @n_frame_start: start frame number for computed CRC
49 * @n_frame_end: end frame number for computed CRC
51 struct vkms_crtc_state {
52 struct drm_crtc_state base;
53 struct work_struct composer_work;
55 int num_active_planes;
56 /* stack of active planes for crc computation, should be in z order */
57 struct vkms_plane_state **active_planes;
58 void *active_writeback;
60 /* below four are protected by vkms_output.composer_lock */
69 struct drm_encoder encoder;
70 struct drm_connector connector;
71 struct drm_writeback_connector wb_connector;
72 struct hrtimer vblank_hrtimer;
74 struct drm_pending_vblank_event *event;
75 /* ordered wq for composer_work */
76 struct workqueue_struct *composer_workq;
77 /* protects concurrent access to composer */
80 /* protected by @lock */
81 bool composer_enabled;
82 struct vkms_crtc_state *composer_state;
84 spinlock_t composer_lock;
93 /* only set when instantiated */
94 struct vkms_device *dev;
98 struct drm_device drm;
99 struct platform_device *platform;
100 struct vkms_output output;
101 const struct vkms_config *config;
104 #define drm_crtc_to_vkms_output(target) \
105 container_of(target, struct vkms_output, crtc)
107 #define drm_device_to_vkms_device(target) \
108 container_of(target, struct vkms_device, drm)
110 #define to_vkms_crtc_state(target)\
111 container_of(target, struct vkms_crtc_state, base)
113 #define to_vkms_plane_state(target)\
114 container_of(target, struct vkms_plane_state, base)
117 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
118 struct drm_plane *primary, struct drm_plane *cursor);
120 int vkms_output_init(struct vkms_device *vkmsdev, int index);
122 struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
123 enum drm_plane_type type, int index);
126 const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
128 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
129 int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
132 /* Composer Support */
133 void vkms_composer_worker(struct work_struct *work);
134 void vkms_set_composer(struct vkms_output *out, bool enabled);
137 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev);
139 #endif /* _VKMS_DRV_H_ */