drm_vblank_work.h 1.9 KB

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