18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: MIT */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci#ifndef _DRM_VBLANK_WORK_H_
48c2ecf20Sopenharmony_ci#define _DRM_VBLANK_WORK_H_
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/kthread.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct drm_crtc;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/**
118c2ecf20Sopenharmony_ci * struct drm_vblank_work - A delayed work item which delays until a target
128c2ecf20Sopenharmony_ci * vblank passes, and then executes at realtime priority outside of IRQ
138c2ecf20Sopenharmony_ci * context.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * See also:
168c2ecf20Sopenharmony_ci * drm_vblank_work_schedule()
178c2ecf20Sopenharmony_ci * drm_vblank_work_init()
188c2ecf20Sopenharmony_ci * drm_vblank_work_cancel_sync()
198c2ecf20Sopenharmony_ci * drm_vblank_work_flush()
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_cistruct drm_vblank_work {
228c2ecf20Sopenharmony_ci	/**
238c2ecf20Sopenharmony_ci	 * @base: The base &kthread_work item which will be executed by
248c2ecf20Sopenharmony_ci	 * &drm_vblank_crtc.worker. Drivers should not interact with this
258c2ecf20Sopenharmony_ci	 * directly, and instead rely on drm_vblank_work_init() to initialize
268c2ecf20Sopenharmony_ci	 * this.
278c2ecf20Sopenharmony_ci	 */
288c2ecf20Sopenharmony_ci	struct kthread_work base;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	/**
318c2ecf20Sopenharmony_ci	 * @vblank: A pointer to &drm_vblank_crtc this work item belongs to.
328c2ecf20Sopenharmony_ci	 */
338c2ecf20Sopenharmony_ci	struct drm_vblank_crtc *vblank;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	/**
368c2ecf20Sopenharmony_ci	 * @count: The target vblank this work will execute on. Drivers should
378c2ecf20Sopenharmony_ci	 * not modify this value directly, and instead use
388c2ecf20Sopenharmony_ci	 * drm_vblank_work_schedule()
398c2ecf20Sopenharmony_ci	 */
408c2ecf20Sopenharmony_ci	u64 count;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	/**
438c2ecf20Sopenharmony_ci	 * @cancelling: The number of drm_vblank_work_cancel_sync() calls that
448c2ecf20Sopenharmony_ci	 * are currently running. A work item cannot be rescheduled until all
458c2ecf20Sopenharmony_ci	 * calls have finished.
468c2ecf20Sopenharmony_ci	 */
478c2ecf20Sopenharmony_ci	int cancelling;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	/**
508c2ecf20Sopenharmony_ci	 * @node: The position of this work item in
518c2ecf20Sopenharmony_ci	 * &drm_vblank_crtc.pending_work.
528c2ecf20Sopenharmony_ci	 */
538c2ecf20Sopenharmony_ci	struct list_head node;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/**
578c2ecf20Sopenharmony_ci * to_drm_vblank_work - Retrieve the respective &drm_vblank_work item from a
588c2ecf20Sopenharmony_ci * &kthread_work
598c2ecf20Sopenharmony_ci * @_work: The &kthread_work embedded inside a &drm_vblank_work
608c2ecf20Sopenharmony_ci */
618c2ecf20Sopenharmony_ci#define to_drm_vblank_work(_work) \
628c2ecf20Sopenharmony_ci	container_of((_work), struct drm_vblank_work, base)
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciint drm_vblank_work_schedule(struct drm_vblank_work *work,
658c2ecf20Sopenharmony_ci			     u64 count, bool nextonmiss);
668c2ecf20Sopenharmony_civoid drm_vblank_work_init(struct drm_vblank_work *work, struct drm_crtc *crtc,
678c2ecf20Sopenharmony_ci			  void (*func)(struct kthread_work *work));
688c2ecf20Sopenharmony_cibool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
698c2ecf20Sopenharmony_civoid drm_vblank_work_flush(struct drm_vblank_work *work);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#endif /* !_DRM_VBLANK_WORK_H_ */
72