1 /* SPDX-License-Identifier: GPL-2.0 */
3 * (C) COPYRIGHT 2016 ARM Limited. All rights reserved.
4 * Author: Brian Starkey <brian.starkey@arm.com>
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
12 #ifndef __DRM_WRITEBACK_H__
13 #define __DRM_WRITEBACK_H__
14 #include <drm/drm_connector.h>
15 #include <drm/drm_encoder.h>
16 #include <linux/workqueue.h>
18 struct drm_writeback_connector {
19 struct drm_connector base;
22 * @encoder: Internal encoder used by the connector to fulfill
23 * the DRM framework requirements. The users of the
24 * @drm_writeback_connector control the behaviour of the @encoder
25 * by passing the @enc_funcs parameter to drm_writeback_connector_init()
28 struct drm_encoder encoder;
31 * @pixel_formats_blob_ptr:
33 * DRM blob property data for the pixel formats list on writeback
35 * See also drm_writeback_connector_init()
37 struct drm_property_blob *pixel_formats_blob_ptr;
39 /** @job_lock: Protects job_queue */
45 * Holds a list of a connector's writeback jobs; the last item is the
46 * most recent. The first item may be either waiting for the hardware
47 * to begin writing, or currently being written.
49 * See also: drm_writeback_queue_job() and
50 * drm_writeback_signal_completion()
52 struct list_head job_queue;
57 * timeline context used for fence operations.
59 unsigned int fence_context;
63 * spinlock to protect the fences in the fence_context.
65 spinlock_t fence_lock;
69 * Seqno variable used as monotonic counter for the fences
70 * created on the connector's timeline.
72 unsigned long fence_seqno;
76 * The name of the connector's fence timeline.
78 char timeline_name[32];
81 struct drm_writeback_job {
85 * Used to allow drm_writeback_signal_completion to defer dropping the
86 * framebuffer reference to a workqueue
88 struct work_struct cleanup_work;
93 * List item for the writeback connector's @job_queue
95 struct list_head list_entry;
100 * Framebuffer to be written to by the writeback connector. Do not set
101 * directly, use drm_atomic_set_writeback_fb_for_connector()
103 struct drm_framebuffer *fb;
108 * Fence which will signal once the writeback has completed
110 struct dma_fence *out_fence;
113 static inline struct drm_writeback_connector *
114 drm_connector_to_writeback(struct drm_connector *connector)
116 return container_of(connector, struct drm_writeback_connector, base);
119 int drm_writeback_connector_init(struct drm_device *dev,
120 struct drm_writeback_connector *wb_connector,
121 const struct drm_connector_funcs *con_funcs,
122 const struct drm_encoder_helper_funcs *enc_helper_funcs,
123 const u32 *formats, int n_formats);
125 void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
126 struct drm_writeback_job *job);
128 void drm_writeback_cleanup_job(struct drm_writeback_job *job);
131 drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
135 drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector);