aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-09-27 20:28:23 -0400
committerDave Airlie <airlied@redhat.com>2016-09-27 20:28:23 -0400
commit3f346d5dcb591c2a5a26653d093af710cf2e5a31 (patch)
tree24384b63b4ba23912afa6dac409f354b097156ff /include
parent196ebdcc1db26977948c760664f024fa766950e4 (diff)
parent089cfdd9b0ec1b21d3356d2e057f69b89d46ae66 (diff)
Merge tag 'topic/drm-misc-2016-09-25' of git://anongit.freedesktop.org/drm-intel into drm-next
- more core cleanup patches to prep drm_file to be used for kernel-internal contexts (David Herrmann) - more split-up+docs for drm_crtc.c - lots of small fixes and polish all over * tag 'topic/drm-misc-2016-09-25' of git://anongit.freedesktop.org/drm-intel: (37 commits) drm: bridge: analogix/dp: mark symbols static where possible drm/bochs: mark bochs_connector_get_modes() static drm/bridge: analogix_dp: Improve panel on time drm/bridge: analogix_dp: Don't read EDID if panel present drm/bridge: analogix_dp: Remove duplicated code Revert "drm/i2c: tda998x: don't register the connector" drm: Fix plane type uabi breakage dma-buf/sync_file: free fences array in num_fences is 1 drm/i2c: tda998x: don't register the connector drm: Don't swallow error codes in drm_dev_alloc() drm: Distinguish no name from ENOMEM in set_unique() drm: Remove dirty property from docs drm/doc: Document color space handling drm: Extract drm_color_mgmt.[hc] drm/doc: Polish plane composition property docs drm: Conslidate blending properties in drm_blend.[hc] drm/doc: Polish for drm_plane.[hc] drm: Extract drm_plane.[hc] drm/tilcdc: Add atomic and crtc headers to crtc.c drm: Fix typo in encoder docs ...
Diffstat (limited to 'include')
-rw-r--r--include/drm/drmP.h1
-rw-r--r--include/drm/drm_atomic.h154
-rw-r--r--include/drm/drm_blend.h62
-rw-r--r--include/drm/drm_bridge.h218
-rw-r--r--include/drm/drm_color_mgmt.h61
-rw-r--r--include/drm/drm_connector.h28
-rw-r--r--include/drm/drm_core.h34
-rw-r--r--include/drm/drm_crtc.h887
-rw-r--r--include/drm/drm_edid.h30
-rw-r--r--include/drm/drm_encoder.h22
-rw-r--r--include/drm/drm_fb_helper.h5
-rw-r--r--include/drm/drm_framebuffer.h17
-rw-r--r--include/drm/drm_mode_object.h1
-rw-r--r--include/drm/drm_modes.h6
-rw-r--r--include/drm/drm_plane.h526
-rw-r--r--include/drm/drm_property.h1
-rw-r--r--include/drm/drm_vma_manager.h20
-rw-r--r--include/uapi/linux/sync_file.h13
18 files changed, 1145 insertions, 941 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e341e7f6eef5..c53dc90942e0 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -396,7 +396,6 @@ struct drm_file {
396 unsigned is_master:1; 396 unsigned is_master:1;
397 397
398 struct pid *pid; 398 struct pid *pid;
399 kuid_t uid;
400 drm_magic_t magic; 399 drm_magic_t magic;
401 struct list_head lhead; 400 struct list_head lhead;
402 struct drm_minor *minor; 401 struct drm_minor *minor;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 856a9c85a838..9701f2dfb784 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -30,6 +30,160 @@
30 30
31#include <drm/drm_crtc.h> 31#include <drm/drm_crtc.h>
32 32
33/**
34 * struct drm_crtc_commit - track modeset commits on a CRTC
35 *
36 * This structure is used to track pending modeset changes and atomic commit on
37 * a per-CRTC basis. Since updating the list should never block this structure
38 * is reference counted to allow waiters to safely wait on an event to complete,
39 * without holding any locks.
40 *
41 * It has 3 different events in total to allow a fine-grained synchronization
42 * between outstanding updates::
43 *
44 * atomic commit thread hardware
45 *
46 * write new state into hardware ----> ...
47 * signal hw_done
48 * switch to new state on next
49 * ... v/hblank
50 *
51 * wait for buffers to show up ...
52 *
53 * ... send completion irq
54 * irq handler signals flip_done
55 * cleanup old buffers
56 *
57 * signal cleanup_done
58 *
59 * wait for flip_done <----
60 * clean up atomic state
61 *
62 * The important bit to know is that cleanup_done is the terminal event, but the
63 * ordering between flip_done and hw_done is entirely up to the specific driver
64 * and modeset state change.
65 *
66 * For an implementation of how to use this look at
67 * drm_atomic_helper_setup_commit() from the atomic helper library.
68 */
69struct drm_crtc_commit {
70 /**
71 * @crtc:
72 *
73 * DRM CRTC for this commit.
74 */
75 struct drm_crtc *crtc;
76
77 /**
78 * @ref:
79 *
80 * Reference count for this structure. Needed to allow blocking on
81 * completions without the risk of the completion disappearing
82 * meanwhile.
83 */
84 struct kref ref;
85
86 /**
87 * @flip_done:
88 *
89 * Will be signaled when the hardware has flipped to the new set of
90 * buffers. Signals at the same time as when the drm event for this
91 * commit is sent to userspace, or when an out-fence is singalled. Note
92 * that for most hardware, in most cases this happens after @hw_done is
93 * signalled.
94 */
95 struct completion flip_done;
96
97 /**
98 * @hw_done:
99 *
100 * Will be signalled when all hw register changes for this commit have
101 * been written out. Especially when disabling a pipe this can be much
102 * later than than @flip_done, since that can signal already when the
103 * screen goes black, whereas to fully shut down a pipe more register
104 * I/O is required.
105 *
106 * Note that this does not need to include separately reference-counted
107 * resources like backing storage buffer pinning, or runtime pm
108 * management.
109 */
110 struct completion hw_done;
111
112 /**
113 * @cleanup_done:
114 *
115 * Will be signalled after old buffers have been cleaned up by calling
116 * drm_atomic_helper_cleanup_planes(). Since this can only happen after
117 * a vblank wait completed it might be a bit later. This completion is
118 * useful to throttle updates and avoid hardware updates getting ahead
119 * of the buffer cleanup too much.
120 */
121 struct completion cleanup_done;
122
123 /**
124 * @commit_entry:
125 *
126 * Entry on the per-CRTC commit_list. Protected by crtc->commit_lock.
127 */
128 struct list_head commit_entry;
129
130 /**
131 * @event:
132 *
133 * &drm_pending_vblank_event pointer to clean up private events.
134 */
135 struct drm_pending_vblank_event *event;
136};
137
138struct __drm_planes_state {
139 struct drm_plane *ptr;
140 struct drm_plane_state *state;
141};
142
143struct __drm_crtcs_state {
144 struct drm_crtc *ptr;
145 struct drm_crtc_state *state;
146 struct drm_crtc_commit *commit;
147};
148
149struct __drm_connnectors_state {
150 struct drm_connector *ptr;
151 struct drm_connector_state *state;
152};
153
154/**
155 * struct drm_atomic_state - the global state object for atomic updates
156 * @dev: parent DRM device
157 * @allow_modeset: allow full modeset
158 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
159 * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
160 * @planes: pointer to array of structures with per-plane data
161 * @crtcs: pointer to array of CRTC pointers
162 * @num_connector: size of the @connectors and @connector_states arrays
163 * @connectors: pointer to array of structures with per-connector data
164 * @acquire_ctx: acquire context for this atomic modeset state update
165 */
166struct drm_atomic_state {
167 struct drm_device *dev;
168 bool allow_modeset : 1;
169 bool legacy_cursor_update : 1;
170 bool legacy_set_config : 1;
171 struct __drm_planes_state *planes;
172 struct __drm_crtcs_state *crtcs;
173 int num_connector;
174 struct __drm_connnectors_state *connectors;
175
176 struct drm_modeset_acquire_ctx *acquire_ctx;
177
178 /**
179 * @commit_work:
180 *
181 * Work item which can be used by the driver or helpers to execute the
182 * commit without blocking.
183 */
184 struct work_struct commit_work;
185};
186
33void drm_crtc_commit_put(struct drm_crtc_commit *commit); 187void drm_crtc_commit_put(struct drm_crtc_commit *commit);
34static inline void drm_crtc_commit_get(struct drm_crtc_commit *commit) 188static inline void drm_crtc_commit_get(struct drm_crtc_commit *commit)
35{ 189{
diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h
new file mode 100644
index 000000000000..36baa175de99
--- /dev/null
+++ b/include/drm/drm_blend.h
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef __DRM_BLEND_H__
24#define __DRM_BLEND_H__
25
26#include <linux/list.h>
27#include <linux/ctype.h>
28
29struct drm_device;
30struct drm_atomic_state;
31
32/*
33 * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the
34 * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and
35 * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation
36 *
37 * WARNING: These defines are UABI since they're exposed in the rotation
38 * property.
39 */
40#define DRM_ROTATE_0 BIT(0)
41#define DRM_ROTATE_90 BIT(1)
42#define DRM_ROTATE_180 BIT(2)
43#define DRM_ROTATE_270 BIT(3)
44#define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \
45 DRM_ROTATE_180 | DRM_ROTATE_270)
46#define DRM_REFLECT_X BIT(4)
47#define DRM_REFLECT_Y BIT(5)
48#define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y)
49
50struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
51 unsigned int supported_rotations);
52unsigned int drm_rotation_simplify(unsigned int rotation,
53 unsigned int supported_rotations);
54
55int drm_plane_create_zpos_property(struct drm_plane *plane,
56 unsigned int zpos,
57 unsigned int min, unsigned int max);
58int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
59 unsigned int zpos);
60int drm_atomic_normalize_zpos(struct drm_device *dev,
61 struct drm_atomic_state *state);
62#endif
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
new file mode 100644
index 000000000000..530a1d6e8cde
--- /dev/null
+++ b/include/drm/drm_bridge.h
@@ -0,0 +1,218 @@
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef __DRM_BRIDGE_H__
24#define __DRM_BRIDGE_H__
25
26#include <linux/list.h>
27#include <linux/ctype.h>
28#include <drm/drm_mode_object.h>
29#include <drm/drm_modes.h>
30
31struct drm_bridge;
32
33/**
34 * struct drm_bridge_funcs - drm_bridge control functions
35 */
36struct drm_bridge_funcs {
37 /**
38 * @attach:
39 *
40 * This callback is invoked whenever our bridge is being attached to a
41 * &drm_encoder.
42 *
43 * The attach callback is optional.
44 *
45 * RETURNS:
46 *
47 * Zero on success, error code on failure.
48 */
49 int (*attach)(struct drm_bridge *bridge);
50
51 /**
52 * @detach:
53 *
54 * This callback is invoked whenever our bridge is being detached from a
55 * &drm_encoder.
56 *
57 * The detach callback is optional.
58 */
59 void (*detach)(struct drm_bridge *bridge);
60
61 /**
62 * @mode_fixup:
63 *
64 * This callback is used to validate and adjust a mode. The paramater
65 * mode is the display mode that should be fed to the next element in
66 * the display chain, either the final &drm_connector or the next
67 * &drm_bridge. The parameter adjusted_mode is the input mode the bridge
68 * requires. It can be modified by this callback and does not need to
69 * match mode.
70 *
71 * This is the only hook that allows a bridge to reject a modeset. If
72 * this function passes all other callbacks must succeed for this
73 * configuration.
74 *
75 * The mode_fixup callback is optional.
76 *
77 * NOTE:
78 *
79 * This function is called in the check phase of atomic modesets, which
80 * can be aborted for any reason (including on userspace's request to
81 * just check whether a configuration would be possible). Drivers MUST
82 * NOT touch any persistent state (hardware or software) or data
83 * structures except the passed in @state parameter.
84 *
85 * RETURNS:
86 *
87 * True if an acceptable configuration is possible, false if the modeset
88 * operation should be rejected.
89 */
90 bool (*mode_fixup)(struct drm_bridge *bridge,
91 const struct drm_display_mode *mode,
92 struct drm_display_mode *adjusted_mode);
93 /**
94 * @disable:
95 *
96 * This callback should disable the bridge. It is called right before
97 * the preceding element in the display pipe is disabled. If the
98 * preceding element is a bridge this means it's called before that
99 * bridge's ->disable() function. If the preceding element is a
100 * &drm_encoder it's called right before the encoder's ->disable(),
101 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
102 *
103 * The bridge can assume that the display pipe (i.e. clocks and timing
104 * signals) feeding it is still running when this callback is called.
105 *
106 * The disable callback is optional.
107 */
108 void (*disable)(struct drm_bridge *bridge);
109
110 /**
111 * @post_disable:
112 *
113 * This callback should disable the bridge. It is called right after
114 * the preceding element in the display pipe is disabled. If the
115 * preceding element is a bridge this means it's called after that
116 * bridge's ->post_disable() function. If the preceding element is a
117 * &drm_encoder it's called right after the encoder's ->disable(),
118 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
119 *
120 * The bridge must assume that the display pipe (i.e. clocks and timing
121 * singals) feeding it is no longer running when this callback is
122 * called.
123 *
124 * The post_disable callback is optional.
125 */
126 void (*post_disable)(struct drm_bridge *bridge);
127
128 /**
129 * @mode_set:
130 *
131 * This callback should set the given mode on the bridge. It is called
132 * after the ->mode_set() callback for the preceding element in the
133 * display pipeline has been called already. The display pipe (i.e.
134 * clocks and timing signals) is off when this function is called.
135 */
136 void (*mode_set)(struct drm_bridge *bridge,
137 struct drm_display_mode *mode,
138 struct drm_display_mode *adjusted_mode);
139 /**
140 * @pre_enable:
141 *
142 * This callback should enable the bridge. It is called right before
143 * the preceding element in the display pipe is enabled. If the
144 * preceding element is a bridge this means it's called before that
145 * bridge's ->pre_enable() function. If the preceding element is a
146 * &drm_encoder it's called right before the encoder's ->enable(),
147 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
148 *
149 * The display pipe (i.e. clocks and timing signals) feeding this bridge
150 * will not yet be running when this callback is called. The bridge must
151 * not enable the display link feeding the next bridge in the chain (if
152 * there is one) when this callback is called.
153 *
154 * The pre_enable callback is optional.
155 */
156 void (*pre_enable)(struct drm_bridge *bridge);
157
158 /**
159 * @enable:
160 *
161 * This callback should enable the bridge. It is called right after
162 * the preceding element in the display pipe is enabled. If the
163 * preceding element is a bridge this means it's called after that
164 * bridge's ->enable() function. If the preceding element is a
165 * &drm_encoder it's called right after the encoder's ->enable(),
166 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
167 *
168 * The bridge can assume that the display pipe (i.e. clocks and timing
169 * signals) feeding it is running when this callback is called. This
170 * callback must enable the display link feeding the next bridge in the
171 * chain if there is one.
172 *
173 * The enable callback is optional.
174 */
175 void (*enable)(struct drm_bridge *bridge);
176};
177
178/**
179 * struct drm_bridge - central DRM bridge control structure
180 * @dev: DRM device this bridge belongs to
181 * @encoder: encoder to which this bridge is connected
182 * @next: the next bridge in the encoder chain
183 * @of_node: device node pointer to the bridge
184 * @list: to keep track of all added bridges
185 * @funcs: control functions
186 * @driver_private: pointer to the bridge driver's internal context
187 */
188struct drm_bridge {
189 struct drm_device *dev;
190 struct drm_encoder *encoder;
191 struct drm_bridge *next;
192#ifdef CONFIG_OF
193 struct device_node *of_node;
194#endif
195 struct list_head list;
196
197 const struct drm_bridge_funcs *funcs;
198 void *driver_private;
199};
200
201int drm_bridge_add(struct drm_bridge *bridge);
202void drm_bridge_remove(struct drm_bridge *bridge);
203struct drm_bridge *of_drm_find_bridge(struct device_node *np);
204int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
205void drm_bridge_detach(struct drm_bridge *bridge);
206
207bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
208 const struct drm_display_mode *mode,
209 struct drm_display_mode *adjusted_mode);
210void drm_bridge_disable(struct drm_bridge *bridge);
211void drm_bridge_post_disable(struct drm_bridge *bridge);
212void drm_bridge_mode_set(struct drm_bridge *bridge,
213 struct drm_display_mode *mode,
214 struct drm_display_mode *adjusted_mode);
215void drm_bridge_pre_enable(struct drm_bridge *bridge);
216void drm_bridge_enable(struct drm_bridge *bridge);
217
218#endif
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
new file mode 100644
index 000000000000..c767238ac9d5
--- /dev/null
+++ b/include/drm/drm_color_mgmt.h
@@ -0,0 +1,61 @@
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef __DRM_COLOR_MGMT_H__
24#define __DRM_COLOR_MGMT_H__
25
26#include <linux/ctype.h>
27
28void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
29 uint degamma_lut_size,
30 bool has_ctm,
31 uint gamma_lut_size);
32
33int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
34 int gamma_size);
35
36/**
37 * drm_color_lut_extract - clamp&round LUT entries
38 * @user_input: input value
39 * @bit_precision: number of bits the hw LUT supports
40 *
41 * Extract a degamma/gamma LUT value provided by user (in the form of
42 * &drm_color_lut entries) and round it to the precision supported by the
43 * hardware.
44 */
45static inline uint32_t drm_color_lut_extract(uint32_t user_input,
46 uint32_t bit_precision)
47{
48 uint32_t val = user_input;
49 uint32_t max = 0xffff >> (16 - bit_precision);
50
51 /* Round only if we're not using full precision. */
52 if (bit_precision < 16) {
53 val += 1UL << (16 - bit_precision - 1);
54 val >>= 16 - bit_precision;
55 }
56
57 return clamp_val(val, 0, max);
58}
59
60
61#endif
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 66b7d6744dd2..51a15deda161 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -27,6 +27,10 @@
27#include <linux/ctype.h> 27#include <linux/ctype.h>
28#include <drm/drm_mode_object.h> 28#include <drm/drm_mode_object.h>
29 29
30#include <uapi/drm/drm_mode.h>
31
32struct drm_device;
33
30struct drm_connector_helper_funcs; 34struct drm_connector_helper_funcs;
31struct drm_device; 35struct drm_device;
32struct drm_crtc; 36struct drm_crtc;
@@ -181,14 +185,19 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
181/** 185/**
182 * struct drm_connector_state - mutable connector state 186 * struct drm_connector_state - mutable connector state
183 * @connector: backpointer to the connector 187 * @connector: backpointer to the connector
184 * @crtc: CRTC to connect connector to, NULL if disabled
185 * @best_encoder: can be used by helpers and drivers to select the encoder 188 * @best_encoder: can be used by helpers and drivers to select the encoder
186 * @state: backpointer to global drm_atomic_state 189 * @state: backpointer to global drm_atomic_state
187 */ 190 */
188struct drm_connector_state { 191struct drm_connector_state {
189 struct drm_connector *connector; 192 struct drm_connector *connector;
190 193
191 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ 194 /**
195 * @crtc: CRTC to connect connector to, NULL if disabled.
196 *
197 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
198 * instead.
199 */
200 struct drm_crtc *crtc;
192 201
193 struct drm_encoder *best_encoder; 202 struct drm_encoder *best_encoder;
194 203
@@ -744,4 +753,19 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
744int drm_mode_connector_set_tile_property(struct drm_connector *connector); 753int drm_mode_connector_set_tile_property(struct drm_connector *connector);
745int drm_mode_connector_update_edid_property(struct drm_connector *connector, 754int drm_mode_connector_update_edid_property(struct drm_connector *connector,
746 const struct edid *edid); 755 const struct edid *edid);
756
757/**
758 * drm_for_each_connector - iterate over all connectors
759 * @connector: the loop cursor
760 * @dev: the DRM device
761 *
762 * Iterate over all connectors of @dev.
763 */
764#define drm_for_each_connector(connector, dev) \
765 for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \
766 connector = list_first_entry(&(dev)->mode_config.connector_list, \
767 struct drm_connector, head); \
768 &connector->head != (&(dev)->mode_config.connector_list); \
769 connector = list_next_entry(connector, head))
770
747#endif 771#endif
diff --git a/include/drm/drm_core.h b/include/drm/drm_core.h
deleted file mode 100644
index 4e7523863a4b..000000000000
--- a/include/drm/drm_core.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright 2004 Jon Smirl <jonsmirl@gmail.com>
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, sub license,
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
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23#define CORE_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"
24
25#define CORE_NAME "drm"
26#define CORE_DESC "DRM shared core routines"
27#define CORE_DATE "20060810"
28
29#define DRM_IF_MAJOR 1
30#define DRM_IF_MINOR 4
31
32#define CORE_MAJOR 1
33#define CORE_MINOR 1
34#define CORE_PATCHLEVEL 0
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8ca71d66282b..a544b7502493 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -42,6 +42,11 @@
42#include <drm/drm_connector.h> 42#include <drm/drm_connector.h>
43#include <drm/drm_encoder.h> 43#include <drm/drm_encoder.h>
44#include <drm/drm_property.h> 44#include <drm/drm_property.h>
45#include <drm/drm_bridge.h>
46#include <drm/drm_edid.h>
47#include <drm/drm_plane.h>
48#include <drm/drm_blend.h>
49#include <drm/drm_color_mgmt.h>
45 50
46struct drm_device; 51struct drm_device;
47struct drm_mode_set; 52struct drm_mode_set;
@@ -60,21 +65,6 @@ static inline uint64_t I642U64(int64_t val)
60 return (uint64_t)*((uint64_t *)&val); 65 return (uint64_t)*((uint64_t *)&val);
61} 66}
62 67
63/*
64 * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the
65 * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and
66 * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation
67 */
68#define DRM_ROTATE_0 BIT(0)
69#define DRM_ROTATE_90 BIT(1)
70#define DRM_ROTATE_180 BIT(2)
71#define DRM_ROTATE_270 BIT(3)
72#define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \
73 DRM_ROTATE_180 | DRM_ROTATE_270)
74#define DRM_REFLECT_X BIT(4)
75#define DRM_REFLECT_Y BIT(5)
76#define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y)
77
78/* data corresponds to displayid vend/prod/serial */ 68/* data corresponds to displayid vend/prod/serial */
79struct drm_tile_group { 69struct drm_tile_group {
80 struct kref refcount; 70 struct kref refcount;
@@ -655,693 +645,6 @@ struct drm_crtc {
655}; 645};
656 646
657/** 647/**
658 * struct drm_plane_state - mutable plane state
659 * @plane: backpointer to the plane
660 * @crtc: currently bound CRTC, NULL if disabled
661 * @fb: currently bound framebuffer
662 * @fence: optional fence to wait for before scanning out @fb
663 * @crtc_x: left position of visible portion of plane on crtc
664 * @crtc_y: upper position of visible portion of plane on crtc
665 * @crtc_w: width of visible portion of plane on crtc
666 * @crtc_h: height of visible portion of plane on crtc
667 * @src_x: left position of visible portion of plane within
668 * plane (in 16.16)
669 * @src_y: upper position of visible portion of plane within
670 * plane (in 16.16)
671 * @src_w: width of visible portion of plane (in 16.16)
672 * @src_h: height of visible portion of plane (in 16.16)
673 * @rotation: rotation of the plane
674 * @zpos: priority of the given plane on crtc (optional)
675 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
676 * where N is the number of active planes for given crtc
677 * @src: clipped source coordinates of the plane (in 16.16)
678 * @dst: clipped destination coordinates of the plane
679 * @visible: visibility of the plane
680 * @state: backpointer to global drm_atomic_state
681 */
682struct drm_plane_state {
683 struct drm_plane *plane;
684
685 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
686 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
687 struct fence *fence;
688
689 /* Signed dest location allows it to be partially off screen */
690 int32_t crtc_x, crtc_y;
691 uint32_t crtc_w, crtc_h;
692
693 /* Source values are 16.16 fixed point */
694 uint32_t src_x, src_y;
695 uint32_t src_h, src_w;
696
697 /* Plane rotation */
698 unsigned int rotation;
699
700 /* Plane zpos */
701 unsigned int zpos;
702 unsigned int normalized_zpos;
703
704 /* Clipped coordinates */
705 struct drm_rect src, dst;
706
707 /*
708 * Is the plane actually visible? Can be false even
709 * if fb!=NULL and crtc!=NULL, due to clipping.
710 */
711 bool visible;
712
713 struct drm_atomic_state *state;
714};
715
716
717/**
718 * struct drm_plane_funcs - driver plane control functions
719 */
720struct drm_plane_funcs {
721 /**
722 * @update_plane:
723 *
724 * This is the legacy entry point to enable and configure the plane for
725 * the given CRTC and framebuffer. It is never called to disable the
726 * plane, i.e. the passed-in crtc and fb paramters are never NULL.
727 *
728 * The source rectangle in frame buffer memory coordinates is given by
729 * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
730 * values). Devices that don't support subpixel plane coordinates can
731 * ignore the fractional part.
732 *
733 * The destination rectangle in CRTC coordinates is given by the
734 * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
735 * Devices scale the source rectangle to the destination rectangle. If
736 * scaling is not supported, and the source rectangle size doesn't match
737 * the destination rectangle size, the driver must return a
738 * -<errorname>EINVAL</errorname> error.
739 *
740 * Drivers implementing atomic modeset should use
741 * drm_atomic_helper_update_plane() to implement this hook.
742 *
743 * RETURNS:
744 *
745 * 0 on success or a negative error code on failure.
746 */
747 int (*update_plane)(struct drm_plane *plane,
748 struct drm_crtc *crtc, struct drm_framebuffer *fb,
749 int crtc_x, int crtc_y,
750 unsigned int crtc_w, unsigned int crtc_h,
751 uint32_t src_x, uint32_t src_y,
752 uint32_t src_w, uint32_t src_h);
753
754 /**
755 * @disable_plane:
756 *
757 * This is the legacy entry point to disable the plane. The DRM core
758 * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
759 * with the frame buffer ID set to 0. Disabled planes must not be
760 * processed by the CRTC.
761 *
762 * Drivers implementing atomic modeset should use
763 * drm_atomic_helper_disable_plane() to implement this hook.
764 *
765 * RETURNS:
766 *
767 * 0 on success or a negative error code on failure.
768 */
769 int (*disable_plane)(struct drm_plane *plane);
770
771 /**
772 * @destroy:
773 *
774 * Clean up plane resources. This is only called at driver unload time
775 * through drm_mode_config_cleanup() since a plane cannot be hotplugged
776 * in DRM.
777 */
778 void (*destroy)(struct drm_plane *plane);
779
780 /**
781 * @reset:
782 *
783 * Reset plane hardware and software state to off. This function isn't
784 * called by the core directly, only through drm_mode_config_reset().
785 * It's not a helper hook only for historical reasons.
786 *
787 * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
788 * atomic state using this hook.
789 */
790 void (*reset)(struct drm_plane *plane);
791
792 /**
793 * @set_property:
794 *
795 * This is the legacy entry point to update a property attached to the
796 * plane.
797 *
798 * Drivers implementing atomic modeset should use
799 * drm_atomic_helper_plane_set_property() to implement this hook.
800 *
801 * This callback is optional if the driver does not support any legacy
802 * driver-private properties.
803 *
804 * RETURNS:
805 *
806 * 0 on success or a negative error code on failure.
807 */
808 int (*set_property)(struct drm_plane *plane,
809 struct drm_property *property, uint64_t val);
810
811 /**
812 * @atomic_duplicate_state:
813 *
814 * Duplicate the current atomic state for this plane and return it.
815 * The core and helpers gurantee that any atomic state duplicated with
816 * this hook and still owned by the caller (i.e. not transferred to the
817 * driver by calling ->atomic_commit() from struct
818 * &drm_mode_config_funcs) will be cleaned up by calling the
819 * @atomic_destroy_state hook in this structure.
820 *
821 * Atomic drivers which don't subclass struct &drm_plane_state should use
822 * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
823 * state structure to extend it with driver-private state should use
824 * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
825 * duplicated in a consistent fashion across drivers.
826 *
827 * It is an error to call this hook before plane->state has been
828 * initialized correctly.
829 *
830 * NOTE:
831 *
832 * If the duplicate state references refcounted resources this hook must
833 * acquire a reference for each of them. The driver must release these
834 * references again in @atomic_destroy_state.
835 *
836 * RETURNS:
837 *
838 * Duplicated atomic state or NULL when the allocation failed.
839 */
840 struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
841
842 /**
843 * @atomic_destroy_state:
844 *
845 * Destroy a state duplicated with @atomic_duplicate_state and release
846 * or unreference all resources it references
847 */
848 void (*atomic_destroy_state)(struct drm_plane *plane,
849 struct drm_plane_state *state);
850
851 /**
852 * @atomic_set_property:
853 *
854 * Decode a driver-private property value and store the decoded value
855 * into the passed-in state structure. Since the atomic core decodes all
856 * standardized properties (even for extensions beyond the core set of
857 * properties which might not be implemented by all drivers) this
858 * requires drivers to subclass the state structure.
859 *
860 * Such driver-private properties should really only be implemented for
861 * truly hardware/vendor specific state. Instead it is preferred to
862 * standardize atomic extension and decode the properties used to expose
863 * such an extension in the core.
864 *
865 * Do not call this function directly, use
866 * drm_atomic_plane_set_property() instead.
867 *
868 * This callback is optional if the driver does not support any
869 * driver-private atomic properties.
870 *
871 * NOTE:
872 *
873 * This function is called in the state assembly phase of atomic
874 * modesets, which can be aborted for any reason (including on
875 * userspace's request to just check whether a configuration would be
876 * possible). Drivers MUST NOT touch any persistent state (hardware or
877 * software) or data structures except the passed in @state parameter.
878 *
879 * Also since userspace controls in which order properties are set this
880 * function must not do any input validation (since the state update is
881 * incomplete and hence likely inconsistent). Instead any such input
882 * validation must be done in the various atomic_check callbacks.
883 *
884 * RETURNS:
885 *
886 * 0 if the property has been found, -EINVAL if the property isn't
887 * implemented by the driver (which shouldn't ever happen, the core only
888 * asks for properties attached to this plane). No other validation is
889 * allowed by the driver. The core already checks that the property
890 * value is within the range (integer, valid enum value, ...) the driver
891 * set when registering the property.
892 */
893 int (*atomic_set_property)(struct drm_plane *plane,
894 struct drm_plane_state *state,
895 struct drm_property *property,
896 uint64_t val);
897
898 /**
899 * @atomic_get_property:
900 *
901 * Reads out the decoded driver-private property. This is used to
902 * implement the GETPLANE IOCTL.
903 *
904 * Do not call this function directly, use
905 * drm_atomic_plane_get_property() instead.
906 *
907 * This callback is optional if the driver does not support any
908 * driver-private atomic properties.
909 *
910 * RETURNS:
911 *
912 * 0 on success, -EINVAL if the property isn't implemented by the
913 * driver (which should never happen, the core only asks for
914 * properties attached to this plane).
915 */
916 int (*atomic_get_property)(struct drm_plane *plane,
917 const struct drm_plane_state *state,
918 struct drm_property *property,
919 uint64_t *val);
920 /**
921 * @late_register:
922 *
923 * This optional hook can be used to register additional userspace
924 * interfaces attached to the plane like debugfs interfaces.
925 * It is called late in the driver load sequence from drm_dev_register().
926 * Everything added from this callback should be unregistered in
927 * the early_unregister callback.
928 *
929 * Returns:
930 *
931 * 0 on success, or a negative error code on failure.
932 */
933 int (*late_register)(struct drm_plane *plane);
934
935 /**
936 * @early_unregister:
937 *
938 * This optional hook should be used to unregister the additional
939 * userspace interfaces attached to the plane from
940 * late_unregister(). It is called from drm_dev_unregister(),
941 * early in the driver unload sequence to disable userspace access
942 * before data structures are torndown.
943 */
944 void (*early_unregister)(struct drm_plane *plane);
945};
946
947enum drm_plane_type {
948 DRM_PLANE_TYPE_OVERLAY,
949 DRM_PLANE_TYPE_PRIMARY,
950 DRM_PLANE_TYPE_CURSOR,
951};
952
953
954/**
955 * struct drm_plane - central DRM plane control structure
956 * @dev: DRM device this plane belongs to
957 * @head: for list management
958 * @name: human readable name, can be overwritten by the driver
959 * @base: base mode object
960 * @possible_crtcs: pipes this plane can be bound to
961 * @format_types: array of formats supported by this plane
962 * @format_count: number of formats supported
963 * @format_default: driver hasn't supplied supported formats for the plane
964 * @crtc: currently bound CRTC
965 * @fb: currently bound fb
966 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
967 * drm_mode_set_config_internal() to implement correct refcounting.
968 * @funcs: helper functions
969 * @properties: property tracking for this plane
970 * @type: type of plane (overlay, primary, cursor)
971 * @state: current atomic state for this plane
972 * @zpos_property: zpos property for this plane
973 * @helper_private: mid-layer private data
974 */
975struct drm_plane {
976 struct drm_device *dev;
977 struct list_head head;
978
979 char *name;
980
981 /**
982 * @mutex:
983 *
984 * Protects modeset plane state, together with the mutex of &drm_crtc
985 * this plane is linked to (when active, getting actived or getting
986 * disabled).
987 */
988 struct drm_modeset_lock mutex;
989
990 struct drm_mode_object base;
991
992 uint32_t possible_crtcs;
993 uint32_t *format_types;
994 unsigned int format_count;
995 bool format_default;
996
997 struct drm_crtc *crtc;
998 struct drm_framebuffer *fb;
999
1000 struct drm_framebuffer *old_fb;
1001
1002 const struct drm_plane_funcs *funcs;
1003
1004 struct drm_object_properties properties;
1005
1006 enum drm_plane_type type;
1007
1008 /**
1009 * @index: Position inside the mode_config.list, can be used as an array
1010 * index. It is invariant over the lifetime of the plane.
1011 */
1012 unsigned index;
1013
1014 const struct drm_plane_helper_funcs *helper_private;
1015
1016 struct drm_plane_state *state;
1017
1018 struct drm_property *zpos_property;
1019};
1020
1021/**
1022 * struct drm_bridge_funcs - drm_bridge control functions
1023 */
1024struct drm_bridge_funcs {
1025 /**
1026 * @attach:
1027 *
1028 * This callback is invoked whenever our bridge is being attached to a
1029 * &drm_encoder.
1030 *
1031 * The attach callback is optional.
1032 *
1033 * RETURNS:
1034 *
1035 * Zero on success, error code on failure.
1036 */
1037 int (*attach)(struct drm_bridge *bridge);
1038
1039 /**
1040 * @detach:
1041 *
1042 * This callback is invoked whenever our bridge is being detached from a
1043 * &drm_encoder.
1044 *
1045 * The detach callback is optional.
1046 */
1047 void (*detach)(struct drm_bridge *bridge);
1048
1049 /**
1050 * @mode_fixup:
1051 *
1052 * This callback is used to validate and adjust a mode. The paramater
1053 * mode is the display mode that should be fed to the next element in
1054 * the display chain, either the final &drm_connector or the next
1055 * &drm_bridge. The parameter adjusted_mode is the input mode the bridge
1056 * requires. It can be modified by this callback and does not need to
1057 * match mode.
1058 *
1059 * This is the only hook that allows a bridge to reject a modeset. If
1060 * this function passes all other callbacks must succeed for this
1061 * configuration.
1062 *
1063 * The mode_fixup callback is optional.
1064 *
1065 * NOTE:
1066 *
1067 * This function is called in the check phase of atomic modesets, which
1068 * can be aborted for any reason (including on userspace's request to
1069 * just check whether a configuration would be possible). Drivers MUST
1070 * NOT touch any persistent state (hardware or software) or data
1071 * structures except the passed in @state parameter.
1072 *
1073 * RETURNS:
1074 *
1075 * True if an acceptable configuration is possible, false if the modeset
1076 * operation should be rejected.
1077 */
1078 bool (*mode_fixup)(struct drm_bridge *bridge,
1079 const struct drm_display_mode *mode,
1080 struct drm_display_mode *adjusted_mode);
1081 /**
1082 * @disable:
1083 *
1084 * This callback should disable the bridge. It is called right before
1085 * the preceding element in the display pipe is disabled. If the
1086 * preceding element is a bridge this means it's called before that
1087 * bridge's ->disable() function. If the preceding element is a
1088 * &drm_encoder it's called right before the encoder's ->disable(),
1089 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
1090 *
1091 * The bridge can assume that the display pipe (i.e. clocks and timing
1092 * signals) feeding it is still running when this callback is called.
1093 *
1094 * The disable callback is optional.
1095 */
1096 void (*disable)(struct drm_bridge *bridge);
1097
1098 /**
1099 * @post_disable:
1100 *
1101 * This callback should disable the bridge. It is called right after
1102 * the preceding element in the display pipe is disabled. If the
1103 * preceding element is a bridge this means it's called after that
1104 * bridge's ->post_disable() function. If the preceding element is a
1105 * &drm_encoder it's called right after the encoder's ->disable(),
1106 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
1107 *
1108 * The bridge must assume that the display pipe (i.e. clocks and timing
1109 * singals) feeding it is no longer running when this callback is
1110 * called.
1111 *
1112 * The post_disable callback is optional.
1113 */
1114 void (*post_disable)(struct drm_bridge *bridge);
1115
1116 /**
1117 * @mode_set:
1118 *
1119 * This callback should set the given mode on the bridge. It is called
1120 * after the ->mode_set() callback for the preceding element in the
1121 * display pipeline has been called already. The display pipe (i.e.
1122 * clocks and timing signals) is off when this function is called.
1123 */
1124 void (*mode_set)(struct drm_bridge *bridge,
1125 struct drm_display_mode *mode,
1126 struct drm_display_mode *adjusted_mode);
1127 /**
1128 * @pre_enable:
1129 *
1130 * This callback should enable the bridge. It is called right before
1131 * the preceding element in the display pipe is enabled. If the
1132 * preceding element is a bridge this means it's called before that
1133 * bridge's ->pre_enable() function. If the preceding element is a
1134 * &drm_encoder it's called right before the encoder's ->enable(),
1135 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
1136 *
1137 * The display pipe (i.e. clocks and timing signals) feeding this bridge
1138 * will not yet be running when this callback is called. The bridge must
1139 * not enable the display link feeding the next bridge in the chain (if
1140 * there is one) when this callback is called.
1141 *
1142 * The pre_enable callback is optional.
1143 */
1144 void (*pre_enable)(struct drm_bridge *bridge);
1145
1146 /**
1147 * @enable:
1148 *
1149 * This callback should enable the bridge. It is called right after
1150 * the preceding element in the display pipe is enabled. If the
1151 * preceding element is a bridge this means it's called after that
1152 * bridge's ->enable() function. If the preceding element is a
1153 * &drm_encoder it's called right after the encoder's ->enable(),
1154 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
1155 *
1156 * The bridge can assume that the display pipe (i.e. clocks and timing
1157 * signals) feeding it is running when this callback is called. This
1158 * callback must enable the display link feeding the next bridge in the
1159 * chain if there is one.
1160 *
1161 * The enable callback is optional.
1162 */
1163 void (*enable)(struct drm_bridge *bridge);
1164};
1165
1166/**
1167 * struct drm_bridge - central DRM bridge control structure
1168 * @dev: DRM device this bridge belongs to
1169 * @encoder: encoder to which this bridge is connected
1170 * @next: the next bridge in the encoder chain
1171 * @of_node: device node pointer to the bridge
1172 * @list: to keep track of all added bridges
1173 * @funcs: control functions
1174 * @driver_private: pointer to the bridge driver's internal context
1175 */
1176struct drm_bridge {
1177 struct drm_device *dev;
1178 struct drm_encoder *encoder;
1179 struct drm_bridge *next;
1180#ifdef CONFIG_OF
1181 struct device_node *of_node;
1182#endif
1183 struct list_head list;
1184
1185 const struct drm_bridge_funcs *funcs;
1186 void *driver_private;
1187};
1188
1189/**
1190 * struct drm_crtc_commit - track modeset commits on a CRTC
1191 *
1192 * This structure is used to track pending modeset changes and atomic commit on
1193 * a per-CRTC basis. Since updating the list should never block this structure
1194 * is reference counted to allow waiters to safely wait on an event to complete,
1195 * without holding any locks.
1196 *
1197 * It has 3 different events in total to allow a fine-grained synchronization
1198 * between outstanding updates::
1199 *
1200 * atomic commit thread hardware
1201 *
1202 * write new state into hardware ----> ...
1203 * signal hw_done
1204 * switch to new state on next
1205 * ... v/hblank
1206 *
1207 * wait for buffers to show up ...
1208 *
1209 * ... send completion irq
1210 * irq handler signals flip_done
1211 * cleanup old buffers
1212 *
1213 * signal cleanup_done
1214 *
1215 * wait for flip_done <----
1216 * clean up atomic state
1217 *
1218 * The important bit to know is that cleanup_done is the terminal event, but the
1219 * ordering between flip_done and hw_done is entirely up to the specific driver
1220 * and modeset state change.
1221 *
1222 * For an implementation of how to use this look at
1223 * drm_atomic_helper_setup_commit() from the atomic helper library.
1224 */
1225struct drm_crtc_commit {
1226 /**
1227 * @crtc:
1228 *
1229 * DRM CRTC for this commit.
1230 */
1231 struct drm_crtc *crtc;
1232
1233 /**
1234 * @ref:
1235 *
1236 * Reference count for this structure. Needed to allow blocking on
1237 * completions without the risk of the completion disappearing
1238 * meanwhile.
1239 */
1240 struct kref ref;
1241
1242 /**
1243 * @flip_done:
1244 *
1245 * Will be signaled when the hardware has flipped to the new set of
1246 * buffers. Signals at the same time as when the drm event for this
1247 * commit is sent to userspace, or when an out-fence is singalled. Note
1248 * that for most hardware, in most cases this happens after @hw_done is
1249 * signalled.
1250 */
1251 struct completion flip_done;
1252
1253 /**
1254 * @hw_done:
1255 *
1256 * Will be signalled when all hw register changes for this commit have
1257 * been written out. Especially when disabling a pipe this can be much
1258 * later than than @flip_done, since that can signal already when the
1259 * screen goes black, whereas to fully shut down a pipe more register
1260 * I/O is required.
1261 *
1262 * Note that this does not need to include separately reference-counted
1263 * resources like backing storage buffer pinning, or runtime pm
1264 * management.
1265 */
1266 struct completion hw_done;
1267
1268 /**
1269 * @cleanup_done:
1270 *
1271 * Will be signalled after old buffers have been cleaned up by calling
1272 * drm_atomic_helper_cleanup_planes(). Since this can only happen after
1273 * a vblank wait completed it might be a bit later. This completion is
1274 * useful to throttle updates and avoid hardware updates getting ahead
1275 * of the buffer cleanup too much.
1276 */
1277 struct completion cleanup_done;
1278
1279 /**
1280 * @commit_entry:
1281 *
1282 * Entry on the per-CRTC commit_list. Protected by crtc->commit_lock.
1283 */
1284 struct list_head commit_entry;
1285
1286 /**
1287 * @event:
1288 *
1289 * &drm_pending_vblank_event pointer to clean up private events.
1290 */
1291 struct drm_pending_vblank_event *event;
1292};
1293
1294struct __drm_planes_state {
1295 struct drm_plane *ptr;
1296 struct drm_plane_state *state;
1297};
1298
1299struct __drm_crtcs_state {
1300 struct drm_crtc *ptr;
1301 struct drm_crtc_state *state;
1302 struct drm_crtc_commit *commit;
1303};
1304
1305struct __drm_connnectors_state {
1306 struct drm_connector *ptr;
1307 struct drm_connector_state *state;
1308};
1309
1310/**
1311 * struct drm_atomic_state - the global state object for atomic updates
1312 * @dev: parent DRM device
1313 * @allow_modeset: allow full modeset
1314 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
1315 * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
1316 * @planes: pointer to array of structures with per-plane data
1317 * @crtcs: pointer to array of CRTC pointers
1318 * @num_connector: size of the @connectors and @connector_states arrays
1319 * @connectors: pointer to array of structures with per-connector data
1320 * @acquire_ctx: acquire context for this atomic modeset state update
1321 */
1322struct drm_atomic_state {
1323 struct drm_device *dev;
1324 bool allow_modeset : 1;
1325 bool legacy_cursor_update : 1;
1326 bool legacy_set_config : 1;
1327 struct __drm_planes_state *planes;
1328 struct __drm_crtcs_state *crtcs;
1329 int num_connector;
1330 struct __drm_connnectors_state *connectors;
1331
1332 struct drm_modeset_acquire_ctx *acquire_ctx;
1333
1334 /**
1335 * @commit_work:
1336 *
1337 * Work item which can be used by the driver or helpers to execute the
1338 * commit without blocking.
1339 */
1340 struct work_struct commit_work;
1341};
1342
1343
1344/**
1345 * struct drm_mode_set - new values for a CRTC config change 648 * struct drm_mode_set - new values for a CRTC config change
1346 * @fb: framebuffer to use for new config 649 * @fb: framebuffer to use for new config
1347 * @crtc: CRTC whose configuration we're about to change 650 * @crtc: CRTC whose configuration we're about to change
@@ -1991,35 +1294,7 @@ struct drm_mode_config {
1991 struct drm_mode_config_helper_funcs *helper_private; 1294 struct drm_mode_config_helper_funcs *helper_private;
1992}; 1295};
1993 1296
1994/**
1995 * drm_for_each_plane_mask - iterate over planes specified by bitmask
1996 * @plane: the loop cursor
1997 * @dev: the DRM device
1998 * @plane_mask: bitmask of plane indices
1999 *
2000 * Iterate over all planes specified by bitmask.
2001 */
2002#define drm_for_each_plane_mask(plane, dev, plane_mask) \
2003 list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
2004 for_each_if ((plane_mask) & (1 << drm_plane_index(plane)))
2005
2006/**
2007 * drm_for_each_encoder_mask - iterate over encoders specified by bitmask
2008 * @encoder: the loop cursor
2009 * @dev: the DRM device
2010 * @encoder_mask: bitmask of encoder indices
2011 *
2012 * Iterate over all encoders specified by bitmask.
2013 */
2014#define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \
2015 list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \
2016 for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder)))
2017
2018#define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 1297#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
2019#define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
2020#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
2021#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
2022#define obj_to_plane(x) container_of(x, struct drm_plane, base)
2023 1298
2024extern __printf(6, 7) 1299extern __printf(6, 7)
2025int drm_crtc_init_with_planes(struct drm_device *dev, 1300int drm_crtc_init_with_planes(struct drm_device *dev,
@@ -2054,36 +1329,6 @@ static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc)
2054 return 1 << drm_crtc_index(crtc); 1329 return 1 << drm_crtc_index(crtc);
2055} 1330}
2056 1331
2057extern __printf(8, 9)
2058int drm_universal_plane_init(struct drm_device *dev,
2059 struct drm_plane *plane,
2060 unsigned long possible_crtcs,
2061 const struct drm_plane_funcs *funcs,
2062 const uint32_t *formats,
2063 unsigned int format_count,
2064 enum drm_plane_type type,
2065 const char *name, ...);
2066extern int drm_plane_init(struct drm_device *dev,
2067 struct drm_plane *plane,
2068 unsigned long possible_crtcs,
2069 const struct drm_plane_funcs *funcs,
2070 const uint32_t *formats, unsigned int format_count,
2071 bool is_primary);
2072extern void drm_plane_cleanup(struct drm_plane *plane);
2073
2074/**
2075 * drm_plane_index - find the index of a registered plane
2076 * @plane: plane to find index for
2077 *
2078 * Given a registered plane, return the index of that plane within a DRM
2079 * device's list of planes.
2080 */
2081static inline unsigned int drm_plane_index(struct drm_plane *plane)
2082{
2083 return plane->index;
2084}
2085extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
2086extern void drm_plane_force_disable(struct drm_plane *plane);
2087extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, 1332extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
2088 int *hdisplay, int *vdisplay); 1333 int *hdisplay, int *vdisplay);
2089extern int drm_crtc_force_disable(struct drm_crtc *crtc); 1334extern int drm_crtc_force_disable(struct drm_crtc *crtc);
@@ -2093,9 +1338,6 @@ extern void drm_mode_config_init(struct drm_device *dev);
2093extern void drm_mode_config_reset(struct drm_device *dev); 1338extern void drm_mode_config_reset(struct drm_device *dev);
2094extern void drm_mode_config_cleanup(struct drm_device *dev); 1339extern void drm_mode_config_cleanup(struct drm_device *dev);
2095 1340
2096extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
2097 int gamma_size);
2098
2099extern int drm_mode_set_config_internal(struct drm_mode_set *set); 1341extern int drm_mode_set_config_internal(struct drm_mode_set *set);
2100 1342
2101extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, 1343extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
@@ -2105,35 +1347,7 @@ extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
2105extern void drm_mode_put_tile_group(struct drm_device *dev, 1347extern void drm_mode_put_tile_group(struct drm_device *dev,
2106 struct drm_tile_group *tg); 1348 struct drm_tile_group *tg);
2107 1349
2108extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
2109 struct drm_property *property,
2110 uint64_t value);
2111
2112extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
2113 unsigned int supported_rotations);
2114extern unsigned int drm_rotation_simplify(unsigned int rotation,
2115 unsigned int supported_rotations);
2116extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
2117 uint degamma_lut_size,
2118 bool has_ctm,
2119 uint gamma_lut_size);
2120
2121int drm_plane_create_zpos_property(struct drm_plane *plane,
2122 unsigned int zpos,
2123 unsigned int min, unsigned int max);
2124
2125int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
2126 unsigned int zpos);
2127
2128/* Helpers */ 1350/* Helpers */
2129static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
2130 uint32_t id)
2131{
2132 struct drm_mode_object *mo;
2133 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
2134 return mo ? obj_to_plane(mo) : NULL;
2135}
2136
2137static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, 1351static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
2138 uint32_t id) 1352 uint32_t id)
2139{ 1353{
@@ -2142,33 +1356,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
2142 return mo ? obj_to_crtc(mo) : NULL; 1356 return mo ? obj_to_crtc(mo) : NULL;
2143} 1357}
2144 1358
2145/*
2146 * Extract a degamma/gamma LUT value provided by user and round it to the
2147 * precision supported by the hardware.
2148 */
2149static inline uint32_t drm_color_lut_extract(uint32_t user_input,
2150 uint32_t bit_precision)
2151{
2152 uint32_t val = user_input;
2153 uint32_t max = 0xffff >> (16 - bit_precision);
2154
2155 /* Round only if we're not using full precision. */
2156 if (bit_precision < 16) {
2157 val += 1UL << (16 - bit_precision - 1);
2158 val >>= 16 - bit_precision;
2159 }
2160
2161 return clamp_val(val, 0, max);
2162}
2163
2164/* Plane list iterator for legacy (overlay only) planes. */
2165#define drm_for_each_legacy_plane(plane, dev) \
2166 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
2167 for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
2168
2169#define drm_for_each_plane(plane, dev) \
2170 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
2171
2172#define drm_for_each_crtc(crtc, dev) \ 1359#define drm_for_each_crtc(crtc, dev) \
2173 list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) 1360 list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
2174 1361
@@ -2186,68 +1373,4 @@ assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config)
2186 !drm_modeset_is_locked(&mode_config->connection_mutex)); 1373 !drm_modeset_is_locked(&mode_config->connection_mutex));
2187} 1374}
2188 1375
2189#define drm_for_each_connector(connector, dev) \
2190 for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \
2191 connector = list_first_entry(&(dev)->mode_config.connector_list, \
2192 struct drm_connector, head); \
2193 &connector->head != (&(dev)->mode_config.connector_list); \
2194 connector = list_next_entry(connector, head))
2195
2196#define drm_for_each_encoder(encoder, dev) \
2197 list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head)
2198
2199#define drm_for_each_fb(fb, dev) \
2200 for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \
2201 fb = list_first_entry(&(dev)->mode_config.fb_list, \
2202 struct drm_framebuffer, head); \
2203 &fb->head != (&(dev)->mode_config.fb_list); \
2204 fb = list_next_entry(fb, head))
2205
2206/* drm_edid.c */
2207bool drm_probe_ddc(struct i2c_adapter *adapter);
2208struct edid *drm_get_edid(struct drm_connector *connector,
2209 struct i2c_adapter *adapter);
2210struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
2211 struct i2c_adapter *adapter);
2212struct edid *drm_edid_duplicate(const struct edid *edid);
2213int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
2214
2215u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
2216enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
2217bool drm_detect_hdmi_monitor(struct edid *edid);
2218bool drm_detect_monitor_audio(struct edid *edid);
2219bool drm_rgb_quant_range_selectable(struct edid *edid);
2220int drm_add_modes_noedid(struct drm_connector *connector,
2221 int hdisplay, int vdisplay);
2222void drm_set_preferred_mode(struct drm_connector *connector,
2223 int hpref, int vpref);
2224
2225int drm_edid_header_is_valid(const u8 *raw_edid);
2226bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
2227 bool *edid_corrupt);
2228bool drm_edid_is_valid(struct edid *edid);
2229void drm_edid_get_monitor_name(struct edid *edid, char *name,
2230 int buflen);
2231struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
2232 int hsize, int vsize, int fresh,
2233 bool rb);
2234
2235/* drm_bridge.c */
2236extern int drm_bridge_add(struct drm_bridge *bridge);
2237extern void drm_bridge_remove(struct drm_bridge *bridge);
2238extern struct drm_bridge *of_drm_find_bridge(struct device_node *np);
2239extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
2240extern void drm_bridge_detach(struct drm_bridge *bridge);
2241
2242bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
2243 const struct drm_display_mode *mode,
2244 struct drm_display_mode *adjusted_mode);
2245void drm_bridge_disable(struct drm_bridge *bridge);
2246void drm_bridge_post_disable(struct drm_bridge *bridge);
2247void drm_bridge_mode_set(struct drm_bridge *bridge,
2248 struct drm_display_mode *mode,
2249 struct drm_display_mode *adjusted_mode);
2250void drm_bridge_pre_enable(struct drm_bridge *bridge);
2251void drm_bridge_enable(struct drm_bridge *bridge);
2252
2253#endif /* __DRM_CRTC_H__ */ 1376#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 919933d1beb4..c3a7d440bc11 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -25,6 +25,9 @@
25 25
26#include <linux/types.h> 26#include <linux/types.h>
27 27
28struct drm_device;
29struct i2c_adapter;
30
28#define EDID_LENGTH 128 31#define EDID_LENGTH 128
29#define DDC_ADDR 0x50 32#define DDC_ADDR 0x50
30#define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */ 33#define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */
@@ -423,9 +426,36 @@ static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
423 return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK; 426 return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK;
424} 427}
425 428
429bool drm_probe_ddc(struct i2c_adapter *adapter);
426struct edid *drm_do_get_edid(struct drm_connector *connector, 430struct edid *drm_do_get_edid(struct drm_connector *connector,
427 int (*get_edid_block)(void *data, u8 *buf, unsigned int block, 431 int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
428 size_t len), 432 size_t len),
429 void *data); 433 void *data);
434struct edid *drm_get_edid(struct drm_connector *connector,
435 struct i2c_adapter *adapter);
436struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
437 struct i2c_adapter *adapter);
438struct edid *drm_edid_duplicate(const struct edid *edid);
439int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
440
441u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
442enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
443bool drm_detect_hdmi_monitor(struct edid *edid);
444bool drm_detect_monitor_audio(struct edid *edid);
445bool drm_rgb_quant_range_selectable(struct edid *edid);
446int drm_add_modes_noedid(struct drm_connector *connector,
447 int hdisplay, int vdisplay);
448void drm_set_preferred_mode(struct drm_connector *connector,
449 int hpref, int vpref);
450
451int drm_edid_header_is_valid(const u8 *raw_edid);
452bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
453 bool *edid_corrupt);
454bool drm_edid_is_valid(struct edid *edid);
455void drm_edid_get_monitor_name(struct edid *edid, char *name,
456 int buflen);
457struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
458 int hsize, int vsize, int fresh,
459 bool rb);
430 460
431#endif /* __DRM_EDID_H__ */ 461#endif /* __DRM_EDID_H__ */
diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
index fce0203094f7..387e33a4d6ee 100644
--- a/include/drm/drm_encoder.h
+++ b/include/drm/drm_encoder.h
@@ -224,4 +224,26 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
224 224
225void drm_encoder_cleanup(struct drm_encoder *encoder); 225void drm_encoder_cleanup(struct drm_encoder *encoder);
226 226
227/**
228 * drm_for_each_encoder_mask - iterate over encoders specified by bitmask
229 * @encoder: the loop cursor
230 * @dev: the DRM device
231 * @encoder_mask: bitmask of encoder indices
232 *
233 * Iterate over all encoders specified by bitmask.
234 */
235#define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \
236 list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \
237 for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder)))
238
239/**
240 * drm_for_each_encoder - iterate over all encoders
241 * @encoder: the loop cursor
242 * @dev: the DRM device
243 *
244 * Iterate over all encoders of @dev.
245 */
246#define drm_for_each_encoder(encoder, dev) \
247 list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head)
248
227#endif 249#endif
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 797fb5f80c45..e19458dd1a43 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -287,11 +287,6 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_
287int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, 287int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
288 struct drm_connector *connector); 288 struct drm_connector *connector);
289#else 289#else
290static inline int drm_fb_helper_modinit(void)
291{
292 return 0;
293}
294
295static inline void drm_fb_helper_prepare(struct drm_device *dev, 290static inline void drm_fb_helper_prepare(struct drm_device *dev,
296 struct drm_fb_helper *helper, 291 struct drm_fb_helper *helper,
297 const struct drm_fb_helper_funcs *funcs) 292 const struct drm_fb_helper_funcs *funcs)
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index b2554c50a903..f5ae1f436a4b 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -206,6 +206,8 @@ struct drm_framebuffer {
206 struct list_head filp_head; 206 struct list_head filp_head;
207}; 207};
208 208
209#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
210
209int drm_framebuffer_init(struct drm_device *dev, 211int drm_framebuffer_init(struct drm_device *dev,
210 struct drm_framebuffer *fb, 212 struct drm_framebuffer *fb,
211 const struct drm_framebuffer_funcs *funcs); 213 const struct drm_framebuffer_funcs *funcs);
@@ -247,4 +249,19 @@ static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
247{ 249{
248 return atomic_read(&fb->base.refcount.refcount); 250 return atomic_read(&fb->base.refcount.refcount);
249} 251}
252
253/**
254 * drm_for_each_fb - iterate over all framebuffers
255 * @fb: the loop cursor
256 * @dev: the DRM device
257 *
258 * Iterate over all framebuffers of @dev. User must hold the fb_lock from
259 * &drm_mode_config.
260 */
261#define drm_for_each_fb(fb, dev) \
262 for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \
263 fb = list_first_entry(&(dev)->mode_config.fb_list, \
264 struct drm_framebuffer, head); \
265 &fb->head != (&(dev)->mode_config.fb_list); \
266 fb = list_next_entry(fb, head))
250#endif 267#endif
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index be3d93839ae2..43460b21d112 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -26,6 +26,7 @@
26#include <linux/kref.h> 26#include <linux/kref.h>
27struct drm_object_properties; 27struct drm_object_properties;
28struct drm_property; 28struct drm_property;
29struct drm_device;
29 30
30/** 31/**
31 * struct drm_mode_object - base structure for modeset objects 32 * struct drm_mode_object - base structure for modeset objects
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 011f199d3bcf..9934d91619c1 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -27,9 +27,13 @@
27#ifndef __DRM_MODES_H__ 27#ifndef __DRM_MODES_H__
28#define __DRM_MODES_H__ 28#define __DRM_MODES_H__
29 29
30#include <linux/hdmi.h>
31
30#include <drm/drm_mode_object.h> 32#include <drm/drm_mode_object.h>
31#include <drm/drm_connector.h> 33#include <drm/drm_connector.h>
32 34
35struct videomode;
36
33/* 37/*
34 * Note on terminology: here, for brevity and convenience, we refer to connector 38 * Note on terminology: here, for brevity and convenience, we refer to connector
35 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, 39 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
@@ -403,6 +407,8 @@ struct drm_display_mode {
403 enum hdmi_picture_aspect picture_aspect_ratio; 407 enum hdmi_picture_aspect picture_aspect_ratio;
404}; 408};
405 409
410#define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
411
406/** 412/**
407 * drm_mode_is_stereo - check for stereo mode flags 413 * drm_mode_is_stereo - check for stereo mode flags
408 * @mode: drm_display_mode to check 414 * @mode: drm_display_mode to check
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
new file mode 100644
index 000000000000..43cf193e54d6
--- /dev/null
+++ b/include/drm/drm_plane.h
@@ -0,0 +1,526 @@
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef __DRM_PLANE_H__
24#define __DRM_PLANE_H__
25
26#include <linux/list.h>
27#include <linux/ctype.h>
28#include <drm/drm_mode_object.h>
29
30struct drm_crtc;
31
32/**
33 * struct drm_plane_state - mutable plane state
34 * @plane: backpointer to the plane
35 * @crtc: currently bound CRTC, NULL if disabled
36 * @fb: currently bound framebuffer
37 * @fence: optional fence to wait for before scanning out @fb
38 * @crtc_x: left position of visible portion of plane on crtc
39 * @crtc_y: upper position of visible portion of plane on crtc
40 * @crtc_w: width of visible portion of plane on crtc
41 * @crtc_h: height of visible portion of plane on crtc
42 * @src_x: left position of visible portion of plane within
43 * plane (in 16.16)
44 * @src_y: upper position of visible portion of plane within
45 * plane (in 16.16)
46 * @src_w: width of visible portion of plane (in 16.16)
47 * @src_h: height of visible portion of plane (in 16.16)
48 * @rotation: rotation of the plane
49 * @zpos: priority of the given plane on crtc (optional)
50 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
51 * where N is the number of active planes for given crtc
52 * @src: clipped source coordinates of the plane (in 16.16)
53 * @dst: clipped destination coordinates of the plane
54 * @visible: visibility of the plane
55 * @state: backpointer to global drm_atomic_state
56 */
57struct drm_plane_state {
58 struct drm_plane *plane;
59
60 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
61 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
62 struct fence *fence;
63
64 /* Signed dest location allows it to be partially off screen */
65 int32_t crtc_x, crtc_y;
66 uint32_t crtc_w, crtc_h;
67
68 /* Source values are 16.16 fixed point */
69 uint32_t src_x, src_y;
70 uint32_t src_h, src_w;
71
72 /* Plane rotation */
73 unsigned int rotation;
74
75 /* Plane zpos */
76 unsigned int zpos;
77 unsigned int normalized_zpos;
78
79 /* Clipped coordinates */
80 struct drm_rect src, dst;
81
82 /*
83 * Is the plane actually visible? Can be false even
84 * if fb!=NULL and crtc!=NULL, due to clipping.
85 */
86 bool visible;
87
88 struct drm_atomic_state *state;
89};
90
91
92/**
93 * struct drm_plane_funcs - driver plane control functions
94 */
95struct drm_plane_funcs {
96 /**
97 * @update_plane:
98 *
99 * This is the legacy entry point to enable and configure the plane for
100 * the given CRTC and framebuffer. It is never called to disable the
101 * plane, i.e. the passed-in crtc and fb paramters are never NULL.
102 *
103 * The source rectangle in frame buffer memory coordinates is given by
104 * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
105 * values). Devices that don't support subpixel plane coordinates can
106 * ignore the fractional part.
107 *
108 * The destination rectangle in CRTC coordinates is given by the
109 * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
110 * Devices scale the source rectangle to the destination rectangle. If
111 * scaling is not supported, and the source rectangle size doesn't match
112 * the destination rectangle size, the driver must return a
113 * -<errorname>EINVAL</errorname> error.
114 *
115 * Drivers implementing atomic modeset should use
116 * drm_atomic_helper_update_plane() to implement this hook.
117 *
118 * RETURNS:
119 *
120 * 0 on success or a negative error code on failure.
121 */
122 int (*update_plane)(struct drm_plane *plane,
123 struct drm_crtc *crtc, struct drm_framebuffer *fb,
124 int crtc_x, int crtc_y,
125 unsigned int crtc_w, unsigned int crtc_h,
126 uint32_t src_x, uint32_t src_y,
127 uint32_t src_w, uint32_t src_h);
128
129 /**
130 * @disable_plane:
131 *
132 * This is the legacy entry point to disable the plane. The DRM core
133 * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
134 * with the frame buffer ID set to 0. Disabled planes must not be
135 * processed by the CRTC.
136 *
137 * Drivers implementing atomic modeset should use
138 * drm_atomic_helper_disable_plane() to implement this hook.
139 *
140 * RETURNS:
141 *
142 * 0 on success or a negative error code on failure.
143 */
144 int (*disable_plane)(struct drm_plane *plane);
145
146 /**
147 * @destroy:
148 *
149 * Clean up plane resources. This is only called at driver unload time
150 * through drm_mode_config_cleanup() since a plane cannot be hotplugged
151 * in DRM.
152 */
153 void (*destroy)(struct drm_plane *plane);
154
155 /**
156 * @reset:
157 *
158 * Reset plane hardware and software state to off. This function isn't
159 * called by the core directly, only through drm_mode_config_reset().
160 * It's not a helper hook only for historical reasons.
161 *
162 * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
163 * atomic state using this hook.
164 */
165 void (*reset)(struct drm_plane *plane);
166
167 /**
168 * @set_property:
169 *
170 * This is the legacy entry point to update a property attached to the
171 * plane.
172 *
173 * Drivers implementing atomic modeset should use
174 * drm_atomic_helper_plane_set_property() to implement this hook.
175 *
176 * This callback is optional if the driver does not support any legacy
177 * driver-private properties.
178 *
179 * RETURNS:
180 *
181 * 0 on success or a negative error code on failure.
182 */
183 int (*set_property)(struct drm_plane *plane,
184 struct drm_property *property, uint64_t val);
185
186 /**
187 * @atomic_duplicate_state:
188 *
189 * Duplicate the current atomic state for this plane and return it.
190 * The core and helpers gurantee that any atomic state duplicated with
191 * this hook and still owned by the caller (i.e. not transferred to the
192 * driver by calling ->atomic_commit() from struct
193 * &drm_mode_config_funcs) will be cleaned up by calling the
194 * @atomic_destroy_state hook in this structure.
195 *
196 * Atomic drivers which don't subclass struct &drm_plane_state should use
197 * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
198 * state structure to extend it with driver-private state should use
199 * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
200 * duplicated in a consistent fashion across drivers.
201 *
202 * It is an error to call this hook before plane->state has been
203 * initialized correctly.
204 *
205 * NOTE:
206 *
207 * If the duplicate state references refcounted resources this hook must
208 * acquire a reference for each of them. The driver must release these
209 * references again in @atomic_destroy_state.
210 *
211 * RETURNS:
212 *
213 * Duplicated atomic state or NULL when the allocation failed.
214 */
215 struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
216
217 /**
218 * @atomic_destroy_state:
219 *
220 * Destroy a state duplicated with @atomic_duplicate_state and release
221 * or unreference all resources it references
222 */
223 void (*atomic_destroy_state)(struct drm_plane *plane,
224 struct drm_plane_state *state);
225
226 /**
227 * @atomic_set_property:
228 *
229 * Decode a driver-private property value and store the decoded value
230 * into the passed-in state structure. Since the atomic core decodes all
231 * standardized properties (even for extensions beyond the core set of
232 * properties which might not be implemented by all drivers) this
233 * requires drivers to subclass the state structure.
234 *
235 * Such driver-private properties should really only be implemented for
236 * truly hardware/vendor specific state. Instead it is preferred to
237 * standardize atomic extension and decode the properties used to expose
238 * such an extension in the core.
239 *
240 * Do not call this function directly, use
241 * drm_atomic_plane_set_property() instead.
242 *
243 * This callback is optional if the driver does not support any
244 * driver-private atomic properties.
245 *
246 * NOTE:
247 *
248 * This function is called in the state assembly phase of atomic
249 * modesets, which can be aborted for any reason (including on
250 * userspace's request to just check whether a configuration would be
251 * possible). Drivers MUST NOT touch any persistent state (hardware or
252 * software) or data structures except the passed in @state parameter.
253 *
254 * Also since userspace controls in which order properties are set this
255 * function must not do any input validation (since the state update is
256 * incomplete and hence likely inconsistent). Instead any such input
257 * validation must be done in the various atomic_check callbacks.
258 *
259 * RETURNS:
260 *
261 * 0 if the property has been found, -EINVAL if the property isn't
262 * implemented by the driver (which shouldn't ever happen, the core only
263 * asks for properties attached to this plane). No other validation is
264 * allowed by the driver. The core already checks that the property
265 * value is within the range (integer, valid enum value, ...) the driver
266 * set when registering the property.
267 */
268 int (*atomic_set_property)(struct drm_plane *plane,
269 struct drm_plane_state *state,
270 struct drm_property *property,
271 uint64_t val);
272
273 /**
274 * @atomic_get_property:
275 *
276 * Reads out the decoded driver-private property. This is used to
277 * implement the GETPLANE IOCTL.
278 *
279 * Do not call this function directly, use
280 * drm_atomic_plane_get_property() instead.
281 *
282 * This callback is optional if the driver does not support any
283 * driver-private atomic properties.
284 *
285 * RETURNS:
286 *
287 * 0 on success, -EINVAL if the property isn't implemented by the
288 * driver (which should never happen, the core only asks for
289 * properties attached to this plane).
290 */
291 int (*atomic_get_property)(struct drm_plane *plane,
292 const struct drm_plane_state *state,
293 struct drm_property *property,
294 uint64_t *val);
295 /**
296 * @late_register:
297 *
298 * This optional hook can be used to register additional userspace
299 * interfaces attached to the plane like debugfs interfaces.
300 * It is called late in the driver load sequence from drm_dev_register().
301 * Everything added from this callback should be unregistered in
302 * the early_unregister callback.
303 *
304 * Returns:
305 *
306 * 0 on success, or a negative error code on failure.
307 */
308 int (*late_register)(struct drm_plane *plane);
309
310 /**
311 * @early_unregister:
312 *
313 * This optional hook should be used to unregister the additional
314 * userspace interfaces attached to the plane from
315 * late_unregister(). It is called from drm_dev_unregister(),
316 * early in the driver unload sequence to disable userspace access
317 * before data structures are torndown.
318 */
319 void (*early_unregister)(struct drm_plane *plane);
320};
321
322/**
323 * enum drm_plane_type - uapi plane type enumeration
324 *
325 * For historical reasons not all planes are made the same. This enumeration is
326 * used to tell the different types of planes apart to implement the different
327 * uapi semantics for them. For userspace which is universal plane aware and
328 * which is using that atomic IOCTL there's no difference between these planes
329 * (beyong what the driver and hardware can support of course).
330 *
331 * For compatibility with legacy userspace, only overlay planes are made
332 * available to userspace by default. Userspace clients may set the
333 * DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that they
334 * wish to receive a universal plane list containing all plane types. See also
335 * drm_for_each_legacy_plane().
336 *
337 * WARNING: The values of this enum is UABI since they're exposed in the "type"
338 * property.
339 */
340enum drm_plane_type {
341 /**
342 * @DRM_PLANE_TYPE_OVERLAY:
343 *
344 * Overlay planes represent all non-primary, non-cursor planes. Some
345 * drivers refer to these types of planes as "sprites" internally.
346 */
347 DRM_PLANE_TYPE_OVERLAY,
348
349 /**
350 * @DRM_PLANE_TYPE_PRIMARY:
351 *
352 * Primary planes represent a "main" plane for a CRTC. Primary planes
353 * are the planes operated upon by CRTC modesetting and flipping
354 * operations described in the page_flip and set_config hooks in struct
355 * &drm_crtc_funcs.
356 */
357 DRM_PLANE_TYPE_PRIMARY,
358
359 /**
360 * @DRM_PLANE_TYPE_CURSOR:
361 *
362 * Cursor planes represent a "cursor" plane for a CRTC. Cursor planes
363 * are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
364 * DRM_IOCTL_MODE_CURSOR2 IOCTLs.
365 */
366 DRM_PLANE_TYPE_CURSOR,
367};
368
369
370/**
371 * struct drm_plane - central DRM plane control structure
372 * @dev: DRM device this plane belongs to
373 * @head: for list management
374 * @name: human readable name, can be overwritten by the driver
375 * @base: base mode object
376 * @possible_crtcs: pipes this plane can be bound to
377 * @format_types: array of formats supported by this plane
378 * @format_count: number of formats supported
379 * @format_default: driver hasn't supplied supported formats for the plane
380 * @crtc: currently bound CRTC
381 * @fb: currently bound fb
382 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
383 * drm_mode_set_config_internal() to implement correct refcounting.
384 * @funcs: helper functions
385 * @properties: property tracking for this plane
386 * @type: type of plane (overlay, primary, cursor)
387 * @state: current atomic state for this plane
388 * @zpos_property: zpos property for this plane
389 * @helper_private: mid-layer private data
390 */
391struct drm_plane {
392 struct drm_device *dev;
393 struct list_head head;
394
395 char *name;
396
397 /**
398 * @mutex:
399 *
400 * Protects modeset plane state, together with the mutex of &drm_crtc
401 * this plane is linked to (when active, getting actived or getting
402 * disabled).
403 */
404 struct drm_modeset_lock mutex;
405
406 struct drm_mode_object base;
407
408 uint32_t possible_crtcs;
409 uint32_t *format_types;
410 unsigned int format_count;
411 bool format_default;
412
413 struct drm_crtc *crtc;
414 struct drm_framebuffer *fb;
415
416 struct drm_framebuffer *old_fb;
417
418 const struct drm_plane_funcs *funcs;
419
420 struct drm_object_properties properties;
421
422 enum drm_plane_type type;
423
424 /**
425 * @index: Position inside the mode_config.list, can be used as an array
426 * index. It is invariant over the lifetime of the plane.
427 */
428 unsigned index;
429
430 const struct drm_plane_helper_funcs *helper_private;
431
432 struct drm_plane_state *state;
433
434 struct drm_property *zpos_property;
435};
436
437#define obj_to_plane(x) container_of(x, struct drm_plane, base)
438
439extern __printf(8, 9)
440int drm_universal_plane_init(struct drm_device *dev,
441 struct drm_plane *plane,
442 unsigned long possible_crtcs,
443 const struct drm_plane_funcs *funcs,
444 const uint32_t *formats,
445 unsigned int format_count,
446 enum drm_plane_type type,
447 const char *name, ...);
448extern int drm_plane_init(struct drm_device *dev,
449 struct drm_plane *plane,
450 unsigned long possible_crtcs,
451 const struct drm_plane_funcs *funcs,
452 const uint32_t *formats, unsigned int format_count,
453 bool is_primary);
454extern void drm_plane_cleanup(struct drm_plane *plane);
455
456/**
457 * drm_plane_index - find the index of a registered plane
458 * @plane: plane to find index for
459 *
460 * Given a registered plane, return the index of that plane within a DRM
461 * device's list of planes.
462 */
463static inline unsigned int drm_plane_index(struct drm_plane *plane)
464{
465 return plane->index;
466}
467extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
468extern void drm_plane_force_disable(struct drm_plane *plane);
469
470int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
471 struct drm_property *property,
472 uint64_t value);
473
474/**
475 * drm_plane_find - find a &drm_plane
476 * @dev: DRM device
477 * @id: plane id
478 *
479 * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around
480 * drm_mode_object_find().
481 */
482static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
483 uint32_t id)
484{
485 struct drm_mode_object *mo;
486 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
487 return mo ? obj_to_plane(mo) : NULL;
488}
489
490/**
491 * drm_for_each_plane_mask - iterate over planes specified by bitmask
492 * @plane: the loop cursor
493 * @dev: the DRM device
494 * @plane_mask: bitmask of plane indices
495 *
496 * Iterate over all planes specified by bitmask.
497 */
498#define drm_for_each_plane_mask(plane, dev, plane_mask) \
499 list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
500 for_each_if ((plane_mask) & (1 << drm_plane_index(plane)))
501
502/**
503 * drm_for_each_legacy_plane - iterate over all planes for legacy userspace
504 * @plane: the loop cursor
505 * @dev: the DRM device
506 *
507 * Iterate over all legacy planes of @dev, excluding primary and cursor planes.
508 * This is useful for implementing userspace apis when userspace is not
509 * universal plane aware. See also enum &drm_plane_type.
510 */
511#define drm_for_each_legacy_plane(plane, dev) \
512 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
513 for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
514
515/**
516 * drm_for_each_plane - iterate over all planes
517 * @plane: the loop cursor
518 * @dev: the DRM device
519 *
520 * Iterate over all planes of @dev, include primary and cursor planes.
521 */
522#define drm_for_each_plane(plane, dev) \
523 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
524
525
526#endif
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index 30ab289be05d..43c4b6a2046d 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -219,6 +219,7 @@ struct drm_prop_enum_list {
219}; 219};
220 220
221#define obj_to_property(x) container_of(x, struct drm_property, base) 221#define obj_to_property(x) container_of(x, struct drm_property, base)
222#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
222 223
223/** 224/**
224 * drm_property_type_is - check the type of a property 225 * drm_property_type_is - check the type of a property
diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h
index afba6fcac853..9c03895dc479 100644
--- a/include/drm/drm_vma_manager.h
+++ b/include/drm/drm_vma_manager.h
@@ -24,16 +24,17 @@
24 */ 24 */
25 25
26#include <drm/drm_mm.h> 26#include <drm/drm_mm.h>
27#include <linux/fs.h>
28#include <linux/mm.h> 27#include <linux/mm.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/rbtree.h> 29#include <linux/rbtree.h>
31#include <linux/spinlock.h> 30#include <linux/spinlock.h>
32#include <linux/types.h> 31#include <linux/types.h>
33 32
33struct drm_file;
34
34struct drm_vma_offset_file { 35struct drm_vma_offset_file {
35 struct rb_node vm_rb; 36 struct rb_node vm_rb;
36 struct file *vm_filp; 37 struct drm_file *vm_tag;
37 unsigned long vm_count; 38 unsigned long vm_count;
38}; 39};
39 40
@@ -60,10 +61,11 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
60void drm_vma_offset_remove(struct drm_vma_offset_manager *mgr, 61void drm_vma_offset_remove(struct drm_vma_offset_manager *mgr,
61 struct drm_vma_offset_node *node); 62 struct drm_vma_offset_node *node);
62 63
63int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp); 64int drm_vma_node_allow(struct drm_vma_offset_node *node, struct drm_file *tag);
64void drm_vma_node_revoke(struct drm_vma_offset_node *node, struct file *filp); 65void drm_vma_node_revoke(struct drm_vma_offset_node *node,
66 struct drm_file *tag);
65bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node, 67bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node,
66 struct file *filp); 68 struct drm_file *tag);
67 69
68/** 70/**
69 * drm_vma_offset_exact_lookup_locked() - Look up node by exact address 71 * drm_vma_offset_exact_lookup_locked() - Look up node by exact address
@@ -214,9 +216,9 @@ static inline void drm_vma_node_unmap(struct drm_vma_offset_node *node,
214/** 216/**
215 * drm_vma_node_verify_access() - Access verification helper for TTM 217 * drm_vma_node_verify_access() - Access verification helper for TTM
216 * @node: Offset node 218 * @node: Offset node
217 * @filp: Open-file 219 * @tag: Tag of file to check
218 * 220 *
219 * This checks whether @filp is granted access to @node. It is the same as 221 * This checks whether @tag is granted access to @node. It is the same as
220 * drm_vma_node_is_allowed() but suitable as drop-in helper for TTM 222 * drm_vma_node_is_allowed() but suitable as drop-in helper for TTM
221 * verify_access() callbacks. 223 * verify_access() callbacks.
222 * 224 *
@@ -224,9 +226,9 @@ static inline void drm_vma_node_unmap(struct drm_vma_offset_node *node,
224 * 0 if access is granted, -EACCES otherwise. 226 * 0 if access is granted, -EACCES otherwise.
225 */ 227 */
226static inline int drm_vma_node_verify_access(struct drm_vma_offset_node *node, 228static inline int drm_vma_node_verify_access(struct drm_vma_offset_node *node,
227 struct file *filp) 229 struct drm_file *tag)
228{ 230{
229 return drm_vma_node_is_allowed(node, filp) ? 0 : -EACCES; 231 return drm_vma_node_is_allowed(node, tag) ? 0 : -EACCES;
230} 232}
231 233
232#endif /* __DRM_VMA_MANAGER_H__ */ 234#endif /* __DRM_VMA_MANAGER_H__ */
diff --git a/include/uapi/linux/sync_file.h b/include/uapi/linux/sync_file.h
index 413303d37b56..5b287d6970b3 100644
--- a/include/uapi/linux/sync_file.h
+++ b/include/uapi/linux/sync_file.h
@@ -85,15 +85,12 @@ struct sync_file_info {
85#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data) 85#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
86 86
87/** 87/**
88 * DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence 88 * DOC: SYNC_IOC_FILE_INFO - get detailed information on a sync_file
89 * 89 *
90 * Takes a struct sync_file_info_data with extra space allocated for pt_info. 90 * Takes a struct sync_file_info. If num_fences is 0, the field is updated
91 * Caller should write the size of the buffer into len. On return, len is 91 * with the actual number of fences. If num_fences is > 0, the system will
92 * updated to reflect the total size of the sync_file_info_data including 92 * use the pointer provided on sync_fence_info to return up to num_fences of
93 * pt_info. 93 * struct sync_fence_info, with detailed fence information.
94 *
95 * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence.
96 * To iterate over the sync_pt_infos, use the sync_pt_info.len field.
97 */ 94 */
98#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info) 95#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
99 96