1 /* SPDX-License-Identifier: GPL-2.0+ */
6 #include <linux/hrtimer.h>
9 #include <drm/drm_gem.h>
10 #include <drm/drm_encoder.h>
21 extern bool enable_cursor
;
23 struct vkms_composer
{
24 struct drm_framebuffer fb
;
25 struct drm_rect src
, dst
;
32 * vkms_plane_state - Driver specific plane state
33 * @base: base plane state
34 * @composer: data required for composing computation
36 struct vkms_plane_state
{
37 struct drm_plane_state base
;
38 struct vkms_composer
*composer
;
42 * vkms_crtc_state - Driver specific CRTC state
43 * @base: base CRTC state
44 * @composer_work: work struct to compose and add CRC entries
45 * @n_frame_start: start frame number for computed CRC
46 * @n_frame_end: end frame number for computed CRC
48 struct vkms_crtc_state
{
49 struct drm_crtc_state base
;
50 struct work_struct composer_work
;
52 int num_active_planes
;
53 /* stack of active planes for crc computation, should be in z order */
54 struct vkms_plane_state
**active_planes
;
56 /* below three are protected by vkms_output.composer_lock */
64 struct drm_encoder encoder
;
65 struct drm_connector connector
;
66 struct hrtimer vblank_hrtimer
;
68 struct drm_pending_vblank_event
*event
;
69 /* ordered wq for composer_work */
70 struct workqueue_struct
*composer_workq
;
71 /* protects concurrent access to composer */
74 /* protected by @lock */
75 bool composer_enabled
;
76 struct vkms_crtc_state
*composer_state
;
78 spinlock_t composer_lock
;
82 struct drm_device drm
;
83 struct platform_device
*platform
;
84 struct vkms_output output
;
87 struct vkms_gem_object
{
88 struct drm_gem_object gem
;
89 struct mutex pages_lock
; /* Page lock used in page fault handler */
91 unsigned int vmap_count
;
95 #define drm_crtc_to_vkms_output(target) \
96 container_of(target, struct vkms_output, crtc)
98 #define drm_device_to_vkms_device(target) \
99 container_of(target, struct vkms_device, drm)
101 #define drm_gem_to_vkms_gem(target)\
102 container_of(target, struct vkms_gem_object, gem)
104 #define to_vkms_crtc_state(target)\
105 container_of(target, struct vkms_crtc_state, base)
107 #define to_vkms_plane_state(target)\
108 container_of(target, struct vkms_plane_state, base)
111 int vkms_crtc_init(struct drm_device
*dev
, struct drm_crtc
*crtc
,
112 struct drm_plane
*primary
, struct drm_plane
*cursor
);
114 bool vkms_get_vblank_timestamp(struct drm_device
*dev
, unsigned int pipe
,
115 int *max_error
, ktime_t
*vblank_time
,
118 int vkms_output_init(struct vkms_device
*vkmsdev
, int index
);
120 struct drm_plane
*vkms_plane_init(struct vkms_device
*vkmsdev
,
121 enum drm_plane_type type
, int index
);
124 struct drm_gem_object
*vkms_gem_create(struct drm_device
*dev
,
125 struct drm_file
*file
,
129 vm_fault_t
vkms_gem_fault(struct vm_fault
*vmf
);
131 int vkms_dumb_create(struct drm_file
*file
, struct drm_device
*dev
,
132 struct drm_mode_create_dumb
*args
);
134 void vkms_gem_free_object(struct drm_gem_object
*obj
);
136 int vkms_gem_vmap(struct drm_gem_object
*obj
);
138 void vkms_gem_vunmap(struct drm_gem_object
*obj
);
141 struct drm_gem_object
*
142 vkms_prime_import_sg_table(struct drm_device
*dev
,
143 struct dma_buf_attachment
*attach
,
144 struct sg_table
*sg
);
147 const char *const *vkms_get_crc_sources(struct drm_crtc
*crtc
,
149 int vkms_set_crc_source(struct drm_crtc
*crtc
, const char *src_name
);
150 int vkms_verify_crc_source(struct drm_crtc
*crtc
, const char *source_name
,
153 /* Composer Support */
154 void vkms_composer_worker(struct work_struct
*work
);
156 #endif /* _VKMS_DRV_H_ */