drm_flip_work.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. #ifndef DRM_FLIP_WORK_H
  24. #define DRM_FLIP_WORK_H
  25. #include <linux/kfifo.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/workqueue.h>
  28. /**
  29. * DOC: flip utils
  30. *
  31. * Utility to queue up work to run from work-queue context after flip/vblank.
  32. * Typically this can be used to defer unref of framebuffer's, cursor
  33. * bo's, etc until after vblank. The APIs are all thread-safe. Moreover,
  34. * drm_flip_work_commit() can be called in atomic context.
  35. */
  36. struct drm_flip_work;
  37. /*
  38. * drm_flip_func_t - callback function
  39. *
  40. * @work: the flip work
  41. * @val: value queued via drm_flip_work_queue()
  42. *
  43. * Callback function to be called for each of the queue'd work items after
  44. * drm_flip_work_commit() is called.
  45. */
  46. typedef void (*drm_flip_func_t)(struct drm_flip_work *work, void *val);
  47. /**
  48. * struct drm_flip_work - flip work queue
  49. * @name: debug name
  50. * @func: callback fxn called for each committed item
  51. * @worker: worker which calls @func
  52. * @queued: queued tasks
  53. * @commited: commited tasks
  54. * @lock: lock to access queued and commited lists
  55. */
  56. struct drm_flip_work {
  57. const char *name;
  58. drm_flip_func_t func;
  59. struct work_struct worker;
  60. struct list_head queued;
  61. struct list_head commited;
  62. spinlock_t lock;
  63. };
  64. void drm_flip_work_queue(struct drm_flip_work *work, void *val);
  65. void drm_flip_work_commit(struct drm_flip_work *work,
  66. struct workqueue_struct *wq);
  67. void drm_flip_work_init(struct drm_flip_work *work,
  68. const char *name, drm_flip_func_t func);
  69. void drm_flip_work_cleanup(struct drm_flip_work *work);
  70. #endif /* DRM_FLIP_WORK_H */