1 /* SPDX-License-Identifier: MIT */ 2 3 #ifndef _DRM_VBLANK_WORK_H_ 4 #define _DRM_VBLANK_WORK_H_ 5 6 #include <linux/kthread.h> 7 8 struct drm_crtc; 9 10 /** 11 * struct drm_vblank_work - A delayed work item which delays until a target 12 * vblank passes, and then executes at realtime priority outside of IRQ 13 * context. 14 * 15 * See also: 16 * drm_vblank_work_schedule() 17 * drm_vblank_work_init() 18 * drm_vblank_work_cancel_sync() 19 * drm_vblank_work_flush() 20 * drm_vblank_work_flush_all() 21 */ 22 struct drm_vblank_work { 23 /** 24 * @base: The base &kthread_work item which will be executed by 25 * &drm_vblank_crtc.worker. Drivers should not interact with this 26 * directly, and instead rely on drm_vblank_work_init() to initialize 27 * this. 28 */ 29 struct kthread_work base; 30 31 /** 32 * @vblank: A pointer to &drm_vblank_crtc this work item belongs to. 33 */ 34 struct drm_vblank_crtc *vblank; 35 36 /** 37 * @count: The target vblank this work will execute on. Drivers should 38 * not modify this value directly, and instead use 39 * drm_vblank_work_schedule() 40 */ 41 u64 count; 42 43 /** 44 * @cancelling: The number of drm_vblank_work_cancel_sync() calls that 45 * are currently running. A work item cannot be rescheduled until all 46 * calls have finished. 47 */ 48 int cancelling; 49 50 /** 51 * @node: The position of this work item in 52 * &drm_vblank_crtc.pending_work. 53 */ 54 struct list_head node; 55 }; 56 57 /** 58 * to_drm_vblank_work - Retrieve the respective &drm_vblank_work item from a 59 * &kthread_work 60 * @_work: The &kthread_work embedded inside a &drm_vblank_work 61 */ 62 #define to_drm_vblank_work(_work) \ 63 container_of((_work), struct drm_vblank_work, base) 64 65 int drm_vblank_work_schedule(struct drm_vblank_work *work, 66 u64 count, bool nextonmiss); 67 void drm_vblank_work_init(struct drm_vblank_work *work, struct drm_crtc *crtc, 68 void (*func)(struct kthread_work *work)); 69 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work); 70 void drm_vblank_work_flush(struct drm_vblank_work *work); 71 void drm_vblank_work_flush_all(struct drm_crtc *crtc); 72 73 #endif /* !_DRM_VBLANK_WORK_H_ */ 74