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 extern bool enable_cursor
;
24 struct vkms_composer
{
25 struct drm_framebuffer fb
;
26 struct drm_rect src
, dst
;
33 * vkms_plane_state - Driver specific plane state
34 * @base: base plane state
35 * @composer: data required for composing computation
37 struct vkms_plane_state
{
38 struct drm_plane_state base
;
39 struct vkms_composer
*composer
;
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
49 struct vkms_crtc_state
{
50 struct drm_crtc_state base
;
51 struct work_struct composer_work
;
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
;
58 /* below four are protected by vkms_output.composer_lock */
67 struct drm_encoder encoder
;
68 struct drm_connector connector
;
69 struct drm_writeback_connector wb_connector
;
70 struct hrtimer vblank_hrtimer
;
72 struct drm_pending_vblank_event
*event
;
73 /* ordered wq for composer_work */
74 struct workqueue_struct
*composer_workq
;
75 /* protects concurrent access to composer */
78 /* protected by @lock */
79 bool composer_enabled
;
80 struct vkms_crtc_state
*composer_state
;
82 spinlock_t composer_lock
;
86 struct drm_device drm
;
87 struct platform_device
*platform
;
88 struct vkms_output output
;
91 #define drm_crtc_to_vkms_output(target) \
92 container_of(target, struct vkms_output, crtc)
94 #define drm_device_to_vkms_device(target) \
95 container_of(target, struct vkms_device, drm)
97 #define to_vkms_crtc_state(target)\
98 container_of(target, struct vkms_crtc_state, base)
100 #define to_vkms_plane_state(target)\
101 container_of(target, struct vkms_plane_state, base)
104 int vkms_crtc_init(struct drm_device
*dev
, struct drm_crtc
*crtc
,
105 struct drm_plane
*primary
, struct drm_plane
*cursor
);
107 int vkms_output_init(struct vkms_device
*vkmsdev
, int index
);
109 struct drm_plane
*vkms_plane_init(struct vkms_device
*vkmsdev
,
110 enum drm_plane_type type
, int index
);
113 const char *const *vkms_get_crc_sources(struct drm_crtc
*crtc
,
115 int vkms_set_crc_source(struct drm_crtc
*crtc
, const char *src_name
);
116 int vkms_verify_crc_source(struct drm_crtc
*crtc
, const char *source_name
,
119 /* Composer Support */
120 void vkms_composer_worker(struct work_struct
*work
);
121 void vkms_set_composer(struct vkms_output
*out
, bool enabled
);
124 int vkms_enable_writeback_connector(struct vkms_device
*vkmsdev
);
126 #endif /* _VKMS_DRV_H_ */