Rev 5271 | Rev 6937 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5271 | Rev 6084 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2014 Red Hat |
2 | * Copyright (C) 2014 Red Hat |
3 | * Copyright (C) 2014 Intel Corp. |
3 | * Copyright (C) 2014 Intel Corp. |
4 | * |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), |
6 | * copy of this software and associated documentation files (the "Software"), |
7 | * to deal in the Software without restriction, including without limitation |
7 | * to deal in the Software without restriction, including without limitation |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | * and/or sell copies of the Software, and to permit persons to whom the |
9 | * and/or sell copies of the Software, and to permit persons to whom the |
10 | * Software is furnished to do so, subject to the following conditions: |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * |
11 | * |
12 | * The above copyright notice and this permission notice shall be included in |
12 | * The above copyright notice and this permission notice shall be included in |
13 | * all copies or substantial portions of the Software. |
13 | * all copies or substantial portions of the Software. |
14 | * |
14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
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, |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
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 |
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
21 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * OTHER DEALINGS IN THE SOFTWARE. |
22 | * |
22 | * |
23 | * Authors: |
23 | * Authors: |
24 | * Rob Clark |
24 | * Rob Clark |
25 | * Daniel Vetter |
25 | * Daniel Vetter |
26 | */ |
26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include |
29 | #include |
30 | #include |
30 | #include |
31 | #include |
31 | #include |
- | 32 | ||
- | 33 | /** |
|
- | 34 | * drm_atomic_state_default_release - |
|
- | 35 | * release memory initialized by drm_atomic_state_init |
|
- | 36 | * @state: atomic state |
|
- | 37 | * |
|
- | 38 | * Free all the memory allocated by drm_atomic_state_init. |
|
- | 39 | * This is useful for drivers that subclass the atomic state. |
|
32 | 40 | */ |
|
33 | static void kfree_state(struct drm_atomic_state *state) |
41 | void drm_atomic_state_default_release(struct drm_atomic_state *state) |
34 | { |
42 | { |
35 | kfree(state->connectors); |
43 | kfree(state->connectors); |
36 | kfree(state->connector_states); |
44 | kfree(state->connector_states); |
37 | kfree(state->crtcs); |
45 | kfree(state->crtcs); |
38 | kfree(state->crtc_states); |
46 | kfree(state->crtc_states); |
39 | kfree(state->planes); |
47 | kfree(state->planes); |
40 | kfree(state->plane_states); |
48 | kfree(state->plane_states); |
41 | kfree(state); |
- | |
42 | } |
49 | } |
- | 50 | EXPORT_SYMBOL(drm_atomic_state_default_release); |
|
43 | 51 | ||
44 | /** |
52 | /** |
45 | * drm_atomic_state_alloc - allocate atomic state |
53 | * drm_atomic_state_init - init new atomic state |
- | 54 | * @dev: DRM device |
|
46 | * @dev: DRM device |
55 | * @state: atomic state |
- | 56 | * |
|
47 | * |
57 | * Default implementation for filling in a new atomic state. |
48 | * This allocates an empty atomic state to track updates. |
58 | * This is useful for drivers that subclass the atomic state. |
49 | */ |
59 | */ |
50 | struct drm_atomic_state * |
60 | int |
51 | drm_atomic_state_alloc(struct drm_device *dev) |
61 | drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) |
52 | { |
62 | { |
53 | struct drm_atomic_state *state; |
- | |
54 | 63 | /* TODO legacy paths should maybe do a better job about |
|
55 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
64 | * setting this appropriately? |
56 | if (!state) |
65 | */ |
57 | return NULL; |
66 | state->allow_modeset = true; |
58 | 67 | ||
59 | state->num_connector = ACCESS_ONCE(dev->mode_config.num_connector); |
68 | state->num_connector = ACCESS_ONCE(dev->mode_config.num_connector); |
60 | 69 | ||
61 | state->crtcs = kcalloc(dev->mode_config.num_crtc, |
70 | state->crtcs = kcalloc(dev->mode_config.num_crtc, |
62 | sizeof(*state->crtcs), GFP_KERNEL); |
71 | sizeof(*state->crtcs), GFP_KERNEL); |
63 | if (!state->crtcs) |
72 | if (!state->crtcs) |
64 | goto fail; |
73 | goto fail; |
65 | state->crtc_states = kcalloc(dev->mode_config.num_crtc, |
74 | state->crtc_states = kcalloc(dev->mode_config.num_crtc, |
66 | sizeof(*state->crtc_states), GFP_KERNEL); |
75 | sizeof(*state->crtc_states), GFP_KERNEL); |
67 | if (!state->crtc_states) |
76 | if (!state->crtc_states) |
68 | goto fail; |
77 | goto fail; |
69 | state->planes = kcalloc(dev->mode_config.num_total_plane, |
78 | state->planes = kcalloc(dev->mode_config.num_total_plane, |
70 | sizeof(*state->planes), GFP_KERNEL); |
79 | sizeof(*state->planes), GFP_KERNEL); |
71 | if (!state->planes) |
80 | if (!state->planes) |
72 | goto fail; |
81 | goto fail; |
73 | state->plane_states = kcalloc(dev->mode_config.num_total_plane, |
82 | state->plane_states = kcalloc(dev->mode_config.num_total_plane, |
74 | sizeof(*state->plane_states), GFP_KERNEL); |
83 | sizeof(*state->plane_states), GFP_KERNEL); |
75 | if (!state->plane_states) |
84 | if (!state->plane_states) |
76 | goto fail; |
85 | goto fail; |
77 | state->connectors = kcalloc(state->num_connector, |
86 | state->connectors = kcalloc(state->num_connector, |
78 | sizeof(*state->connectors), |
87 | sizeof(*state->connectors), |
79 | GFP_KERNEL); |
88 | GFP_KERNEL); |
80 | if (!state->connectors) |
89 | if (!state->connectors) |
81 | goto fail; |
90 | goto fail; |
82 | state->connector_states = kcalloc(state->num_connector, |
91 | state->connector_states = kcalloc(state->num_connector, |
83 | sizeof(*state->connector_states), |
92 | sizeof(*state->connector_states), |
84 | GFP_KERNEL); |
93 | GFP_KERNEL); |
85 | if (!state->connector_states) |
94 | if (!state->connector_states) |
86 | goto fail; |
95 | goto fail; |
87 | 96 | ||
88 | state->dev = dev; |
97 | state->dev = dev; |
89 | 98 | ||
90 | DRM_DEBUG_KMS("Allocate atomic state %p\n", state); |
99 | DRM_DEBUG_ATOMIC("Allocated atomic state %p\n", state); |
91 | 100 | ||
- | 101 | return 0; |
|
92 | return state; |
102 | fail: |
- | 103 | drm_atomic_state_default_release(state); |
|
- | 104 | return -ENOMEM; |
|
- | 105 | } |
|
- | 106 | EXPORT_SYMBOL(drm_atomic_state_init); |
|
- | 107 | ||
- | 108 | /** |
|
- | 109 | * drm_atomic_state_alloc - allocate atomic state |
|
- | 110 | * @dev: DRM device |
|
- | 111 | * |
|
- | 112 | * This allocates an empty atomic state to track updates. |
|
- | 113 | */ |
|
- | 114 | struct drm_atomic_state * |
|
- | 115 | drm_atomic_state_alloc(struct drm_device *dev) |
|
- | 116 | { |
|
- | 117 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 118 | struct drm_atomic_state *state; |
|
- | 119 | ||
- | 120 | if (!config->funcs->atomic_state_alloc) { |
|
- | 121 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
|
- | 122 | if (!state) |
|
93 | fail: |
123 | return NULL; |
94 | kfree_state(state); |
124 | if (drm_atomic_state_init(dev, state) < 0) { |
- | 125 | kfree(state); |
|
- | 126 | return NULL; |
|
- | 127 | } |
|
- | 128 | return state; |
|
- | 129 | } |
|
95 | 130 | ||
96 | return NULL; |
131 | return config->funcs->atomic_state_alloc(dev); |
97 | } |
132 | } |
98 | EXPORT_SYMBOL(drm_atomic_state_alloc); |
133 | EXPORT_SYMBOL(drm_atomic_state_alloc); |
99 | 134 | ||
100 | /** |
135 | /** |
101 | * drm_atomic_state_clear - clear state object |
136 | * drm_atomic_state_default_clear - clear base atomic state |
102 | * @state: atomic state |
137 | * @state: atomic state |
103 | * |
138 | * |
104 | * When the w/w mutex algorithm detects a deadlock we need to back off and drop |
- | |
105 | * all locks. So someone else could sneak in and change the current modeset |
- | |
106 | * configuration. Which means that all the state assembled in @state is no |
139 | * Default implementation for clearing atomic state. |
107 | * longer an atomic update to the current state, but to some arbitrary earlier |
- | |
108 | * state. Which could break assumptions the driver's ->atomic_check likely |
- | |
109 | * relies on. |
- | |
110 | * |
- | |
111 | * Hence we must clear all cached state and completely start over, using this |
140 | * This is useful for drivers that subclass the atomic state. |
112 | * function. |
- | |
113 | */ |
141 | */ |
114 | void drm_atomic_state_clear(struct drm_atomic_state *state) |
142 | void drm_atomic_state_default_clear(struct drm_atomic_state *state) |
115 | { |
143 | { |
116 | struct drm_device *dev = state->dev; |
144 | struct drm_device *dev = state->dev; |
117 | struct drm_mode_config *config = &dev->mode_config; |
145 | struct drm_mode_config *config = &dev->mode_config; |
118 | int i; |
146 | int i; |
119 | 147 | ||
120 | DRM_DEBUG_KMS("Clearing atomic state %p\n", state); |
148 | DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state); |
121 | 149 | ||
122 | for (i = 0; i < state->num_connector; i++) { |
150 | for (i = 0; i < state->num_connector; i++) { |
123 | struct drm_connector *connector = state->connectors[i]; |
151 | struct drm_connector *connector = state->connectors[i]; |
124 | 152 | ||
125 | if (!connector) |
153 | if (!connector) |
126 | continue; |
154 | continue; |
- | 155 | ||
127 | 156 | /* |
|
- | 157 | * FIXME: Async commits can race with connector unplugging and |
|
- | 158 | * there's currently nothing that prevents cleanup up state for |
|
- | 159 | * deleted connectors. As long as the callback doesn't look at |
|
- | 160 | * the connector we'll be fine though, so make sure that's the |
|
128 | WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); |
161 | * case by setting all connector pointers to NULL. |
- | 162 | */ |
|
129 | 163 | state->connector_states[i]->connector = NULL; |
|
130 | connector->funcs->atomic_destroy_state(connector, |
164 | connector->funcs->atomic_destroy_state(NULL, |
- | 165 | state->connector_states[i]); |
|
- | 166 | state->connectors[i] = NULL; |
|
131 | state->connector_states[i]); |
167 | state->connector_states[i] = NULL; |
132 | } |
168 | } |
133 | 169 | ||
134 | for (i = 0; i < config->num_crtc; i++) { |
170 | for (i = 0; i < config->num_crtc; i++) { |
135 | struct drm_crtc *crtc = state->crtcs[i]; |
171 | struct drm_crtc *crtc = state->crtcs[i]; |
136 | 172 | ||
137 | if (!crtc) |
173 | if (!crtc) |
138 | continue; |
174 | continue; |
139 | 175 | ||
140 | crtc->funcs->atomic_destroy_state(crtc, |
176 | crtc->funcs->atomic_destroy_state(crtc, |
141 | state->crtc_states[i]); |
177 | state->crtc_states[i]); |
- | 178 | state->crtcs[i] = NULL; |
|
- | 179 | state->crtc_states[i] = NULL; |
|
142 | } |
180 | } |
143 | 181 | ||
144 | for (i = 0; i < config->num_total_plane; i++) { |
182 | for (i = 0; i < config->num_total_plane; i++) { |
145 | struct drm_plane *plane = state->planes[i]; |
183 | struct drm_plane *plane = state->planes[i]; |
146 | 184 | ||
147 | if (!plane) |
185 | if (!plane) |
148 | continue; |
186 | continue; |
149 | 187 | ||
150 | plane->funcs->atomic_destroy_state(plane, |
188 | plane->funcs->atomic_destroy_state(plane, |
151 | state->plane_states[i]); |
189 | state->plane_states[i]); |
- | 190 | state->planes[i] = NULL; |
|
- | 191 | state->plane_states[i] = NULL; |
|
152 | } |
192 | } |
153 | } |
193 | } |
- | 194 | EXPORT_SYMBOL(drm_atomic_state_default_clear); |
|
- | 195 | ||
- | 196 | /** |
|
- | 197 | * drm_atomic_state_clear - clear state object |
|
- | 198 | * @state: atomic state |
|
- | 199 | * |
|
- | 200 | * When the w/w mutex algorithm detects a deadlock we need to back off and drop |
|
- | 201 | * all locks. So someone else could sneak in and change the current modeset |
|
- | 202 | * configuration. Which means that all the state assembled in @state is no |
|
- | 203 | * longer an atomic update to the current state, but to some arbitrary earlier |
|
- | 204 | * state. Which could break assumptions the driver's ->atomic_check likely |
|
- | 205 | * relies on. |
|
- | 206 | * |
|
- | 207 | * Hence we must clear all cached state and completely start over, using this |
|
- | 208 | * function. |
|
- | 209 | */ |
|
- | 210 | void drm_atomic_state_clear(struct drm_atomic_state *state) |
|
- | 211 | { |
|
- | 212 | struct drm_device *dev = state->dev; |
|
- | 213 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 214 | ||
- | 215 | if (config->funcs->atomic_state_clear) |
|
- | 216 | config->funcs->atomic_state_clear(state); |
|
- | 217 | else |
|
- | 218 | drm_atomic_state_default_clear(state); |
|
- | 219 | } |
|
154 | EXPORT_SYMBOL(drm_atomic_state_clear); |
220 | EXPORT_SYMBOL(drm_atomic_state_clear); |
155 | 221 | ||
156 | /** |
222 | /** |
157 | * drm_atomic_state_free - free all memory for an atomic state |
223 | * drm_atomic_state_free - free all memory for an atomic state |
158 | * @state: atomic state to deallocate |
224 | * @state: atomic state to deallocate |
159 | * |
225 | * |
160 | * This frees all memory associated with an atomic state, including all the |
226 | * This frees all memory associated with an atomic state, including all the |
161 | * per-object state for planes, crtcs and connectors. |
227 | * per-object state for planes, crtcs and connectors. |
162 | */ |
228 | */ |
163 | void drm_atomic_state_free(struct drm_atomic_state *state) |
229 | void drm_atomic_state_free(struct drm_atomic_state *state) |
164 | { |
230 | { |
- | 231 | struct drm_device *dev; |
|
- | 232 | struct drm_mode_config *config; |
|
- | 233 | ||
- | 234 | if (!state) |
|
- | 235 | return; |
|
- | 236 | ||
- | 237 | dev = state->dev; |
|
- | 238 | config = &dev->mode_config; |
|
- | 239 | ||
165 | drm_atomic_state_clear(state); |
240 | drm_atomic_state_clear(state); |
166 | 241 | ||
- | 242 | DRM_DEBUG_ATOMIC("Freeing atomic state %p\n", state); |
|
- | 243 | ||
- | 244 | if (config->funcs->atomic_state_free) { |
|
- | 245 | config->funcs->atomic_state_free(state); |
|
167 | DRM_DEBUG_KMS("Freeing atomic state %p\n", state); |
246 | } else { |
- | 247 | drm_atomic_state_default_release(state); |
|
168 | 248 | kfree(state); |
|
169 | kfree_state(state); |
249 | } |
170 | } |
250 | } |
171 | EXPORT_SYMBOL(drm_atomic_state_free); |
251 | EXPORT_SYMBOL(drm_atomic_state_free); |
172 | 252 | ||
173 | /** |
253 | /** |
174 | * drm_atomic_get_crtc_state - get crtc state |
254 | * drm_atomic_get_crtc_state - get crtc state |
175 | * @state: global atomic state object |
255 | * @state: global atomic state object |
176 | * @crtc: crtc to get state object for |
256 | * @crtc: crtc to get state object for |
177 | * |
257 | * |
178 | * This function returns the crtc state for the given crtc, allocating it if |
258 | * This function returns the crtc state for the given crtc, allocating it if |
179 | * needed. It will also grab the relevant crtc lock to make sure that the state |
259 | * needed. It will also grab the relevant crtc lock to make sure that the state |
180 | * is consistent. |
260 | * is consistent. |
181 | * |
261 | * |
182 | * Returns: |
262 | * Returns: |
183 | * |
263 | * |
184 | * Either the allocated state or the error code encoded into the pointer. When |
264 | * Either the allocated state or the error code encoded into the pointer. When |
185 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
265 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
186 | * entire atomic sequence must be restarted. All other errors are fatal. |
266 | * entire atomic sequence must be restarted. All other errors are fatal. |
187 | */ |
267 | */ |
188 | struct drm_crtc_state * |
268 | struct drm_crtc_state * |
189 | drm_atomic_get_crtc_state(struct drm_atomic_state *state, |
269 | drm_atomic_get_crtc_state(struct drm_atomic_state *state, |
190 | struct drm_crtc *crtc) |
270 | struct drm_crtc *crtc) |
191 | { |
271 | { |
192 | int ret, index; |
272 | int ret, index = drm_crtc_index(crtc); |
193 | struct drm_crtc_state *crtc_state; |
273 | struct drm_crtc_state *crtc_state; |
194 | 274 | ||
195 | index = drm_crtc_index(crtc); |
- | |
196 | 275 | crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); |
|
197 | if (state->crtc_states[index]) |
276 | if (crtc_state) |
198 | return state->crtc_states[index]; |
277 | return crtc_state; |
199 | 278 | ||
200 | ret = drm_modeset_lock(&crtc->mutex, state->acquire_ctx); |
279 | ret = drm_modeset_lock(&crtc->mutex, state->acquire_ctx); |
201 | if (ret) |
280 | if (ret) |
202 | return ERR_PTR(ret); |
281 | return ERR_PTR(ret); |
203 | 282 | ||
204 | crtc_state = crtc->funcs->atomic_duplicate_state(crtc); |
283 | crtc_state = crtc->funcs->atomic_duplicate_state(crtc); |
205 | if (!crtc_state) |
284 | if (!crtc_state) |
206 | return ERR_PTR(-ENOMEM); |
285 | return ERR_PTR(-ENOMEM); |
207 | 286 | ||
208 | state->crtc_states[index] = crtc_state; |
287 | state->crtc_states[index] = crtc_state; |
209 | state->crtcs[index] = crtc; |
288 | state->crtcs[index] = crtc; |
210 | crtc_state->state = state; |
289 | crtc_state->state = state; |
211 | 290 | ||
212 | DRM_DEBUG_KMS("Added [CRTC:%d] %p state to %p\n", |
291 | DRM_DEBUG_ATOMIC("Added [CRTC:%d] %p state to %p\n", |
213 | crtc->base.id, crtc_state, state); |
292 | crtc->base.id, crtc_state, state); |
214 | 293 | ||
215 | return crtc_state; |
294 | return crtc_state; |
216 | } |
295 | } |
217 | EXPORT_SYMBOL(drm_atomic_get_crtc_state); |
296 | EXPORT_SYMBOL(drm_atomic_get_crtc_state); |
218 | 297 | ||
219 | /** |
298 | /** |
- | 299 | * drm_atomic_set_mode_for_crtc - set mode for CRTC |
|
- | 300 | * @state: the CRTC whose incoming state to update |
|
- | 301 | * @mode: kernel-internal mode to use for the CRTC, or NULL to disable |
|
- | 302 | * |
|
- | 303 | * Set a mode (originating from the kernel) on the desired CRTC state. Does |
|
- | 304 | * not change any other state properties, including enable, active, or |
|
- | 305 | * mode_changed. |
|
- | 306 | * |
|
- | 307 | * RETURNS: |
|
- | 308 | * Zero on success, error code on failure. Cannot return -EDEADLK. |
|
- | 309 | */ |
|
- | 310 | int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, |
|
- | 311 | struct drm_display_mode *mode) |
|
- | 312 | { |
|
- | 313 | struct drm_mode_modeinfo umode; |
|
- | 314 | ||
- | 315 | /* Early return for no change. */ |
|
- | 316 | if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0) |
|
- | 317 | return 0; |
|
- | 318 | ||
- | 319 | if (state->mode_blob) |
|
- | 320 | drm_property_unreference_blob(state->mode_blob); |
|
- | 321 | state->mode_blob = NULL; |
|
- | 322 | ||
- | 323 | if (mode) { |
|
- | 324 | drm_mode_convert_to_umode(&umode, mode); |
|
- | 325 | state->mode_blob = |
|
- | 326 | drm_property_create_blob(state->crtc->dev, |
|
- | 327 | sizeof(umode), |
|
- | 328 | &umode); |
|
- | 329 | if (IS_ERR(state->mode_blob)) |
|
- | 330 | return PTR_ERR(state->mode_blob); |
|
- | 331 | ||
- | 332 | drm_mode_copy(&state->mode, mode); |
|
- | 333 | state->enable = true; |
|
- | 334 | DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n", |
|
- | 335 | mode->name, state); |
|
- | 336 | } else { |
|
- | 337 | memset(&state->mode, 0, sizeof(state->mode)); |
|
- | 338 | state->enable = false; |
|
- | 339 | DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n", |
|
- | 340 | state); |
|
- | 341 | } |
|
- | 342 | ||
- | 343 | return 0; |
|
- | 344 | } |
|
- | 345 | EXPORT_SYMBOL(drm_atomic_set_mode_for_crtc); |
|
- | 346 | ||
- | 347 | /** |
|
- | 348 | * drm_atomic_set_mode_prop_for_crtc - set mode for CRTC |
|
- | 349 | * @state: the CRTC whose incoming state to update |
|
- | 350 | * @blob: pointer to blob property to use for mode |
|
- | 351 | * |
|
- | 352 | * Set a mode (originating from a blob property) on the desired CRTC state. |
|
- | 353 | * This function will take a reference on the blob property for the CRTC state, |
|
- | 354 | * and release the reference held on the state's existing mode property, if any |
|
- | 355 | * was set. |
|
- | 356 | * |
|
- | 357 | * RETURNS: |
|
- | 358 | * Zero on success, error code on failure. Cannot return -EDEADLK. |
|
- | 359 | */ |
|
- | 360 | int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state, |
|
- | 361 | struct drm_property_blob *blob) |
|
- | 362 | { |
|
- | 363 | if (blob == state->mode_blob) |
|
- | 364 | return 0; |
|
- | 365 | ||
- | 366 | if (state->mode_blob) |
|
- | 367 | drm_property_unreference_blob(state->mode_blob); |
|
- | 368 | state->mode_blob = NULL; |
|
- | 369 | ||
- | 370 | if (blob) { |
|
- | 371 | if (blob->length != sizeof(struct drm_mode_modeinfo) || |
|
- | 372 | drm_mode_convert_umode(&state->mode, |
|
- | 373 | (const struct drm_mode_modeinfo *) |
|
- | 374 | blob->data)) |
|
- | 375 | return -EINVAL; |
|
- | 376 | ||
- | 377 | state->mode_blob = drm_property_reference_blob(blob); |
|
- | 378 | state->enable = true; |
|
- | 379 | DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n", |
|
- | 380 | state->mode.name, state); |
|
- | 381 | } else { |
|
- | 382 | memset(&state->mode, 0, sizeof(state->mode)); |
|
- | 383 | state->enable = false; |
|
- | 384 | DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n", |
|
- | 385 | state); |
|
- | 386 | } |
|
- | 387 | ||
- | 388 | return 0; |
|
- | 389 | } |
|
- | 390 | EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc); |
|
- | 391 | ||
- | 392 | /** |
|
- | 393 | * drm_atomic_crtc_set_property - set property on CRTC |
|
- | 394 | * @crtc: the drm CRTC to set a property on |
|
- | 395 | * @state: the state object to update with the new property value |
|
- | 396 | * @property: the property to set |
|
- | 397 | * @val: the new property value |
|
- | 398 | * |
|
- | 399 | * Use this instead of calling crtc->atomic_set_property directly. |
|
- | 400 | * This function handles generic/core properties and calls out to |
|
- | 401 | * driver's ->atomic_set_property() for driver properties. To ensure |
|
- | 402 | * consistent behavior you must call this function rather than the |
|
- | 403 | * driver hook directly. |
|
- | 404 | * |
|
- | 405 | * RETURNS: |
|
- | 406 | * Zero on success, error code on failure |
|
- | 407 | */ |
|
- | 408 | int drm_atomic_crtc_set_property(struct drm_crtc *crtc, |
|
- | 409 | struct drm_crtc_state *state, struct drm_property *property, |
|
- | 410 | uint64_t val) |
|
- | 411 | { |
|
- | 412 | struct drm_device *dev = crtc->dev; |
|
- | 413 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 414 | int ret; |
|
- | 415 | ||
- | 416 | if (property == config->prop_active) |
|
- | 417 | state->active = val; |
|
- | 418 | else if (property == config->prop_mode_id) { |
|
- | 419 | struct drm_property_blob *mode = |
|
- | 420 | drm_property_lookup_blob(dev, val); |
|
- | 421 | ret = drm_atomic_set_mode_prop_for_crtc(state, mode); |
|
- | 422 | if (mode) |
|
- | 423 | drm_property_unreference_blob(mode); |
|
- | 424 | return ret; |
|
- | 425 | } |
|
- | 426 | else if (crtc->funcs->atomic_set_property) |
|
- | 427 | return crtc->funcs->atomic_set_property(crtc, state, property, val); |
|
- | 428 | else |
|
- | 429 | return -EINVAL; |
|
- | 430 | ||
- | 431 | return 0; |
|
- | 432 | } |
|
- | 433 | EXPORT_SYMBOL(drm_atomic_crtc_set_property); |
|
- | 434 | ||
- | 435 | /* |
|
- | 436 | * This function handles generic/core properties and calls out to |
|
- | 437 | * driver's ->atomic_get_property() for driver properties. To ensure |
|
- | 438 | * consistent behavior you must call this function rather than the |
|
- | 439 | * driver hook directly. |
|
- | 440 | */ |
|
- | 441 | static int |
|
- | 442 | drm_atomic_crtc_get_property(struct drm_crtc *crtc, |
|
- | 443 | const struct drm_crtc_state *state, |
|
- | 444 | struct drm_property *property, uint64_t *val) |
|
- | 445 | { |
|
- | 446 | struct drm_device *dev = crtc->dev; |
|
- | 447 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 448 | ||
- | 449 | if (property == config->prop_active) |
|
- | 450 | *val = state->active; |
|
- | 451 | else if (property == config->prop_mode_id) |
|
- | 452 | *val = (state->mode_blob) ? state->mode_blob->base.id : 0; |
|
- | 453 | else if (crtc->funcs->atomic_get_property) |
|
- | 454 | return crtc->funcs->atomic_get_property(crtc, state, property, val); |
|
- | 455 | else |
|
- | 456 | return -EINVAL; |
|
- | 457 | ||
- | 458 | return 0; |
|
- | 459 | } |
|
- | 460 | ||
- | 461 | /** |
|
- | 462 | * drm_atomic_crtc_check - check crtc state |
|
- | 463 | * @crtc: crtc to check |
|
- | 464 | * @state: crtc state to check |
|
- | 465 | * |
|
- | 466 | * Provides core sanity checks for crtc state. |
|
- | 467 | * |
|
- | 468 | * RETURNS: |
|
- | 469 | * Zero on success, error code on failure |
|
- | 470 | */ |
|
- | 471 | static int drm_atomic_crtc_check(struct drm_crtc *crtc, |
|
- | 472 | struct drm_crtc_state *state) |
|
- | 473 | { |
|
- | 474 | /* NOTE: we explicitly don't enforce constraints such as primary |
|
- | 475 | * layer covering entire screen, since that is something we want |
|
- | 476 | * to allow (on hw that supports it). For hw that does not, it |
|
- | 477 | * should be checked in driver's crtc->atomic_check() vfunc. |
|
- | 478 | * |
|
- | 479 | * TODO: Add generic modeset state checks once we support those. |
|
- | 480 | */ |
|
- | 481 | ||
- | 482 | if (state->active && !state->enable) { |
|
- | 483 | DRM_DEBUG_ATOMIC("[CRTC:%d] active without enabled\n", |
|
- | 484 | crtc->base.id); |
|
- | 485 | return -EINVAL; |
|
- | 486 | } |
|
- | 487 | ||
- | 488 | /* The state->enable vs. state->mode_blob checks can be WARN_ON, |
|
- | 489 | * as this is a kernel-internal detail that userspace should never |
|
- | 490 | * be able to trigger. */ |
|
- | 491 | if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) && |
|
- | 492 | WARN_ON(state->enable && !state->mode_blob)) { |
|
- | 493 | DRM_DEBUG_ATOMIC("[CRTC:%d] enabled without mode blob\n", |
|
- | 494 | crtc->base.id); |
|
- | 495 | return -EINVAL; |
|
- | 496 | } |
|
- | 497 | ||
- | 498 | if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) && |
|
- | 499 | WARN_ON(!state->enable && state->mode_blob)) { |
|
- | 500 | DRM_DEBUG_ATOMIC("[CRTC:%d] disabled with mode blob\n", |
|
- | 501 | crtc->base.id); |
|
- | 502 | return -EINVAL; |
|
- | 503 | } |
|
- | 504 | ||
- | 505 | return 0; |
|
- | 506 | } |
|
- | 507 | ||
- | 508 | /** |
|
220 | * drm_atomic_get_plane_state - get plane state |
509 | * drm_atomic_get_plane_state - get plane state |
221 | * @state: global atomic state object |
510 | * @state: global atomic state object |
222 | * @plane: plane to get state object for |
511 | * @plane: plane to get state object for |
223 | * |
512 | * |
224 | * This function returns the plane state for the given plane, allocating it if |
513 | * This function returns the plane state for the given plane, allocating it if |
225 | * needed. It will also grab the relevant plane lock to make sure that the state |
514 | * needed. It will also grab the relevant plane lock to make sure that the state |
226 | * is consistent. |
515 | * is consistent. |
227 | * |
516 | * |
228 | * Returns: |
517 | * Returns: |
229 | * |
518 | * |
230 | * Either the allocated state or the error code encoded into the pointer. When |
519 | * Either the allocated state or the error code encoded into the pointer. When |
231 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
520 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
232 | * entire atomic sequence must be restarted. All other errors are fatal. |
521 | * entire atomic sequence must be restarted. All other errors are fatal. |
233 | */ |
522 | */ |
234 | struct drm_plane_state * |
523 | struct drm_plane_state * |
235 | drm_atomic_get_plane_state(struct drm_atomic_state *state, |
524 | drm_atomic_get_plane_state(struct drm_atomic_state *state, |
236 | struct drm_plane *plane) |
525 | struct drm_plane *plane) |
237 | { |
526 | { |
238 | int ret, index; |
527 | int ret, index = drm_plane_index(plane); |
239 | struct drm_plane_state *plane_state; |
528 | struct drm_plane_state *plane_state; |
240 | 529 | ||
241 | index = drm_plane_index(plane); |
- | |
242 | 530 | plane_state = drm_atomic_get_existing_plane_state(state, plane); |
|
243 | if (state->plane_states[index]) |
531 | if (plane_state) |
244 | return state->plane_states[index]; |
532 | return plane_state; |
245 | 533 | ||
246 | ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx); |
534 | ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx); |
247 | if (ret) |
535 | if (ret) |
248 | return ERR_PTR(ret); |
536 | return ERR_PTR(ret); |
249 | 537 | ||
250 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
538 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
251 | if (!plane_state) |
539 | if (!plane_state) |
252 | return ERR_PTR(-ENOMEM); |
540 | return ERR_PTR(-ENOMEM); |
253 | 541 | ||
254 | state->plane_states[index] = plane_state; |
542 | state->plane_states[index] = plane_state; |
255 | state->planes[index] = plane; |
543 | state->planes[index] = plane; |
256 | plane_state->state = state; |
544 | plane_state->state = state; |
257 | 545 | ||
258 | DRM_DEBUG_KMS("Added [PLANE:%d] %p state to %p\n", |
546 | DRM_DEBUG_ATOMIC("Added [PLANE:%d] %p state to %p\n", |
259 | plane->base.id, plane_state, state); |
547 | plane->base.id, plane_state, state); |
260 | 548 | ||
261 | if (plane_state->crtc) { |
549 | if (plane_state->crtc) { |
262 | struct drm_crtc_state *crtc_state; |
550 | struct drm_crtc_state *crtc_state; |
263 | 551 | ||
264 | crtc_state = drm_atomic_get_crtc_state(state, |
552 | crtc_state = drm_atomic_get_crtc_state(state, |
265 | plane_state->crtc); |
553 | plane_state->crtc); |
266 | if (IS_ERR(crtc_state)) |
554 | if (IS_ERR(crtc_state)) |
267 | return ERR_CAST(crtc_state); |
555 | return ERR_CAST(crtc_state); |
268 | } |
556 | } |
269 | 557 | ||
270 | return plane_state; |
558 | return plane_state; |
271 | } |
559 | } |
272 | EXPORT_SYMBOL(drm_atomic_get_plane_state); |
560 | EXPORT_SYMBOL(drm_atomic_get_plane_state); |
273 | 561 | ||
274 | /** |
562 | /** |
- | 563 | * drm_atomic_plane_set_property - set property on plane |
|
- | 564 | * @plane: the drm plane to set a property on |
|
- | 565 | * @state: the state object to update with the new property value |
|
- | 566 | * @property: the property to set |
|
- | 567 | * @val: the new property value |
|
- | 568 | * |
|
- | 569 | * Use this instead of calling plane->atomic_set_property directly. |
|
- | 570 | * This function handles generic/core properties and calls out to |
|
- | 571 | * driver's ->atomic_set_property() for driver properties. To ensure |
|
- | 572 | * consistent behavior you must call this function rather than the |
|
- | 573 | * driver hook directly. |
|
- | 574 | * |
|
- | 575 | * RETURNS: |
|
- | 576 | * Zero on success, error code on failure |
|
- | 577 | */ |
|
- | 578 | int drm_atomic_plane_set_property(struct drm_plane *plane, |
|
- | 579 | struct drm_plane_state *state, struct drm_property *property, |
|
- | 580 | uint64_t val) |
|
- | 581 | { |
|
- | 582 | struct drm_device *dev = plane->dev; |
|
- | 583 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 584 | ||
- | 585 | if (property == config->prop_fb_id) { |
|
- | 586 | struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, val); |
|
- | 587 | drm_atomic_set_fb_for_plane(state, fb); |
|
- | 588 | if (fb) |
|
- | 589 | drm_framebuffer_unreference(fb); |
|
- | 590 | } else if (property == config->prop_crtc_id) { |
|
- | 591 | struct drm_crtc *crtc = drm_crtc_find(dev, val); |
|
- | 592 | return drm_atomic_set_crtc_for_plane(state, crtc); |
|
- | 593 | } else if (property == config->prop_crtc_x) { |
|
- | 594 | state->crtc_x = U642I64(val); |
|
- | 595 | } else if (property == config->prop_crtc_y) { |
|
- | 596 | state->crtc_y = U642I64(val); |
|
- | 597 | } else if (property == config->prop_crtc_w) { |
|
- | 598 | state->crtc_w = val; |
|
- | 599 | } else if (property == config->prop_crtc_h) { |
|
- | 600 | state->crtc_h = val; |
|
- | 601 | } else if (property == config->prop_src_x) { |
|
- | 602 | state->src_x = val; |
|
- | 603 | } else if (property == config->prop_src_y) { |
|
- | 604 | state->src_y = val; |
|
- | 605 | } else if (property == config->prop_src_w) { |
|
- | 606 | state->src_w = val; |
|
- | 607 | } else if (property == config->prop_src_h) { |
|
- | 608 | state->src_h = val; |
|
- | 609 | } else if (property == config->rotation_property) { |
|
- | 610 | state->rotation = val; |
|
- | 611 | } else if (plane->funcs->atomic_set_property) { |
|
- | 612 | return plane->funcs->atomic_set_property(plane, state, |
|
- | 613 | property, val); |
|
- | 614 | } else { |
|
- | 615 | return -EINVAL; |
|
- | 616 | } |
|
- | 617 | ||
- | 618 | return 0; |
|
- | 619 | } |
|
- | 620 | EXPORT_SYMBOL(drm_atomic_plane_set_property); |
|
- | 621 | ||
- | 622 | /* |
|
- | 623 | * This function handles generic/core properties and calls out to |
|
- | 624 | * driver's ->atomic_get_property() for driver properties. To ensure |
|
- | 625 | * consistent behavior you must call this function rather than the |
|
- | 626 | * driver hook directly. |
|
- | 627 | */ |
|
- | 628 | static int |
|
- | 629 | drm_atomic_plane_get_property(struct drm_plane *plane, |
|
- | 630 | const struct drm_plane_state *state, |
|
- | 631 | struct drm_property *property, uint64_t *val) |
|
- | 632 | { |
|
- | 633 | struct drm_device *dev = plane->dev; |
|
- | 634 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 635 | ||
- | 636 | if (property == config->prop_fb_id) { |
|
- | 637 | *val = (state->fb) ? state->fb->base.id : 0; |
|
- | 638 | } else if (property == config->prop_crtc_id) { |
|
- | 639 | *val = (state->crtc) ? state->crtc->base.id : 0; |
|
- | 640 | } else if (property == config->prop_crtc_x) { |
|
- | 641 | *val = I642U64(state->crtc_x); |
|
- | 642 | } else if (property == config->prop_crtc_y) { |
|
- | 643 | *val = I642U64(state->crtc_y); |
|
- | 644 | } else if (property == config->prop_crtc_w) { |
|
- | 645 | *val = state->crtc_w; |
|
- | 646 | } else if (property == config->prop_crtc_h) { |
|
- | 647 | *val = state->crtc_h; |
|
- | 648 | } else if (property == config->prop_src_x) { |
|
- | 649 | *val = state->src_x; |
|
- | 650 | } else if (property == config->prop_src_y) { |
|
- | 651 | *val = state->src_y; |
|
- | 652 | } else if (property == config->prop_src_w) { |
|
- | 653 | *val = state->src_w; |
|
- | 654 | } else if (property == config->prop_src_h) { |
|
- | 655 | *val = state->src_h; |
|
- | 656 | } else if (property == config->rotation_property) { |
|
- | 657 | *val = state->rotation; |
|
- | 658 | } else if (plane->funcs->atomic_get_property) { |
|
- | 659 | return plane->funcs->atomic_get_property(plane, state, property, val); |
|
- | 660 | } else { |
|
- | 661 | return -EINVAL; |
|
- | 662 | } |
|
- | 663 | ||
- | 664 | return 0; |
|
- | 665 | } |
|
- | 666 | ||
- | 667 | static bool |
|
- | 668 | plane_switching_crtc(struct drm_atomic_state *state, |
|
- | 669 | struct drm_plane *plane, |
|
- | 670 | struct drm_plane_state *plane_state) |
|
- | 671 | { |
|
- | 672 | if (!plane->state->crtc || !plane_state->crtc) |
|
- | 673 | return false; |
|
- | 674 | ||
- | 675 | if (plane->state->crtc == plane_state->crtc) |
|
- | 676 | return false; |
|
- | 677 | ||
- | 678 | /* This could be refined, but currently there's no helper or driver code |
|
- | 679 | * to implement direct switching of active planes nor userspace to take |
|
- | 680 | * advantage of more direct plane switching without the intermediate |
|
- | 681 | * full OFF state. |
|
- | 682 | */ |
|
- | 683 | return true; |
|
- | 684 | } |
|
- | 685 | ||
- | 686 | /** |
|
- | 687 | * drm_atomic_plane_check - check plane state |
|
- | 688 | * @plane: plane to check |
|
- | 689 | * @state: plane state to check |
|
- | 690 | * |
|
- | 691 | * Provides core sanity checks for plane state. |
|
- | 692 | * |
|
- | 693 | * RETURNS: |
|
- | 694 | * Zero on success, error code on failure |
|
- | 695 | */ |
|
- | 696 | static int drm_atomic_plane_check(struct drm_plane *plane, |
|
- | 697 | struct drm_plane_state *state) |
|
- | 698 | { |
|
- | 699 | unsigned int fb_width, fb_height; |
|
- | 700 | int ret; |
|
- | 701 | ||
- | 702 | /* either *both* CRTC and FB must be set, or neither */ |
|
- | 703 | if (WARN_ON(state->crtc && !state->fb)) { |
|
- | 704 | DRM_DEBUG_ATOMIC("CRTC set but no FB\n"); |
|
- | 705 | return -EINVAL; |
|
- | 706 | } else if (WARN_ON(state->fb && !state->crtc)) { |
|
- | 707 | DRM_DEBUG_ATOMIC("FB set but no CRTC\n"); |
|
- | 708 | return -EINVAL; |
|
- | 709 | } |
|
- | 710 | ||
- | 711 | /* if disabled, we don't care about the rest of the state: */ |
|
- | 712 | if (!state->crtc) |
|
- | 713 | return 0; |
|
- | 714 | ||
- | 715 | /* Check whether this plane is usable on this CRTC */ |
|
- | 716 | if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) { |
|
- | 717 | DRM_DEBUG_ATOMIC("Invalid crtc for plane\n"); |
|
- | 718 | return -EINVAL; |
|
- | 719 | } |
|
- | 720 | ||
- | 721 | /* Check whether this plane supports the fb pixel format. */ |
|
- | 722 | ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format); |
|
- | 723 | if (ret) { |
|
- | 724 | DRM_DEBUG_ATOMIC("Invalid pixel format %s\n", |
|
- | 725 | drm_get_format_name(state->fb->pixel_format)); |
|
- | 726 | return ret; |
|
- | 727 | } |
|
- | 728 | ||
- | 729 | /* Give drivers some help against integer overflows */ |
|
- | 730 | if (state->crtc_w > INT_MAX || |
|
- | 731 | state->crtc_x > INT_MAX - (int32_t) state->crtc_w || |
|
- | 732 | state->crtc_h > INT_MAX || |
|
- | 733 | state->crtc_y > INT_MAX - (int32_t) state->crtc_h) { |
|
- | 734 | DRM_DEBUG_ATOMIC("Invalid CRTC coordinates %ux%u+%d+%d\n", |
|
- | 735 | state->crtc_w, state->crtc_h, |
|
- | 736 | state->crtc_x, state->crtc_y); |
|
- | 737 | return -ERANGE; |
|
- | 738 | } |
|
- | 739 | ||
- | 740 | fb_width = state->fb->width << 16; |
|
- | 741 | fb_height = state->fb->height << 16; |
|
- | 742 | ||
- | 743 | /* Make sure source coordinates are inside the fb. */ |
|
- | 744 | if (state->src_w > fb_width || |
|
- | 745 | state->src_x > fb_width - state->src_w || |
|
- | 746 | state->src_h > fb_height || |
|
- | 747 | state->src_y > fb_height - state->src_h) { |
|
- | 748 | DRM_DEBUG_ATOMIC("Invalid source coordinates " |
|
- | 749 | "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n", |
|
- | 750 | state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10, |
|
- | 751 | state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10, |
|
- | 752 | state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10, |
|
- | 753 | state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10); |
|
- | 754 | return -ENOSPC; |
|
- | 755 | } |
|
- | 756 | ||
- | 757 | if (plane_switching_crtc(state->state, plane, state)) { |
|
- | 758 | DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n", |
|
- | 759 | plane->base.id); |
|
- | 760 | return -EINVAL; |
|
- | 761 | } |
|
- | 762 | ||
- | 763 | return 0; |
|
- | 764 | } |
|
- | 765 | ||
- | 766 | /** |
|
275 | * drm_atomic_get_connector_state - get connector state |
767 | * drm_atomic_get_connector_state - get connector state |
276 | * @state: global atomic state object |
768 | * @state: global atomic state object |
277 | * @connector: connector to get state object for |
769 | * @connector: connector to get state object for |
278 | * |
770 | * |
279 | * This function returns the connector state for the given connector, |
771 | * This function returns the connector state for the given connector, |
280 | * allocating it if needed. It will also grab the relevant connector lock to |
772 | * allocating it if needed. It will also grab the relevant connector lock to |
281 | * make sure that the state is consistent. |
773 | * make sure that the state is consistent. |
282 | * |
774 | * |
283 | * Returns: |
775 | * Returns: |
284 | * |
776 | * |
285 | * Either the allocated state or the error code encoded into the pointer. When |
777 | * Either the allocated state or the error code encoded into the pointer. When |
286 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
778 | * the error is EDEADLK then the w/w mutex code has detected a deadlock and the |
287 | * entire atomic sequence must be restarted. All other errors are fatal. |
779 | * entire atomic sequence must be restarted. All other errors are fatal. |
288 | */ |
780 | */ |
289 | struct drm_connector_state * |
781 | struct drm_connector_state * |
290 | drm_atomic_get_connector_state(struct drm_atomic_state *state, |
782 | drm_atomic_get_connector_state(struct drm_atomic_state *state, |
291 | struct drm_connector *connector) |
783 | struct drm_connector *connector) |
292 | { |
784 | { |
293 | int ret, index; |
785 | int ret, index; |
294 | struct drm_mode_config *config = &connector->dev->mode_config; |
786 | struct drm_mode_config *config = &connector->dev->mode_config; |
295 | struct drm_connector_state *connector_state; |
787 | struct drm_connector_state *connector_state; |
296 | 788 | ||
297 | ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); |
789 | ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); |
298 | if (ret) |
790 | if (ret) |
299 | return ERR_PTR(ret); |
791 | return ERR_PTR(ret); |
300 | 792 | ||
301 | index = drm_connector_index(connector); |
793 | index = drm_connector_index(connector); |
302 | 794 | ||
303 | /* |
795 | /* |
304 | * Construction of atomic state updates can race with a connector |
796 | * Construction of atomic state updates can race with a connector |
305 | * hot-add which might overflow. In this case flip the table and just |
797 | * hot-add which might overflow. In this case flip the table and just |
306 | * restart the entire ioctl - no one is fast enough to livelock a cpu |
798 | * restart the entire ioctl - no one is fast enough to livelock a cpu |
307 | * with physical hotplug events anyway. |
799 | * with physical hotplug events anyway. |
308 | * |
800 | * |
309 | * Note that we only grab the indexes once we have the right lock to |
801 | * Note that we only grab the indexes once we have the right lock to |
310 | * prevent hotplug/unplugging of connectors. So removal is no problem, |
802 | * prevent hotplug/unplugging of connectors. So removal is no problem, |
311 | * at most the array is a bit too large. |
803 | * at most the array is a bit too large. |
312 | */ |
804 | */ |
313 | if (index >= state->num_connector) { |
805 | if (index >= state->num_connector) { |
314 | DRM_DEBUG_KMS("Hot-added connector would overflow state array, restarting\n"); |
806 | DRM_DEBUG_ATOMIC("Hot-added connector would overflow state array, restarting\n"); |
315 | return ERR_PTR(-EAGAIN); |
807 | return ERR_PTR(-EAGAIN); |
316 | } |
808 | } |
317 | 809 | ||
318 | if (state->connector_states[index]) |
810 | if (state->connector_states[index]) |
319 | return state->connector_states[index]; |
811 | return state->connector_states[index]; |
320 | 812 | ||
321 | connector_state = connector->funcs->atomic_duplicate_state(connector); |
813 | connector_state = connector->funcs->atomic_duplicate_state(connector); |
322 | if (!connector_state) |
814 | if (!connector_state) |
323 | return ERR_PTR(-ENOMEM); |
815 | return ERR_PTR(-ENOMEM); |
324 | 816 | ||
325 | state->connector_states[index] = connector_state; |
817 | state->connector_states[index] = connector_state; |
326 | state->connectors[index] = connector; |
818 | state->connectors[index] = connector; |
327 | connector_state->state = state; |
819 | connector_state->state = state; |
328 | 820 | ||
329 | DRM_DEBUG_KMS("Added [CONNECTOR:%d] %p state to %p\n", |
821 | DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n", |
330 | connector->base.id, connector_state, state); |
822 | connector->base.id, connector_state, state); |
331 | 823 | ||
332 | if (connector_state->crtc) { |
824 | if (connector_state->crtc) { |
333 | struct drm_crtc_state *crtc_state; |
825 | struct drm_crtc_state *crtc_state; |
334 | 826 | ||
335 | crtc_state = drm_atomic_get_crtc_state(state, |
827 | crtc_state = drm_atomic_get_crtc_state(state, |
336 | connector_state->crtc); |
828 | connector_state->crtc); |
337 | if (IS_ERR(crtc_state)) |
829 | if (IS_ERR(crtc_state)) |
338 | return ERR_CAST(crtc_state); |
830 | return ERR_CAST(crtc_state); |
339 | } |
831 | } |
340 | 832 | ||
341 | return connector_state; |
833 | return connector_state; |
342 | } |
834 | } |
343 | EXPORT_SYMBOL(drm_atomic_get_connector_state); |
835 | EXPORT_SYMBOL(drm_atomic_get_connector_state); |
344 | 836 | ||
345 | /** |
837 | /** |
- | 838 | * drm_atomic_connector_set_property - set property on connector. |
|
- | 839 | * @connector: the drm connector to set a property on |
|
- | 840 | * @state: the state object to update with the new property value |
|
- | 841 | * @property: the property to set |
|
- | 842 | * @val: the new property value |
|
- | 843 | * |
|
- | 844 | * Use this instead of calling connector->atomic_set_property directly. |
|
- | 845 | * This function handles generic/core properties and calls out to |
|
- | 846 | * driver's ->atomic_set_property() for driver properties. To ensure |
|
- | 847 | * consistent behavior you must call this function rather than the |
|
- | 848 | * driver hook directly. |
|
- | 849 | * |
|
- | 850 | * RETURNS: |
|
- | 851 | * Zero on success, error code on failure |
|
- | 852 | */ |
|
- | 853 | int drm_atomic_connector_set_property(struct drm_connector *connector, |
|
- | 854 | struct drm_connector_state *state, struct drm_property *property, |
|
- | 855 | uint64_t val) |
|
- | 856 | { |
|
- | 857 | struct drm_device *dev = connector->dev; |
|
- | 858 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 859 | ||
- | 860 | if (property == config->prop_crtc_id) { |
|
- | 861 | struct drm_crtc *crtc = drm_crtc_find(dev, val); |
|
- | 862 | return drm_atomic_set_crtc_for_connector(state, crtc); |
|
- | 863 | } else if (property == config->dpms_property) { |
|
- | 864 | /* setting DPMS property requires special handling, which |
|
- | 865 | * is done in legacy setprop path for us. Disallow (for |
|
- | 866 | * now?) atomic writes to DPMS property: |
|
- | 867 | */ |
|
- | 868 | return -EINVAL; |
|
- | 869 | } else if (connector->funcs->atomic_set_property) { |
|
- | 870 | return connector->funcs->atomic_set_property(connector, |
|
- | 871 | state, property, val); |
|
- | 872 | } else { |
|
- | 873 | return -EINVAL; |
|
- | 874 | } |
|
- | 875 | } |
|
- | 876 | EXPORT_SYMBOL(drm_atomic_connector_set_property); |
|
- | 877 | ||
- | 878 | /* |
|
- | 879 | * This function handles generic/core properties and calls out to |
|
- | 880 | * driver's ->atomic_get_property() for driver properties. To ensure |
|
- | 881 | * consistent behavior you must call this function rather than the |
|
- | 882 | * driver hook directly. |
|
- | 883 | */ |
|
- | 884 | static int |
|
- | 885 | drm_atomic_connector_get_property(struct drm_connector *connector, |
|
- | 886 | const struct drm_connector_state *state, |
|
- | 887 | struct drm_property *property, uint64_t *val) |
|
- | 888 | { |
|
- | 889 | struct drm_device *dev = connector->dev; |
|
- | 890 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 891 | ||
- | 892 | if (property == config->prop_crtc_id) { |
|
- | 893 | *val = (state->crtc) ? state->crtc->base.id : 0; |
|
- | 894 | } else if (property == config->dpms_property) { |
|
- | 895 | *val = connector->dpms; |
|
- | 896 | } else if (connector->funcs->atomic_get_property) { |
|
- | 897 | return connector->funcs->atomic_get_property(connector, |
|
- | 898 | state, property, val); |
|
- | 899 | } else { |
|
- | 900 | return -EINVAL; |
|
- | 901 | } |
|
- | 902 | ||
- | 903 | return 0; |
|
- | 904 | } |
|
- | 905 | ||
- | 906 | int drm_atomic_get_property(struct drm_mode_object *obj, |
|
- | 907 | struct drm_property *property, uint64_t *val) |
|
- | 908 | { |
|
- | 909 | struct drm_device *dev = property->dev; |
|
- | 910 | int ret; |
|
- | 911 | ||
- | 912 | switch (obj->type) { |
|
- | 913 | case DRM_MODE_OBJECT_CONNECTOR: { |
|
- | 914 | struct drm_connector *connector = obj_to_connector(obj); |
|
- | 915 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); |
|
- | 916 | ret = drm_atomic_connector_get_property(connector, |
|
- | 917 | connector->state, property, val); |
|
- | 918 | break; |
|
- | 919 | } |
|
- | 920 | case DRM_MODE_OBJECT_CRTC: { |
|
- | 921 | struct drm_crtc *crtc = obj_to_crtc(obj); |
|
- | 922 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); |
|
- | 923 | ret = drm_atomic_crtc_get_property(crtc, |
|
- | 924 | crtc->state, property, val); |
|
- | 925 | break; |
|
- | 926 | } |
|
- | 927 | case DRM_MODE_OBJECT_PLANE: { |
|
- | 928 | struct drm_plane *plane = obj_to_plane(obj); |
|
- | 929 | WARN_ON(!drm_modeset_is_locked(&plane->mutex)); |
|
- | 930 | ret = drm_atomic_plane_get_property(plane, |
|
- | 931 | plane->state, property, val); |
|
- | 932 | break; |
|
- | 933 | } |
|
- | 934 | default: |
|
- | 935 | ret = -EINVAL; |
|
- | 936 | break; |
|
- | 937 | } |
|
- | 938 | ||
- | 939 | return ret; |
|
- | 940 | } |
|
- | 941 | ||
- | 942 | /** |
|
346 | * drm_atomic_set_crtc_for_plane - set crtc for plane |
943 | * drm_atomic_set_crtc_for_plane - set crtc for plane |
347 | * @state: the incoming atomic state |
- | |
348 | * @plane: the plane whose incoming state to update |
944 | * @plane_state: the plane whose incoming state to update |
349 | * @crtc: crtc to use for the plane |
945 | * @crtc: crtc to use for the plane |
350 | * |
946 | * |
351 | * Changing the assigned crtc for a plane requires us to grab the lock and state |
947 | * Changing the assigned crtc for a plane requires us to grab the lock and state |
352 | * for the new crtc, as needed. This function takes care of all these details |
948 | * for the new crtc, as needed. This function takes care of all these details |
353 | * besides updating the pointer in the state object itself. |
949 | * besides updating the pointer in the state object itself. |
354 | * |
950 | * |
355 | * Returns: |
951 | * Returns: |
356 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
952 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
357 | * then the w/w mutex code has detected a deadlock and the entire atomic |
953 | * then the w/w mutex code has detected a deadlock and the entire atomic |
358 | * sequence must be restarted. All other errors are fatal. |
954 | * sequence must be restarted. All other errors are fatal. |
359 | */ |
955 | */ |
360 | int |
956 | int |
361 | drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, |
957 | drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state, |
362 | struct drm_plane *plane, struct drm_crtc *crtc) |
958 | struct drm_crtc *crtc) |
363 | { |
959 | { |
364 | struct drm_plane_state *plane_state = |
960 | struct drm_plane *plane = plane_state->plane; |
365 | drm_atomic_get_plane_state(state, plane); |
- | |
366 | struct drm_crtc_state *crtc_state; |
961 | struct drm_crtc_state *crtc_state; |
367 | - | ||
368 | if (WARN_ON(IS_ERR(plane_state))) |
- | |
369 | return PTR_ERR(plane_state); |
- | |
370 | 962 | ||
371 | if (plane_state->crtc) { |
963 | if (plane_state->crtc) { |
372 | crtc_state = drm_atomic_get_crtc_state(plane_state->state, |
964 | crtc_state = drm_atomic_get_crtc_state(plane_state->state, |
373 | plane_state->crtc); |
965 | plane_state->crtc); |
374 | if (WARN_ON(IS_ERR(crtc_state))) |
966 | if (WARN_ON(IS_ERR(crtc_state))) |
375 | return PTR_ERR(crtc_state); |
967 | return PTR_ERR(crtc_state); |
376 | 968 | ||
377 | crtc_state->plane_mask &= ~(1 << drm_plane_index(plane)); |
969 | crtc_state->plane_mask &= ~(1 << drm_plane_index(plane)); |
378 | } |
970 | } |
379 | 971 | ||
380 | plane_state->crtc = crtc; |
972 | plane_state->crtc = crtc; |
381 | 973 | ||
382 | if (crtc) { |
974 | if (crtc) { |
383 | crtc_state = drm_atomic_get_crtc_state(plane_state->state, |
975 | crtc_state = drm_atomic_get_crtc_state(plane_state->state, |
384 | crtc); |
976 | crtc); |
385 | if (IS_ERR(crtc_state)) |
977 | if (IS_ERR(crtc_state)) |
386 | return PTR_ERR(crtc_state); |
978 | return PTR_ERR(crtc_state); |
387 | crtc_state->plane_mask |= (1 << drm_plane_index(plane)); |
979 | crtc_state->plane_mask |= (1 << drm_plane_index(plane)); |
388 | } |
980 | } |
389 | 981 | ||
390 | if (crtc) |
982 | if (crtc) |
391 | DRM_DEBUG_KMS("Link plane state %p to [CRTC:%d]\n", |
983 | DRM_DEBUG_ATOMIC("Link plane state %p to [CRTC:%d]\n", |
392 | plane_state, crtc->base.id); |
984 | plane_state, crtc->base.id); |
393 | else |
985 | else |
394 | DRM_DEBUG_KMS("Link plane state %p to [NOCRTC]\n", plane_state); |
986 | DRM_DEBUG_ATOMIC("Link plane state %p to [NOCRTC]\n", |
- | 987 | plane_state); |
|
395 | 988 | ||
396 | return 0; |
989 | return 0; |
397 | } |
990 | } |
398 | EXPORT_SYMBOL(drm_atomic_set_crtc_for_plane); |
991 | EXPORT_SYMBOL(drm_atomic_set_crtc_for_plane); |
399 | 992 | ||
400 | /** |
993 | /** |
401 | * drm_atomic_set_fb_for_plane - set crtc for plane |
994 | * drm_atomic_set_fb_for_plane - set framebuffer for plane |
402 | * @plane_state: atomic state object for the plane |
995 | * @plane_state: atomic state object for the plane |
403 | * @fb: fb to use for the plane |
996 | * @fb: fb to use for the plane |
404 | * |
997 | * |
405 | * Changing the assigned framebuffer for a plane requires us to grab a reference |
998 | * Changing the assigned framebuffer for a plane requires us to grab a reference |
406 | * to the new fb and drop the reference to the old fb, if there is one. This |
999 | * to the new fb and drop the reference to the old fb, if there is one. This |
407 | * function takes care of all these details besides updating the pointer in the |
1000 | * function takes care of all these details besides updating the pointer in the |
408 | * state object itself. |
1001 | * state object itself. |
409 | */ |
1002 | */ |
410 | void |
1003 | void |
411 | drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, |
1004 | drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, |
412 | struct drm_framebuffer *fb) |
1005 | struct drm_framebuffer *fb) |
413 | { |
1006 | { |
414 | if (plane_state->fb) |
1007 | if (plane_state->fb) |
415 | drm_framebuffer_unreference(plane_state->fb); |
1008 | drm_framebuffer_unreference(plane_state->fb); |
416 | if (fb) |
1009 | if (fb) |
417 | drm_framebuffer_reference(fb); |
1010 | drm_framebuffer_reference(fb); |
418 | plane_state->fb = fb; |
1011 | plane_state->fb = fb; |
419 | 1012 | ||
420 | if (fb) |
1013 | if (fb) |
421 | DRM_DEBUG_KMS("Set [FB:%d] for plane state %p\n", |
1014 | DRM_DEBUG_ATOMIC("Set [FB:%d] for plane state %p\n", |
422 | fb->base.id, plane_state); |
1015 | fb->base.id, plane_state); |
423 | else |
1016 | else |
424 | DRM_DEBUG_KMS("Set [NOFB] for plane state %p\n", plane_state); |
1017 | DRM_DEBUG_ATOMIC("Set [NOFB] for plane state %p\n", |
- | 1018 | plane_state); |
|
425 | } |
1019 | } |
426 | EXPORT_SYMBOL(drm_atomic_set_fb_for_plane); |
1020 | EXPORT_SYMBOL(drm_atomic_set_fb_for_plane); |
427 | 1021 | ||
428 | /** |
1022 | /** |
429 | * drm_atomic_set_crtc_for_connector - set crtc for connector |
1023 | * drm_atomic_set_crtc_for_connector - set crtc for connector |
430 | * @conn_state: atomic state object for the connector |
1024 | * @conn_state: atomic state object for the connector |
431 | * @crtc: crtc to use for the connector |
1025 | * @crtc: crtc to use for the connector |
432 | * |
1026 | * |
433 | * Changing the assigned crtc for a connector requires us to grab the lock and |
1027 | * Changing the assigned crtc for a connector requires us to grab the lock and |
434 | * state for the new crtc, as needed. This function takes care of all these |
1028 | * state for the new crtc, as needed. This function takes care of all these |
435 | * details besides updating the pointer in the state object itself. |
1029 | * details besides updating the pointer in the state object itself. |
436 | * |
1030 | * |
437 | * Returns: |
1031 | * Returns: |
438 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
1032 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
439 | * then the w/w mutex code has detected a deadlock and the entire atomic |
1033 | * then the w/w mutex code has detected a deadlock and the entire atomic |
440 | * sequence must be restarted. All other errors are fatal. |
1034 | * sequence must be restarted. All other errors are fatal. |
441 | */ |
1035 | */ |
442 | int |
1036 | int |
443 | drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, |
1037 | drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, |
444 | struct drm_crtc *crtc) |
1038 | struct drm_crtc *crtc) |
445 | { |
1039 | { |
446 | struct drm_crtc_state *crtc_state; |
1040 | struct drm_crtc_state *crtc_state; |
447 | 1041 | ||
448 | if (crtc) { |
1042 | if (crtc) { |
449 | crtc_state = drm_atomic_get_crtc_state(conn_state->state, crtc); |
1043 | crtc_state = drm_atomic_get_crtc_state(conn_state->state, crtc); |
450 | if (IS_ERR(crtc_state)) |
1044 | if (IS_ERR(crtc_state)) |
451 | return PTR_ERR(crtc_state); |
1045 | return PTR_ERR(crtc_state); |
452 | } |
1046 | } |
453 | 1047 | ||
454 | conn_state->crtc = crtc; |
1048 | conn_state->crtc = crtc; |
455 | 1049 | ||
456 | if (crtc) |
1050 | if (crtc) |
457 | DRM_DEBUG_KMS("Link connector state %p to [CRTC:%d]\n", |
1051 | DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d]\n", |
458 | conn_state, crtc->base.id); |
1052 | conn_state, crtc->base.id); |
459 | else |
1053 | else |
460 | DRM_DEBUG_KMS("Link connector state %p to [NOCRTC]\n", |
1054 | DRM_DEBUG_ATOMIC("Link connector state %p to [NOCRTC]\n", |
461 | conn_state); |
1055 | conn_state); |
462 | 1056 | ||
463 | return 0; |
1057 | return 0; |
464 | } |
1058 | } |
465 | EXPORT_SYMBOL(drm_atomic_set_crtc_for_connector); |
1059 | EXPORT_SYMBOL(drm_atomic_set_crtc_for_connector); |
466 | 1060 | ||
467 | /** |
1061 | /** |
468 | * drm_atomic_add_affected_connectors - add connectors for crtc |
1062 | * drm_atomic_add_affected_connectors - add connectors for crtc |
469 | * @state: atomic state |
1063 | * @state: atomic state |
470 | * @crtc: DRM crtc |
1064 | * @crtc: DRM crtc |
471 | * |
1065 | * |
472 | * This function walks the current configuration and adds all connectors |
1066 | * This function walks the current configuration and adds all connectors |
473 | * currently using @crtc to the atomic configuration @state. Note that this |
1067 | * currently using @crtc to the atomic configuration @state. Note that this |
474 | * function must acquire the connection mutex. This can potentially cause |
1068 | * function must acquire the connection mutex. This can potentially cause |
475 | * unneeded seralization if the update is just for the planes on one crtc. Hence |
1069 | * unneeded seralization if the update is just for the planes on one crtc. Hence |
476 | * drivers and helpers should only call this when really needed (e.g. when a |
1070 | * drivers and helpers should only call this when really needed (e.g. when a |
477 | * full modeset needs to happen due to some change). |
1071 | * full modeset needs to happen due to some change). |
478 | * |
1072 | * |
479 | * Returns: |
1073 | * Returns: |
480 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
1074 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
481 | * then the w/w mutex code has detected a deadlock and the entire atomic |
1075 | * then the w/w mutex code has detected a deadlock and the entire atomic |
482 | * sequence must be restarted. All other errors are fatal. |
1076 | * sequence must be restarted. All other errors are fatal. |
483 | */ |
1077 | */ |
484 | int |
1078 | int |
485 | drm_atomic_add_affected_connectors(struct drm_atomic_state *state, |
1079 | drm_atomic_add_affected_connectors(struct drm_atomic_state *state, |
486 | struct drm_crtc *crtc) |
1080 | struct drm_crtc *crtc) |
487 | { |
1081 | { |
488 | struct drm_mode_config *config = &state->dev->mode_config; |
1082 | struct drm_mode_config *config = &state->dev->mode_config; |
489 | struct drm_connector *connector; |
1083 | struct drm_connector *connector; |
490 | struct drm_connector_state *conn_state; |
1084 | struct drm_connector_state *conn_state; |
491 | int ret; |
1085 | int ret; |
492 | 1086 | ||
493 | ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); |
1087 | ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); |
494 | if (ret) |
1088 | if (ret) |
495 | return ret; |
1089 | return ret; |
496 | 1090 | ||
497 | DRM_DEBUG_KMS("Adding all current connectors for [CRTC:%d] to %p\n", |
1091 | DRM_DEBUG_ATOMIC("Adding all current connectors for [CRTC:%d] to %p\n", |
498 | crtc->base.id, state); |
1092 | crtc->base.id, state); |
499 | 1093 | ||
500 | /* |
1094 | /* |
501 | * Changed connectors are already in @state, so only need to look at the |
1095 | * Changed connectors are already in @state, so only need to look at the |
502 | * current configuration. |
1096 | * current configuration. |
503 | */ |
1097 | */ |
504 | list_for_each_entry(connector, &config->connector_list, head) { |
1098 | drm_for_each_connector(connector, state->dev) { |
505 | if (connector->state->crtc != crtc) |
1099 | if (connector->state->crtc != crtc) |
506 | continue; |
1100 | continue; |
507 | 1101 | ||
508 | conn_state = drm_atomic_get_connector_state(state, connector); |
1102 | conn_state = drm_atomic_get_connector_state(state, connector); |
509 | if (IS_ERR(conn_state)) |
1103 | if (IS_ERR(conn_state)) |
510 | return PTR_ERR(conn_state); |
1104 | return PTR_ERR(conn_state); |
511 | } |
1105 | } |
512 | 1106 | ||
513 | return 0; |
1107 | return 0; |
514 | } |
1108 | } |
515 | EXPORT_SYMBOL(drm_atomic_add_affected_connectors); |
1109 | EXPORT_SYMBOL(drm_atomic_add_affected_connectors); |
516 | 1110 | ||
517 | /** |
1111 | /** |
- | 1112 | * drm_atomic_add_affected_planes - add planes for crtc |
|
- | 1113 | * @state: atomic state |
|
- | 1114 | * @crtc: DRM crtc |
|
- | 1115 | * |
|
- | 1116 | * This function walks the current configuration and adds all planes |
|
- | 1117 | * currently used by @crtc to the atomic configuration @state. This is useful |
|
- | 1118 | * when an atomic commit also needs to check all currently enabled plane on |
|
- | 1119 | * @crtc, e.g. when changing the mode. It's also useful when re-enabling a CRTC |
|
- | 1120 | * to avoid special code to force-enable all planes. |
|
- | 1121 | * |
|
- | 1122 | * Since acquiring a plane state will always also acquire the w/w mutex of the |
|
- | 1123 | * current CRTC for that plane (if there is any) adding all the plane states for |
|
- | 1124 | * a CRTC will not reduce parallism of atomic updates. |
|
- | 1125 | * |
|
- | 1126 | * Returns: |
|
- | 1127 | * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK |
|
- | 1128 | * then the w/w mutex code has detected a deadlock and the entire atomic |
|
- | 1129 | * sequence must be restarted. All other errors are fatal. |
|
- | 1130 | */ |
|
- | 1131 | int |
|
- | 1132 | drm_atomic_add_affected_planes(struct drm_atomic_state *state, |
|
- | 1133 | struct drm_crtc *crtc) |
|
- | 1134 | { |
|
- | 1135 | struct drm_plane *plane; |
|
- | 1136 | ||
- | 1137 | WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc)); |
|
- | 1138 | ||
- | 1139 | drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) { |
|
- | 1140 | struct drm_plane_state *plane_state = |
|
- | 1141 | drm_atomic_get_plane_state(state, plane); |
|
- | 1142 | ||
- | 1143 | if (IS_ERR(plane_state)) |
|
- | 1144 | return PTR_ERR(plane_state); |
|
- | 1145 | } |
|
- | 1146 | return 0; |
|
- | 1147 | } |
|
- | 1148 | EXPORT_SYMBOL(drm_atomic_add_affected_planes); |
|
- | 1149 | ||
- | 1150 | /** |
|
518 | * drm_atomic_connectors_for_crtc - count number of connected outputs |
1151 | * drm_atomic_connectors_for_crtc - count number of connected outputs |
519 | * @state: atomic state |
1152 | * @state: atomic state |
520 | * @crtc: DRM crtc |
1153 | * @crtc: DRM crtc |
521 | * |
1154 | * |
522 | * This function counts all connectors which will be connected to @crtc |
1155 | * This function counts all connectors which will be connected to @crtc |
523 | * according to @state. Useful to recompute the enable state for @crtc. |
1156 | * according to @state. Useful to recompute the enable state for @crtc. |
524 | */ |
1157 | */ |
525 | int |
1158 | int |
526 | drm_atomic_connectors_for_crtc(struct drm_atomic_state *state, |
1159 | drm_atomic_connectors_for_crtc(struct drm_atomic_state *state, |
527 | struct drm_crtc *crtc) |
1160 | struct drm_crtc *crtc) |
528 | { |
1161 | { |
529 | int i, num_connected_connectors = 0; |
1162 | struct drm_connector *connector; |
530 | - | ||
531 | for (i = 0; i < state->num_connector; i++) { |
- | |
532 | struct drm_connector_state *conn_state; |
1163 | struct drm_connector_state *conn_state; |
533 | 1164 | ||
- | 1165 | int i, num_connected_connectors = 0; |
|
534 | conn_state = state->connector_states[i]; |
1166 | |
535 | 1167 | for_each_connector_in_state(state, connector, conn_state, i) { |
|
536 | if (conn_state && conn_state->crtc == crtc) |
1168 | if (conn_state->crtc == crtc) |
537 | num_connected_connectors++; |
1169 | num_connected_connectors++; |
538 | } |
1170 | } |
539 | 1171 | ||
540 | DRM_DEBUG_KMS("State %p has %i connectors for [CRTC:%d]\n", |
1172 | DRM_DEBUG_ATOMIC("State %p has %i connectors for [CRTC:%d]\n", |
541 | state, num_connected_connectors, crtc->base.id); |
1173 | state, num_connected_connectors, crtc->base.id); |
542 | 1174 | ||
543 | return num_connected_connectors; |
1175 | return num_connected_connectors; |
544 | } |
1176 | } |
545 | EXPORT_SYMBOL(drm_atomic_connectors_for_crtc); |
1177 | EXPORT_SYMBOL(drm_atomic_connectors_for_crtc); |
546 | 1178 | ||
547 | /** |
1179 | /** |
548 | * drm_atomic_legacy_backoff - locking backoff for legacy ioctls |
1180 | * drm_atomic_legacy_backoff - locking backoff for legacy ioctls |
549 | * @state: atomic state |
1181 | * @state: atomic state |
550 | * |
1182 | * |
551 | * This function should be used by legacy entry points which don't understand |
1183 | * This function should be used by legacy entry points which don't understand |
552 | * -EDEADLK semantics. For simplicity this one will grab all modeset locks after |
1184 | * -EDEADLK semantics. For simplicity this one will grab all modeset locks after |
553 | * the slowpath completed. |
1185 | * the slowpath completed. |
554 | */ |
1186 | */ |
555 | void drm_atomic_legacy_backoff(struct drm_atomic_state *state) |
1187 | void drm_atomic_legacy_backoff(struct drm_atomic_state *state) |
556 | { |
1188 | { |
557 | int ret; |
1189 | int ret; |
558 | 1190 | ||
559 | retry: |
1191 | retry: |
560 | drm_modeset_backoff(state->acquire_ctx); |
1192 | drm_modeset_backoff(state->acquire_ctx); |
561 | 1193 | ||
562 | ret = drm_modeset_lock(&state->dev->mode_config.connection_mutex, |
1194 | ret = drm_modeset_lock(&state->dev->mode_config.connection_mutex, |
563 | state->acquire_ctx); |
1195 | state->acquire_ctx); |
564 | if (ret) |
1196 | if (ret) |
565 | goto retry; |
1197 | goto retry; |
566 | ret = drm_modeset_lock_all_crtcs(state->dev, |
1198 | ret = drm_modeset_lock_all_crtcs(state->dev, |
567 | state->acquire_ctx); |
1199 | state->acquire_ctx); |
568 | if (ret) |
1200 | if (ret) |
569 | goto retry; |
1201 | goto retry; |
570 | } |
1202 | } |
571 | EXPORT_SYMBOL(drm_atomic_legacy_backoff); |
1203 | EXPORT_SYMBOL(drm_atomic_legacy_backoff); |
572 | 1204 | ||
573 | /** |
1205 | /** |
574 | * drm_atomic_check_only - check whether a given config would work |
1206 | * drm_atomic_check_only - check whether a given config would work |
575 | * @state: atomic configuration to check |
1207 | * @state: atomic configuration to check |
576 | * |
1208 | * |
577 | * Note that this function can return -EDEADLK if the driver needed to acquire |
1209 | * Note that this function can return -EDEADLK if the driver needed to acquire |
578 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
1210 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
579 | * backoff dance and restart. All other errors are fatal. |
1211 | * backoff dance and restart. All other errors are fatal. |
580 | * |
1212 | * |
581 | * Returns: |
1213 | * Returns: |
582 | * 0 on success, negative error code on failure. |
1214 | * 0 on success, negative error code on failure. |
583 | */ |
1215 | */ |
584 | int drm_atomic_check_only(struct drm_atomic_state *state) |
1216 | int drm_atomic_check_only(struct drm_atomic_state *state) |
585 | { |
1217 | { |
- | 1218 | struct drm_device *dev = state->dev; |
|
586 | struct drm_mode_config *config = &state->dev->mode_config; |
1219 | struct drm_mode_config *config = &dev->mode_config; |
- | 1220 | struct drm_plane *plane; |
|
- | 1221 | struct drm_plane_state *plane_state; |
|
- | 1222 | struct drm_crtc *crtc; |
|
- | 1223 | struct drm_crtc_state *crtc_state; |
|
- | 1224 | int i, ret = 0; |
|
- | 1225 | ||
- | 1226 | DRM_DEBUG_ATOMIC("checking %p\n", state); |
|
- | 1227 | ||
- | 1228 | for_each_plane_in_state(state, plane, plane_state, i) { |
|
- | 1229 | ret = drm_atomic_plane_check(plane, plane_state); |
|
- | 1230 | if (ret) { |
|
- | 1231 | DRM_DEBUG_ATOMIC("[PLANE:%d] atomic core check failed\n", |
|
- | 1232 | plane->base.id); |
|
- | 1233 | return ret; |
|
- | 1234 | } |
|
- | 1235 | } |
|
- | 1236 | ||
587 | 1237 | for_each_crtc_in_state(state, crtc, crtc_state, i) { |
|
- | 1238 | ret = drm_atomic_crtc_check(crtc, crtc_state); |
|
- | 1239 | if (ret) { |
|
- | 1240 | DRM_DEBUG_ATOMIC("[CRTC:%d] atomic core check failed\n", |
|
- | 1241 | crtc->base.id); |
|
- | 1242 | return ret; |
|
- | 1243 | } |
|
588 | DRM_DEBUG_KMS("checking %p\n", state); |
1244 | } |
589 | 1245 | ||
- | 1246 | if (config->funcs->atomic_check) |
|
- | 1247 | ret = config->funcs->atomic_check(state->dev, state); |
|
- | 1248 | ||
- | 1249 | if (!state->allow_modeset) { |
|
- | 1250 | for_each_crtc_in_state(state, crtc, crtc_state, i) { |
|
- | 1251 | if (drm_atomic_crtc_needs_modeset(crtc_state)) { |
|
- | 1252 | DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n", |
|
590 | if (config->funcs->atomic_check) |
1253 | crtc->base.id); |
- | 1254 | return -EINVAL; |
|
- | 1255 | } |
|
- | 1256 | } |
|
591 | return config->funcs->atomic_check(state->dev, state); |
1257 | } |
592 | else |
1258 | |
593 | return 0; |
1259 | return ret; |
594 | } |
1260 | } |
595 | EXPORT_SYMBOL(drm_atomic_check_only); |
1261 | EXPORT_SYMBOL(drm_atomic_check_only); |
596 | 1262 | ||
597 | /** |
1263 | /** |
598 | * drm_atomic_commit - commit configuration atomically |
1264 | * drm_atomic_commit - commit configuration atomically |
599 | * @state: atomic configuration to check |
1265 | * @state: atomic configuration to check |
600 | * |
1266 | * |
601 | * Note that this function can return -EDEADLK if the driver needed to acquire |
1267 | * Note that this function can return -EDEADLK if the driver needed to acquire |
602 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
1268 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
603 | * backoff dance and restart. All other errors are fatal. |
1269 | * backoff dance and restart. All other errors are fatal. |
604 | * |
1270 | * |
605 | * Also note that on successful execution ownership of @state is transferred |
1271 | * Also note that on successful execution ownership of @state is transferred |
606 | * from the caller of this function to the function itself. The caller must not |
1272 | * from the caller of this function to the function itself. The caller must not |
607 | * free or in any other way access @state. If the function fails then the caller |
1273 | * free or in any other way access @state. If the function fails then the caller |
608 | * must clean up @state itself. |
1274 | * must clean up @state itself. |
609 | * |
1275 | * |
610 | * Returns: |
1276 | * Returns: |
611 | * 0 on success, negative error code on failure. |
1277 | * 0 on success, negative error code on failure. |
612 | */ |
1278 | */ |
613 | int drm_atomic_commit(struct drm_atomic_state *state) |
1279 | int drm_atomic_commit(struct drm_atomic_state *state) |
614 | { |
1280 | { |
615 | struct drm_mode_config *config = &state->dev->mode_config; |
1281 | struct drm_mode_config *config = &state->dev->mode_config; |
616 | int ret; |
1282 | int ret; |
617 | 1283 | ||
618 | ret = drm_atomic_check_only(state); |
1284 | ret = drm_atomic_check_only(state); |
619 | if (ret) |
1285 | if (ret) |
620 | return ret; |
1286 | return ret; |
621 | 1287 | ||
622 | DRM_DEBUG_KMS("commiting %p\n", state); |
1288 | DRM_DEBUG_ATOMIC("commiting %p\n", state); |
623 | 1289 | ||
624 | return config->funcs->atomic_commit(state->dev, state, false); |
1290 | return config->funcs->atomic_commit(state->dev, state, false); |
625 | } |
1291 | } |
626 | EXPORT_SYMBOL(drm_atomic_commit); |
1292 | EXPORT_SYMBOL(drm_atomic_commit); |
627 | 1293 | ||
628 | /** |
1294 | /** |
629 | * drm_atomic_async_commit - atomic&async configuration commit |
1295 | * drm_atomic_async_commit - atomic&async configuration commit |
630 | * @state: atomic configuration to check |
1296 | * @state: atomic configuration to check |
631 | * |
1297 | * |
632 | * Note that this function can return -EDEADLK if the driver needed to acquire |
1298 | * Note that this function can return -EDEADLK if the driver needed to acquire |
633 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
1299 | * more locks but encountered a deadlock. The caller must then do the usual w/w |
634 | * backoff dance and restart. All other errors are fatal. |
1300 | * backoff dance and restart. All other errors are fatal. |
635 | * |
1301 | * |
636 | * Also note that on successful execution ownership of @state is transferred |
1302 | * Also note that on successful execution ownership of @state is transferred |
637 | * from the caller of this function to the function itself. The caller must not |
1303 | * from the caller of this function to the function itself. The caller must not |
638 | * free or in any other way access @state. If the function fails then the caller |
1304 | * free or in any other way access @state. If the function fails then the caller |
639 | * must clean up @state itself. |
1305 | * must clean up @state itself. |
640 | * |
1306 | * |
641 | * Returns: |
1307 | * Returns: |
642 | * 0 on success, negative error code on failure. |
1308 | * 0 on success, negative error code on failure. |
643 | */ |
1309 | */ |
644 | int drm_atomic_async_commit(struct drm_atomic_state *state) |
1310 | int drm_atomic_async_commit(struct drm_atomic_state *state) |
645 | { |
1311 | { |
646 | struct drm_mode_config *config = &state->dev->mode_config; |
1312 | struct drm_mode_config *config = &state->dev->mode_config; |
647 | int ret; |
1313 | int ret; |
648 | 1314 | ||
649 | ret = drm_atomic_check_only(state); |
1315 | ret = drm_atomic_check_only(state); |
650 | if (ret) |
1316 | if (ret) |
651 | return ret; |
1317 | return ret; |
652 | 1318 | ||
653 | DRM_DEBUG_KMS("commiting %p asynchronously\n", state); |
1319 | DRM_DEBUG_ATOMIC("commiting %p asynchronously\n", state); |
654 | 1320 | ||
655 | return config->funcs->atomic_commit(state->dev, state, true); |
1321 | return config->funcs->atomic_commit(state->dev, state, true); |
656 | } |
1322 | } |
657 | EXPORT_SYMBOL(drm_atomic_async_commit); |
1323 | EXPORT_SYMBOL(drm_atomic_async_commit); |
658 | 1324 | ||
659 | /** |
- | |
660 | * drm_atomic_helper_plane_duplicate_state - default state duplicate hook |
1325 | /* |
661 | * @plane: drm plane |
- | |
662 | * |
- | |
663 | * Default plane state duplicate hook for drivers which don't have their own |
- | |
664 | * subclassed plane state structure. |
1326 | * The big monstor ioctl |
- | 1327 | */ |
|
665 | */ |
1328 | |
666 | struct drm_plane_state * |
1329 | static struct drm_pending_vblank_event *create_vblank_event( |
667 | drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane) |
1330 | struct drm_device *dev, struct drm_file *file_priv, uint64_t user_data) |
668 | { |
1331 | { |
- | 1332 | struct drm_pending_vblank_event *e = NULL; |
|
- | 1333 | unsigned long flags; |
|
- | 1334 | ||
- | 1335 | spin_lock_irqsave(&dev->event_lock, flags); |
|
- | 1336 | if (file_priv->event_space < sizeof e->event) { |
|
- | 1337 | spin_unlock_irqrestore(&dev->event_lock, flags); |
|
- | 1338 | goto out; |
|
- | 1339 | } |
|
- | 1340 | file_priv->event_space -= sizeof e->event; |
|
669 | struct drm_plane_state *state; |
1341 | spin_unlock_irqrestore(&dev->event_lock, flags); |
670 | 1342 | ||
- | 1343 | e = kzalloc(sizeof *e, GFP_KERNEL); |
|
- | 1344 | if (e == NULL) { |
|
- | 1345 | spin_lock_irqsave(&dev->event_lock, flags); |
|
- | 1346 | file_priv->event_space += sizeof e->event; |
|
- | 1347 | spin_unlock_irqrestore(&dev->event_lock, flags); |
|
- | 1348 | goto out; |
|
- | 1349 | } |
|
- | 1350 | ||
- | 1351 | e->event.base.type = DRM_EVENT_FLIP_COMPLETE; |
|
- | 1352 | e->event.base.length = sizeof e->event; |
|
- | 1353 | e->event.user_data = user_data; |
|
- | 1354 | e->base.event = &e->event.base; |
|
- | 1355 | e->base.file_priv = file_priv; |
|
671 | if (WARN_ON(!plane->state)) |
1356 | e->base.destroy = (void (*) (struct drm_pending_event *)) kfree; |
- | 1357 | ||
672 | return NULL; |
1358 | out: |
673 | 1359 | return e; |
|
- | 1360 | } |
|
- | 1361 | ||
- | 1362 | static void destroy_vblank_event(struct drm_device *dev, |
|
- | 1363 | struct drm_file *file_priv, struct drm_pending_vblank_event *e) |
|
- | 1364 | { |
|
674 | state = kmemdup(plane->state, sizeof(*plane->state), GFP_KERNEL); |
1365 | unsigned long flags; |
675 | 1366 | ||
676 | if (state && state->fb) |
- | |
677 | drm_framebuffer_reference(state->fb); |
- | |
678 | - | ||
679 | return state; |
1367 | spin_lock_irqsave(&dev->event_lock, flags); |
680 | } |
- | |
681 | EXPORT_SYMBOL(drm_atomic_helper_plane_duplicate_state); |
- | |
682 | - | ||
683 | - | ||
684 | /** |
- | |
685 | * drm_atomic_helper_crtc_destroy_state - default state destroy hook |
- | |
686 | * @crtc: drm CRTC |
1368 | file_priv->event_space += sizeof e->event; |
687 | * @state: CRTC state object to release |
1369 | spin_unlock_irqrestore(&dev->event_lock, flags); |
688 | * |
1370 | kfree(e); |
- | 1371 | } |
|
- | 1372 | ||
- | 1373 | static int atomic_set_prop(struct drm_atomic_state *state, |
|
- | 1374 | struct drm_mode_object *obj, struct drm_property *prop, |
|
- | 1375 | uint64_t prop_value) |
|
- | 1376 | { |
|
- | 1377 | struct drm_mode_object *ref; |
|
- | 1378 | int ret; |
|
- | 1379 | ||
- | 1380 | if (!drm_property_change_valid_get(prop, prop_value, &ref)) |
|
- | 1381 | return -EINVAL; |
|
- | 1382 | ||
- | 1383 | switch (obj->type) { |
|
- | 1384 | case DRM_MODE_OBJECT_CONNECTOR: { |
|
- | 1385 | struct drm_connector *connector = obj_to_connector(obj); |
|
- | 1386 | struct drm_connector_state *connector_state; |
|
- | 1387 | ||
- | 1388 | connector_state = drm_atomic_get_connector_state(state, connector); |
|
- | 1389 | if (IS_ERR(connector_state)) { |
|
- | 1390 | ret = PTR_ERR(connector_state); |
|
- | 1391 | break; |
|
- | 1392 | } |
|
- | 1393 | ||
- | 1394 | ret = drm_atomic_connector_set_property(connector, |
|
- | 1395 | connector_state, prop, prop_value); |
|
- | 1396 | break; |
|
- | 1397 | } |
|
689 | * Default CRTC state destroy hook for drivers which don't have their own |
1398 | case DRM_MODE_OBJECT_CRTC: { |
- | 1399 | struct drm_crtc *crtc = obj_to_crtc(obj); |
|
- | 1400 | struct drm_crtc_state *crtc_state; |
|
- | 1401 | ||
- | 1402 | crtc_state = drm_atomic_get_crtc_state(state, crtc); |
|
- | 1403 | if (IS_ERR(crtc_state)) { |
|
- | 1404 | ret = PTR_ERR(crtc_state); |
|
- | 1405 | break; |
|
- | 1406 | } |
|
- | 1407 | ||
- | 1408 | ret = drm_atomic_crtc_set_property(crtc, |
|
- | 1409 | crtc_state, prop, prop_value); |
|
- | 1410 | break; |
|
- | 1411 | } |
|
- | 1412 | case DRM_MODE_OBJECT_PLANE: { |
|
- | 1413 | struct drm_plane *plane = obj_to_plane(obj); |
|
- | 1414 | struct drm_plane_state *plane_state; |
|
- | 1415 | ||
- | 1416 | plane_state = drm_atomic_get_plane_state(state, plane); |
|
- | 1417 | if (IS_ERR(plane_state)) { |
|
- | 1418 | ret = PTR_ERR(plane_state); |
|
- | 1419 | break; |
|
- | 1420 | } |
|
- | 1421 | ||
- | 1422 | ret = drm_atomic_plane_set_property(plane, |
|
- | 1423 | plane_state, prop, prop_value); |
|
- | 1424 | break; |
|
- | 1425 | } |
|
- | 1426 | default: |
|
690 | * subclassed CRTC state structure. |
1427 | ret = -EINVAL; |
691 | */ |
- | |
692 | void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, |
1428 | break; |
693 | struct drm_crtc_state *state) |
1429 | } |
694 | { |
- | |
695 | kfree(state); |
- | |
696 | } |
1430 | |
- | 1431 | drm_property_change_valid_put(prop, ref); |
|
697 | EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state); |
1432 | return ret; |
698 | 1433 | } |
|
- | 1434 | ||
- | 1435 | /** |
|
- | 1436 | * drm_atomic_update_old_fb -- Unset old_fb pointers and set plane->fb pointers. |
|
- | 1437 | * |
|
- | 1438 | * @dev: drm device to check. |
|
699 | /** |
1439 | * @plane_mask: plane mask for planes that were updated. |
700 | * drm_atomic_helper_plane_destroy_state - default state destroy hook |
1440 | * @ret: return value, can be -EDEADLK for a retry. |
701 | * @plane: drm plane |
1441 | * |
- | 1442 | * Before doing an update plane->old_fb is set to plane->fb, |
|
702 | * @state: plane state object to release |
1443 | * but before dropping the locks old_fb needs to be set to NULL |
703 | * |
1444 | * and plane->fb updated. This is a common operation for each |
704 | * Default plane state destroy hook for drivers which don't have their own |
- | |
- | 1445 | * atomic update, so this call is split off as a helper. |
|
- | 1446 | */ |
|
- | 1447 | void drm_atomic_clean_old_fb(struct drm_device *dev, |
|
- | 1448 | unsigned plane_mask, |
|
- | 1449 | int ret) |
|
- | 1450 | { |
|
705 | * subclassed plane state structure. |
1451 | struct drm_plane *plane; |
- | 1452 | ||
- | 1453 | /* if succeeded, fixup legacy plane crtc/fb ptrs before dropping |
|
- | 1454 | * locks (ie. while it is still safe to deref plane->state). We |
|
- | 1455 | * need to do this here because the driver entry points cannot |
|
- | 1456 | * distinguish between legacy and atomic ioctls. |
|
- | 1457 | */ |
|
- | 1458 | drm_for_each_plane_mask(plane, dev, plane_mask) { |
|
- | 1459 | if (ret == 0) { |
|
- | 1460 | struct drm_framebuffer *new_fb = plane->state->fb; |
|
- | 1461 | if (new_fb) |
|
- | 1462 | drm_framebuffer_reference(new_fb); |
|
706 | */ |
1463 | plane->fb = new_fb; |
707 | void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane, |
1464 | plane->crtc = plane->state->crtc; |
708 | struct drm_plane_state *state) |
1465 | |
709 | { |
1466 | if (plane->old_fb) |
710 | if (state->fb) |
1467 | drm_framebuffer_unreference(plane->old_fb); |
711 | drm_framebuffer_unreference(state->fb); |
1468 | } |
712 | 1469 | plane->old_fb = NULL; |
|
713 | kfree(state); |
1470 | } |
714 | } |
1471 | } |
715 | EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);>><>><>>>> |
1472 | EXPORT_SYMBOL(drm_atomic_clean_old_fb);>><>><>><>><>>>>> |