Rev 4560 | Rev 5271 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4560 | Rev 5060 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include |
35 | #include |
36 | #include |
36 | #include |
37 | #include |
37 | #include |
38 | #include |
38 | #include |
39 | #include |
39 | #include |
- | 40 | #include |
|
- | 41 | ||
- | 42 | #include "drm_crtc_internal.h" |
|
- | 43 | ||
- | 44 | static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, |
|
- | 45 | struct drm_mode_fb_cmd2 *r, |
|
- | 46 | struct drm_file *file_priv); |
|
Line 40... | Line 47... | ||
40 | 47 | ||
41 | /** |
48 | /** |
42 | * drm_modeset_lock_all - take all modeset locks |
49 | * drm_modeset_lock_all - take all modeset locks |
43 | * @dev: drm device |
50 | * @dev: drm device |
44 | * |
51 | * |
45 | * This function takes all modeset locks, suitable where a more fine-grained |
52 | * This function takes all modeset locks, suitable where a more fine-grained |
- | 53 | * scheme isn't (yet) implemented. Locks must be dropped with |
|
46 | * scheme isn't (yet) implemented. |
54 | * drm_modeset_unlock_all. |
47 | */ |
55 | */ |
48 | void drm_modeset_lock_all(struct drm_device *dev) |
56 | void drm_modeset_lock_all(struct drm_device *dev) |
- | 57 | { |
|
49 | { |
58 | struct drm_mode_config *config = &dev->mode_config; |
- | 59 | struct drm_modeset_acquire_ctx *ctx; |
|
Line 50... | Line 60... | ||
50 | struct drm_crtc *crtc; |
60 | int ret; |
- | 61 | ||
- | 62 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
|
Line -... | Line 63... | ||
- | 63 | if (WARN_ON(!ctx)) |
|
- | 64 | return; |
|
- | 65 | ||
- | 66 | mutex_lock(&config->mutex); |
|
- | 67 | ||
51 | 68 | drm_modeset_acquire_init(ctx, 0); |
|
- | 69 | ||
- | 70 | retry: |
|
52 | mutex_lock(&dev->mode_config.mutex); |
71 | ret = drm_modeset_lock(&config->connection_mutex, ctx); |
- | 72 | if (ret) |
|
- | 73 | goto fail; |
|
- | 74 | ret = drm_modeset_lock_all_crtcs(dev, ctx); |
|
- | 75 | if (ret) |
|
- | 76 | goto fail; |
|
- | 77 | ||
- | 78 | WARN_ON(config->acquire_ctx); |
|
- | 79 | ||
- | 80 | /* now we hold the locks, so now that it is safe, stash the |
|
- | 81 | * ctx for drm_modeset_unlock_all(): |
|
- | 82 | */ |
|
- | 83 | config->acquire_ctx = ctx; |
|
- | 84 | ||
- | 85 | drm_warn_on_modeset_not_all_locked(dev); |
|
- | 86 | ||
- | 87 | return; |
|
- | 88 | ||
- | 89 | fail: |
|
- | 90 | if (ret == -EDEADLK) { |
|
53 | 91 | drm_modeset_backoff(ctx); |
|
54 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
92 | goto retry; |
Line 55... | Line 93... | ||
55 | mutex_lock_nest_lock(&crtc->mutex, &dev->mode_config.mutex); |
93 | } |
56 | } |
94 | } |
57 | EXPORT_SYMBOL(drm_modeset_lock_all); |
95 | EXPORT_SYMBOL(drm_modeset_lock_all); |
- | 96 | ||
- | 97 | /** |
|
58 | 98 | * drm_modeset_unlock_all - drop all modeset locks |
|
59 | /** |
99 | * @dev: device |
60 | * drm_modeset_unlock_all - drop all modeset locks |
100 | * |
61 | * @dev: device |
101 | * This function drop all modeset locks taken by drm_modeset_lock_all. |
- | 102 | */ |
|
Line -... | Line 103... | ||
- | 103 | void drm_modeset_unlock_all(struct drm_device *dev) |
|
- | 104 | { |
|
- | 105 | struct drm_mode_config *config = &dev->mode_config; |
|
- | 106 | struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx; |
|
62 | */ |
107 | |
63 | void drm_modeset_unlock_all(struct drm_device *dev) |
108 | if (WARN_ON(!ctx)) |
- | 109 | return; |
|
- | 110 | ||
Line 64... | Line 111... | ||
64 | { |
111 | config->acquire_ctx = NULL; |
65 | struct drm_crtc *crtc; |
112 | drm_modeset_drop_locks(ctx); |
66 | 113 | drm_modeset_acquire_fini(ctx); |
|
Line 67... | Line 114... | ||
67 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
114 | |
68 | mutex_unlock(&crtc->mutex); |
115 | kfree(ctx); |
69 | 116 | ||
- | 117 | mutex_unlock(&dev->mode_config.mutex); |
|
- | 118 | } |
|
70 | mutex_unlock(&dev->mode_config.mutex); |
119 | EXPORT_SYMBOL(drm_modeset_unlock_all); |
71 | } |
120 | |
72 | EXPORT_SYMBOL(drm_modeset_unlock_all); |
121 | /** |
73 | 122 | * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked |
|
Line 74... | Line 123... | ||
74 | /** |
123 | * @dev: device |
75 | * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked |
124 | * |
Line -... | Line 125... | ||
- | 125 | * Useful as a debug assert. |
|
76 | * @dev: device |
126 | */ |
77 | */ |
127 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev) |
78 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev) |
128 | { |
Line 79... | Line 129... | ||
79 | { |
129 | struct drm_crtc *crtc; |
Line 108... | Line 158... | ||
108 | { DRM_MODE_DPMS_OFF, "Off" } |
158 | { DRM_MODE_DPMS_OFF, "Off" } |
109 | }; |
159 | }; |
Line 110... | Line 160... | ||
110 | 160 | ||
Line -... | Line 161... | ||
- | 161 | DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) |
|
- | 162 | ||
- | 163 | static const struct drm_prop_enum_list drm_plane_type_enum_list[] = |
|
- | 164 | { |
|
- | 165 | { DRM_PLANE_TYPE_OVERLAY, "Overlay" }, |
|
- | 166 | { DRM_PLANE_TYPE_PRIMARY, "Primary" }, |
|
- | 167 | { DRM_PLANE_TYPE_CURSOR, "Cursor" }, |
|
111 | DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) |
168 | }; |
112 | 169 | ||
113 | /* |
170 | /* |
114 | * Optional properties |
171 | * Optional properties |
115 | */ |
172 | */ |
Line 119... | Line 176... | ||
119 | { DRM_MODE_SCALE_FULLSCREEN, "Full" }, |
176 | { DRM_MODE_SCALE_FULLSCREEN, "Full" }, |
120 | { DRM_MODE_SCALE_CENTER, "Center" }, |
177 | { DRM_MODE_SCALE_CENTER, "Center" }, |
121 | { DRM_MODE_SCALE_ASPECT, "Full aspect" }, |
178 | { DRM_MODE_SCALE_ASPECT, "Full aspect" }, |
122 | }; |
179 | }; |
Line -... | Line 180... | ||
- | 180 | ||
- | 181 | static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { |
|
- | 182 | { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, |
|
- | 183 | { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, |
|
- | 184 | { DRM_MODE_PICTURE_ASPECT_16_9, "16:9" }, |
|
- | 185 | }; |
|
123 | 186 | ||
124 | /* |
187 | /* |
125 | * Non-global properties, but "required" for certain connectors. |
188 | * Non-global properties, but "required" for certain connectors. |
126 | */ |
189 | */ |
127 | static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = |
190 | static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = |
Line 207... | Line 270... | ||
207 | { DRM_MODE_ENCODER_TMDS, "TMDS" }, |
270 | { DRM_MODE_ENCODER_TMDS, "TMDS" }, |
208 | { DRM_MODE_ENCODER_LVDS, "LVDS" }, |
271 | { DRM_MODE_ENCODER_LVDS, "LVDS" }, |
209 | { DRM_MODE_ENCODER_TVDAC, "TV" }, |
272 | { DRM_MODE_ENCODER_TVDAC, "TV" }, |
210 | { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, |
273 | { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, |
211 | { DRM_MODE_ENCODER_DSI, "DSI" }, |
274 | { DRM_MODE_ENCODER_DSI, "DSI" }, |
- | 275 | { DRM_MODE_ENCODER_DPMST, "DP MST" }, |
|
- | 276 | }; |
|
- | 277 | ||
- | 278 | static const struct drm_prop_enum_list drm_subpixel_enum_list[] = |
|
- | 279 | { |
|
- | 280 | { SubPixelUnknown, "Unknown" }, |
|
- | 281 | { SubPixelHorizontalRGB, "Horizontal RGB" }, |
|
- | 282 | { SubPixelHorizontalBGR, "Horizontal BGR" }, |
|
- | 283 | { SubPixelVerticalRGB, "Vertical RGB" }, |
|
- | 284 | { SubPixelVerticalBGR, "Vertical BGR" }, |
|
- | 285 | { SubPixelNone, "None" }, |
|
212 | }; |
286 | }; |
Line 213... | Line 287... | ||
213 | 287 | ||
214 | void drm_connector_ida_init(void) |
288 | void drm_connector_ida_init(void) |
215 | { |
289 | { |
Line 225... | Line 299... | ||
225 | 299 | ||
226 | for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) |
300 | for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) |
227 | ida_destroy(&drm_connector_enum_list[i].ida); |
301 | ida_destroy(&drm_connector_enum_list[i].ida); |
Line 228... | Line -... | ||
228 | } |
- | |
229 | 302 | } |
|
230 | const char *drm_get_encoder_name(const struct drm_encoder *encoder) |
- | |
231 | { |
- | |
232 | static char buf[32]; |
- | |
233 | 303 | ||
234 | snprintf(buf, 32, "%s-%d", |
- | |
235 | drm_encoder_enum_list[encoder->encoder_type].name, |
- | |
236 | encoder->base.id); |
- | |
237 | return buf; |
- | |
238 | } |
- | |
239 | EXPORT_SYMBOL(drm_get_encoder_name); |
304 | /** |
240 | 305 | * drm_get_connector_status_name - return a string for connector status |
|
241 | const char *drm_get_connector_name(const struct drm_connector *connector) |
- | |
242 | { |
- | |
243 | static char buf[32]; |
- | |
244 | 306 | * @status: connector status to compute name of |
|
245 | snprintf(buf, 32, "%s-%d", |
307 | * |
246 | drm_connector_enum_list[connector->connector_type].name, |
- | |
247 | connector->connector_type_id); |
308 | * In contrast to the other drm_get_*_name functions this one here returns a |
248 | return buf; |
- | |
249 | } |
- | |
250 | EXPORT_SYMBOL(drm_get_connector_name); |
309 | * const pointer and hence is threadsafe. |
251 | 310 | */ |
|
252 | const char *drm_get_connector_status_name(enum drm_connector_status status) |
311 | const char *drm_get_connector_status_name(enum drm_connector_status status) |
253 | { |
312 | { |
254 | if (status == connector_status_connected) |
313 | if (status == connector_status_connected) |
Line 258... | Line 317... | ||
258 | else |
317 | else |
259 | return "unknown"; |
318 | return "unknown"; |
260 | } |
319 | } |
261 | EXPORT_SYMBOL(drm_get_connector_status_name); |
320 | EXPORT_SYMBOL(drm_get_connector_status_name); |
Line -... | Line 321... | ||
- | 321 | ||
- | 322 | /** |
|
- | 323 | * drm_get_subpixel_order_name - return a string for a given subpixel enum |
|
- | 324 | * @order: enum of subpixel_order |
|
- | 325 | * |
|
- | 326 | * Note you could abuse this and return something out of bounds, but that |
|
- | 327 | * would be a caller error. No unscrubbed user data should make it here. |
|
- | 328 | */ |
|
- | 329 | const char *drm_get_subpixel_order_name(enum subpixel_order order) |
|
- | 330 | { |
|
- | 331 | return drm_subpixel_enum_list[order].name; |
|
- | 332 | } |
|
- | 333 | EXPORT_SYMBOL(drm_get_subpixel_order_name); |
|
262 | 334 | ||
263 | static char printable_char(int c) |
335 | static char printable_char(int c) |
264 | { |
336 | { |
265 | return isascii(c) && isprint(c) ? c : '?'; |
337 | return isascii(c) && isprint(c) ? c : '?'; |
Line -... | Line 338... | ||
- | 338 | } |
|
- | 339 | ||
- | 340 | /** |
|
- | 341 | * drm_get_format_name - return a string for drm fourcc format |
|
- | 342 | * @format: format to compute name of |
|
- | 343 | * |
|
- | 344 | * Note that the buffer used by this function is globally shared and owned by |
|
- | 345 | * the function itself. |
|
- | 346 | * |
|
266 | } |
347 | * FIXME: This isn't really multithreading safe. |
267 | 348 | */ |
|
268 | const char *drm_get_format_name(uint32_t format) |
349 | const char *drm_get_format_name(uint32_t format) |
Line 269... | Line 350... | ||
269 | { |
350 | { |
Line 280... | Line 361... | ||
280 | 361 | ||
281 | return buf; |
362 | return buf; |
282 | } |
363 | } |
Line 283... | Line 364... | ||
283 | EXPORT_SYMBOL(drm_get_format_name); |
364 | EXPORT_SYMBOL(drm_get_format_name); |
284 | 365 | ||
285 | /** |
- | |
286 | * drm_mode_object_get - allocate a new modeset identifier |
- | |
287 | * @dev: DRM device |
366 | /* |
288 | * @obj: object pointer, used to generate unique ID |
- | |
289 | * @obj_type: object type |
- | |
290 | * |
- | |
291 | * Create a unique identifier based on @ptr in @dev's identifier space. Used |
- | |
292 | * for tracking modes, CRTCs and connectors. |
- | |
293 | * |
- | |
294 | * RETURNS: |
- | |
295 | * New unique (relative to other objects in @dev) integer identifier for the |
367 | * Internal function to assign a slot in the object idr and optionally |
296 | * object. |
368 | * register the object into the idr. |
297 | */ |
369 | */ |
- | 370 | static int drm_mode_object_get_reg(struct drm_device *dev, |
|
- | 371 | struct drm_mode_object *obj, |
|
298 | static int drm_mode_object_get(struct drm_device *dev, |
372 | uint32_t obj_type, |
299 | struct drm_mode_object *obj, uint32_t obj_type) |
373 | bool register_obj) |
Line 300... | Line 374... | ||
300 | { |
374 | { |
301 | int ret; |
375 | int ret; |
302 | 376 | ||
303 | mutex_lock(&dev->mode_config.idr_mutex); |
377 | mutex_lock(&dev->mode_config.idr_mutex); |
304 | ret = idr_alloc(&dev->mode_config.crtc_idr, obj, 1, 0, GFP_KERNEL); |
378 | ret = idr_alloc(&dev->mode_config.crtc_idr, register_obj ? obj : NULL, 1, 0, GFP_KERNEL); |
305 | if (ret >= 0) { |
379 | if (ret >= 0) { |
306 | /* |
380 | /* |
Line 314... | Line 388... | ||
314 | 388 | ||
315 | return ret < 0 ? ret : 0; |
389 | return ret < 0 ? ret : 0; |
Line 316... | Line 390... | ||
316 | } |
390 | } |
- | 391 | ||
- | 392 | /** |
|
- | 393 | * drm_mode_object_get - allocate a new modeset identifier |
|
- | 394 | * @dev: DRM device |
|
- | 395 | * @obj: object pointer, used to generate unique ID |
|
- | 396 | * @obj_type: object type |
|
- | 397 | * |
|
- | 398 | * Create a unique identifier based on @ptr in @dev's identifier space. Used |
|
- | 399 | * for tracking modes, CRTCs and connectors. Note that despite the _get postfix |
|
- | 400 | * modeset identifiers are _not_ reference counted. Hence don't use this for |
|
- | 401 | * reference counted modeset objects like framebuffers. |
|
- | 402 | * |
|
- | 403 | * Returns: |
|
- | 404 | * New unique (relative to other objects in @dev) integer identifier for the |
|
- | 405 | * object. |
|
- | 406 | */ |
|
- | 407 | int drm_mode_object_get(struct drm_device *dev, |
|
- | 408 | struct drm_mode_object *obj, uint32_t obj_type) |
|
- | 409 | { |
|
- | 410 | return drm_mode_object_get_reg(dev, obj, obj_type, true); |
|
- | 411 | } |
|
- | 412 | ||
- | 413 | static void drm_mode_object_register(struct drm_device *dev, |
|
- | 414 | struct drm_mode_object *obj) |
|
- | 415 | { |
|
- | 416 | mutex_lock(&dev->mode_config.idr_mutex); |
|
- | 417 | idr_replace(&dev->mode_config.crtc_idr, obj, obj->id); |
|
- | 418 | mutex_unlock(&dev->mode_config.idr_mutex); |
|
- | 419 | } |
|
317 | 420 | ||
318 | /** |
421 | /** |
319 | * drm_mode_object_put - free a modeset identifer |
422 | * drm_mode_object_put - free a modeset identifer |
320 | * @dev: DRM device |
423 | * @dev: DRM device |
321 | * @object: object to free |
424 | * @object: object to free |
- | 425 | * |
|
- | 426 | * Free @id from @dev's unique identifier pool. Note that despite the _get |
|
322 | * |
427 | * postfix modeset identifiers are _not_ reference counted. Hence don't use this |
323 | * Free @id from @dev's unique identifier pool. |
428 | * for reference counted modeset objects like framebuffers. |
324 | */ |
429 | */ |
325 | static void drm_mode_object_put(struct drm_device *dev, |
430 | void drm_mode_object_put(struct drm_device *dev, |
326 | struct drm_mode_object *object) |
431 | struct drm_mode_object *object) |
327 | { |
432 | { |
328 | mutex_lock(&dev->mode_config.idr_mutex); |
433 | mutex_lock(&dev->mode_config.idr_mutex); |
329 | idr_remove(&dev->mode_config.crtc_idr, object->id); |
434 | idr_remove(&dev->mode_config.crtc_idr, object->id); |
Line -... | Line 435... | ||
- | 435 | mutex_unlock(&dev->mode_config.idr_mutex); |
|
- | 436 | } |
|
- | 437 | ||
- | 438 | static struct drm_mode_object *_object_find(struct drm_device *dev, |
|
- | 439 | uint32_t id, uint32_t type) |
|
- | 440 | { |
|
- | 441 | struct drm_mode_object *obj = NULL; |
|
- | 442 | ||
- | 443 | mutex_lock(&dev->mode_config.idr_mutex); |
|
- | 444 | obj = idr_find(&dev->mode_config.crtc_idr, id); |
|
- | 445 | if (obj && type != DRM_MODE_OBJECT_ANY && obj->type != type) |
|
- | 446 | obj = NULL; |
|
- | 447 | if (obj && obj->id != id) |
|
- | 448 | obj = NULL; |
|
- | 449 | /* don't leak out unref'd fb's */ |
|
- | 450 | if (obj && (obj->type == DRM_MODE_OBJECT_FB)) |
|
- | 451 | obj = NULL; |
|
- | 452 | mutex_unlock(&dev->mode_config.idr_mutex); |
|
- | 453 | ||
330 | mutex_unlock(&dev->mode_config.idr_mutex); |
454 | return obj; |
331 | } |
455 | } |
332 | 456 | ||
333 | /** |
457 | /** |
334 | * drm_mode_object_find - look up a drm object with static lifetime |
458 | * drm_mode_object_find - look up a drm object with static lifetime |
335 | * @dev: drm device |
459 | * @dev: drm device |
336 | * @id: id of the mode object |
460 | * @id: id of the mode object |
337 | * @type: type of the mode object |
461 | * @type: type of the mode object |
- | 462 | * |
|
- | 463 | * Note that framebuffers cannot be looked up with this functions - since those |
|
338 | * |
464 | * are reference counted, they need special treatment. Even with |
339 | * Note that framebuffers cannot be looked up with this functions - since those |
465 | * DRM_MODE_OBJECT_ANY (although that will simply return NULL |
340 | * are reference counted, they need special treatment. |
466 | * rather than WARN_ON()). |
341 | */ |
467 | */ |
342 | struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
468 | struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
Line 343... | Line 469... | ||
343 | uint32_t id, uint32_t type) |
469 | uint32_t id, uint32_t type) |
344 | { |
470 | { |
345 | struct drm_mode_object *obj = NULL; |
471 | struct drm_mode_object *obj = NULL; |
346 | - | ||
347 | /* Framebuffers are reference counted and need their own lookup |
- | |
348 | * function.*/ |
472 | |
349 | WARN_ON(type == DRM_MODE_OBJECT_FB); |
- | |
350 | - | ||
351 | mutex_lock(&dev->mode_config.idr_mutex); |
- | |
352 | obj = idr_find(&dev->mode_config.crtc_idr, id); |
- | |
353 | if (!obj || (obj->type != type) || (obj->id != id)) |
473 | /* Framebuffers are reference counted and need their own lookup |
354 | obj = NULL; |
474 | * function.*/ |
355 | mutex_unlock(&dev->mode_config.idr_mutex); |
475 | WARN_ON(type == DRM_MODE_OBJECT_FB); |
Line 356... | Line 476... | ||
356 | 476 | obj = _object_find(dev, id, type); |
|
Line 371... | Line 491... | ||
371 | * This functions publishes the fb and makes it available for concurrent access |
491 | * This functions publishes the fb and makes it available for concurrent access |
372 | * by other users. Which means by this point the fb _must_ be fully set up - |
492 | * by other users. Which means by this point the fb _must_ be fully set up - |
373 | * since all the fb attributes are invariant over its lifetime, no further |
493 | * since all the fb attributes are invariant over its lifetime, no further |
374 | * locking but only correct reference counting is required. |
494 | * locking but only correct reference counting is required. |
375 | * |
495 | * |
376 | * RETURNS: |
496 | * Returns: |
377 | * Zero on success, error code on failure. |
497 | * Zero on success, error code on failure. |
378 | */ |
498 | */ |
379 | int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, |
499 | int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, |
380 | const struct drm_framebuffer_funcs *funcs) |
500 | const struct drm_framebuffer_funcs *funcs) |
381 | { |
501 | { |
Line 432... | Line 552... | ||
432 | * @dev: drm device |
552 | * @dev: drm device |
433 | * @id: id of the fb object |
553 | * @id: id of the fb object |
434 | * |
554 | * |
435 | * If successful, this grabs an additional reference to the framebuffer - |
555 | * If successful, this grabs an additional reference to the framebuffer - |
436 | * callers need to make sure to eventually unreference the returned framebuffer |
556 | * callers need to make sure to eventually unreference the returned framebuffer |
437 | * again. |
557 | * again, using @drm_framebuffer_unreference. |
438 | */ |
558 | */ |
439 | struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
559 | struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
440 | uint32_t id) |
560 | uint32_t id) |
441 | { |
561 | { |
442 | struct drm_framebuffer *fb; |
562 | struct drm_framebuffer *fb; |
Line 457... | Line 577... | ||
457 | * |
577 | * |
458 | * This functions decrements the fb's refcount and frees it if it drops to zero. |
578 | * This functions decrements the fb's refcount and frees it if it drops to zero. |
459 | */ |
579 | */ |
460 | void drm_framebuffer_unreference(struct drm_framebuffer *fb) |
580 | void drm_framebuffer_unreference(struct drm_framebuffer *fb) |
461 | { |
581 | { |
462 | DRM_DEBUG("FB ID: %d\n", fb->base.id); |
582 | DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); |
463 | kref_put(&fb->refcount, drm_framebuffer_free); |
583 | kref_put(&fb->refcount, drm_framebuffer_free); |
464 | } |
584 | } |
465 | EXPORT_SYMBOL(drm_framebuffer_unreference); |
585 | EXPORT_SYMBOL(drm_framebuffer_unreference); |
Line 466... | Line 586... | ||
466 | 586 | ||
467 | /** |
587 | /** |
468 | * drm_framebuffer_reference - incr the fb refcnt |
588 | * drm_framebuffer_reference - incr the fb refcnt |
- | 589 | * @fb: framebuffer |
|
- | 590 | * |
|
469 | * @fb: framebuffer |
591 | * This functions increments the fb's refcount. |
470 | */ |
592 | */ |
471 | void drm_framebuffer_reference(struct drm_framebuffer *fb) |
593 | void drm_framebuffer_reference(struct drm_framebuffer *fb) |
472 | { |
594 | { |
473 | DRM_DEBUG("FB ID: %d\n", fb->base.id); |
595 | DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); |
474 | kref_get(&fb->refcount); |
596 | kref_get(&fb->refcount); |
475 | } |
597 | } |
Line 476... | Line 598... | ||
476 | EXPORT_SYMBOL(drm_framebuffer_reference); |
598 | EXPORT_SYMBOL(drm_framebuffer_reference); |
Line 480... | Line 602... | ||
480 | BUG(); |
602 | BUG(); |
481 | } |
603 | } |
Line 482... | Line 604... | ||
482 | 604 | ||
483 | static void __drm_framebuffer_unreference(struct drm_framebuffer *fb) |
605 | static void __drm_framebuffer_unreference(struct drm_framebuffer *fb) |
484 | { |
606 | { |
485 | DRM_DEBUG("FB ID: %d\n", fb->base.id); |
607 | DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); |
486 | kref_put(&fb->refcount, drm_framebuffer_free_bug); |
608 | kref_put(&fb->refcount, drm_framebuffer_free_bug); |
Line 487... | Line 609... | ||
487 | } |
609 | } |
488 | 610 | ||
Line 521... | Line 643... | ||
521 | 643 | ||
522 | /** |
644 | /** |
523 | * drm_framebuffer_cleanup - remove a framebuffer object |
645 | * drm_framebuffer_cleanup - remove a framebuffer object |
524 | * @fb: framebuffer to remove |
646 | * @fb: framebuffer to remove |
525 | * |
647 | * |
- | 648 | * Cleanup framebuffer. This function is intended to be used from the drivers |
|
526 | * Cleanup references to a user-created framebuffer. This function is intended |
649 | * ->destroy callback. It can also be used to clean up driver private |
527 | * to be used from the drivers ->destroy callback. |
650 | * framebuffers embedded into a larger structure. |
528 | * |
651 | * |
529 | * Note that this function does not remove the fb from active usuage - if it is |
652 | * Note that this function does not remove the fb from active usuage - if it is |
530 | * still used anywhere, hilarity can ensue since userspace could call getfb on |
653 | * still used anywhere, hilarity can ensue since userspace could call getfb on |
531 | * the id and get back -EINVAL. Obviously no concern at driver unload time. |
654 | * the id and get back -EINVAL. Obviously no concern at driver unload time. |
Line 585... | Line 708... | ||
585 | */ |
708 | */ |
586 | if (atomic_read(&fb->refcount.refcount) > 1) { |
709 | if (atomic_read(&fb->refcount.refcount) > 1) { |
587 | drm_modeset_lock_all(dev); |
710 | drm_modeset_lock_all(dev); |
588 | /* remove from any CRTC */ |
711 | /* remove from any CRTC */ |
589 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
712 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
590 | if (crtc->fb == fb) { |
713 | if (crtc->primary->fb == fb) { |
591 | /* should turn off the crtc */ |
714 | /* should turn off the crtc */ |
592 | memset(&set, 0, sizeof(struct drm_mode_set)); |
715 | memset(&set, 0, sizeof(struct drm_mode_set)); |
593 | set.crtc = crtc; |
716 | set.crtc = crtc; |
594 | set.fb = NULL; |
717 | set.fb = NULL; |
595 | ret = drm_mode_set_config_internal(&set); |
718 | ret = drm_mode_set_config_internal(&set); |
Line 607... | Line 730... | ||
607 | 730 | ||
608 | drm_framebuffer_unreference(fb); |
731 | drm_framebuffer_unreference(fb); |
609 | } |
732 | } |
Line -... | Line 733... | ||
- | 733 | EXPORT_SYMBOL(drm_framebuffer_remove); |
|
- | 734 | ||
610 | EXPORT_SYMBOL(drm_framebuffer_remove); |
735 | DEFINE_WW_CLASS(crtc_ww_class); |
611 | 736 | ||
- | 737 | /** |
|
612 | /** |
738 | * drm_crtc_init_with_planes - Initialise a new CRTC object with |
613 | * drm_crtc_init - Initialise a new CRTC object |
739 | * specified primary and cursor planes. |
- | 740 | * @dev: DRM device |
|
- | 741 | * @crtc: CRTC object to init |
|
614 | * @dev: DRM device |
742 | * @primary: Primary plane for CRTC |
615 | * @crtc: CRTC object to init |
743 | * @cursor: Cursor plane for CRTC |
616 | * @funcs: callbacks for the new CRTC |
744 | * @funcs: callbacks for the new CRTC |
617 | * |
745 | * |
618 | * Inits a new object created as base part of a driver crtc object. |
746 | * Inits a new object created as base part of a driver crtc object. |
619 | * |
747 | * |
620 | * RETURNS: |
748 | * Returns: |
621 | * Zero on success, error code on failure. |
749 | * Zero on success, error code on failure. |
- | 750 | */ |
|
- | 751 | int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, |
|
622 | */ |
752 | struct drm_plane *primary, |
623 | int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, |
753 | struct drm_plane *cursor, |
- | 754 | const struct drm_crtc_funcs *funcs) |
|
624 | const struct drm_crtc_funcs *funcs) |
755 | { |
Line 625... | Line 756... | ||
625 | { |
756 | struct drm_mode_config *config = &dev->mode_config; |
626 | int ret; |
757 | int ret; |
627 | 758 | ||
Line 628... | Line 759... | ||
628 | crtc->dev = dev; |
759 | crtc->dev = dev; |
629 | crtc->funcs = funcs; |
760 | crtc->funcs = funcs; |
- | 761 | crtc->invert_dimensions = false; |
|
630 | crtc->invert_dimensions = false; |
762 | |
Line 631... | Line 763... | ||
631 | 763 | drm_modeset_lock_all(dev); |
|
632 | drm_modeset_lock_all(dev); |
764 | drm_modeset_lock_init(&crtc->mutex); |
633 | mutex_init(&crtc->mutex); |
765 | /* dropped by _unlock_all(): */ |
Line 634... | Line 766... | ||
634 | mutex_lock_nest_lock(&crtc->mutex, &dev->mode_config.mutex); |
766 | drm_modeset_lock(&crtc->mutex, config->acquire_ctx); |
Line 635... | Line 767... | ||
635 | 767 | ||
636 | ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); |
768 | ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); |
- | 769 | if (ret) |
|
- | 770 | goto out; |
|
- | 771 | ||
- | 772 | crtc->base.properties = &crtc->properties; |
|
- | 773 | ||
- | 774 | list_add_tail(&crtc->head, &config->crtc_list); |
|
- | 775 | config->num_crtc++; |
|
Line 637... | Line 776... | ||
637 | if (ret) |
776 | |
638 | goto out; |
777 | crtc->primary = primary; |
Line 639... | Line 778... | ||
639 | 778 | crtc->cursor = cursor; |
|
640 | crtc->base.properties = &crtc->properties; |
779 | if (primary) |
641 | 780 | primary->possible_crtcs = 1 << drm_crtc_index(crtc); |
|
Line 642... | Line 781... | ||
642 | list_add_tail(&crtc->head, &dev->mode_config.crtc_list); |
781 | if (cursor) |
643 | dev->mode_config.num_crtc++; |
782 | cursor->possible_crtcs = 1 << drm_crtc_index(crtc); |
644 | 783 | ||
645 | out: |
784 | out: |
Line 662... | Line 801... | ||
662 | struct drm_device *dev = crtc->dev; |
801 | struct drm_device *dev = crtc->dev; |
Line 663... | Line 802... | ||
663 | 802 | ||
664 | kfree(crtc->gamma_store); |
803 | kfree(crtc->gamma_store); |
Line -... | Line 804... | ||
- | 804 | crtc->gamma_store = NULL; |
|
- | 805 | ||
665 | crtc->gamma_store = NULL; |
806 | drm_modeset_lock_fini(&crtc->mutex); |
666 | 807 | ||
667 | drm_mode_object_put(dev, &crtc->base); |
808 | drm_mode_object_put(dev, &crtc->base); |
668 | list_del(&crtc->head); |
809 | list_del(&crtc->head); |
669 | dev->mode_config.num_crtc--; |
810 | dev->mode_config.num_crtc--; |
Line 691... | Line 832... | ||
691 | 832 | ||
692 | BUG(); |
833 | BUG(); |
693 | } |
834 | } |
Line 694... | Line -... | ||
694 | EXPORT_SYMBOL(drm_crtc_index); |
- | |
695 | - | ||
696 | /** |
- | |
697 | * drm_mode_probed_add - add a mode to a connector's probed mode list |
- | |
698 | * @connector: connector the new mode |
- | |
699 | * @mode: mode data |
- | |
700 | * |
- | |
701 | * Add @mode to @connector's mode list for later use. |
- | |
702 | */ |
- | |
703 | void drm_mode_probed_add(struct drm_connector *connector, |
- | |
704 | struct drm_display_mode *mode) |
- | |
705 | { |
- | |
706 | list_add_tail(&mode->head, &connector->probed_modes); |
- | |
707 | } |
- | |
708 | EXPORT_SYMBOL(drm_mode_probed_add); |
835 | EXPORT_SYMBOL(drm_crtc_index); |
709 | 836 | ||
710 | /* |
837 | /* |
711 | * drm_mode_remove - remove and free a mode |
838 | * drm_mode_remove - remove and free a mode |
712 | * @connector: connector list to modify |
839 | * @connector: connector list to modify |
Line 729... | Line 856... | ||
729 | * @connector_type: user visible type of the connector |
856 | * @connector_type: user visible type of the connector |
730 | * |
857 | * |
731 | * Initialises a preallocated connector. Connectors should be |
858 | * Initialises a preallocated connector. Connectors should be |
732 | * subclassed as part of driver connector objects. |
859 | * subclassed as part of driver connector objects. |
733 | * |
860 | * |
734 | * RETURNS: |
861 | * Returns: |
735 | * Zero on success, error code on failure. |
862 | * Zero on success, error code on failure. |
736 | */ |
863 | */ |
737 | int drm_connector_init(struct drm_device *dev, |
864 | int drm_connector_init(struct drm_device *dev, |
738 | struct drm_connector *connector, |
865 | struct drm_connector *connector, |
739 | const struct drm_connector_funcs *funcs, |
866 | const struct drm_connector_funcs *funcs, |
Line 743... | Line 870... | ||
743 | struct ida *connector_ida = |
870 | struct ida *connector_ida = |
744 | &drm_connector_enum_list[connector_type].ida; |
871 | &drm_connector_enum_list[connector_type].ida; |
Line 745... | Line 872... | ||
745 | 872 | ||
Line 746... | Line 873... | ||
746 | drm_modeset_lock_all(dev); |
873 | drm_modeset_lock_all(dev); |
747 | 874 | ||
748 | ret = drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR); |
875 | ret = drm_mode_object_get_reg(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR, false); |
Line 749... | Line 876... | ||
749 | if (ret) |
876 | if (ret) |
750 | goto out; |
877 | goto out_unlock; |
751 | 878 | ||
752 | connector->base.properties = &connector->properties; |
879 | connector->base.properties = &connector->properties; |
753 | connector->dev = dev; |
880 | connector->dev = dev; |
754 | connector->funcs = funcs; |
881 | connector->funcs = funcs; |
755 | connector->connector_type = connector_type; |
882 | connector->connector_type = connector_type; |
756 | connector->connector_type_id = |
883 | connector->connector_type_id = |
- | 884 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); |
|
- | 885 | if (connector->connector_type_id < 0) { |
|
- | 886 | ret = connector->connector_type_id; |
|
- | 887 | goto out_put; |
|
757 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); |
888 | } |
- | 889 | connector->name = |
|
- | 890 | kasprintf(GFP_KERNEL, "%s-%d", |
|
- | 891 | drm_connector_enum_list[connector_type].name, |
|
758 | if (connector->connector_type_id < 0) { |
892 | connector->connector_type_id); |
759 | ret = connector->connector_type_id; |
893 | if (!connector->name) { |
- | 894 | ret = -ENOMEM; |
|
760 | drm_mode_object_put(dev, &connector->base); |
895 | goto out_put; |
761 | goto out; |
896 | } |
762 | } |
897 | |
763 | INIT_LIST_HEAD(&connector->probed_modes); |
898 | INIT_LIST_HEAD(&connector->probed_modes); |
Line 774... | Line 909... | ||
774 | 0); |
909 | 0); |
Line 775... | Line 910... | ||
775 | 910 | ||
776 | drm_object_attach_property(&connector->base, |
911 | drm_object_attach_property(&connector->base, |
Line -... | Line 912... | ||
- | 912 | dev->mode_config.dpms_property, 0); |
|
- | 913 | ||
777 | dev->mode_config.dpms_property, 0); |
914 | connector->debugfs_entry = NULL; |
- | 915 | ||
- | 916 | out_put: |
|
- | 917 | if (ret) |
|
- | 918 | drm_mode_object_put(dev, &connector->base); |
|
778 | 919 | ||
Line 779... | Line 920... | ||
779 | out: |
920 | out_unlock: |
780 | drm_modeset_unlock_all(dev); |
921 | drm_modeset_unlock_all(dev); |
781 | 922 | ||
Line 802... | Line 943... | ||
802 | 943 | ||
803 | ida_remove(&drm_connector_enum_list[connector->connector_type].ida, |
944 | ida_remove(&drm_connector_enum_list[connector->connector_type].ida, |
Line 804... | Line 945... | ||
804 | connector->connector_type_id); |
945 | connector->connector_type_id); |
- | 946 | ||
- | 947 | drm_mode_object_put(dev, &connector->base); |
|
805 | 948 | kfree(connector->name); |
|
806 | drm_mode_object_put(dev, &connector->base); |
949 | connector->name = NULL; |
807 | list_del(&connector->head); |
950 | list_del(&connector->head); |
808 | dev->mode_config.num_connector--; |
951 | dev->mode_config.num_connector--; |
Line -... | Line 952... | ||
- | 952 | } |
|
- | 953 | EXPORT_SYMBOL(drm_connector_cleanup); |
|
- | 954 | ||
- | 955 | /** |
|
- | 956 | * drm_connector_register - register a connector |
|
- | 957 | * @connector: the connector to register |
|
- | 958 | * |
|
- | 959 | * Register userspace interfaces for a connector |
|
- | 960 | * |
|
- | 961 | * Returns: |
|
- | 962 | * Zero on success, error code on failure. |
|
- | 963 | */ |
|
- | 964 | int drm_connector_register(struct drm_connector *connector) |
|
- | 965 | { |
|
- | 966 | int ret; |
|
- | 967 | ||
- | 968 | drm_mode_object_register(connector->dev, &connector->base); |
|
- | 969 | ||
- | 970 | return 0; |
|
- | 971 | } |
|
- | 972 | EXPORT_SYMBOL(drm_connector_register); |
|
- | 973 | ||
- | 974 | /** |
|
- | 975 | * drm_connector_unregister - unregister a connector |
|
- | 976 | * @connector: the connector to unregister |
|
- | 977 | * |
|
- | 978 | * Unregister userspace interfaces for a connector |
|
- | 979 | */ |
|
- | 980 | void drm_connector_unregister(struct drm_connector *connector) |
|
- | 981 | { |
|
- | 982 | } |
|
- | 983 | EXPORT_SYMBOL(drm_connector_unregister); |
|
- | 984 | ||
- | 985 | ||
- | 986 | /** |
|
- | 987 | * drm_connector_unplug_all - unregister connector userspace interfaces |
|
- | 988 | * @dev: drm device |
|
- | 989 | * |
|
- | 990 | * This function unregisters all connector userspace interfaces in sysfs. Should |
|
809 | } |
991 | * be call when the device is disconnected, e.g. from an usb driver's |
810 | EXPORT_SYMBOL(drm_connector_cleanup); |
992 | * ->disconnect callback. |
811 | 993 | */ |
|
Line 812... | Line 994... | ||
812 | void drm_connector_unplug_all(struct drm_device *dev) |
994 | void drm_connector_unplug_all(struct drm_device *dev) |
813 | { |
995 | { |
814 | struct drm_connector *connector; |
996 | struct drm_connector *connector; |
Line 815... | Line 997... | ||
815 | 997 | ||
816 | /* taking the mode config mutex ends up in a clash with sysfs */ |
998 | /* taking the mode config mutex ends up in a clash with sysfs */ |
Line -... | Line 999... | ||
- | 999 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
|
- | 1000 | drm_connector_unregister(connector); |
|
- | 1001 | ||
- | 1002 | } |
|
- | 1003 | EXPORT_SYMBOL(drm_connector_unplug_all); |
|
- | 1004 | ||
- | 1005 | /** |
|
- | 1006 | * drm_bridge_init - initialize a drm transcoder/bridge |
|
- | 1007 | * @dev: drm device |
|
- | 1008 | * @bridge: transcoder/bridge to set up |
|
- | 1009 | * @funcs: bridge function table |
|
- | 1010 | * |
|
817 | // list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
1011 | * Initialises a preallocated bridge. Bridges should be |
818 | // drm_sysfs_connector_remove(connector); |
1012 | * subclassed as part of driver connector objects. |
819 | 1013 | * |
|
820 | } |
1014 | * Returns: |
Line 841... | Line 1035... | ||
841 | drm_modeset_unlock_all(dev); |
1035 | drm_modeset_unlock_all(dev); |
842 | return ret; |
1036 | return ret; |
843 | } |
1037 | } |
844 | EXPORT_SYMBOL(drm_bridge_init); |
1038 | EXPORT_SYMBOL(drm_bridge_init); |
Line -... | Line 1039... | ||
- | 1039 | ||
- | 1040 | /** |
|
- | 1041 | * drm_bridge_cleanup - cleans up an initialised bridge |
|
- | 1042 | * @bridge: bridge to cleanup |
|
- | 1043 | * |
|
- | 1044 | * Cleans up the bridge but doesn't free the object. |
|
845 | 1045 | */ |
|
846 | void drm_bridge_cleanup(struct drm_bridge *bridge) |
1046 | void drm_bridge_cleanup(struct drm_bridge *bridge) |
847 | { |
1047 | { |
Line 848... | Line 1048... | ||
848 | struct drm_device *dev = bridge->dev; |
1048 | struct drm_device *dev = bridge->dev; |
Line 853... | Line 1053... | ||
853 | dev->mode_config.num_bridge--; |
1053 | dev->mode_config.num_bridge--; |
854 | drm_modeset_unlock_all(dev); |
1054 | drm_modeset_unlock_all(dev); |
855 | } |
1055 | } |
856 | EXPORT_SYMBOL(drm_bridge_cleanup); |
1056 | EXPORT_SYMBOL(drm_bridge_cleanup); |
Line -... | Line 1057... | ||
- | 1057 | ||
- | 1058 | /** |
|
- | 1059 | * drm_encoder_init - Init a preallocated encoder |
|
- | 1060 | * @dev: drm device |
|
- | 1061 | * @encoder: the encoder to init |
|
- | 1062 | * @funcs: callbacks for this encoder |
|
- | 1063 | * @encoder_type: user visible type of the encoder |
|
- | 1064 | * |
|
- | 1065 | * Initialises a preallocated encoder. Encoder should be |
|
- | 1066 | * subclassed as part of driver encoder objects. |
|
- | 1067 | * |
|
- | 1068 | * Returns: |
|
- | 1069 | * Zero on success, error code on failure. |
|
857 | 1070 | */ |
|
858 | int drm_encoder_init(struct drm_device *dev, |
1071 | int drm_encoder_init(struct drm_device *dev, |
859 | struct drm_encoder *encoder, |
1072 | struct drm_encoder *encoder, |
860 | const struct drm_encoder_funcs *funcs, |
1073 | const struct drm_encoder_funcs *funcs, |
861 | int encoder_type) |
1074 | int encoder_type) |
Line 864... | Line 1077... | ||
864 | 1077 | ||
Line 865... | Line 1078... | ||
865 | drm_modeset_lock_all(dev); |
1078 | drm_modeset_lock_all(dev); |
866 | 1079 | ||
867 | ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER); |
1080 | ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER); |
Line 868... | Line 1081... | ||
868 | if (ret) |
1081 | if (ret) |
869 | goto out; |
1082 | goto out_unlock; |
870 | 1083 | ||
- | 1084 | encoder->dev = dev; |
|
- | 1085 | encoder->encoder_type = encoder_type; |
|
- | 1086 | encoder->funcs = funcs; |
|
- | 1087 | encoder->name = kasprintf(GFP_KERNEL, "%s-%d", |
|
- | 1088 | drm_encoder_enum_list[encoder_type].name, |
|
- | 1089 | encoder->base.id); |
|
- | 1090 | if (!encoder->name) { |
|
Line 871... | Line 1091... | ||
871 | encoder->dev = dev; |
1091 | ret = -ENOMEM; |
872 | encoder->encoder_type = encoder_type; |
1092 | goto out_put; |
Line 873... | Line 1093... | ||
873 | encoder->funcs = funcs; |
1093 | } |
- | 1094 | ||
- | 1095 | list_add_tail(&encoder->head, &dev->mode_config.encoder_list); |
|
- | 1096 | dev->mode_config.num_encoder++; |
|
- | 1097 | ||
874 | 1098 | out_put: |
|
Line 875... | Line 1099... | ||
875 | list_add_tail(&encoder->head, &dev->mode_config.encoder_list); |
1099 | if (ret) |
876 | dev->mode_config.num_encoder++; |
1100 | drm_mode_object_put(dev, &encoder->base); |
877 | 1101 | ||
Line -... | Line 1102... | ||
- | 1102 | out_unlock: |
|
- | 1103 | drm_modeset_unlock_all(dev); |
|
- | 1104 | ||
- | 1105 | return ret; |
|
- | 1106 | } |
|
- | 1107 | EXPORT_SYMBOL(drm_encoder_init); |
|
878 | out: |
1108 | |
879 | drm_modeset_unlock_all(dev); |
1109 | /** |
880 | 1110 | * drm_encoder_cleanup - cleans up an initialised encoder |
|
881 | return ret; |
1111 | * @encoder: encoder to cleanup |
882 | } |
1112 | * |
- | 1113 | * Cleans up the encoder but doesn't free the object. |
|
- | 1114 | */ |
|
883 | EXPORT_SYMBOL(drm_encoder_init); |
1115 | void drm_encoder_cleanup(struct drm_encoder *encoder) |
884 | 1116 | { |
|
885 | void drm_encoder_cleanup(struct drm_encoder *encoder) |
1117 | struct drm_device *dev = encoder->dev; |
886 | { |
1118 | drm_modeset_lock_all(dev); |
887 | struct drm_device *dev = encoder->dev; |
1119 | drm_mode_object_put(dev, &encoder->base); |
Line 888... | Line 1120... | ||
888 | drm_modeset_lock_all(dev); |
1120 | kfree(encoder->name); |
889 | drm_mode_object_put(dev, &encoder->base); |
1121 | encoder->name = NULL; |
890 | list_del(&encoder->head); |
1122 | list_del(&encoder->head); |
891 | dev->mode_config.num_encoder--; |
1123 | dev->mode_config.num_encoder--; |
892 | drm_modeset_unlock_all(dev); |
1124 | drm_modeset_unlock_all(dev); |
893 | } |
1125 | } |
894 | EXPORT_SYMBOL(drm_encoder_cleanup); |
1126 | EXPORT_SYMBOL(drm_encoder_cleanup); |
895 | 1127 | ||
896 | /** |
1128 | /** |
897 | * drm_plane_init - Initialise a new plane object |
1129 | * drm_universal_plane_init - Initialize a new universal plane object |
898 | * @dev: DRM device |
1130 | * @dev: DRM device |
899 | * @plane: plane object to init |
1131 | * @plane: plane object to init |
900 | * @possible_crtcs: bitmask of possible CRTCs |
1132 | * @possible_crtcs: bitmask of possible CRTCs |
901 | * @funcs: callbacks for the new plane |
1133 | * @funcs: callbacks for the new plane |
902 | * @formats: array of supported formats (%DRM_FORMAT_*) |
1134 | * @formats: array of supported formats (%DRM_FORMAT_*) |
903 | * @format_count: number of elements in @formats |
1135 | * @format_count: number of elements in @formats |
904 | * @priv: plane is private (hidden from userspace)? |
1136 | * @type: type of plane (overlay, primary, cursor) |
905 | * |
1137 | * |
906 | * Inits a new object created as base part of a driver plane object. |
1138 | * Initializes a plane object of type @type. |
907 | * |
1139 | * |
908 | * RETURNS: |
1140 | * Returns: |
909 | * Zero on success, error code on failure. |
1141 | * Zero on success, error code on failure. |
Line 910... | Line 1142... | ||
910 | */ |
1142 | */ |
Line 935... | Line 1167... | ||
935 | } |
1167 | } |
Line 936... | Line 1168... | ||
936 | 1168 | ||
937 | memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); |
1169 | memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); |
938 | plane->format_count = format_count; |
1170 | plane->format_count = format_count; |
- | 1171 | plane->possible_crtcs = possible_crtcs; |
|
Line 939... | Line -... | ||
939 | plane->possible_crtcs = possible_crtcs; |
- | |
940 | - | ||
941 | /* private planes are not exposed to userspace, but depending on |
- | |
942 | * display hardware, might be convenient to allow sharing programming |
- | |
943 | * for the scanout engine with the crtc implementation. |
- | |
944 | */ |
1172 | plane->type = type; |
945 | if (!priv) { |
1173 | |
946 | list_add_tail(&plane->head, &dev->mode_config.plane_list); |
1174 | list_add_tail(&plane->head, &dev->mode_config.plane_list); |
947 | dev->mode_config.num_plane++; |
1175 | dev->mode_config.num_total_plane++; |
948 | } else { |
1176 | if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
- | 1177 | dev->mode_config.num_overlay_plane++; |
|
- | 1178 | ||
- | 1179 | drm_object_attach_property(&plane->base, |
|
Line 949... | Line 1180... | ||
949 | INIT_LIST_HEAD(&plane->head); |
1180 | dev->mode_config.plane_type_property, |
950 | } |
1181 | plane->type); |
Line 951... | Line 1182... | ||
951 | 1182 | ||
952 | out: |
1183 | out: |
- | 1184 | drm_modeset_unlock_all(dev); |
|
- | 1185 | ||
- | 1186 | return ret; |
|
- | 1187 | } |
|
- | 1188 | EXPORT_SYMBOL(drm_universal_plane_init); |
|
- | 1189 | ||
- | 1190 | /** |
|
- | 1191 | * drm_plane_init - Initialize a legacy plane |
|
- | 1192 | * @dev: DRM device |
|
- | 1193 | * @plane: plane object to init |
|
- | 1194 | * @possible_crtcs: bitmask of possible CRTCs |
|
- | 1195 | * @funcs: callbacks for the new plane |
|
- | 1196 | * @formats: array of supported formats (%DRM_FORMAT_*) |
|
- | 1197 | * @format_count: number of elements in @formats |
|
- | 1198 | * @is_primary: plane type (primary vs overlay) |
|
- | 1199 | * |
|
- | 1200 | * Legacy API to initialize a DRM plane. |
|
- | 1201 | * |
|
- | 1202 | * New drivers should call drm_universal_plane_init() instead. |
|
- | 1203 | * |
|
- | 1204 | * Returns: |
|
- | 1205 | * Zero on success, error code on failure. |
|
- | 1206 | */ |
|
- | 1207 | int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, |
|
- | 1208 | unsigned long possible_crtcs, |
|
- | 1209 | const struct drm_plane_funcs *funcs, |
|
- | 1210 | const uint32_t *formats, uint32_t format_count, |
|
- | 1211 | bool is_primary) |
|
- | 1212 | { |
|
- | 1213 | enum drm_plane_type type; |
|
- | 1214 | ||
953 | drm_modeset_unlock_all(dev); |
1215 | type = is_primary ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; |
Line 954... | Line 1216... | ||
954 | 1216 | return drm_universal_plane_init(dev, plane, possible_crtcs, funcs, |
|
955 | return ret; |
1217 | formats, format_count, type); |
956 | } |
1218 | } |
Line 969... | Line 1231... | ||
969 | struct drm_device *dev = plane->dev; |
1231 | struct drm_device *dev = plane->dev; |
Line 970... | Line 1232... | ||
970 | 1232 | ||
971 | drm_modeset_lock_all(dev); |
1233 | drm_modeset_lock_all(dev); |
972 | kfree(plane->format_types); |
1234 | kfree(plane->format_types); |
973 | drm_mode_object_put(dev, &plane->base); |
- | |
- | 1235 | drm_mode_object_put(dev, &plane->base); |
|
974 | /* if not added to a list, it must be a private plane */ |
1236 | |
- | 1237 | BUG_ON(list_empty(&plane->head)); |
|
975 | if (!list_empty(&plane->head)) { |
1238 | |
976 | list_del(&plane->head); |
1239 | list_del(&plane->head); |
977 | dev->mode_config.num_plane--; |
- | |
- | 1240 | dev->mode_config.num_total_plane--; |
|
- | 1241 | if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
|
978 | } |
1242 | dev->mode_config.num_overlay_plane--; |
979 | drm_modeset_unlock_all(dev); |
1243 | drm_modeset_unlock_all(dev); |
980 | } |
1244 | } |
Line 981... | Line 1245... | ||
981 | EXPORT_SYMBOL(drm_plane_cleanup); |
1245 | EXPORT_SYMBOL(drm_plane_cleanup); |
Line 989... | Line 1253... | ||
989 | * Used when the plane's current framebuffer is destroyed, |
1253 | * Used when the plane's current framebuffer is destroyed, |
990 | * and when restoring fbdev mode. |
1254 | * and when restoring fbdev mode. |
991 | */ |
1255 | */ |
992 | void drm_plane_force_disable(struct drm_plane *plane) |
1256 | void drm_plane_force_disable(struct drm_plane *plane) |
993 | { |
1257 | { |
- | 1258 | struct drm_framebuffer *old_fb = plane->fb; |
|
994 | int ret; |
1259 | int ret; |
Line 995... | Line 1260... | ||
995 | 1260 | ||
996 | if (!plane->fb) |
1261 | if (!old_fb) |
Line 997... | Line 1262... | ||
997 | return; |
1262 | return; |
998 | 1263 | ||
999 | ret = plane->funcs->disable_plane(plane); |
1264 | ret = plane->funcs->disable_plane(plane); |
- | 1265 | if (ret) { |
|
- | 1266 | DRM_ERROR("failed to disable plane with busy fb\n"); |
|
1000 | if (ret) |
1267 | return; |
1001 | DRM_ERROR("failed to disable plane with busy fb\n"); |
1268 | } |
1002 | /* disconnect the plane from the fb and crtc: */ |
1269 | /* disconnect the plane from the fb and crtc: */ |
1003 | __drm_framebuffer_unreference(plane->fb); |
1270 | __drm_framebuffer_unreference(old_fb); |
1004 | plane->fb = NULL; |
1271 | plane->fb = NULL; |
1005 | plane->crtc = NULL; |
1272 | plane->crtc = NULL; |
Line 1006... | Line -... | ||
1006 | } |
- | |
1007 | EXPORT_SYMBOL(drm_plane_force_disable); |
- | |
1008 | - | ||
1009 | /** |
- | |
1010 | * drm_mode_create - create a new display mode |
- | |
1011 | * @dev: DRM device |
- | |
1012 | * |
- | |
1013 | * Create a new drm_display_mode, give it an ID, and return it. |
- | |
1014 | * |
- | |
1015 | * RETURNS: |
- | |
1016 | * Pointer to new mode on success, NULL on error. |
- | |
1017 | */ |
- | |
1018 | struct drm_display_mode *drm_mode_create(struct drm_device *dev) |
- | |
1019 | { |
- | |
1020 | struct drm_display_mode *nmode; |
- | |
1021 | - | ||
1022 | nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL); |
- | |
1023 | if (!nmode) |
- | |
1024 | return NULL; |
- | |
1025 | - | ||
1026 | if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) { |
- | |
1027 | kfree(nmode); |
- | |
1028 | return NULL; |
- | |
1029 | } |
- | |
1030 | - | ||
1031 | return nmode; |
- | |
1032 | } |
- | |
1033 | EXPORT_SYMBOL(drm_mode_create); |
- | |
1034 | - | ||
1035 | /** |
- | |
1036 | * drm_mode_destroy - remove a mode |
- | |
1037 | * @dev: DRM device |
- | |
1038 | * @mode: mode to remove |
- | |
1039 | * |
- | |
1040 | * Free @mode's unique identifier, then free it. |
- | |
1041 | */ |
- | |
1042 | void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) |
- | |
1043 | { |
- | |
1044 | if (!mode) |
- | |
1045 | return; |
- | |
1046 | - | ||
1047 | drm_mode_object_put(dev, &mode->base); |
- | |
1048 | - | ||
1049 | kfree(mode); |
- | |
1050 | } |
1273 | } |
1051 | EXPORT_SYMBOL(drm_mode_destroy); |
1274 | EXPORT_SYMBOL(drm_plane_force_disable); |
1052 | 1275 | ||
1053 | static int drm_mode_create_standard_connector_properties(struct drm_device *dev) |
1276 | static int drm_mode_create_standard_connector_properties(struct drm_device *dev) |
- | 1277 | { |
|
Line 1054... | Line 1278... | ||
1054 | { |
1278 | struct drm_property *edid; |
1055 | struct drm_property *edid; |
1279 | struct drm_property *dpms; |
1056 | struct drm_property *dpms; |
1280 | struct drm_property *dev_path; |
1057 | 1281 | ||
Line 1066... | Line 1290... | ||
1066 | dpms = drm_property_create_enum(dev, 0, |
1290 | dpms = drm_property_create_enum(dev, 0, |
1067 | "DPMS", drm_dpms_enum_list, |
1291 | "DPMS", drm_dpms_enum_list, |
1068 | ARRAY_SIZE(drm_dpms_enum_list)); |
1292 | ARRAY_SIZE(drm_dpms_enum_list)); |
1069 | dev->mode_config.dpms_property = dpms; |
1293 | dev->mode_config.dpms_property = dpms; |
Line -... | Line 1294... | ||
- | 1294 | ||
- | 1295 | dev_path = drm_property_create(dev, |
|
- | 1296 | DRM_MODE_PROP_BLOB | |
|
- | 1297 | DRM_MODE_PROP_IMMUTABLE, |
|
- | 1298 | "PATH", 0); |
|
- | 1299 | dev->mode_config.path_property = dev_path; |
|
- | 1300 | ||
- | 1301 | return 0; |
|
- | 1302 | } |
|
- | 1303 | ||
- | 1304 | static int drm_mode_create_standard_plane_properties(struct drm_device *dev) |
|
- | 1305 | { |
|
- | 1306 | struct drm_property *type; |
|
- | 1307 | ||
- | 1308 | /* |
|
- | 1309 | * Standard properties (apply to all planes) |
|
- | 1310 | */ |
|
- | 1311 | type = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, |
|
- | 1312 | "type", drm_plane_type_enum_list, |
|
- | 1313 | ARRAY_SIZE(drm_plane_type_enum_list)); |
|
- | 1314 | dev->mode_config.plane_type_property = type; |
|
1070 | 1315 | ||
1071 | return 0; |
1316 | return 0; |
Line 1072... | Line 1317... | ||
1072 | } |
1317 | } |
1073 | 1318 | ||
Line 1207... | Line 1452... | ||
1207 | return 0; |
1452 | return 0; |
1208 | } |
1453 | } |
1209 | EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); |
1454 | EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); |
Line 1210... | Line 1455... | ||
1210 | 1455 | ||
- | 1456 | /** |
|
- | 1457 | * drm_mode_create_aspect_ratio_property - create aspect ratio property |
|
- | 1458 | * @dev: DRM device |
|
- | 1459 | * |
|
- | 1460 | * Called by a driver the first time it's needed, must be attached to desired |
|
- | 1461 | * connectors. |
|
- | 1462 | * |
|
- | 1463 | * Returns: |
|
- | 1464 | * Zero on success, errno on failure. |
|
- | 1465 | */ |
|
- | 1466 | int drm_mode_create_aspect_ratio_property(struct drm_device *dev) |
|
- | 1467 | { |
|
- | 1468 | if (dev->mode_config.aspect_ratio_property) |
|
- | 1469 | return 0; |
|
- | 1470 | ||
- | 1471 | dev->mode_config.aspect_ratio_property = |
|
- | 1472 | drm_property_create_enum(dev, 0, "aspect ratio", |
|
- | 1473 | drm_aspect_ratio_enum_list, |
|
- | 1474 | ARRAY_SIZE(drm_aspect_ratio_enum_list)); |
|
- | 1475 | ||
- | 1476 | if (dev->mode_config.aspect_ratio_property == NULL) |
|
- | 1477 | return -ENOMEM; |
|
- | 1478 | ||
- | 1479 | return 0; |
|
- | 1480 | } |
|
- | 1481 | EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property); |
|
- | 1482 | ||
1211 | /** |
1483 | /** |
1212 | * drm_mode_create_dirty_property - create dirty property |
1484 | * drm_mode_create_dirty_property - create dirty property |
1213 | * @dev: DRM device |
1485 | * @dev: DRM device |
1214 | * |
1486 | * |
1215 | * Called by a driver the first time it's needed, must be attached to desired |
1487 | * Called by a driver the first time it's needed, must be attached to desired |
Line 1251... | Line 1523... | ||
1251 | group->num_encoders = 0; |
1523 | group->num_encoders = 0; |
1252 | group->num_bridges = 0; |
1524 | group->num_bridges = 0; |
1253 | return 0; |
1525 | return 0; |
1254 | } |
1526 | } |
Line -... | Line 1527... | ||
- | 1527 | ||
- | 1528 | void drm_mode_group_destroy(struct drm_mode_group *group) |
|
- | 1529 | { |
|
- | 1530 | kfree(group->id_list); |
|
- | 1531 | group->id_list = NULL; |
|
- | 1532 | } |
|
- | 1533 | ||
- | 1534 | /* |
|
- | 1535 | * NOTE: Driver's shouldn't ever call drm_mode_group_init_legacy_group - it is |
|
- | 1536 | * the drm core's responsibility to set up mode control groups. |
|
1255 | 1537 | */ |
|
1256 | int drm_mode_group_init_legacy_group(struct drm_device *dev, |
1538 | int drm_mode_group_init_legacy_group(struct drm_device *dev, |
1257 | struct drm_mode_group *group) |
1539 | struct drm_mode_group *group) |
1258 | { |
1540 | { |
1259 | struct drm_crtc *crtc; |
1541 | struct drm_crtc *crtc; |
Line 1283... | Line 1565... | ||
1283 | 1565 | ||
1284 | return 0; |
1566 | return 0; |
1285 | } |
1567 | } |
Line -... | Line 1568... | ||
- | 1568 | EXPORT_SYMBOL(drm_mode_group_init_legacy_group); |
|
- | 1569 | ||
- | 1570 | void drm_reinit_primary_mode_group(struct drm_device *dev) |
|
- | 1571 | { |
|
- | 1572 | drm_modeset_lock_all(dev); |
|
- | 1573 | drm_mode_group_destroy(&dev->primary->mode_group); |
|
- | 1574 | drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group); |
|
- | 1575 | drm_modeset_unlock_all(dev); |
|
- | 1576 | } |
|
1286 | EXPORT_SYMBOL(drm_mode_group_init_legacy_group); |
1577 | EXPORT_SYMBOL(drm_reinit_primary_mode_group); |
1287 | 1578 | ||
1288 | /** |
1579 | /** |
1289 | * drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo |
1580 | * drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo |
1290 | * @out: drm_mode_modeinfo struct to return to the user |
1581 | * @out: drm_mode_modeinfo struct to return to the user |
Line 1327... | Line 1618... | ||
1327 | * @in: drm_mode_modeinfo to use |
1618 | * @in: drm_mode_modeinfo to use |
1328 | * |
1619 | * |
1329 | * Convert a drm_mode_modeinfo into a drm_display_mode structure to return to |
1620 | * Convert a drm_mode_modeinfo into a drm_display_mode structure to return to |
1330 | * the caller. |
1621 | * the caller. |
1331 | * |
1622 | * |
1332 | * RETURNS: |
1623 | * Returns: |
1333 | * Zero on success, errno on failure. |
1624 | * Zero on success, errno on failure. |
1334 | */ |
1625 | */ |
1335 | static int drm_crtc_convert_umode(struct drm_display_mode *out, |
1626 | static int drm_crtc_convert_umode(struct drm_display_mode *out, |
1336 | const struct drm_mode_modeinfo *in) |
1627 | const struct drm_mode_modeinfo *in) |
1337 | { |
1628 | { |
Line 1372... | Line 1663... | ||
1372 | * Construct a set of configuration description structures and return |
1663 | * Construct a set of configuration description structures and return |
1373 | * them to the user, including CRTC, connector and framebuffer configuration. |
1664 | * them to the user, including CRTC, connector and framebuffer configuration. |
1374 | * |
1665 | * |
1375 | * Called by the user via ioctl. |
1666 | * Called by the user via ioctl. |
1376 | * |
1667 | * |
1377 | * RETURNS: |
1668 | * Returns: |
1378 | * Zero on success, errno on failure. |
1669 | * Zero on success, errno on failure. |
1379 | */ |
1670 | */ |
1380 | int drm_mode_getresources(struct drm_device *dev, void *data, |
1671 | int drm_mode_getresources(struct drm_device *dev, void *data, |
1381 | struct drm_file *file_priv) |
1672 | struct drm_file *file_priv) |
1382 | { |
1673 | { |
Line 1425... | Line 1716... | ||
1425 | } |
1716 | } |
1426 | card_res->count_fbs = fb_count; |
1717 | card_res->count_fbs = fb_count; |
1427 | mutex_unlock(&file_priv->fbs_lock); |
1718 | mutex_unlock(&file_priv->fbs_lock); |
Line 1428... | Line 1719... | ||
1428 | 1719 | ||
1429 | drm_modeset_lock_all(dev); |
- | |
1430 | mode_group = &file_priv->master->minor->mode_group; |
1720 | drm_modeset_lock_all(dev); |
Line -... | Line 1721... | ||
- | 1721 | if (!drm_is_primary_client(file_priv)) { |
|
1431 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1722 | |
1432 | 1723 | mode_group = NULL; |
|
Line 1433... | Line 1724... | ||
1433 | list_for_each(lh, &dev->mode_config.crtc_list) |
1724 | list_for_each(lh, &dev->mode_config.crtc_list) |
1434 | crtc_count++; |
1725 | crtc_count++; |
Line 1435... | Line 1726... | ||
1435 | 1726 | ||
1436 | list_for_each(lh, &dev->mode_config.connector_list) |
1727 | list_for_each(lh, &dev->mode_config.connector_list) |
1437 | connector_count++; |
1728 | connector_count++; |
Line -... | Line 1729... | ||
- | 1729 | ||
1438 | 1730 | list_for_each(lh, &dev->mode_config.encoder_list) |
|
1439 | list_for_each(lh, &dev->mode_config.encoder_list) |
1731 | encoder_count++; |
1440 | encoder_count++; |
1732 | } else { |
1441 | } else { |
1733 | |
Line 1452... | Line 1744... | ||
1452 | 1744 | ||
1453 | /* CRTCs */ |
1745 | /* CRTCs */ |
1454 | if (card_res->count_crtcs >= crtc_count) { |
1746 | if (card_res->count_crtcs >= crtc_count) { |
1455 | copied = 0; |
1747 | copied = 0; |
1456 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; |
1748 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; |
1457 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1749 | if (!mode_group) { |
1458 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, |
1750 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, |
1459 | head) { |
1751 | head) { |
1460 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
1752 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
1461 | if (put_user(crtc->base.id, crtc_id + copied)) { |
1753 | if (put_user(crtc->base.id, crtc_id + copied)) { |
Line 1479... | Line 1771... | ||
1479 | 1771 | ||
1480 | /* Encoders */ |
1772 | /* Encoders */ |
1481 | if (card_res->count_encoders >= encoder_count) { |
1773 | if (card_res->count_encoders >= encoder_count) { |
1482 | copied = 0; |
1774 | copied = 0; |
1483 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; |
1775 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; |
1484 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1776 | if (!mode_group) { |
1485 | list_for_each_entry(encoder, |
1777 | list_for_each_entry(encoder, |
1486 | &dev->mode_config.encoder_list, |
1778 | &dev->mode_config.encoder_list, |
1487 | head) { |
1779 | head) { |
1488 | DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id, |
1780 | DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id, |
1489 | drm_get_encoder_name(encoder)); |
1781 | encoder->name); |
1490 | if (put_user(encoder->base.id, encoder_id + |
1782 | if (put_user(encoder->base.id, encoder_id + |
1491 | copied)) { |
1783 | copied)) { |
1492 | ret = -EFAULT; |
1784 | ret = -EFAULT; |
1493 | goto out; |
1785 | goto out; |
Line 1510... | Line 1802... | ||
1510 | 1802 | ||
1511 | /* Connectors */ |
1803 | /* Connectors */ |
1512 | if (card_res->count_connectors >= connector_count) { |
1804 | if (card_res->count_connectors >= connector_count) { |
1513 | copied = 0; |
1805 | copied = 0; |
1514 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; |
1806 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; |
1515 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1807 | if (!mode_group) { |
1516 | list_for_each_entry(connector, |
1808 | list_for_each_entry(connector, |
1517 | &dev->mode_config.connector_list, |
1809 | &dev->mode_config.connector_list, |
1518 | head) { |
1810 | head) { |
1519 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
1811 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
1520 | connector->base.id, |
1812 | connector->base.id, |
1521 | drm_get_connector_name(connector)); |
1813 | connector->name); |
1522 | if (put_user(connector->base.id, |
1814 | if (put_user(connector->base.id, |
1523 | connector_id + copied)) { |
1815 | connector_id + copied)) { |
1524 | ret = -EFAULT; |
1816 | ret = -EFAULT; |
1525 | goto out; |
1817 | goto out; |
Line 1557... | Line 1849... | ||
1557 | * |
1849 | * |
1558 | * Construct a CRTC configuration structure to return to the user. |
1850 | * Construct a CRTC configuration structure to return to the user. |
1559 | * |
1851 | * |
1560 | * Called by the user via ioctl. |
1852 | * Called by the user via ioctl. |
1561 | * |
1853 | * |
1562 | * RETURNS: |
1854 | * Returns: |
1563 | * Zero on success, errno on failure. |
1855 | * Zero on success, errno on failure. |
1564 | */ |
1856 | */ |
1565 | int drm_mode_getcrtc(struct drm_device *dev, |
1857 | int drm_mode_getcrtc(struct drm_device *dev, |
1566 | void *data, struct drm_file *file_priv) |
1858 | void *data, struct drm_file *file_priv) |
1567 | { |
1859 | { |
1568 | struct drm_mode_crtc *crtc_resp = data; |
1860 | struct drm_mode_crtc *crtc_resp = data; |
1569 | struct drm_crtc *crtc; |
1861 | struct drm_crtc *crtc; |
1570 | struct drm_mode_object *obj; |
- | |
1571 | int ret = 0; |
1862 | int ret = 0; |
Line 1572... | Line 1863... | ||
1572 | 1863 | ||
1573 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
1864 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
Line 1574... | Line 1865... | ||
1574 | return -EINVAL; |
1865 | return -EINVAL; |
Line 1575... | Line 1866... | ||
1575 | 1866 | ||
1576 | drm_modeset_lock_all(dev); |
- | |
1577 | 1867 | drm_modeset_lock_all(dev); |
|
1578 | obj = drm_mode_object_find(dev, crtc_resp->crtc_id, |
1868 | |
1579 | DRM_MODE_OBJECT_CRTC); |
1869 | crtc = drm_crtc_find(dev, crtc_resp->crtc_id); |
1580 | if (!obj) { |
1870 | if (!crtc) { |
1581 | ret = -ENOENT; |
- | |
Line 1582... | Line 1871... | ||
1582 | goto out; |
1871 | ret = -ENOENT; |
1583 | } |
1872 | goto out; |
1584 | crtc = obj_to_crtc(obj); |
1873 | } |
1585 | 1874 | ||
1586 | crtc_resp->x = crtc->x; |
1875 | crtc_resp->x = crtc->x; |
1587 | crtc_resp->y = crtc->y; |
1876 | crtc_resp->y = crtc->y; |
1588 | crtc_resp->gamma_size = crtc->gamma_size; |
1877 | crtc_resp->gamma_size = crtc->gamma_size; |
Line 1589... | Line 1878... | ||
1589 | if (crtc->fb) |
1878 | if (crtc->primary->fb) |
Line 1626... | Line 1915... | ||
1626 | * |
1915 | * |
1627 | * Construct a connector configuration structure to return to the user. |
1916 | * Construct a connector configuration structure to return to the user. |
1628 | * |
1917 | * |
1629 | * Called by the user via ioctl. |
1918 | * Called by the user via ioctl. |
1630 | * |
1919 | * |
1631 | * RETURNS: |
1920 | * Returns: |
1632 | * Zero on success, errno on failure. |
1921 | * Zero on success, errno on failure. |
1633 | */ |
1922 | */ |
1634 | int drm_mode_getconnector(struct drm_device *dev, void *data, |
1923 | int drm_mode_getconnector(struct drm_device *dev, void *data, |
1635 | struct drm_file *file_priv) |
1924 | struct drm_file *file_priv) |
1636 | { |
1925 | { |
1637 | struct drm_mode_get_connector *out_resp = data; |
1926 | struct drm_mode_get_connector *out_resp = data; |
1638 | struct drm_mode_object *obj; |
- | |
1639 | struct drm_connector *connector; |
1927 | struct drm_connector *connector; |
1640 | struct drm_display_mode *mode; |
1928 | struct drm_display_mode *mode; |
1641 | int mode_count = 0; |
1929 | int mode_count = 0; |
1642 | int props_count = 0; |
1930 | int props_count = 0; |
1643 | int encoders_count = 0; |
1931 | int encoders_count = 0; |
Line 1657... | Line 1945... | ||
1657 | 1945 | ||
Line 1658... | Line 1946... | ||
1658 | DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id); |
1946 | DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id); |
Line 1659... | Line 1947... | ||
1659 | 1947 | ||
1660 | mutex_lock(&dev->mode_config.mutex); |
- | |
1661 | 1948 | mutex_lock(&dev->mode_config.mutex); |
|
1662 | obj = drm_mode_object_find(dev, out_resp->connector_id, |
1949 | |
1663 | DRM_MODE_OBJECT_CONNECTOR); |
1950 | connector = drm_connector_find(dev, out_resp->connector_id); |
1664 | if (!obj) { |
1951 | if (!connector) { |
1665 | ret = -ENOENT; |
- | |
Line 1666... | Line 1952... | ||
1666 | goto out; |
1952 | ret = -ENOENT; |
Line 1667... | Line 1953... | ||
1667 | } |
1953 | goto out; |
1668 | connector = obj_to_connector(obj); |
1954 | } |
Line 1691... | Line 1977... | ||
1691 | out_resp->connector_type_id = connector->connector_type_id; |
1977 | out_resp->connector_type_id = connector->connector_type_id; |
1692 | out_resp->mm_width = connector->display_info.width_mm; |
1978 | out_resp->mm_width = connector->display_info.width_mm; |
1693 | out_resp->mm_height = connector->display_info.height_mm; |
1979 | out_resp->mm_height = connector->display_info.height_mm; |
1694 | out_resp->subpixel = connector->display_info.subpixel_order; |
1980 | out_resp->subpixel = connector->display_info.subpixel_order; |
1695 | out_resp->connection = connector->status; |
1981 | out_resp->connection = connector->status; |
- | 1982 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); |
|
1696 | if (connector->encoder) |
1983 | if (connector->encoder) |
1697 | out_resp->encoder_id = connector->encoder->base.id; |
1984 | out_resp->encoder_id = connector->encoder->base.id; |
1698 | else |
1985 | else |
1699 | out_resp->encoder_id = 0; |
1986 | out_resp->encoder_id = 0; |
- | 1987 | drm_modeset_unlock(&dev->mode_config.connection_mutex); |
|
Line 1700... | Line 1988... | ||
1700 | 1988 | ||
1701 | /* |
1989 | /* |
1702 | * This ioctl is called twice, once to determine how much space is |
1990 | * This ioctl is called twice, once to determine how much space is |
1703 | * needed, and the 2nd time to fill it. |
1991 | * needed, and the 2nd time to fill it. |
Line 1761... | Line 2049... | ||
1761 | mutex_unlock(&dev->mode_config.mutex); |
2049 | mutex_unlock(&dev->mode_config.mutex); |
Line 1762... | Line 2050... | ||
1762 | 2050 | ||
1763 | return ret; |
2051 | return ret; |
Line -... | Line 2052... | ||
- | 2052 | } |
|
- | 2053 | ||
- | 2054 | /** |
|
- | 2055 | * drm_mode_getencoder - get encoder configuration |
|
- | 2056 | * @dev: drm device for the ioctl |
|
- | 2057 | * @data: data pointer for the ioctl |
|
- | 2058 | * @file_priv: drm file for the ioctl call |
|
- | 2059 | * |
|
- | 2060 | * Construct a encoder configuration structure to return to the user. |
|
- | 2061 | * |
|
- | 2062 | * Called by the user via ioctl. |
|
- | 2063 | * |
|
- | 2064 | * Returns: |
|
1764 | } |
2065 | * Zero on success, errno on failure. |
1765 | 2066 | */ |
|
1766 | int drm_mode_getencoder(struct drm_device *dev, void *data, |
2067 | int drm_mode_getencoder(struct drm_device *dev, void *data, |
1767 | struct drm_file *file_priv) |
2068 | struct drm_file *file_priv) |
1768 | { |
- | |
1769 | struct drm_mode_get_encoder *enc_resp = data; |
2069 | { |
1770 | struct drm_mode_object *obj; |
2070 | struct drm_mode_get_encoder *enc_resp = data; |
Line 1771... | Line 2071... | ||
1771 | struct drm_encoder *encoder; |
2071 | struct drm_encoder *encoder; |
1772 | int ret = 0; |
2072 | int ret = 0; |
Line 1773... | Line 2073... | ||
1773 | 2073 | ||
1774 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2074 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
1775 | return -EINVAL; |
- | |
1776 | 2075 | return -EINVAL; |
|
1777 | drm_modeset_lock_all(dev); |
2076 | |
1778 | obj = drm_mode_object_find(dev, enc_resp->encoder_id, |
2077 | drm_modeset_lock_all(dev); |
1779 | DRM_MODE_OBJECT_ENCODER); |
2078 | encoder = drm_encoder_find(dev, enc_resp->encoder_id); |
1780 | if (!obj) { |
- | |
Line 1781... | Line 2079... | ||
1781 | ret = -ENOENT; |
2079 | if (!encoder) { |
1782 | goto out; |
2080 | ret = -ENOENT; |
1783 | } |
2081 | goto out; |
1784 | encoder = obj_to_encoder(obj); |
2082 | } |
Line 1796... | Line 2094... | ||
1796 | drm_modeset_unlock_all(dev); |
2094 | drm_modeset_unlock_all(dev); |
1797 | return ret; |
2095 | return ret; |
1798 | } |
2096 | } |
Line 1799... | Line 2097... | ||
1799 | 2097 | ||
1800 | /** |
2098 | /** |
1801 | * drm_mode_getplane_res - get plane info |
2099 | * drm_mode_getplane_res - enumerate all plane resources |
1802 | * @dev: DRM device |
2100 | * @dev: DRM device |
1803 | * @data: ioctl data |
2101 | * @data: ioctl data |
1804 | * @file_priv: DRM file info |
2102 | * @file_priv: DRM file info |
- | 2103 | * |
|
- | 2104 | * Construct a list of plane ids to return to the user. |
|
- | 2105 | * |
|
- | 2106 | * Called by the user via ioctl. |
|
- | 2107 | * |
|
1805 | * |
2108 | * Returns: |
1806 | * Return an plane count and set of IDs. |
2109 | * Zero on success, errno on failure. |
1807 | */ |
2110 | */ |
1808 | int drm_mode_getplane_res(struct drm_device *dev, void *data, |
2111 | int drm_mode_getplane_res(struct drm_device *dev, void *data, |
1809 | struct drm_file *file_priv) |
2112 | struct drm_file *file_priv) |
1810 | { |
2113 | { |
1811 | struct drm_mode_get_plane_res *plane_resp = data; |
2114 | struct drm_mode_get_plane_res *plane_resp = data; |
1812 | struct drm_mode_config *config; |
2115 | struct drm_mode_config *config; |
1813 | struct drm_plane *plane; |
2116 | struct drm_plane *plane; |
1814 | uint32_t __user *plane_ptr; |
2117 | uint32_t __user *plane_ptr; |
- | 2118 | int copied = 0, ret = 0; |
|
Line 1815... | Line 2119... | ||
1815 | int copied = 0, ret = 0; |
2119 | unsigned num_planes; |
1816 | 2120 | ||
Line 1817... | Line 2121... | ||
1817 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2121 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
1818 | return -EINVAL; |
2122 | return -EINVAL; |
Line -... | Line 2123... | ||
- | 2123 | ||
- | 2124 | drm_modeset_lock_all(dev); |
|
- | 2125 | config = &dev->mode_config; |
|
- | 2126 | ||
- | 2127 | if (file_priv->universal_planes) |
|
1819 | 2128 | num_planes = config->num_total_plane; |
|
1820 | drm_modeset_lock_all(dev); |
2129 | else |
1821 | config = &dev->mode_config; |
2130 | num_planes = config->num_overlay_plane; |
1822 | 2131 | ||
1823 | /* |
2132 | /* |
1824 | * This ioctl is called twice, once to determine how much space is |
2133 | * This ioctl is called twice, once to determine how much space is |
1825 | * needed, and the 2nd time to fill it. |
2134 | * needed, and the 2nd time to fill it. |
Line 1826... | Line 2135... | ||
1826 | */ |
2135 | */ |
- | 2136 | if (num_planes && |
|
- | 2137 | (plane_resp->count_planes >= num_planes)) { |
|
- | 2138 | plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr; |
|
- | 2139 | ||
- | 2140 | list_for_each_entry(plane, &config->plane_list, head) { |
|
- | 2141 | /* |
|
- | 2142 | * Unless userspace set the 'universal planes' |
|
- | 2143 | * capability bit, only advertise overlays. |
|
1827 | if (config->num_plane && |
2144 | */ |
1828 | (plane_resp->count_planes >= config->num_plane)) { |
2145 | if (plane->type != DRM_PLANE_TYPE_OVERLAY && |
1829 | plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr; |
2146 | !file_priv->universal_planes) |
1830 | 2147 | continue; |
|
1831 | list_for_each_entry(plane, &config->plane_list, head) { |
2148 | |
1832 | if (put_user(plane->base.id, plane_ptr + copied)) { |
2149 | if (put_user(plane->base.id, plane_ptr + copied)) { |
1833 | ret = -EFAULT; |
2150 | ret = -EFAULT; |
1834 | goto out; |
2151 | goto out; |
Line 1835... | Line 2152... | ||
1835 | } |
2152 | } |
1836 | copied++; |
2153 | copied++; |
1837 | } |
2154 | } |
1838 | } |
2155 | } |
Line 1839... | Line 2156... | ||
1839 | plane_resp->count_planes = config->num_plane; |
2156 | plane_resp->count_planes = num_planes; |
1840 | 2157 | ||
1841 | out: |
2158 | out: |
1842 | drm_modeset_unlock_all(dev); |
2159 | drm_modeset_unlock_all(dev); |
1843 | return ret; |
2160 | return ret; |
1844 | } |
2161 | } |
1845 | 2162 | ||
- | 2163 | /** |
|
- | 2164 | * drm_mode_getplane - get plane configuration |
|
- | 2165 | * @dev: DRM device |
|
1846 | /** |
2166 | * @data: ioctl data |
- | 2167 | * @file_priv: DRM file info |
|
1847 | * drm_mode_getplane - get plane info |
2168 | * |
1848 | * @dev: DRM device |
2169 | * Construct a plane configuration structure to return to the user. |
1849 | * @data: ioctl data |
2170 | * |
1850 | * @file_priv: DRM file info |
2171 | * Called by the user via ioctl. |
1851 | * |
2172 | * |
1852 | * Return plane info, including formats supported, gamma size, any |
- | |
1853 | * current fb, etc. |
2173 | * Returns: |
1854 | */ |
2174 | * Zero on success, errno on failure. |
1855 | int drm_mode_getplane(struct drm_device *dev, void *data, |
2175 | */ |
Line 1856... | Line 2176... | ||
1856 | struct drm_file *file_priv) |
2176 | int drm_mode_getplane(struct drm_device *dev, void *data, |
1857 | { |
2177 | struct drm_file *file_priv) |
Line 1858... | Line 2178... | ||
1858 | struct drm_mode_get_plane *plane_resp = data; |
2178 | { |
1859 | struct drm_mode_object *obj; |
2179 | struct drm_mode_get_plane *plane_resp = data; |
1860 | struct drm_plane *plane; |
- | |
1861 | uint32_t __user *format_ptr; |
2180 | struct drm_plane *plane; |
1862 | int ret = 0; |
2181 | uint32_t __user *format_ptr; |
1863 | 2182 | int ret = 0; |
|
1864 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2183 | |
1865 | return -EINVAL; |
- | |
Line 1866... | Line 2184... | ||
1866 | 2184 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
1867 | drm_modeset_lock_all(dev); |
2185 | return -EINVAL; |
1868 | obj = drm_mode_object_find(dev, plane_resp->plane_id, |
2186 | |
1869 | DRM_MODE_OBJECT_PLANE); |
2187 | drm_modeset_lock_all(dev); |
Line 1906... | Line 2224... | ||
1906 | out: |
2224 | out: |
1907 | drm_modeset_unlock_all(dev); |
2225 | drm_modeset_unlock_all(dev); |
1908 | return ret; |
2226 | return ret; |
1909 | } |
2227 | } |
Line 1910... | Line 2228... | ||
1910 | 2228 | ||
1911 | /** |
2229 | /* |
1912 | * drm_mode_setplane - set up or tear down an plane |
- | |
1913 | * @dev: DRM device |
- | |
1914 | * @data: ioctl data* |
- | |
1915 | * @file_priv: DRM file info |
2230 | * setplane_internal - setplane handler for internal callers |
1916 | * |
2231 | * |
- | 2232 | * Note that we assume an extra reference has already been taken on fb. If the |
|
- | 2233 | * update fails, this reference will be dropped before return; if it succeeds, |
|
- | 2234 | * the previous framebuffer (if any) will be unreferenced instead. |
|
1917 | * Set plane info, including placement, fb, scaling, and other factors. |
2235 | * |
1918 | * Or pass a NULL fb to disable. |
2236 | * src_{x,y,w,h} are provided in 16.16 fixed point format |
1919 | */ |
2237 | */ |
- | 2238 | static int setplane_internal(struct drm_plane *plane, |
|
1920 | int drm_mode_setplane(struct drm_device *dev, void *data, |
2239 | struct drm_crtc *crtc, |
- | 2240 | struct drm_framebuffer *fb, |
|
- | 2241 | int32_t crtc_x, int32_t crtc_y, |
|
- | 2242 | uint32_t crtc_w, uint32_t crtc_h, |
|
- | 2243 | /* src_{x,y,w,h} values are 16.16 fixed point */ |
|
- | 2244 | uint32_t src_x, uint32_t src_y, |
|
1921 | struct drm_file *file_priv) |
2245 | uint32_t src_w, uint32_t src_h) |
1922 | { |
- | |
1923 | struct drm_mode_set_plane *plane_req = data; |
- | |
1924 | struct drm_mode_object *obj; |
2246 | { |
1925 | struct drm_plane *plane; |
- | |
1926 | struct drm_crtc *crtc; |
2247 | struct drm_device *dev = plane->dev; |
1927 | struct drm_framebuffer *fb = NULL, *old_fb = NULL; |
2248 | struct drm_framebuffer *old_fb = NULL; |
1928 | int ret = 0; |
2249 | int ret = 0; |
1929 | unsigned int fb_width, fb_height; |
2250 | unsigned int fb_width, fb_height; |
Line 1930... | Line -... | ||
1930 | int i; |
- | |
1931 | - | ||
1932 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
- | |
1933 | return -EINVAL; |
- | |
1934 | - | ||
1935 | /* |
- | |
1936 | * First, find the plane, crtc, and fb objects. If not available, |
- | |
1937 | * we don't bother to call the driver. |
- | |
1938 | */ |
- | |
1939 | obj = drm_mode_object_find(dev, plane_req->plane_id, |
- | |
1940 | DRM_MODE_OBJECT_PLANE); |
- | |
1941 | if (!obj) { |
- | |
1942 | DRM_DEBUG_KMS("Unknown plane ID %d\n", |
- | |
1943 | plane_req->plane_id); |
- | |
1944 | return -ENOENT; |
- | |
1945 | } |
- | |
1946 | plane = obj_to_plane(obj); |
2251 | int i; |
1947 | 2252 | ||
1948 | /* No fb means shut it down */ |
2253 | /* No fb means shut it down */ |
1949 | if (!plane_req->fb_id) { |
2254 | if (!fb) { |
1950 | drm_modeset_lock_all(dev); |
2255 | drm_modeset_lock_all(dev); |
- | 2256 | old_fb = plane->fb; |
|
1951 | old_fb = plane->fb; |
2257 | ret = plane->funcs->disable_plane(plane); |
1952 | plane->funcs->disable_plane(plane); |
2258 | if (!ret) { |
1953 | plane->crtc = NULL; |
2259 | plane->crtc = NULL; |
1954 | plane->fb = NULL; |
2260 | plane->fb = NULL; |
1955 | drm_modeset_unlock_all(dev); |
2261 | } else { |
1956 | goto out; |
- | |
1957 | } |
- | |
1958 | - | ||
1959 | obj = drm_mode_object_find(dev, plane_req->crtc_id, |
- | |
1960 | DRM_MODE_OBJECT_CRTC); |
- | |
1961 | if (!obj) { |
2262 | old_fb = NULL; |
1962 | DRM_DEBUG_KMS("Unknown crtc ID %d\n", |
- | |
1963 | plane_req->crtc_id); |
2263 | } |
1964 | ret = -ENOENT; |
2264 | drm_modeset_unlock_all(dev); |
1965 | goto out; |
- | |
Line 1966... | Line 2265... | ||
1966 | } |
2265 | goto out; |
1967 | crtc = obj_to_crtc(obj); |
2266 | } |
1968 | 2267 | ||
1969 | fb = drm_framebuffer_lookup(dev, plane_req->fb_id); |
- | |
1970 | if (!fb) { |
2268 | /* Check whether this plane is usable on this CRTC */ |
1971 | DRM_DEBUG_KMS("Unknown framebuffer ID %d\n", |
2269 | if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) { |
1972 | plane_req->fb_id); |
2270 | DRM_DEBUG_KMS("Invalid crtc for plane\n"); |
Line 1973... | Line 2271... | ||
1973 | ret = -ENOENT; |
2271 | ret = -EINVAL; |
1974 | goto out; |
2272 | goto out; |
Line 1987... | Line 2285... | ||
1987 | 2285 | ||
1988 | fb_width = fb->width << 16; |
2286 | fb_width = fb->width << 16; |
Line 1989... | Line 2287... | ||
1989 | fb_height = fb->height << 16; |
2287 | fb_height = fb->height << 16; |
1990 | 2288 | ||
1991 | /* Make sure source coordinates are inside the fb. */ |
2289 | /* Make sure source coordinates are inside the fb. */ |
1992 | if (plane_req->src_w > fb_width || |
2290 | if (src_w > fb_width || |
1993 | plane_req->src_x > fb_width - plane_req->src_w || |
2291 | src_x > fb_width - src_w || |
1994 | plane_req->src_h > fb_height || |
2292 | src_h > fb_height || |
1995 | plane_req->src_y > fb_height - plane_req->src_h) { |
2293 | src_y > fb_height - src_h) { |
1996 | DRM_DEBUG_KMS("Invalid source coordinates " |
- | |
1997 | "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n", |
2294 | DRM_DEBUG_KMS("Invalid source coordinates " |
1998 | plane_req->src_w >> 16, |
- | |
1999 | ((plane_req->src_w & 0xffff) * 15625) >> 10, |
2295 | "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n", |
2000 | plane_req->src_h >> 16, |
- | |
2001 | ((plane_req->src_h & 0xffff) * 15625) >> 10, |
2296 | src_w >> 16, ((src_w & 0xffff) * 15625) >> 10, |
2002 | plane_req->src_x >> 16, |
- | |
2003 | ((plane_req->src_x & 0xffff) * 15625) >> 10, |
2297 | src_h >> 16, ((src_h & 0xffff) * 15625) >> 10, |
2004 | plane_req->src_y >> 16, |
2298 | src_x >> 16, ((src_x & 0xffff) * 15625) >> 10, |
2005 | ((plane_req->src_y & 0xffff) * 15625) >> 10); |
2299 | src_y >> 16, ((src_y & 0xffff) * 15625) >> 10); |
2006 | ret = -ENOSPC; |
2300 | ret = -ENOSPC; |
Line 2007... | Line -... | ||
2007 | goto out; |
- | |
2008 | } |
- | |
2009 | - | ||
2010 | /* Give drivers some help against integer overflows */ |
- | |
2011 | if (plane_req->crtc_w > INT_MAX || |
- | |
2012 | plane_req->crtc_x > INT_MAX - (int32_t) plane_req->crtc_w || |
- | |
2013 | plane_req->crtc_h > INT_MAX || |
- | |
2014 | plane_req->crtc_y > INT_MAX - (int32_t) plane_req->crtc_h) { |
- | |
2015 | DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n", |
- | |
2016 | plane_req->crtc_w, plane_req->crtc_h, |
- | |
2017 | plane_req->crtc_x, plane_req->crtc_y); |
- | |
2018 | ret = -ERANGE; |
- | |
2019 | goto out; |
2301 | goto out; |
- | 2302 | } |
|
2020 | } |
2303 | |
2021 | - | ||
2022 | drm_modeset_lock_all(dev); |
2304 | drm_modeset_lock_all(dev); |
2023 | ret = plane->funcs->update_plane(plane, crtc, fb, |
- | |
2024 | plane_req->crtc_x, plane_req->crtc_y, |
2305 | old_fb = plane->fb; |
2025 | plane_req->crtc_w, plane_req->crtc_h, |
2306 | ret = plane->funcs->update_plane(plane, crtc, fb, |
2026 | plane_req->src_x, plane_req->src_y, |
- | |
2027 | plane_req->src_w, plane_req->src_h); |
2307 | crtc_x, crtc_y, crtc_w, crtc_h, |
2028 | if (!ret) { |
2308 | src_x, src_y, src_w, src_h); |
2029 | old_fb = plane->fb; |
2309 | if (!ret) { |
- | 2310 | plane->crtc = crtc; |
|
- | 2311 | plane->fb = fb; |
|
2030 | plane->crtc = crtc; |
2312 | fb = NULL; |
2031 | plane->fb = fb; |
2313 | } else { |
Line 2032... | Line 2314... | ||
2032 | fb = NULL; |
2314 | old_fb = NULL; |
2033 | } |
2315 | } |
2034 | drm_modeset_unlock_all(dev); |
2316 | drm_modeset_unlock_all(dev); |
2035 | 2317 | ||
2036 | out: |
2318 | out: |
Line 2037... | Line 2319... | ||
2037 | if (fb) |
2319 | if (fb) |
- | 2320 | drm_framebuffer_unreference(fb); |
|
- | 2321 | if (old_fb) |
|
- | 2322 | drm_framebuffer_unreference(old_fb); |
|
- | 2323 | ||
- | 2324 | return ret; |
|
- | 2325 | ||
- | 2326 | } |
|
- | 2327 | ||
- | 2328 | /** |
|
- | 2329 | * drm_mode_setplane - configure a plane's configuration |
|
- | 2330 | * @dev: DRM device |
|
- | 2331 | * @data: ioctl data* |
|
- | 2332 | * @file_priv: DRM file info |
|
- | 2333 | * |
|
- | 2334 | * Set plane configuration, including placement, fb, scaling, and other factors. |
|
- | 2335 | * Or pass a NULL fb to disable (planes may be disabled without providing a |
|
- | 2336 | * valid crtc). |
|
- | 2337 | * |
|
- | 2338 | * Returns: |
|
- | 2339 | * Zero on success, errno on failure. |
|
- | 2340 | */ |
|
- | 2341 | int drm_mode_setplane(struct drm_device *dev, void *data, |
|
- | 2342 | struct drm_file *file_priv) |
|
- | 2343 | { |
|
- | 2344 | struct drm_mode_set_plane *plane_req = data; |
|
- | 2345 | struct drm_mode_object *obj; |
|
- | 2346 | struct drm_plane *plane; |
|
- | 2347 | struct drm_crtc *crtc = NULL; |
|
- | 2348 | struct drm_framebuffer *fb = NULL; |
|
- | 2349 | ||
- | 2350 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2351 | return -EINVAL; |
|
- | 2352 | ||
- | 2353 | /* Give drivers some help against integer overflows */ |
|
- | 2354 | if (plane_req->crtc_w > INT_MAX || |
|
- | 2355 | plane_req->crtc_x > INT_MAX - (int32_t) plane_req->crtc_w || |
|
- | 2356 | plane_req->crtc_h > INT_MAX || |
|
- | 2357 | plane_req->crtc_y > INT_MAX - (int32_t) plane_req->crtc_h) { |
|
- | 2358 | DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n", |
|
- | 2359 | plane_req->crtc_w, plane_req->crtc_h, |
|
- | 2360 | plane_req->crtc_x, plane_req->crtc_y); |
|
- | 2361 | return -ERANGE; |
|
- | 2362 | } |
|
- | 2363 | ||
- | 2364 | /* |
|
- | 2365 | * First, find the plane, crtc, and fb objects. If not available, |
|
- | 2366 | * we don't bother to call the driver. |
|
- | 2367 | */ |
|
- | 2368 | obj = drm_mode_object_find(dev, plane_req->plane_id, |
|
- | 2369 | DRM_MODE_OBJECT_PLANE); |
|
- | 2370 | if (!obj) { |
|
- | 2371 | DRM_DEBUG_KMS("Unknown plane ID %d\n", |
|
- | 2372 | plane_req->plane_id); |
|
- | 2373 | return -ENOENT; |
|
- | 2374 | } |
|
- | 2375 | plane = obj_to_plane(obj); |
|
- | 2376 | ||
- | 2377 | if (plane_req->fb_id) { |
|
- | 2378 | fb = drm_framebuffer_lookup(dev, plane_req->fb_id); |
|
- | 2379 | if (!fb) { |
|
- | 2380 | DRM_DEBUG_KMS("Unknown framebuffer ID %d\n", |
|
- | 2381 | plane_req->fb_id); |
|
- | 2382 | return -ENOENT; |
|
- | 2383 | } |
|
- | 2384 | ||
- | 2385 | obj = drm_mode_object_find(dev, plane_req->crtc_id, |
|
- | 2386 | DRM_MODE_OBJECT_CRTC); |
|
- | 2387 | if (!obj) { |
|
- | 2388 | DRM_DEBUG_KMS("Unknown crtc ID %d\n", |
|
- | 2389 | plane_req->crtc_id); |
|
- | 2390 | return -ENOENT; |
|
- | 2391 | } |
|
- | 2392 | crtc = obj_to_crtc(obj); |
|
- | 2393 | } |
|
- | 2394 | ||
- | 2395 | /* |
|
- | 2396 | * setplane_internal will take care of deref'ing either the old or new |
|
- | 2397 | * framebuffer depending on success. |
|
- | 2398 | */ |
|
2038 | drm_framebuffer_unreference(fb); |
2399 | return setplane_internal(plane, crtc, fb, |
2039 | if (old_fb) |
2400 | plane_req->crtc_x, plane_req->crtc_y, |
Line 2040... | Line 2401... | ||
2040 | drm_framebuffer_unreference(old_fb); |
2401 | plane_req->crtc_w, plane_req->crtc_h, |
2041 | 2402 | plane_req->src_x, plane_req->src_y, |
|
2042 | return ret; |
2403 | plane_req->src_w, plane_req->src_h); |
2043 | } |
2404 | } |
2044 | #endif |
2405 | #endif |
2045 | 2406 | ||
- | 2407 | /** |
|
- | 2408 | * drm_mode_set_config_internal - helper to call ->set_config |
|
- | 2409 | * @set: modeset config to set |
|
2046 | /** |
2410 | * |
2047 | * drm_mode_set_config_internal - helper to call ->set_config |
2411 | * This is a little helper to wrap internal calls to the ->set_config driver |
2048 | * @set: modeset config to set |
2412 | * interface. The only thing it adds is correct refcounting dance. |
2049 | * |
2413 | * |
2050 | * This is a little helper to wrap internal calls to the ->set_config driver |
2414 | * Returns: |
Line 2061... | Line 2425... | ||
2061 | * NOTE: ->set_config can also disable other crtcs (if we steal all |
2425 | * NOTE: ->set_config can also disable other crtcs (if we steal all |
2062 | * connectors from it), hence we need to refcount the fbs across all |
2426 | * connectors from it), hence we need to refcount the fbs across all |
2063 | * crtcs. Atomic modeset will have saner semantics ... |
2427 | * crtcs. Atomic modeset will have saner semantics ... |
2064 | */ |
2428 | */ |
2065 | list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) |
2429 | list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) |
2066 | tmp->old_fb = tmp->fb; |
2430 | tmp->old_fb = tmp->primary->fb; |
Line 2067... | Line 2431... | ||
2067 | 2431 | ||
Line 2068... | Line 2432... | ||
2068 | fb = set->fb; |
2432 | fb = set->fb; |
2069 | 2433 | ||
2070 | ret = crtc->funcs->set_config(set); |
2434 | ret = crtc->funcs->set_config(set); |
2071 | if (ret == 0) { |
2435 | if (ret == 0) { |
2072 | /* crtc->fb must be updated by ->set_config, enforces this. */ |
2436 | crtc->primary->crtc = crtc; |
Line 2073... | Line 2437... | ||
2073 | WARN_ON(fb != crtc->fb); |
2437 | crtc->primary->fb = fb; |
2074 | } |
2438 | } |
2075 | 2439 | ||
2076 | list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) { |
2440 | list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) { |
2077 | if (tmp->fb) |
2441 | if (tmp->primary->fb) |
2078 | drm_framebuffer_reference(tmp->fb); |
2442 | drm_framebuffer_reference(tmp->primary->fb); |
Line 2079... | Line 2443... | ||
2079 | // if (tmp->old_fb) |
2443 | // if (tmp->old_fb) |
2080 | // drm_framebuffer_unreference(tmp->old_fb); |
2444 | // drm_framebuffer_unreference(tmp->old_fb); |
2081 | } |
2445 | } |
Line 2082... | Line 2446... | ||
2082 | 2446 | ||
2083 | return ret; |
2447 | return ret; |
2084 | } |
2448 | } |
2085 | EXPORT_SYMBOL(drm_mode_set_config_internal); |
2449 | EXPORT_SYMBOL(drm_mode_set_config_internal); |
- | 2450 | ||
- | 2451 | #if 0 |
|
- | 2452 | /** |
|
- | 2453 | * drm_crtc_check_viewport - Checks that a framebuffer is big enough for the |
|
- | 2454 | * CRTC viewport |
|
2086 | 2455 | * @crtc: CRTC that framebuffer will be displayed on |
|
2087 | #if 0 |
2456 | * @x: x panning |
2088 | /* |
2457 | * @y: y panning |
2089 | * Checks that the framebuffer is big enough for the CRTC viewport |
2458 | * @mode: mode that framebuffer will be displayed under |
2090 | * (x, y, hdisplay, vdisplay) |
2459 | * @fb: framebuffer to check size of |
Line 2091... | Line 2460... | ||
2091 | */ |
2460 | */ |
Line 2121... | Line 2490... | ||
2121 | return -ENOSPC; |
2490 | return -ENOSPC; |
2122 | } |
2491 | } |
Line 2123... | Line 2492... | ||
2123 | 2492 | ||
2124 | return 0; |
2493 | return 0; |
- | 2494 | } |
|
Line 2125... | Line 2495... | ||
2125 | } |
2495 | EXPORT_SYMBOL(drm_crtc_check_viewport); |
2126 | 2496 | ||
2127 | /** |
2497 | /** |
2128 | * drm_mode_setcrtc - set CRTC configuration |
2498 | * drm_mode_setcrtc - set CRTC configuration |
Line 2132... | Line 2502... | ||
2132 | * |
2502 | * |
2133 | * Build a new CRTC configuration based on user request. |
2503 | * Build a new CRTC configuration based on user request. |
2134 | * |
2504 | * |
2135 | * Called by the user via ioctl. |
2505 | * Called by the user via ioctl. |
2136 | * |
2506 | * |
2137 | * RETURNS: |
2507 | * Returns: |
2138 | * Zero on success, errno on failure. |
2508 | * Zero on success, errno on failure. |
2139 | */ |
2509 | */ |
2140 | int drm_mode_setcrtc(struct drm_device *dev, void *data, |
2510 | int drm_mode_setcrtc(struct drm_device *dev, void *data, |
2141 | struct drm_file *file_priv) |
2511 | struct drm_file *file_priv) |
2142 | { |
2512 | { |
2143 | struct drm_mode_config *config = &dev->mode_config; |
2513 | struct drm_mode_config *config = &dev->mode_config; |
2144 | struct drm_mode_crtc *crtc_req = data; |
2514 | struct drm_mode_crtc *crtc_req = data; |
2145 | struct drm_mode_object *obj; |
- | |
2146 | struct drm_crtc *crtc; |
2515 | struct drm_crtc *crtc; |
2147 | struct drm_connector **connector_set = NULL, *connector; |
2516 | struct drm_connector **connector_set = NULL, *connector; |
2148 | struct drm_framebuffer *fb = NULL; |
2517 | struct drm_framebuffer *fb = NULL; |
2149 | struct drm_display_mode *mode = NULL; |
2518 | struct drm_display_mode *mode = NULL; |
2150 | struct drm_mode_set set; |
2519 | struct drm_mode_set set; |
Line 2158... | Line 2527... | ||
2158 | /* For some reason crtc x/y offsets are signed internally. */ |
2527 | /* For some reason crtc x/y offsets are signed internally. */ |
2159 | if (crtc_req->x > INT_MAX || crtc_req->y > INT_MAX) |
2528 | if (crtc_req->x > INT_MAX || crtc_req->y > INT_MAX) |
2160 | return -ERANGE; |
2529 | return -ERANGE; |
Line 2161... | Line 2530... | ||
2161 | 2530 | ||
2162 | drm_modeset_lock_all(dev); |
2531 | drm_modeset_lock_all(dev); |
2163 | obj = drm_mode_object_find(dev, crtc_req->crtc_id, |
- | |
2164 | DRM_MODE_OBJECT_CRTC); |
2532 | crtc = drm_crtc_find(dev, crtc_req->crtc_id); |
2165 | if (!obj) { |
2533 | if (!crtc) { |
2166 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id); |
2534 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id); |
2167 | ret = -ENOENT; |
2535 | ret = -ENOENT; |
2168 | goto out; |
2536 | goto out; |
2169 | } |
- | |
2170 | crtc = obj_to_crtc(obj); |
2537 | } |
Line 2171... | Line 2538... | ||
2171 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
2538 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
2172 | 2539 | ||
2173 | if (crtc_req->mode_valid) { |
2540 | if (crtc_req->mode_valid) { |
2174 | /* If we have a mode we need a framebuffer. */ |
2541 | /* If we have a mode we need a framebuffer. */ |
2175 | /* If we pass -1, set the mode with the currently bound fb */ |
2542 | /* If we pass -1, set the mode with the currently bound fb */ |
2176 | if (crtc_req->fb_id == -1) { |
2543 | if (crtc_req->fb_id == -1) { |
2177 | if (!crtc->fb) { |
2544 | if (!crtc->primary->fb) { |
2178 | DRM_DEBUG_KMS("CRTC doesn't have current FB\n"); |
2545 | DRM_DEBUG_KMS("CRTC doesn't have current FB\n"); |
2179 | ret = -EINVAL; |
2546 | ret = -EINVAL; |
2180 | goto out; |
2547 | goto out; |
2181 | } |
2548 | } |
2182 | fb = crtc->fb; |
2549 | fb = crtc->primary->fb; |
2183 | /* Make refcounting symmetric with the lookup path. */ |
2550 | /* Make refcounting symmetric with the lookup path. */ |
2184 | drm_framebuffer_reference(fb); |
2551 | drm_framebuffer_reference(fb); |
2185 | } else { |
2552 | } else { |
Line 2248... | Line 2615... | ||
2248 | if (get_user(out_id, &set_connectors_ptr[i])) { |
2615 | if (get_user(out_id, &set_connectors_ptr[i])) { |
2249 | ret = -EFAULT; |
2616 | ret = -EFAULT; |
2250 | goto out; |
2617 | goto out; |
2251 | } |
2618 | } |
Line 2252... | Line 2619... | ||
2252 | 2619 | ||
2253 | obj = drm_mode_object_find(dev, out_id, |
- | |
2254 | DRM_MODE_OBJECT_CONNECTOR); |
2620 | connector = drm_connector_find(dev, out_id); |
2255 | if (!obj) { |
2621 | if (!connector) { |
2256 | DRM_DEBUG_KMS("Connector id %d unknown\n", |
2622 | DRM_DEBUG_KMS("Connector id %d unknown\n", |
2257 | out_id); |
2623 | out_id); |
2258 | ret = -ENOENT; |
2624 | ret = -ENOENT; |
2259 | goto out; |
2625 | goto out; |
2260 | } |
- | |
2261 | connector = obj_to_connector(obj); |
2626 | } |
2262 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
2627 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
2263 | connector->base.id, |
2628 | connector->base.id, |
Line 2264... | Line 2629... | ||
2264 | drm_get_connector_name(connector)); |
2629 | connector->name); |
2265 | 2630 | ||
2266 | connector_set[i] = connector; |
2631 | connector_set[i] = connector; |
Line 2288... | Line 2653... | ||
2288 | 2653 | ||
2289 | static int drm_mode_cursor_common(struct drm_device *dev, |
2654 | static int drm_mode_cursor_common(struct drm_device *dev, |
2290 | struct drm_mode_cursor2 *req, |
2655 | struct drm_mode_cursor2 *req, |
2291 | struct drm_file *file_priv) |
2656 | struct drm_file *file_priv) |
2292 | { |
- | |
2293 | struct drm_mode_object *obj; |
2657 | { |
2294 | struct drm_crtc *crtc; |
2658 | struct drm_crtc *crtc; |
Line 2295... | Line 2659... | ||
2295 | int ret = 0; |
2659 | int ret = 0; |
2296 | 2660 | ||
Line 2297... | Line 2661... | ||
2297 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2661 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2298 | return -EINVAL; |
2662 | return -EINVAL; |
Line 2299... | Line 2663... | ||
2299 | 2663 | ||
2300 | if (!req->flags || (~DRM_MODE_CURSOR_FLAGS & req->flags)) |
2664 | if (!req->flags || (~DRM_MODE_CURSOR_FLAGS & req->flags)) |
2301 | return -EINVAL; |
2665 | return -EINVAL; |
2302 | 2666 | ||
2303 | obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC); |
2667 | crtc = drm_crtc_find(dev, req->crtc_id); |
2304 | if (!obj) { |
- | |
Line -... | Line 2668... | ||
- | 2668 | if (!crtc) { |
|
- | 2669 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id); |
|
- | 2670 | return -ENOENT; |
|
- | 2671 | } |
|
- | 2672 | ||
- | 2673 | /* |
|
- | 2674 | * If this crtc has a universal cursor plane, call that plane's update |
|
2305 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id); |
2675 | * handler rather than using legacy cursor handlers. |
2306 | return -ENOENT; |
2676 | */ |
2307 | } |
2677 | if (crtc->cursor) |
2308 | crtc = obj_to_crtc(obj); |
2678 | return drm_mode_cursor_universal(crtc, req, file_priv); |
2309 | 2679 | ||
2310 | mutex_lock(&crtc->mutex); |
2680 | drm_modeset_lock(&crtc->mutex, NULL); |
Line 2329... | Line 2699... | ||
2329 | ret = -EFAULT; |
2699 | ret = -EFAULT; |
2330 | goto out; |
2700 | goto out; |
2331 | } |
2701 | } |
2332 | } |
2702 | } |
2333 | out: |
2703 | out: |
2334 | mutex_unlock(&crtc->mutex); |
2704 | drm_modeset_unlock(&crtc->mutex); |
Line 2335... | Line 2705... | ||
2335 | 2705 | ||
Line 2336... | Line 2706... | ||
2336 | return ret; |
2706 | return ret; |
- | 2707 | ||
- | 2708 | } |
|
- | 2709 | ||
- | 2710 | ||
- | 2711 | /** |
|
- | 2712 | * drm_mode_cursor_ioctl - set CRTC's cursor configuration |
|
- | 2713 | * @dev: drm device for the ioctl |
|
- | 2714 | * @data: data pointer for the ioctl |
|
- | 2715 | * @file_priv: drm file for the ioctl call |
|
- | 2716 | * |
|
- | 2717 | * Set the cursor configuration based on user request. |
|
- | 2718 | * |
|
- | 2719 | * Called by the user via ioctl. |
|
- | 2720 | * |
|
- | 2721 | * Returns: |
|
2337 | 2722 | * Zero on success, errno on failure. |
|
2338 | } |
2723 | */ |
2339 | int drm_mode_cursor_ioctl(struct drm_device *dev, |
2724 | int drm_mode_cursor_ioctl(struct drm_device *dev, |
2340 | void *data, struct drm_file *file_priv) |
2725 | void *data, struct drm_file *file_priv) |
2341 | { |
2726 | { |
Line 2346... | Line 2731... | ||
2346 | new_req.hot_x = new_req.hot_y = 0; |
2731 | new_req.hot_x = new_req.hot_y = 0; |
Line 2347... | Line 2732... | ||
2347 | 2732 | ||
2348 | return drm_mode_cursor_common(dev, &new_req, file_priv); |
2733 | return drm_mode_cursor_common(dev, &new_req, file_priv); |
Line -... | Line 2734... | ||
- | 2734 | } |
|
- | 2735 | ||
- | 2736 | /** |
|
- | 2737 | * drm_mode_cursor2_ioctl - set CRTC's cursor configuration |
|
- | 2738 | * @dev: drm device for the ioctl |
|
- | 2739 | * @data: data pointer for the ioctl |
|
- | 2740 | * @file_priv: drm file for the ioctl call |
|
- | 2741 | * |
|
- | 2742 | * Set the cursor configuration based on user request. This implements the 2nd |
|
- | 2743 | * version of the cursor ioctl, which allows userspace to additionally specify |
|
- | 2744 | * the hotspot of the pointer. |
|
- | 2745 | * |
|
- | 2746 | * Called by the user via ioctl. |
|
- | 2747 | * |
|
- | 2748 | * Returns: |
|
2349 | } |
2749 | * Zero on success, errno on failure. |
2350 | 2750 | */ |
|
2351 | int drm_mode_cursor2_ioctl(struct drm_device *dev, |
2751 | int drm_mode_cursor2_ioctl(struct drm_device *dev, |
2352 | void *data, struct drm_file *file_priv) |
2752 | void *data, struct drm_file *file_priv) |
2353 | { |
2753 | { |
2354 | struct drm_mode_cursor2 *req = data; |
2754 | struct drm_mode_cursor2 *req = data; |
2355 | return drm_mode_cursor_common(dev, req, file_priv); |
2755 | return drm_mode_cursor_common(dev, req, file_priv); |
Line -... | Line 2756... | ||
- | 2756 | } |
|
- | 2757 | #endif |
|
- | 2758 | ||
- | 2759 | /** |
|
- | 2760 | * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description |
|
2356 | } |
2761 | * @bpp: bits per pixels |
- | 2762 | * @depth: bit depth per pixel |
|
- | 2763 | * |
|
2357 | #endif |
2764 | * Computes a drm fourcc pixel format code for the given @bpp/@depth values. |
2358 | 2765 | * Useful in fbdev emulation code, since that deals in those values. |
|
2359 | /* Original addfb only supported RGB formats, so figure out which one */ |
2766 | */ |
Line 2360... | Line 2767... | ||
2360 | uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth) |
2767 | uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth) |
Line 2396... | Line 2803... | ||
2396 | * drm_mode_addfb - add an FB to the graphics configuration |
2803 | * drm_mode_addfb - add an FB to the graphics configuration |
2397 | * @dev: drm device for the ioctl |
2804 | * @dev: drm device for the ioctl |
2398 | * @data: data pointer for the ioctl |
2805 | * @data: data pointer for the ioctl |
2399 | * @file_priv: drm file for the ioctl call |
2806 | * @file_priv: drm file for the ioctl call |
2400 | * |
2807 | * |
2401 | * Add a new FB to the specified CRTC, given a user request. |
2808 | * Add a new FB to the specified CRTC, given a user request. This is the |
- | 2809 | * original addfb ioclt which only supported RGB formats. |
|
2402 | * |
2810 | * |
2403 | * Called by the user via ioctl. |
2811 | * Called by the user via ioctl. |
2404 | * |
2812 | * |
2405 | * RETURNS: |
2813 | * Returns: |
2406 | * Zero on success, errno on failure. |
2814 | * Zero on success, errno on failure. |
2407 | */ |
2815 | */ |
2408 | int drm_mode_addfb(struct drm_device *dev, |
2816 | int drm_mode_addfb(struct drm_device *dev, |
2409 | void *data, struct drm_file *file_priv) |
2817 | void *data, struct drm_file *file_priv) |
2410 | { |
2818 | { |
Line 2567... | Line 2975... | ||
2567 | } |
2975 | } |
Line 2568... | Line 2976... | ||
2568 | 2976 | ||
2569 | return 0; |
2977 | return 0; |
Line 2570... | Line -... | ||
2570 | } |
- | |
2571 | 2978 | } |
|
2572 | /** |
- | |
2573 | * drm_mode_addfb2 - add an FB to the graphics configuration |
- | |
2574 | * @dev: drm device for the ioctl |
- | |
2575 | * @data: data pointer for the ioctl |
- | |
2576 | * @file_priv: drm file for the ioctl call |
- | |
2577 | * |
- | |
2578 | * Add a new FB to the specified CRTC, given a user request with format. |
- | |
2579 | * |
- | |
2580 | * Called by the user via ioctl. |
- | |
2581 | * |
- | |
2582 | * RETURNS: |
- | |
2583 | * Zero on success, errno on failure. |
2979 | |
2584 | */ |
2980 | static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, |
2585 | int drm_mode_addfb2(struct drm_device *dev, |
2981 | struct drm_mode_fb_cmd2 *r, |
2586 | void *data, struct drm_file *file_priv) |
- | |
2587 | { |
2982 | struct drm_file *file_priv) |
2588 | struct drm_mode_fb_cmd2 *r = data; |
2983 | { |
2589 | struct drm_mode_config *config = &dev->mode_config; |
2984 | struct drm_mode_config *config = &dev->mode_config; |
Line 2590... | Line -... | ||
2590 | struct drm_framebuffer *fb; |
- | |
2591 | int ret; |
- | |
2592 | - | ||
2593 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2985 | struct drm_framebuffer *fb; |
2594 | return -EINVAL; |
2986 | int ret; |
2595 | 2987 | ||
2596 | if (r->flags & ~DRM_MODE_FB_INTERLACED) { |
2988 | if (r->flags & ~DRM_MODE_FB_INTERLACED) { |
Line 2597... | Line 2989... | ||
2597 | DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags); |
2989 | DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags); |
2598 | return -EINVAL; |
2990 | return ERR_PTR(-EINVAL); |
2599 | } |
2991 | } |
2600 | 2992 | ||
2601 | if ((config->min_width > r->width) || (r->width > config->max_width)) { |
2993 | if ((config->min_width > r->width) || (r->width > config->max_width)) { |
2602 | DRM_DEBUG_KMS("bad framebuffer width %d, should be >= %d && <= %d\n", |
2994 | DRM_DEBUG_KMS("bad framebuffer width %d, should be >= %d && <= %d\n", |
2603 | r->width, config->min_width, config->max_width); |
2995 | r->width, config->min_width, config->max_width); |
2604 | return -EINVAL; |
2996 | return ERR_PTR(-EINVAL); |
2605 | } |
2997 | } |
2606 | if ((config->min_height > r->height) || (r->height > config->max_height)) { |
2998 | if ((config->min_height > r->height) || (r->height > config->max_height)) { |
Line 2607... | Line 2999... | ||
2607 | DRM_DEBUG_KMS("bad framebuffer height %d, should be >= %d && <= %d\n", |
2999 | DRM_DEBUG_KMS("bad framebuffer height %d, should be >= %d && <= %d\n", |
2608 | r->height, config->min_height, config->max_height); |
3000 | r->height, config->min_height, config->max_height); |
2609 | return -EINVAL; |
3001 | return ERR_PTR(-EINVAL); |
Line 2610... | Line 3002... | ||
2610 | } |
3002 | } |
2611 | 3003 | ||
2612 | ret = framebuffer_check(r); |
3004 | ret = framebuffer_check(r); |
2613 | if (ret) |
3005 | if (ret) |
2614 | return ret; |
3006 | return ERR_PTR(ret); |
Line 2615... | Line 3007... | ||
2615 | 3007 | ||
2616 | fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); |
3008 | fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); |
2617 | if (IS_ERR(fb)) { |
3009 | if (IS_ERR(fb)) { |
2618 | DRM_DEBUG_KMS("could not create framebuffer\n"); |
3010 | DRM_DEBUG_KMS("could not create framebuffer\n"); |
2619 | return PTR_ERR(fb); |
3011 | return fb; |
Line -... | Line 3012... | ||
- | 3012 | } |
|
- | 3013 | ||
Line -... | Line 3014... | ||
- | 3014 | mutex_lock(&file_priv->fbs_lock); |
|
- | 3015 | r->fb_id = fb->base.id; |
|
- | 3016 | list_add(&fb->filp_head, &file_priv->fbs); |
|
- | 3017 | DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); |
|
- | 3018 | mutex_unlock(&file_priv->fbs_lock); |
|
- | 3019 | ||
- | 3020 | return fb; |
|
- | 3021 | } |
|
- | 3022 | ||
- | 3023 | /** |
|
- | 3024 | * drm_mode_addfb2 - add an FB to the graphics configuration |
|
- | 3025 | * @dev: drm device for the ioctl |
|
- | 3026 | * @data: data pointer for the ioctl |
|
- | 3027 | * @file_priv: drm file for the ioctl call |
|
- | 3028 | * |
|
- | 3029 | * Add a new FB to the specified CRTC, given a user request with format. This is |
|
- | 3030 | * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers |
|
- | 3031 | * and uses fourcc codes as pixel format specifiers. |
|
- | 3032 | * |
|
- | 3033 | * Called by the user via ioctl. |
|
- | 3034 | * |
|
- | 3035 | * Returns: |
|
- | 3036 | * Zero on success, errno on failure. |
|
- | 3037 | */ |
|
- | 3038 | int drm_mode_addfb2(struct drm_device *dev, |
|
- | 3039 | void *data, struct drm_file *file_priv) |
|
- | 3040 | { |
|
2620 | } |
3041 | struct drm_framebuffer *fb; |
2621 | 3042 | ||
Line 2622... | Line 3043... | ||
2622 | mutex_lock(&file_priv->fbs_lock); |
3043 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2623 | r->fb_id = fb->base.id; |
3044 | return -EINVAL; |
2624 | list_add(&fb->filp_head, &file_priv->fbs); |
3045 | |
Line 2637... | Line 3058... | ||
2637 | * |
3058 | * |
2638 | * Remove the FB specified by the user. |
3059 | * Remove the FB specified by the user. |
2639 | * |
3060 | * |
2640 | * Called by the user via ioctl. |
3061 | * Called by the user via ioctl. |
2641 | * |
3062 | * |
2642 | * RETURNS: |
3063 | * Returns: |
2643 | * Zero on success, errno on failure. |
3064 | * Zero on success, errno on failure. |
2644 | */ |
3065 | */ |
2645 | int drm_mode_rmfb(struct drm_device *dev, |
3066 | int drm_mode_rmfb(struct drm_device *dev, |
2646 | void *data, struct drm_file *file_priv) |
3067 | void *data, struct drm_file *file_priv) |
2647 | { |
3068 | { |
Line 2691... | Line 3112... | ||
2691 | * |
3112 | * |
2692 | * Lookup the FB given its ID and return info about it. |
3113 | * Lookup the FB given its ID and return info about it. |
2693 | * |
3114 | * |
2694 | * Called by the user via ioctl. |
3115 | * Called by the user via ioctl. |
2695 | * |
3116 | * |
2696 | * RETURNS: |
3117 | * Returns: |
2697 | * Zero on success, errno on failure. |
3118 | * Zero on success, errno on failure. |
2698 | */ |
3119 | */ |
2699 | int drm_mode_getfb(struct drm_device *dev, |
3120 | int drm_mode_getfb(struct drm_device *dev, |
2700 | void *data, struct drm_file *file_priv) |
3121 | void *data, struct drm_file *file_priv) |
2701 | { |
3122 | { |
Line 2735... | Line 3156... | ||
2735 | drm_framebuffer_unreference(fb); |
3156 | drm_framebuffer_unreference(fb); |
Line 2736... | Line 3157... | ||
2736 | 3157 | ||
2737 | return ret; |
3158 | return ret; |
Line -... | Line 3159... | ||
- | 3159 | } |
|
- | 3160 | ||
- | 3161 | /** |
|
- | 3162 | * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB |
|
- | 3163 | * @dev: drm device for the ioctl |
|
- | 3164 | * @data: data pointer for the ioctl |
|
- | 3165 | * @file_priv: drm file for the ioctl call |
|
- | 3166 | * |
|
- | 3167 | * Lookup the FB and flush out the damaged area supplied by userspace as a clip |
|
- | 3168 | * rectangle list. Generic userspace which does frontbuffer rendering must call |
|
- | 3169 | * this ioctl to flush out the changes on manual-update display outputs, e.g. |
|
- | 3170 | * usb display-link, mipi manual update panels or edp panel self refresh modes. |
|
- | 3171 | * |
|
- | 3172 | * Modesetting drivers which always update the frontbuffer do not need to |
|
- | 3173 | * implement the corresponding ->dirty framebuffer callback. |
|
- | 3174 | * |
|
- | 3175 | * Called by the user via ioctl. |
|
- | 3176 | * |
|
- | 3177 | * Returns: |
|
2738 | } |
3178 | * Zero on success, errno on failure. |
2739 | 3179 | */ |
|
2740 | int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
3180 | int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
2741 | void *data, struct drm_file *file_priv) |
3181 | void *data, struct drm_file *file_priv) |
2742 | { |
3182 | { |
Line 2812... | Line 3252... | ||
2812 | * |
3252 | * |
2813 | * Destroy all the FBs associated with @filp. |
3253 | * Destroy all the FBs associated with @filp. |
2814 | * |
3254 | * |
2815 | * Called by the user via ioctl. |
3255 | * Called by the user via ioctl. |
2816 | * |
3256 | * |
2817 | * RETURNS: |
3257 | * Returns: |
2818 | * Zero on success, errno on failure. |
3258 | * Zero on success, errno on failure. |
2819 | */ |
3259 | */ |
2820 | void drm_fb_release(struct drm_file *priv) |
3260 | void drm_fb_release(struct drm_file *priv) |
2821 | { |
3261 | { |
2822 | struct drm_device *dev = priv->minor->dev; |
3262 | struct drm_device *dev = priv->minor->dev; |
Line 2838... | Line 3278... | ||
2838 | mutex_unlock(&priv->fbs_lock); |
3278 | mutex_unlock(&priv->fbs_lock); |
2839 | } |
3279 | } |
2840 | #endif |
3280 | #endif |
Line -... | Line 3281... | ||
- | 3281 | ||
- | 3282 | ||
- | 3283 | /** |
|
- | 3284 | * drm_property_create - create a new property type |
|
- | 3285 | * @dev: drm device |
|
- | 3286 | * @flags: flags specifying the property type |
|
- | 3287 | * @name: name of the property |
|
- | 3288 | * @num_values: number of pre-defined values |
|
- | 3289 | * |
|
- | 3290 | * This creates a new generic drm property which can then be attached to a drm |
|
- | 3291 | * object with drm_object_attach_property. The returned property object must be |
|
- | 3292 | * freed with drm_property_destroy. |
|
- | 3293 | * |
|
- | 3294 | * Returns: |
|
2841 | 3295 | * A pointer to the newly created property on success, NULL on failure. |
|
2842 | 3296 | */ |
|
2843 | struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
3297 | struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
2844 | const char *name, int num_values) |
3298 | const char *name, int num_values) |
2845 | { |
3299 | { |
Line 2846... | Line 3300... | ||
2846 | struct drm_property *property = NULL; |
3300 | struct drm_property *property = NULL; |
2847 | int ret; |
3301 | int ret; |
2848 | 3302 | ||
Line -... | Line 3303... | ||
- | 3303 | property = kzalloc(sizeof(struct drm_property), GFP_KERNEL); |
|
- | 3304 | if (!property) |
|
2849 | property = kzalloc(sizeof(struct drm_property), GFP_KERNEL); |
3305 | return NULL; |
2850 | if (!property) |
3306 | |
2851 | return NULL; |
3307 | property->dev = dev; |
2852 | 3308 | ||
2853 | if (num_values) { |
3309 | if (num_values) { |
Line 2868... | Line 3324... | ||
2868 | strncpy(property->name, name, DRM_PROP_NAME_LEN); |
3324 | strncpy(property->name, name, DRM_PROP_NAME_LEN); |
2869 | property->name[DRM_PROP_NAME_LEN-1] = '\0'; |
3325 | property->name[DRM_PROP_NAME_LEN-1] = '\0'; |
2870 | } |
3326 | } |
Line 2871... | Line 3327... | ||
2871 | 3327 | ||
- | 3328 | list_add_tail(&property->head, &dev->mode_config.property_list); |
|
- | 3329 | ||
- | 3330 | WARN_ON(!drm_property_type_valid(property)); |
|
2872 | list_add_tail(&property->head, &dev->mode_config.property_list); |
3331 | |
2873 | return property; |
3332 | return property; |
2874 | fail: |
3333 | fail: |
2875 | kfree(property->values); |
3334 | kfree(property->values); |
2876 | kfree(property); |
3335 | kfree(property); |
2877 | return NULL; |
3336 | return NULL; |
2878 | } |
3337 | } |
Line -... | Line 3338... | ||
- | 3338 | EXPORT_SYMBOL(drm_property_create); |
|
- | 3339 | ||
- | 3340 | /** |
|
- | 3341 | * drm_property_create_enum - create a new enumeration property type |
|
- | 3342 | * @dev: drm device |
|
- | 3343 | * @flags: flags specifying the property type |
|
- | 3344 | * @name: name of the property |
|
- | 3345 | * @props: enumeration lists with property values |
|
- | 3346 | * @num_values: number of pre-defined values |
|
- | 3347 | * |
|
- | 3348 | * This creates a new generic drm property which can then be attached to a drm |
|
- | 3349 | * object with drm_object_attach_property. The returned property object must be |
|
- | 3350 | * freed with drm_property_destroy. |
|
- | 3351 | * |
|
- | 3352 | * Userspace is only allowed to set one of the predefined values for enumeration |
|
- | 3353 | * properties. |
|
- | 3354 | * |
|
- | 3355 | * Returns: |
|
2879 | EXPORT_SYMBOL(drm_property_create); |
3356 | * A pointer to the newly created property on success, NULL on failure. |
2880 | 3357 | */ |
|
2881 | struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
3358 | struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
2882 | const char *name, |
3359 | const char *name, |
2883 | const struct drm_prop_enum_list *props, |
3360 | const struct drm_prop_enum_list *props, |
Line 2904... | Line 3381... | ||
2904 | 3381 | ||
2905 | return property; |
3382 | return property; |
2906 | } |
3383 | } |
Line -... | Line 3384... | ||
- | 3384 | EXPORT_SYMBOL(drm_property_create_enum); |
|
- | 3385 | ||
- | 3386 | /** |
|
- | 3387 | * drm_property_create_bitmask - create a new bitmask property type |
|
- | 3388 | * @dev: drm device |
|
- | 3389 | * @flags: flags specifying the property type |
|
- | 3390 | * @name: name of the property |
|
- | 3391 | * @props: enumeration lists with property bitflags |
|
- | 3392 | * @num_values: number of pre-defined values |
|
- | 3393 | * |
|
- | 3394 | * This creates a new generic drm property which can then be attached to a drm |
|
- | 3395 | * object with drm_object_attach_property. The returned property object must be |
|
- | 3396 | * freed with drm_property_destroy. |
|
- | 3397 | * |
|
- | 3398 | * Compared to plain enumeration properties userspace is allowed to set any |
|
- | 3399 | * or'ed together combination of the predefined property bitflag values |
|
- | 3400 | * |
|
- | 3401 | * Returns: |
|
2907 | EXPORT_SYMBOL(drm_property_create_enum); |
3402 | * A pointer to the newly created property on success, NULL on failure. |
2908 | 3403 | */ |
|
2909 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, |
3404 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, |
2910 | int flags, const char *name, |
3405 | int flags, const char *name, |
- | 3406 | const struct drm_prop_enum_list *props, |
|
2911 | const struct drm_prop_enum_list *props, |
3407 | int num_props, |
2912 | int num_values) |
3408 | uint64_t supported_bits) |
2913 | { |
3409 | { |
- | 3410 | struct drm_property *property; |
|
Line 2914... | Line 3411... | ||
2914 | struct drm_property *property; |
3411 | int i, ret, index = 0; |
Line 2915... | Line 3412... | ||
2915 | int i, ret; |
3412 | int num_values = hweight64(supported_bits); |
2916 | 3413 | ||
2917 | flags |= DRM_MODE_PROP_BITMASK; |
3414 | flags |= DRM_MODE_PROP_BITMASK; |
- | 3415 | ||
- | 3416 | property = drm_property_create(dev, flags, name, num_values); |
|
- | 3417 | if (!property) |
|
Line 2918... | Line 3418... | ||
2918 | 3418 | return NULL; |
|
- | 3419 | for (i = 0; i < num_props; i++) { |
|
- | 3420 | if (!(supported_bits & (1ULL << props[i].type))) |
|
- | 3421 | continue; |
|
- | 3422 | ||
2919 | property = drm_property_create(dev, flags, name, num_values); |
3423 | if (WARN_ON(index >= num_values)) { |
2920 | if (!property) |
3424 | drm_property_destroy(dev, property); |
2921 | return NULL; |
3425 | return NULL; |
2922 | 3426 | } |
|
2923 | for (i = 0; i < num_values; i++) { |
3427 | |
2924 | ret = drm_property_add_enum(property, i, |
3428 | ret = drm_property_add_enum(property, index++, |
Line 2932... | Line 3436... | ||
2932 | 3436 | ||
2933 | return property; |
3437 | return property; |
2934 | } |
3438 | } |
Line 2935... | Line 3439... | ||
2935 | EXPORT_SYMBOL(drm_property_create_bitmask); |
3439 | EXPORT_SYMBOL(drm_property_create_bitmask); |
2936 | 3440 | ||
2937 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
3441 | static struct drm_property *property_create_range(struct drm_device *dev, |
2938 | const char *name, |
3442 | int flags, const char *name, |
2939 | uint64_t min, uint64_t max) |
3443 | uint64_t min, uint64_t max) |
Line 2940... | Line -... | ||
2940 | { |
- | |
2941 | struct drm_property *property; |
- | |
2942 | 3444 | { |
|
2943 | flags |= DRM_MODE_PROP_RANGE; |
3445 | struct drm_property *property; |
2944 | 3446 | ||
Line 2945... | Line 3447... | ||
2945 | property = drm_property_create(dev, flags, name, 2); |
3447 | property = drm_property_create(dev, flags, name, 2); |
2946 | if (!property) |
3448 | if (!property) |
Line 2947... | Line 3449... | ||
2947 | return NULL; |
3449 | return NULL; |
2948 | 3450 | ||
- | 3451 | property->values[0] = min; |
|
- | 3452 | property->values[1] = max; |
|
- | 3453 | ||
- | 3454 | return property; |
|
- | 3455 | } |
|
- | 3456 | ||
- | 3457 | /** |
|
- | 3458 | * drm_property_create_range - create a new ranged property type |
|
- | 3459 | * @dev: drm device |
|
- | 3460 | * @flags: flags specifying the property type |
|
- | 3461 | * @name: name of the property |
|
- | 3462 | * @min: minimum value of the property |
|
- | 3463 | * @max: maximum value of the property |
|
- | 3464 | * |
|
- | 3465 | * This creates a new generic drm property which can then be attached to a drm |
|
- | 3466 | * object with drm_object_attach_property. The returned property object must be |
|
- | 3467 | * freed with drm_property_destroy. |
|
- | 3468 | * |
|
- | 3469 | * Userspace is allowed to set any interger value in the (min, max) range |
|
- | 3470 | * inclusive. |
|
- | 3471 | * |
|
- | 3472 | * Returns: |
|
- | 3473 | * A pointer to the newly created property on success, NULL on failure. |
|
- | 3474 | */ |
|
- | 3475 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
|
- | 3476 | const char *name, |
|
2949 | property->values[0] = min; |
3477 | uint64_t min, uint64_t max) |
Line -... | Line 3478... | ||
- | 3478 | { |
|
- | 3479 | return property_create_range(dev, DRM_MODE_PROP_RANGE | flags, |
|
- | 3480 | name, min, max); |
|
- | 3481 | } |
|
- | 3482 | EXPORT_SYMBOL(drm_property_create_range); |
|
- | 3483 | ||
- | 3484 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
|
- | 3485 | int flags, const char *name, |
|
- | 3486 | int64_t min, int64_t max) |
|
- | 3487 | { |
|
- | 3488 | return property_create_range(dev, DRM_MODE_PROP_SIGNED_RANGE | flags, |
|
- | 3489 | name, I642U64(min), I642U64(max)); |
|
- | 3490 | } |
|
- | 3491 | EXPORT_SYMBOL(drm_property_create_signed_range); |
|
- | 3492 | ||
- | 3493 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
|
- | 3494 | int flags, const char *name, uint32_t type) |
|
- | 3495 | { |
|
- | 3496 | struct drm_property *property; |
|
- | 3497 | ||
- | 3498 | flags |= DRM_MODE_PROP_OBJECT; |
|
- | 3499 | ||
- | 3500 | property = drm_property_create(dev, flags, name, 1); |
|
- | 3501 | if (!property) |
|
- | 3502 | return NULL; |
|
- | 3503 | ||
- | 3504 | property->values[0] = type; |
|
- | 3505 | ||
- | 3506 | return property; |
|
- | 3507 | } |
|
- | 3508 | EXPORT_SYMBOL(drm_property_create_object); |
|
- | 3509 | ||
- | 3510 | /** |
|
- | 3511 | * drm_property_add_enum - add a possible value to an enumeration property |
|
- | 3512 | * @property: enumeration property to change |
|
- | 3513 | * @index: index of the new enumeration |
|
- | 3514 | * @value: value of the new enumeration |
|
- | 3515 | * @name: symbolic name of the new enumeration |
|
- | 3516 | * |
|
- | 3517 | * This functions adds enumerations to a property. |
|
- | 3518 | * |
|
2950 | property->values[1] = max; |
3519 | * It's use is deprecated, drivers should use one of the more specific helpers |
2951 | 3520 | * to directly create the property with all enumerations already attached. |
|
2952 | return property; |
3521 | * |
2953 | } |
3522 | * Returns: |
Line -... | Line 3523... | ||
- | 3523 | * Zero on success, error code on failure. |
|
2954 | EXPORT_SYMBOL(drm_property_create_range); |
3524 | */ |
2955 | 3525 | int drm_property_add_enum(struct drm_property *property, int index, |
|
Line 2956... | Line 3526... | ||
2956 | int drm_property_add_enum(struct drm_property *property, int index, |
3526 | uint64_t value, const char *name) |
2957 | uint64_t value, const char *name) |
3527 | { |
2958 | { |
3528 | struct drm_property_enum *prop_enum; |
2959 | struct drm_property_enum *prop_enum; |
3529 | |
2960 | 3530 | if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) || |
|
- | 3531 | drm_property_type_is(property, DRM_MODE_PROP_BITMASK))) |
|
2961 | if (!(property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK))) |
3532 | return -EINVAL; |
Line 2962... | Line 3533... | ||
2962 | return -EINVAL; |
3533 | |
2963 | 3534 | /* |
|
2964 | /* |
3535 | * Bitmask enum properties have the additional constraint of values |
Line 2990... | Line 3561... | ||
2990 | list_add_tail(&prop_enum->head, &property->enum_blob_list); |
3561 | list_add_tail(&prop_enum->head, &property->enum_blob_list); |
2991 | return 0; |
3562 | return 0; |
2992 | } |
3563 | } |
2993 | EXPORT_SYMBOL(drm_property_add_enum); |
3564 | EXPORT_SYMBOL(drm_property_add_enum); |
Line -... | Line 3565... | ||
- | 3565 | ||
- | 3566 | /** |
|
- | 3567 | * drm_property_destroy - destroy a drm property |
|
- | 3568 | * @dev: drm device |
|
- | 3569 | * @property: property to destry |
|
- | 3570 | * |
|
- | 3571 | * This function frees a property including any attached resources like |
|
- | 3572 | * enumeration values. |
|
2994 | 3573 | */ |
|
2995 | void drm_property_destroy(struct drm_device *dev, struct drm_property *property) |
3574 | void drm_property_destroy(struct drm_device *dev, struct drm_property *property) |
2996 | { |
3575 | { |
Line 2997... | Line 3576... | ||
2997 | struct drm_property_enum *prop_enum, *pt; |
3576 | struct drm_property_enum *prop_enum, *pt; |
Line 3007... | Line 3586... | ||
3007 | list_del(&property->head); |
3586 | list_del(&property->head); |
3008 | kfree(property); |
3587 | kfree(property); |
3009 | } |
3588 | } |
3010 | EXPORT_SYMBOL(drm_property_destroy); |
3589 | EXPORT_SYMBOL(drm_property_destroy); |
Line -... | Line 3590... | ||
- | 3590 | ||
- | 3591 | /** |
|
- | 3592 | * drm_object_attach_property - attach a property to a modeset object |
|
- | 3593 | * @obj: drm modeset object |
|
- | 3594 | * @property: property to attach |
|
- | 3595 | * @init_val: initial value of the property |
|
- | 3596 | * |
|
- | 3597 | * This attaches the given property to the modeset object with the given initial |
|
- | 3598 | * value. Currently this function cannot fail since the properties are stored in |
|
- | 3599 | * a statically sized array. |
|
3011 | 3600 | */ |
|
3012 | void drm_object_attach_property(struct drm_mode_object *obj, |
3601 | void drm_object_attach_property(struct drm_mode_object *obj, |
3013 | struct drm_property *property, |
3602 | struct drm_property *property, |
3014 | uint64_t init_val) |
3603 | uint64_t init_val) |
3015 | { |
3604 | { |
Line 3027... | Line 3616... | ||
3027 | obj->properties->values[count] = init_val; |
3616 | obj->properties->values[count] = init_val; |
3028 | obj->properties->count++; |
3617 | obj->properties->count++; |
3029 | } |
3618 | } |
3030 | EXPORT_SYMBOL(drm_object_attach_property); |
3619 | EXPORT_SYMBOL(drm_object_attach_property); |
Line -... | Line 3620... | ||
- | 3620 | ||
- | 3621 | /** |
|
- | 3622 | * drm_object_property_set_value - set the value of a property |
|
- | 3623 | * @obj: drm mode object to set property value for |
|
- | 3624 | * @property: property to set |
|
- | 3625 | * @val: value the property should be set to |
|
- | 3626 | * |
|
- | 3627 | * This functions sets a given property on a given object. This function only |
|
- | 3628 | * changes the software state of the property, it does not call into the |
|
- | 3629 | * driver's ->set_property callback. |
|
- | 3630 | * |
|
- | 3631 | * Returns: |
|
- | 3632 | * Zero on success, error code on failure. |
|
3031 | 3633 | */ |
|
3032 | int drm_object_property_set_value(struct drm_mode_object *obj, |
3634 | int drm_object_property_set_value(struct drm_mode_object *obj, |
3033 | struct drm_property *property, uint64_t val) |
3635 | struct drm_property *property, uint64_t val) |
3034 | { |
3636 | { |
Line 3043... | Line 3645... | ||
3043 | 3645 | ||
3044 | return -EINVAL; |
3646 | return -EINVAL; |
3045 | } |
3647 | } |
Line -... | Line 3648... | ||
- | 3648 | EXPORT_SYMBOL(drm_object_property_set_value); |
|
- | 3649 | ||
- | 3650 | /** |
|
- | 3651 | * drm_object_property_get_value - retrieve the value of a property |
|
- | 3652 | * @obj: drm mode object to get property value from |
|
- | 3653 | * @property: property to retrieve |
|
- | 3654 | * @val: storage for the property value |
|
- | 3655 | * |
|
- | 3656 | * This function retrieves the softare state of the given property for the given |
|
- | 3657 | * property. Since there is no driver callback to retrieve the current property |
|
- | 3658 | * value this might be out of sync with the hardware, depending upon the driver |
|
- | 3659 | * and property. |
|
- | 3660 | * |
|
- | 3661 | * Returns: |
|
3046 | EXPORT_SYMBOL(drm_object_property_set_value); |
3662 | * Zero on success, error code on failure. |
3047 | 3663 | */ |
|
3048 | int drm_object_property_get_value(struct drm_mode_object *obj, |
3664 | int drm_object_property_get_value(struct drm_mode_object *obj, |
3049 | struct drm_property *property, uint64_t *val) |
3665 | struct drm_property *property, uint64_t *val) |
Line 3060... | Line 3676... | ||
3060 | return -EINVAL; |
3676 | return -EINVAL; |
3061 | } |
3677 | } |
3062 | EXPORT_SYMBOL(drm_object_property_get_value); |
3678 | EXPORT_SYMBOL(drm_object_property_get_value); |
Line 3063... | Line 3679... | ||
3063 | 3679 | ||
- | 3680 | #if 0 |
|
- | 3681 | /** |
|
- | 3682 | * drm_mode_getproperty_ioctl - get the current value of a connector's property |
|
- | 3683 | * @dev: DRM device |
|
- | 3684 | * @data: ioctl data |
|
- | 3685 | * @file_priv: DRM file info |
|
- | 3686 | * |
|
- | 3687 | * This function retrieves the current value for an connectors's property. |
|
- | 3688 | * |
|
- | 3689 | * Called by the user via ioctl. |
|
- | 3690 | * |
|
- | 3691 | * Returns: |
|
- | 3692 | * Zero on success, errno on failure. |
|
3064 | #if 0 |
3693 | */ |
3065 | int drm_mode_getproperty_ioctl(struct drm_device *dev, |
3694 | int drm_mode_getproperty_ioctl(struct drm_device *dev, |
3066 | void *data, struct drm_file *file_priv) |
3695 | void *data, struct drm_file *file_priv) |
3067 | { |
- | |
3068 | struct drm_mode_object *obj; |
3696 | { |
3069 | struct drm_mode_get_property *out_resp = data; |
3697 | struct drm_mode_get_property *out_resp = data; |
3070 | struct drm_property *property; |
3698 | struct drm_property *property; |
3071 | int enum_count = 0; |
3699 | int enum_count = 0; |
3072 | int blob_count = 0; |
3700 | int blob_count = 0; |
Line 3082... | Line 3710... | ||
3082 | 3710 | ||
3083 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
3711 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
Line 3084... | Line 3712... | ||
3084 | return -EINVAL; |
3712 | return -EINVAL; |
3085 | 3713 | ||
3086 | drm_modeset_lock_all(dev); |
3714 | drm_modeset_lock_all(dev); |
3087 | obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); |
3715 | property = drm_property_find(dev, out_resp->prop_id); |
3088 | if (!obj) { |
3716 | if (!property) { |
3089 | ret = -ENOENT; |
3717 | ret = -ENOENT; |
3090 | goto done; |
- | |
Line -... | Line 3718... | ||
- | 3718 | goto done; |
|
3091 | } |
3719 | } |
3092 | property = obj_to_property(obj); |
3720 | |
3093 | 3721 | if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) || |
|
3094 | if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) { |
3722 | drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { |
3095 | list_for_each_entry(prop_enum, &property->enum_blob_list, head) |
3723 | list_for_each_entry(prop_enum, &property->enum_blob_list, head) |
3096 | enum_count++; |
3724 | enum_count++; |
3097 | } else if (property->flags & DRM_MODE_PROP_BLOB) { |
3725 | } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { |
Line 3098... | Line 3726... | ||
3098 | list_for_each_entry(prop_blob, &property->enum_blob_list, head) |
3726 | list_for_each_entry(prop_blob, &property->enum_blob_list, head) |
Line 3114... | Line 3742... | ||
3114 | } |
3742 | } |
3115 | } |
3743 | } |
3116 | } |
3744 | } |
3117 | out_resp->count_values = value_count; |
3745 | out_resp->count_values = value_count; |
Line -... | Line 3746... | ||
- | 3746 | ||
3118 | 3747 | if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) || |
|
3119 | if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) { |
3748 | drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { |
3120 | if ((out_resp->count_enum_blobs >= enum_count) && enum_count) { |
3749 | if ((out_resp->count_enum_blobs >= enum_count) && enum_count) { |
3121 | copied = 0; |
3750 | copied = 0; |
3122 | enum_ptr = (struct drm_mode_property_enum __user *)(unsigned long)out_resp->enum_blob_ptr; |
3751 | enum_ptr = (struct drm_mode_property_enum __user *)(unsigned long)out_resp->enum_blob_ptr; |
Line 3136... | Line 3765... | ||
3136 | } |
3765 | } |
3137 | } |
3766 | } |
3138 | out_resp->count_enum_blobs = enum_count; |
3767 | out_resp->count_enum_blobs = enum_count; |
3139 | } |
3768 | } |
Line 3140... | Line 3769... | ||
3140 | 3769 | ||
3141 | if (property->flags & DRM_MODE_PROP_BLOB) { |
3770 | if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { |
3142 | if ((out_resp->count_enum_blobs >= blob_count) && blob_count) { |
3771 | if ((out_resp->count_enum_blobs >= blob_count) && blob_count) { |
3143 | copied = 0; |
3772 | copied = 0; |
3144 | blob_id_ptr = (uint32_t __user *)(unsigned long)out_resp->enum_blob_ptr; |
3773 | blob_id_ptr = (uint32_t __user *)(unsigned long)out_resp->enum_blob_ptr; |
Line 3200... | Line 3829... | ||
3200 | list_del(&blob->head); |
3829 | list_del(&blob->head); |
3201 | kfree(blob); |
3830 | kfree(blob); |
3202 | } |
3831 | } |
Line 3203... | Line 3832... | ||
3203 | 3832 | ||
- | 3833 | #if 0 |
|
- | 3834 | /** |
|
- | 3835 | * drm_mode_getblob_ioctl - get the contents of a blob property value |
|
- | 3836 | * @dev: DRM device |
|
- | 3837 | * @data: ioctl data |
|
- | 3838 | * @file_priv: DRM file info |
|
- | 3839 | * |
|
- | 3840 | * This function retrieves the contents of a blob property. The value stored in |
|
- | 3841 | * an object's blob property is just a normal modeset object id. |
|
- | 3842 | * |
|
- | 3843 | * Called by the user via ioctl. |
|
- | 3844 | * |
|
- | 3845 | * Returns: |
|
- | 3846 | * Zero on success, errno on failure. |
|
3204 | #if 0 |
3847 | */ |
3205 | int drm_mode_getblob_ioctl(struct drm_device *dev, |
3848 | int drm_mode_getblob_ioctl(struct drm_device *dev, |
3206 | void *data, struct drm_file *file_priv) |
3849 | void *data, struct drm_file *file_priv) |
3207 | { |
- | |
3208 | struct drm_mode_object *obj; |
3850 | { |
3209 | struct drm_mode_get_blob *out_resp = data; |
3851 | struct drm_mode_get_blob *out_resp = data; |
3210 | struct drm_property_blob *blob; |
3852 | struct drm_property_blob *blob; |
3211 | int ret = 0; |
3853 | int ret = 0; |
Line 3212... | Line 3854... | ||
3212 | void __user *blob_ptr; |
3854 | void __user *blob_ptr; |
3213 | 3855 | ||
Line 3214... | Line 3856... | ||
3214 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
3856 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
3215 | return -EINVAL; |
3857 | return -EINVAL; |
3216 | 3858 | ||
3217 | drm_modeset_lock_all(dev); |
3859 | drm_modeset_lock_all(dev); |
3218 | obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB); |
3860 | blob = drm_property_blob_find(dev, out_resp->blob_id); |
3219 | if (!obj) { |
3861 | if (!blob) { |
3220 | ret = -ENOENT; |
- | |
Line 3221... | Line 3862... | ||
3221 | goto done; |
3862 | ret = -ENOENT; |
3222 | } |
3863 | goto done; |
3223 | blob = obj_to_blob(obj); |
3864 | } |
3224 | 3865 | ||
Line 3235... | Line 3876... | ||
3235 | drm_modeset_unlock_all(dev); |
3876 | drm_modeset_unlock_all(dev); |
3236 | return ret; |
3877 | return ret; |
3237 | } |
3878 | } |
3238 | #endif |
3879 | #endif |
Line -... | Line 3880... | ||
- | 3880 | ||
- | 3881 | int drm_mode_connector_set_path_property(struct drm_connector *connector, |
|
- | 3882 | char *path) |
|
- | 3883 | { |
|
- | 3884 | struct drm_device *dev = connector->dev; |
|
- | 3885 | int ret, size; |
|
- | 3886 | size = strlen(path) + 1; |
|
- | 3887 | ||
- | 3888 | connector->path_blob_ptr = drm_property_create_blob(connector->dev, |
|
- | 3889 | size, path); |
|
- | 3890 | if (!connector->path_blob_ptr) |
|
- | 3891 | return -EINVAL; |
|
- | 3892 | ||
- | 3893 | ret = drm_object_property_set_value(&connector->base, |
|
- | 3894 | dev->mode_config.path_property, |
|
- | 3895 | connector->path_blob_ptr->base.id); |
|
- | 3896 | return ret; |
|
- | 3897 | } |
|
- | 3898 | EXPORT_SYMBOL(drm_mode_connector_set_path_property); |
|
- | 3899 | ||
- | 3900 | /** |
|
- | 3901 | * drm_mode_connector_update_edid_property - update the edid property of a connector |
|
- | 3902 | * @connector: drm connector |
|
- | 3903 | * @edid: new value of the edid property |
|
- | 3904 | * |
|
- | 3905 | * This function creates a new blob modeset object and assigns its id to the |
|
- | 3906 | * connector's edid property. |
|
- | 3907 | * |
|
- | 3908 | * Returns: |
|
- | 3909 | * Zero on success, errno on failure. |
|
3239 | 3910 | */ |
|
3240 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
3911 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
3241 | struct edid *edid) |
3912 | struct edid *edid) |
3242 | { |
3913 | { |
3243 | struct drm_device *dev = connector->dev; |
3914 | struct drm_device *dev = connector->dev; |
Line -... | Line 3915... | ||
- | 3915 | int ret, size; |
|
- | 3916 | ||
- | 3917 | /* ignore requests to set edid when overridden */ |
|
- | 3918 | if (connector->override_edid) |
|
3244 | int ret, size; |
3919 | return 0; |
3245 | 3920 | ||
Line 3246... | Line 3921... | ||
3246 | if (connector->edid_blob_ptr) |
3921 | if (connector->edid_blob_ptr) |
3247 | drm_property_destroy_blob(dev, connector->edid_blob_ptr); |
3922 | drm_property_destroy_blob(dev, connector->edid_blob_ptr); |
Line 3318... | Line 3993... | ||
3318 | drm_object_property_set_value(obj, property, value); |
3993 | drm_object_property_set_value(obj, property, value); |
Line 3319... | Line 3994... | ||
3319 | 3994 | ||
3320 | return ret; |
3995 | return ret; |
Line -... | Line 3996... | ||
- | 3996 | } |
|
- | 3997 | ||
- | 3998 | /** |
|
- | 3999 | * drm_mode_getproperty_ioctl - get the current value of a object's property |
|
- | 4000 | * @dev: DRM device |
|
- | 4001 | * @data: ioctl data |
|
- | 4002 | * @file_priv: DRM file info |
|
- | 4003 | * |
|
- | 4004 | * This function retrieves the current value for an object's property. Compared |
|
- | 4005 | * to the connector specific ioctl this one is extended to also work on crtc and |
|
- | 4006 | * plane objects. |
|
- | 4007 | * |
|
- | 4008 | * Called by the user via ioctl. |
|
- | 4009 | * |
|
- | 4010 | * Returns: |
|
3321 | } |
4011 | * Zero on success, errno on failure. |
3322 | 4012 | */ |
|
3323 | int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, |
4013 | int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, |
3324 | struct drm_file *file_priv) |
4014 | struct drm_file *file_priv) |
3325 | { |
4015 | { |
Line 3374... | Line 4064... | ||
3374 | out: |
4064 | out: |
3375 | drm_modeset_unlock_all(dev); |
4065 | drm_modeset_unlock_all(dev); |
3376 | return ret; |
4066 | return ret; |
3377 | } |
4067 | } |
Line -... | Line 4068... | ||
- | 4068 | ||
- | 4069 | /** |
|
- | 4070 | * drm_mode_obj_set_property_ioctl - set the current value of an object's property |
|
- | 4071 | * @dev: DRM device |
|
- | 4072 | * @data: ioctl data |
|
- | 4073 | * @file_priv: DRM file info |
|
- | 4074 | * |
|
- | 4075 | * This function sets the current value for an object's property. It also calls |
|
- | 4076 | * into a driver's ->set_property callback to update the hardware state. |
|
- | 4077 | * Compared to the connector specific ioctl this one is extended to also work on |
|
- | 4078 | * crtc and plane objects. |
|
- | 4079 | * |
|
- | 4080 | * Called by the user via ioctl. |
|
- | 4081 | * |
|
- | 4082 | * Returns: |
|
- | 4083 | * Zero on success, errno on failure. |
|
3378 | 4084 | */ |
|
3379 | int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, |
4085 | int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, |
3380 | struct drm_file *file_priv) |
4086 | struct drm_file *file_priv) |
3381 | { |
4087 | { |
3382 | struct drm_mode_obj_set_property *arg = data; |
4088 | struct drm_mode_obj_set_property *arg = data; |
Line 3434... | Line 4140... | ||
3434 | drm_modeset_unlock_all(dev); |
4140 | drm_modeset_unlock_all(dev); |
3435 | return ret; |
4141 | return ret; |
3436 | } |
4142 | } |
3437 | #endif |
4143 | #endif |
Line -... | Line 4144... | ||
- | 4144 | ||
- | 4145 | /** |
|
- | 4146 | * drm_mode_connector_attach_encoder - attach a connector to an encoder |
|
- | 4147 | * @connector: connector to attach |
|
- | 4148 | * @encoder: encoder to attach @connector to |
|
- | 4149 | * |
|
- | 4150 | * This function links up a connector to an encoder. Note that the routing |
|
- | 4151 | * restrictions between encoders and crtcs are exposed to userspace through the |
|
- | 4152 | * possible_clones and possible_crtcs bitmasks. |
|
- | 4153 | * |
|
- | 4154 | * Returns: |
|
- | 4155 | * Zero on success, errno on failure. |
|
3438 | 4156 | */ |
|
3439 | int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
4157 | int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
3440 | struct drm_encoder *encoder) |
4158 | struct drm_encoder *encoder) |
3441 | { |
4159 | { |
Line 3449... | Line 4167... | ||
3449 | } |
4167 | } |
3450 | return -ENOMEM; |
4168 | return -ENOMEM; |
3451 | } |
4169 | } |
3452 | EXPORT_SYMBOL(drm_mode_connector_attach_encoder); |
4170 | EXPORT_SYMBOL(drm_mode_connector_attach_encoder); |
Line -... | Line 4171... | ||
- | 4171 | ||
3453 | 4172 | /** |
|
3454 | void drm_mode_connector_detach_encoder(struct drm_connector *connector, |
4173 | * drm_mode_crtc_set_gamma_size - set the gamma table size |
- | 4174 | * @crtc: CRTC to set the gamma table size for |
|
3455 | struct drm_encoder *encoder) |
4175 | * @gamma_size: size of the gamma table |
3456 | { |
- | |
3457 | int i; |
4176 | * |
3458 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
4177 | * Drivers which support gamma tables should set this to the supported gamma |
3459 | if (connector->encoder_ids[i] == encoder->base.id) { |
- | |
3460 | connector->encoder_ids[i] = 0; |
- | |
3461 | if (connector->encoder == encoder) |
4178 | * table size when initializing the CRTC. Currently the drm core only supports a |
3462 | connector->encoder = NULL; |
- | |
3463 | break; |
- | |
3464 | } |
4179 | * fixed gamma table size. |
3465 | } |
4180 | * |
3466 | } |
4181 | * Returns: |
3467 | EXPORT_SYMBOL(drm_mode_connector_detach_encoder); |
4182 | * Zero on success, errno on failure. |
3468 | 4183 | */ |
|
3469 | int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
4184 | int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
3470 | int gamma_size) |
4185 | int gamma_size) |
3471 | { |
4186 | { |
Line 3480... | Line 4195... | ||
3480 | return 0; |
4195 | return 0; |
3481 | } |
4196 | } |
3482 | EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); |
4197 | EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); |
Line 3483... | Line 4198... | ||
3483 | 4198 | ||
- | 4199 | #if 0 |
|
- | 4200 | /** |
|
- | 4201 | * drm_mode_gamma_set_ioctl - set the gamma table |
|
- | 4202 | * @dev: DRM device |
|
- | 4203 | * @data: ioctl data |
|
- | 4204 | * @file_priv: DRM file info |
|
- | 4205 | * |
|
- | 4206 | * Set the gamma table of a CRTC to the one passed in by the user. Userspace can |
|
- | 4207 | * inquire the required gamma table size through drm_mode_gamma_get_ioctl. |
|
- | 4208 | * |
|
- | 4209 | * Called by the user via ioctl. |
|
- | 4210 | * |
|
- | 4211 | * Returns: |
|
- | 4212 | * Zero on success, errno on failure. |
|
3484 | #if 0 |
4213 | */ |
3485 | int drm_mode_gamma_set_ioctl(struct drm_device *dev, |
4214 | int drm_mode_gamma_set_ioctl(struct drm_device *dev, |
3486 | void *data, struct drm_file *file_priv) |
4215 | void *data, struct drm_file *file_priv) |
3487 | { |
4216 | { |
3488 | struct drm_mode_crtc_lut *crtc_lut = data; |
- | |
3489 | struct drm_mode_object *obj; |
4217 | struct drm_mode_crtc_lut *crtc_lut = data; |
3490 | struct drm_crtc *crtc; |
4218 | struct drm_crtc *crtc; |
3491 | void *r_base, *g_base, *b_base; |
4219 | void *r_base, *g_base, *b_base; |
3492 | int size; |
4220 | int size; |
Line 3493... | Line 4221... | ||
3493 | int ret = 0; |
4221 | int ret = 0; |
3494 | 4222 | ||
Line 3495... | Line 4223... | ||
3495 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
4223 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
3496 | return -EINVAL; |
4224 | return -EINVAL; |
3497 | 4225 | ||
3498 | drm_modeset_lock_all(dev); |
4226 | drm_modeset_lock_all(dev); |
3499 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
4227 | crtc = drm_crtc_find(dev, crtc_lut->crtc_id); |
3500 | if (!obj) { |
4228 | if (!crtc) { |
3501 | ret = -ENOENT; |
- | |
Line 3502... | Line 4229... | ||
3502 | goto out; |
4229 | ret = -ENOENT; |
3503 | } |
4230 | goto out; |
3504 | crtc = obj_to_crtc(obj); |
4231 | } |
3505 | 4232 | ||
Line 3539... | Line 4266... | ||
3539 | drm_modeset_unlock_all(dev); |
4266 | drm_modeset_unlock_all(dev); |
3540 | return ret; |
4267 | return ret; |
Line 3541... | Line 4268... | ||
3541 | 4268 | ||
Line -... | Line 4269... | ||
- | 4269 | } |
|
- | 4270 | ||
- | 4271 | /** |
|
- | 4272 | * drm_mode_gamma_get_ioctl - get the gamma table |
|
- | 4273 | * @dev: DRM device |
|
- | 4274 | * @data: ioctl data |
|
- | 4275 | * @file_priv: DRM file info |
|
- | 4276 | * |
|
- | 4277 | * Copy the current gamma table into the storage provided. This also provides |
|
- | 4278 | * the gamma table size the driver expects, which can be used to size the |
|
- | 4279 | * allocated storage. |
|
- | 4280 | * |
|
- | 4281 | * Called by the user via ioctl. |
|
- | 4282 | * |
|
- | 4283 | * Returns: |
|
3542 | } |
4284 | * Zero on success, errno on failure. |
3543 | 4285 | */ |
|
3544 | int drm_mode_gamma_get_ioctl(struct drm_device *dev, |
4286 | int drm_mode_gamma_get_ioctl(struct drm_device *dev, |
3545 | void *data, struct drm_file *file_priv) |
4287 | void *data, struct drm_file *file_priv) |
3546 | { |
- | |
3547 | struct drm_mode_crtc_lut *crtc_lut = data; |
4288 | { |
3548 | struct drm_mode_object *obj; |
4289 | struct drm_mode_crtc_lut *crtc_lut = data; |
3549 | struct drm_crtc *crtc; |
4290 | struct drm_crtc *crtc; |
3550 | void *r_base, *g_base, *b_base; |
4291 | void *r_base, *g_base, *b_base; |
Line 3551... | Line 4292... | ||
3551 | int size; |
4292 | int size; |
3552 | int ret = 0; |
4293 | int ret = 0; |
Line 3553... | Line 4294... | ||
3553 | 4294 | ||
3554 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
4295 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
3555 | return -EINVAL; |
4296 | return -EINVAL; |
3556 | 4297 | ||
3557 | drm_modeset_lock_all(dev); |
4298 | drm_modeset_lock_all(dev); |
3558 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
4299 | crtc = drm_crtc_find(dev, crtc_lut->crtc_id); |
3559 | if (!obj) { |
- | |
Line 3560... | Line 4300... | ||
3560 | ret = -ENOENT; |
4300 | if (!crtc) { |
3561 | goto out; |
4301 | ret = -ENOENT; |
3562 | } |
4302 | goto out; |
3563 | crtc = obj_to_crtc(obj); |
4303 | } |
Line 3592... | Line 4332... | ||
3592 | } |
4332 | } |
Line 3593... | Line 4333... | ||
3593 | 4333 | ||
Line -... | Line 4334... | ||
- | 4334 | #endif |
|
- | 4335 | ||
- | 4336 | ||
- | 4337 | /** |
|
- | 4338 | * drm_mode_config_reset - call ->reset callbacks |
|
- | 4339 | * @dev: drm device |
|
- | 4340 | * |
|
- | 4341 | * This functions calls all the crtc's, encoder's and connector's ->reset |
|
3594 | #endif |
4342 | * callback. Drivers can use this in e.g. their driver load or resume code to |
3595 | 4343 | * reset hardware and software state. |
|
3596 | 4344 | */ |
|
3597 | void drm_mode_config_reset(struct drm_device *dev) |
4345 | void drm_mode_config_reset(struct drm_device *dev) |
3598 | { |
4346 | { |
Line 3688... | Line 4436... | ||
3688 | 4436 | ||
3689 | /** |
4437 | /** |
3690 | * drm_format_num_planes - get the number of planes for format |
4438 | * drm_format_num_planes - get the number of planes for format |
3691 | * @format: pixel format (DRM_FORMAT_*) |
4439 | * @format: pixel format (DRM_FORMAT_*) |
3692 | * |
4440 | * |
3693 | * RETURNS: |
4441 | * Returns: |
3694 | * The number of planes used by the specified pixel format. |
4442 | * The number of planes used by the specified pixel format. |
3695 | */ |
4443 | */ |
3696 | int drm_format_num_planes(uint32_t format) |
4444 | int drm_format_num_planes(uint32_t format) |
3697 | { |
4445 | { |
Line 3723... | Line 4471... | ||
3723 | /** |
4471 | /** |
3724 | * drm_format_plane_cpp - determine the bytes per pixel value |
4472 | * drm_format_plane_cpp - determine the bytes per pixel value |
3725 | * @format: pixel format (DRM_FORMAT_*) |
4473 | * @format: pixel format (DRM_FORMAT_*) |
3726 | * @plane: plane index |
4474 | * @plane: plane index |
3727 | * |
4475 | * |
3728 | * RETURNS: |
4476 | * Returns: |
3729 | * The bytes per pixel value for the specified plane. |
4477 | * The bytes per pixel value for the specified plane. |
3730 | */ |
4478 | */ |
3731 | int drm_format_plane_cpp(uint32_t format, int plane) |
4479 | int drm_format_plane_cpp(uint32_t format, int plane) |
3732 | { |
4480 | { |
3733 | unsigned int depth; |
4481 | unsigned int depth; |
Line 3769... | Line 4517... | ||
3769 | 4517 | ||
3770 | /** |
4518 | /** |
3771 | * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor |
4519 | * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor |
3772 | * @format: pixel format (DRM_FORMAT_*) |
4520 | * @format: pixel format (DRM_FORMAT_*) |
3773 | * |
4521 | * |
3774 | * RETURNS: |
4522 | * Returns: |
3775 | * The horizontal chroma subsampling factor for the |
4523 | * The horizontal chroma subsampling factor for the |
3776 | * specified pixel format. |
4524 | * specified pixel format. |
3777 | */ |
4525 | */ |
3778 | int drm_format_horz_chroma_subsampling(uint32_t format) |
4526 | int drm_format_horz_chroma_subsampling(uint32_t format) |
Line 3804... | Line 4552... | ||
3804 | 4552 | ||
3805 | /** |
4553 | /** |
3806 | * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor |
4554 | * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor |
3807 | * @format: pixel format (DRM_FORMAT_*) |
4555 | * @format: pixel format (DRM_FORMAT_*) |
3808 | * |
4556 | * |
3809 | * RETURNS: |
4557 | * Returns: |
3810 | * The vertical chroma subsampling factor for the |
4558 | * The vertical chroma subsampling factor for the |
3811 | * specified pixel format. |
4559 | * specified pixel format. |
3812 | */ |
4560 | */ |
3813 | int drm_format_vert_chroma_subsampling(uint32_t format) |
4561 | int drm_format_vert_chroma_subsampling(uint32_t format) |
Line 3840... | Line 4588... | ||
3840 | * |
4588 | * |
3841 | */ |
4589 | */ |
3842 | void drm_mode_config_init(struct drm_device *dev) |
4590 | void drm_mode_config_init(struct drm_device *dev) |
3843 | { |
4591 | { |
3844 | mutex_init(&dev->mode_config.mutex); |
4592 | mutex_init(&dev->mode_config.mutex); |
- | 4593 | drm_modeset_lock_init(&dev->mode_config.connection_mutex); |
|
3845 | mutex_init(&dev->mode_config.idr_mutex); |
4594 | mutex_init(&dev->mode_config.idr_mutex); |
3846 | mutex_init(&dev->mode_config.fb_lock); |
4595 | mutex_init(&dev->mode_config.fb_lock); |
3847 | INIT_LIST_HEAD(&dev->mode_config.fb_list); |
4596 | INIT_LIST_HEAD(&dev->mode_config.fb_list); |
3848 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); |
4597 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); |
3849 | INIT_LIST_HEAD(&dev->mode_config.connector_list); |
4598 | INIT_LIST_HEAD(&dev->mode_config.connector_list); |
Line 3854... | Line 4603... | ||
3854 | INIT_LIST_HEAD(&dev->mode_config.plane_list); |
4603 | INIT_LIST_HEAD(&dev->mode_config.plane_list); |
3855 | idr_init(&dev->mode_config.crtc_idr); |
4604 | idr_init(&dev->mode_config.crtc_idr); |
Line 3856... | Line 4605... | ||
3856 | 4605 | ||
3857 | drm_modeset_lock_all(dev); |
4606 | drm_modeset_lock_all(dev); |
- | 4607 | drm_mode_create_standard_connector_properties(dev); |
|
3858 | drm_mode_create_standard_connector_properties(dev); |
4608 | drm_mode_create_standard_plane_properties(dev); |
Line 3859... | Line 4609... | ||
3859 | drm_modeset_unlock_all(dev); |
4609 | drm_modeset_unlock_all(dev); |
3860 | 4610 | ||
3861 | /* Just to be sure */ |
4611 | /* Just to be sure */ |
3862 | dev->mode_config.num_fb = 0; |
4612 | dev->mode_config.num_fb = 0; |
3863 | dev->mode_config.num_connector = 0; |
4613 | dev->mode_config.num_connector = 0; |
- | 4614 | dev->mode_config.num_crtc = 0; |
|
- | 4615 | dev->mode_config.num_encoder = 0; |
|
3864 | dev->mode_config.num_crtc = 0; |
4616 | dev->mode_config.num_overlay_plane = 0; |
3865 | dev->mode_config.num_encoder = 0; |
4617 | dev->mode_config.num_total_plane = 0; |
Line -... | Line 4618... | ||
- | 4618 | } |
|
- | 4619 | EXPORT_SYMBOL(drm_mode_config_init); |
|
- | 4620 | ||
- | 4621 | /** |
|
- | 4622 | * drm_mode_config_cleanup - free up DRM mode_config info |
|
- | 4623 | * @dev: DRM device |
|
- | 4624 | * |
|
- | 4625 | * Free up all the connectors and CRTCs associated with this DRM device, then |
|
- | 4626 | * free up the framebuffers and associated buffer objects. |
|
- | 4627 | * |
|
- | 4628 | * Note that since this /should/ happen single-threaded at driver/device |
|
- | 4629 | * teardown time, no locking is required. It's the driver's job to ensure that |
|
- | 4630 | * this guarantee actually holds true. |