drm_writeback.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * (C) COPYRIGHT 2016 ARM Limited. All rights reserved.
  4. * Author: Brian Starkey <brian.starkey@arm.com>
  5. *
  6. * This program is free software and is provided to you under the terms of the
  7. * GNU General Public License version 2 as published by the Free Software
  8. * Foundation, and any use by you of this program is subject to the terms
  9. * of such GNU licence.
  10. */
  11. #ifndef __DRM_WRITEBACK_H__
  12. #define __DRM_WRITEBACK_H__
  13. #include <drm/drm_connector.h>
  14. #include <drm/drm_encoder.h>
  15. #include <linux/workqueue.h>
  16. struct drm_writeback_connector {
  17. struct drm_connector base;
  18. /**
  19. * @encoder: Internal encoder used by the connector to fulfill
  20. * the DRM framework requirements. The users of the
  21. * @drm_writeback_connector control the behaviour of the @encoder
  22. * by passing the @enc_funcs parameter to drm_writeback_connector_init()
  23. * function.
  24. */
  25. struct drm_encoder encoder;
  26. /**
  27. * @pixel_formats_blob_ptr:
  28. *
  29. * DRM blob property data for the pixel formats list on writeback
  30. * connectors
  31. * See also drm_writeback_connector_init()
  32. */
  33. struct drm_property_blob *pixel_formats_blob_ptr;
  34. /** @job_lock: Protects job_queue */
  35. spinlock_t job_lock;
  36. /**
  37. * @job_queue:
  38. *
  39. * Holds a list of a connector's writeback jobs; the last item is the
  40. * most recent. The first item may be either waiting for the hardware
  41. * to begin writing, or currently being written.
  42. *
  43. * See also: drm_writeback_queue_job() and
  44. * drm_writeback_signal_completion()
  45. */
  46. struct list_head job_queue;
  47. /**
  48. * @fence_context:
  49. *
  50. * timeline context used for fence operations.
  51. */
  52. unsigned int fence_context;
  53. /**
  54. * @fence_lock:
  55. *
  56. * spinlock to protect the fences in the fence_context.
  57. */
  58. spinlock_t fence_lock;
  59. /**
  60. * @fence_seqno:
  61. *
  62. * Seqno variable used as monotonic counter for the fences
  63. * created on the connector's timeline.
  64. */
  65. unsigned long fence_seqno;
  66. /**
  67. * @timeline_name:
  68. *
  69. * The name of the connector's fence timeline.
  70. */
  71. char timeline_name[32];
  72. };
  73. struct drm_writeback_job {
  74. /**
  75. * @cleanup_work:
  76. *
  77. * Used to allow drm_writeback_signal_completion to defer dropping the
  78. * framebuffer reference to a workqueue
  79. */
  80. struct work_struct cleanup_work;
  81. /**
  82. * @list_entry:
  83. *
  84. * List item for the writeback connector's @job_queue
  85. */
  86. struct list_head list_entry;
  87. /**
  88. * @fb:
  89. *
  90. * Framebuffer to be written to by the writeback connector. Do not set
  91. * directly, use drm_atomic_set_writeback_fb_for_connector()
  92. */
  93. struct drm_framebuffer *fb;
  94. /**
  95. * @out_fence:
  96. *
  97. * Fence which will signal once the writeback has completed
  98. */
  99. struct dma_fence *out_fence;
  100. };
  101. int drm_writeback_connector_init(struct drm_device *dev,
  102. struct drm_writeback_connector *wb_connector,
  103. const struct drm_connector_funcs *con_funcs,
  104. const struct drm_encoder_helper_funcs *enc_helper_funcs,
  105. const u32 *formats, int n_formats);
  106. void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
  107. struct drm_writeback_job *job);
  108. void drm_writeback_cleanup_job(struct drm_writeback_job *job);
  109. void
  110. drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
  111. int status);
  112. struct dma_fence *
  113. drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector);
  114. #endif