Rev 5271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5271 | Rev 6084 | ||
---|---|---|---|
Line 89... | Line 89... | ||
89 | * need to grab the connection_mutex here to be able to make these |
89 | * need to grab the connection_mutex here to be able to make these |
90 | * checks. |
90 | * checks. |
91 | */ |
91 | */ |
92 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); |
92 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); |
Line 93... | Line 93... | ||
93 | 93 | ||
94 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
94 | drm_for_each_connector(connector, dev) { |
95 | if (connector->encoder && connector->encoder->crtc == crtc) { |
95 | if (connector->encoder && connector->encoder->crtc == crtc) { |
96 | if (connector_list != NULL && count < num_connectors) |
96 | if (connector_list != NULL && count < num_connectors) |
Line 97... | Line 97... | ||
97 | *(connector_list++) = connector; |
97 | *(connector_list++) = connector; |
98 | 98 | ||
- | 99 | count++; |
|
Line 99... | Line 100... | ||
99 | count++; |
100 | } |
100 | } |
101 | } |
Line 101... | Line 102... | ||
101 | 102 | ||
Line 140... | Line 141... | ||
140 | bool can_update_disabled, |
141 | bool can_update_disabled, |
141 | bool *visible) |
142 | bool *visible) |
142 | { |
143 | { |
143 | int hscale, vscale; |
144 | int hscale, vscale; |
Line -... | Line 145... | ||
- | 145 | ||
- | 146 | if (!fb) { |
|
- | 147 | *visible = false; |
|
- | 148 | return 0; |
|
- | 149 | } |
|
- | 150 | ||
- | 151 | /* crtc should only be NULL when disabling (i.e., !fb) */ |
|
- | 152 | if (WARN_ON(!crtc)) { |
|
- | 153 | *visible = false; |
|
- | 154 | return 0; |
|
- | 155 | } |
|
144 | 156 | ||
145 | if (!crtc->enabled && !can_update_disabled) { |
157 | if (!crtc->enabled && !can_update_disabled) { |
146 | DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n"); |
158 | DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n"); |
147 | return -EINVAL; |
159 | return -EINVAL; |
Line 153... | Line 165... | ||
153 | if (hscale < 0 || vscale < 0) { |
165 | if (hscale < 0 || vscale < 0) { |
154 | DRM_DEBUG_KMS("Invalid scaling of plane\n"); |
166 | DRM_DEBUG_KMS("Invalid scaling of plane\n"); |
155 | return -ERANGE; |
167 | return -ERANGE; |
156 | } |
168 | } |
Line 157... | Line -... | ||
157 | - | ||
158 | if (!fb) { |
- | |
159 | *visible = false; |
- | |
160 | return 0; |
- | |
161 | } |
- | |
162 | 169 | ||
163 | *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale); |
170 | *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale); |
164 | if (!*visible) |
171 | if (!*visible) |
165 | /* |
172 | /* |
166 | * Plane isn't visible; some drivers can handle this |
173 | * Plane isn't visible; some drivers can handle this |
Line 336... | Line 343... | ||
336 | .disable_plane = drm_primary_helper_disable, |
343 | .disable_plane = drm_primary_helper_disable, |
337 | .destroy = drm_primary_helper_destroy, |
344 | .destroy = drm_primary_helper_destroy, |
338 | }; |
345 | }; |
339 | EXPORT_SYMBOL(drm_primary_helper_funcs); |
346 | EXPORT_SYMBOL(drm_primary_helper_funcs); |
Line 340... | Line -... | ||
340 | - | ||
341 | /** |
- | |
342 | * drm_primary_helper_create_plane() - Create a generic primary plane |
- | |
343 | * @dev: drm device |
- | |
344 | * @formats: pixel formats supported, or NULL for a default safe list |
- | |
345 | * @num_formats: size of @formats; ignored if @formats is NULL |
- | |
346 | * |
- | |
347 | * Allocates and initializes a primary plane that can be used with the primary |
- | |
348 | * plane helpers. Drivers that wish to use driver-specific plane structures or |
- | |
349 | * provide custom handler functions may perform their own allocation and |
- | |
350 | * initialization rather than calling this function. |
- | |
351 | */ |
347 | |
352 | struct drm_plane *drm_primary_helper_create_plane(struct drm_device *dev, |
- | |
353 | const uint32_t *formats, |
- | |
354 | int num_formats) |
348 | static struct drm_plane *create_primary_plane(struct drm_device *dev) |
355 | { |
349 | { |
356 | struct drm_plane *primary; |
350 | struct drm_plane *primary; |
Line 357... | Line 351... | ||
357 | int ret; |
351 | int ret; |
358 | 352 | ||
359 | primary = kzalloc(sizeof(*primary), GFP_KERNEL); |
353 | primary = kzalloc(sizeof(*primary), GFP_KERNEL); |
360 | if (primary == NULL) { |
354 | if (primary == NULL) { |
361 | DRM_DEBUG_KMS("Failed to allocate primary plane\n"); |
355 | DRM_DEBUG_KMS("Failed to allocate primary plane\n"); |
Line 362... | Line 356... | ||
362 | return NULL; |
356 | return NULL; |
363 | } |
357 | } |
364 | 358 | ||
365 | if (formats == NULL) { |
359 | /* |
- | 360 | * Remove the format_default field from drm_plane when dropping |
|
Line 366... | Line 361... | ||
366 | formats = safe_modeset_formats; |
361 | * this helper. |
367 | num_formats = ARRAY_SIZE(safe_modeset_formats); |
362 | */ |
368 | } |
363 | primary->format_default = true; |
369 | 364 | ||
- | 365 | /* possible_crtc's will be filled in later by crtc_init */ |
|
370 | /* possible_crtc's will be filled in later by crtc_init */ |
366 | ret = drm_universal_plane_init(dev, primary, 0, |
371 | ret = drm_universal_plane_init(dev, primary, 0, |
367 | &drm_primary_helper_funcs, |
372 | &drm_primary_helper_funcs, |
368 | safe_modeset_formats, |
373 | formats, num_formats, |
369 | ARRAY_SIZE(safe_modeset_formats), |
374 | DRM_PLANE_TYPE_PRIMARY); |
370 | DRM_PLANE_TYPE_PRIMARY); |
Line 375... | Line 371... | ||
375 | if (ret) { |
371 | if (ret) { |
376 | kfree(primary); |
372 | kfree(primary); |
377 | primary = NULL; |
- | |
Line 378... | Line 373... | ||
378 | } |
373 | primary = NULL; |
379 | 374 | } |
|
380 | return primary; |
375 | |
381 | } |
376 | return primary; |
Line 396... | Line 391... | ||
396 | int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, |
391 | int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, |
397 | const struct drm_crtc_funcs *funcs) |
392 | const struct drm_crtc_funcs *funcs) |
398 | { |
393 | { |
399 | struct drm_plane *primary; |
394 | struct drm_plane *primary; |
Line 400... | Line 395... | ||
400 | 395 | ||
401 | primary = drm_primary_helper_create_plane(dev, NULL, 0); |
396 | primary = create_primary_plane(dev); |
402 | return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs); |
397 | return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs); |
403 | } |
398 | } |
Line 404... | Line 399... | ||
404 | EXPORT_SYMBOL(drm_crtc_init); |
399 | EXPORT_SYMBOL(drm_crtc_init); |
405 | 400 | ||
406 | int drm_plane_helper_commit(struct drm_plane *plane, |
401 | int drm_plane_helper_commit(struct drm_plane *plane, |
407 | struct drm_plane_state *plane_state, |
402 | struct drm_plane_state *plane_state, |
408 | struct drm_framebuffer *old_fb) |
403 | struct drm_framebuffer *old_fb) |
409 | { |
404 | { |
410 | struct drm_plane_helper_funcs *plane_funcs; |
405 | const struct drm_plane_helper_funcs *plane_funcs; |
411 | struct drm_crtc *crtc[2]; |
406 | struct drm_crtc *crtc[2]; |
Line 412... | Line 407... | ||
412 | struct drm_crtc_helper_funcs *crtc_funcs[2]; |
407 | const struct drm_crtc_helper_funcs *crtc_funcs[2]; |
Line 413... | Line 408... | ||
413 | int i, ret = 0; |
408 | int i, ret = 0; |
Line 427... | Line 422... | ||
427 | ret = plane_funcs->atomic_check(plane, plane_state); |
422 | ret = plane_funcs->atomic_check(plane, plane_state); |
428 | if (ret) |
423 | if (ret) |
429 | goto out; |
424 | goto out; |
430 | } |
425 | } |
Line 431... | Line 426... | ||
431 | 426 | ||
- | 427 | if (plane_funcs->prepare_fb && plane_state->fb && |
|
432 | if (plane_funcs->prepare_fb && plane_state->fb) { |
428 | plane_state->fb != old_fb) { |
- | 429 | ret = plane_funcs->prepare_fb(plane, |
|
433 | ret = plane_funcs->prepare_fb(plane, plane_state->fb); |
430 | plane_state); |
434 | if (ret) |
431 | if (ret) |
435 | goto out; |
432 | goto out; |
Line 436... | Line 433... | ||
436 | } |
433 | } |
437 | 434 | ||
Line 438... | Line 435... | ||
438 | /* Point of no return, commit sw state. */ |
435 | /* Point of no return, commit sw state. */ |
439 | swap(plane->state, plane_state); |
436 | swap(plane->state, plane_state); |
440 | 437 | ||
441 | for (i = 0; i < 2; i++) { |
438 | for (i = 0; i < 2; i++) { |
Line -... | Line 439... | ||
- | 439 | if (crtc_funcs[i] && crtc_funcs[i]->atomic_begin) |
|
- | 440 | crtc_funcs[i]->atomic_begin(crtc[i], crtc[i]->state); |
|
- | 441 | } |
|
- | 442 | ||
- | 443 | /* |
|
- | 444 | * Drivers may optionally implement the ->atomic_disable callback, so |
|
- | 445 | * special-case that here. |
|
- | 446 | */ |
|
442 | if (crtc_funcs[i] && crtc_funcs[i]->atomic_begin) |
447 | if (drm_atomic_plane_disabling(plane, plane_state) && |
Line 443... | Line 448... | ||
443 | crtc_funcs[i]->atomic_begin(crtc[i]); |
448 | plane_funcs->atomic_disable) |
444 | } |
449 | plane_funcs->atomic_disable(plane, plane_state); |
445 | 450 | else |
|
446 | plane_funcs->atomic_update(plane, plane_state); |
451 | plane_funcs->atomic_update(plane, plane_state); |
Line -... | Line 452... | ||
- | 452 | ||
- | 453 | for (i = 0; i < 2; i++) { |
|
- | 454 | if (crtc_funcs[i] && crtc_funcs[i]->atomic_flush) |
|
- | 455 | crtc_funcs[i]->atomic_flush(crtc[i], crtc[i]->state); |
|
- | 456 | } |
|
- | 457 | ||
- | 458 | /* |
|
447 | 459 | * If we only moved the plane and didn't change fb's, there's no need to |
|
448 | for (i = 0; i < 2; i++) { |
460 | * wait for vblank. |
449 | if (crtc_funcs[i] && crtc_funcs[i]->atomic_flush) |
461 | */ |
Line -... | Line 462... | ||
- | 462 | if (plane->state->fb == old_fb) |
|
- | 463 | goto out; |
|
- | 464 | ||
450 | crtc_funcs[i]->atomic_flush(crtc[i]); |
465 | for (i = 0; i < 2; i++) { |
451 | } |
466 | if (!crtc[i]) |
452 | 467 | continue; |
|
453 | for (i = 0; i < 2; i++) { |
468 | |
454 | if (!crtc[i]) |
469 | if (crtc[i]->cursor == plane) |
455 | continue; |
470 | continue; |
Line 456... | Line 471... | ||
456 | 471 | ||
457 | /* There's no other way to figure out whether the crtc is running. */ |
472 | /* There's no other way to figure out whether the crtc is running. */ |
Line 458... | Line 473... | ||
458 | ret = drm_crtc_vblank_get(crtc[i]); |
473 | ret = drm_crtc_vblank_get(crtc[i]); |
459 | if (ret == 0) { |
474 | if (ret == 0) { |
460 | drm_crtc_wait_one_vblank(crtc[i]); |
475 | drm_crtc_wait_one_vblank(crtc[i]); |
461 | drm_crtc_vblank_put(crtc[i]); |
476 | drm_crtc_vblank_put(crtc[i]); |
462 | } |
477 | } |
463 | 478 | ||
464 | ret = 0; |
479 | ret = 0; |
Line 476... | Line 491... | ||
476 | 491 | ||
477 | return ret; |
492 | return ret; |
Line 478... | Line 493... | ||
478 | } |
493 | } |
479 | 494 | ||
480 | /** |
495 | /** |
481 | * drm_plane_helper_update() - Helper for primary plane update |
496 | * drm_plane_helper_update() - Transitional helper for plane update |
482 | * @plane: plane object to update |
497 | * @plane: plane object to update |
483 | * @crtc: owning CRTC of owning plane |
498 | * @crtc: owning CRTC of owning plane |
484 | * @fb: framebuffer to flip onto plane |
499 | * @fb: framebuffer to flip onto plane |
Line 509... | Line 524... | ||
509 | { |
524 | { |
510 | struct drm_plane_state *plane_state; |
525 | struct drm_plane_state *plane_state; |
Line 511... | Line 526... | ||
511 | 526 | ||
512 | if (plane->funcs->atomic_duplicate_state) |
527 | if (plane->funcs->atomic_duplicate_state) |
- | 528 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
|
513 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
529 | else { |
- | 530 | if (!plane->state) |
|
- | 531 | drm_atomic_helper_plane_reset(plane); |
|
514 | else if (plane->state) |
532 | |
515 | plane_state = drm_atomic_helper_plane_duplicate_state(plane); |
533 | plane_state = drm_atomic_helper_plane_duplicate_state(plane); |
516 | else |
- | |
517 | plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); |
534 | } |
518 | if (!plane_state) |
535 | if (!plane_state) |
- | 536 | return -ENOMEM; |
|
Line 519... | Line 537... | ||
519 | return -ENOMEM; |
537 | plane_state->plane = plane; |
520 | 538 | ||
521 | plane_state->crtc = crtc; |
539 | plane_state->crtc = crtc; |
522 | drm_atomic_set_fb_for_plane(plane_state, fb); |
540 | drm_atomic_set_fb_for_plane(plane_state, fb); |
Line 532... | Line 550... | ||
532 | return drm_plane_helper_commit(plane, plane_state, plane->fb); |
550 | return drm_plane_helper_commit(plane, plane_state, plane->fb); |
533 | } |
551 | } |
534 | EXPORT_SYMBOL(drm_plane_helper_update); |
552 | EXPORT_SYMBOL(drm_plane_helper_update); |
Line 535... | Line 553... | ||
535 | 553 | ||
536 | /** |
554 | /** |
537 | * drm_plane_helper_disable() - Helper for primary plane disable |
555 | * drm_plane_helper_disable() - Transitional helper for plane disable |
538 | * @plane: plane to disable |
556 | * @plane: plane to disable |
539 | * |
557 | * |
540 | * Provides a default plane disable handler using the atomic plane update |
558 | * Provides a default plane disable handler using the atomic plane update |
541 | * functions. It is fully left to the driver to check plane constraints and |
559 | * functions. It is fully left to the driver to check plane constraints and |
Line 555... | Line 573... | ||
555 | if (!plane->crtc) |
573 | if (!plane->crtc) |
556 | return 0; |
574 | return 0; |
Line 557... | Line 575... | ||
557 | 575 | ||
558 | if (plane->funcs->atomic_duplicate_state) |
576 | if (plane->funcs->atomic_duplicate_state) |
- | 577 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
|
559 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
578 | else { |
- | 579 | if (!plane->state) |
|
- | 580 | drm_atomic_helper_plane_reset(plane); |
|
560 | else if (plane->state) |
581 | |
561 | plane_state = drm_atomic_helper_plane_duplicate_state(plane); |
582 | plane_state = drm_atomic_helper_plane_duplicate_state(plane); |
562 | else |
- | |
563 | plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); |
583 | } |
564 | if (!plane_state) |
584 | if (!plane_state) |
- | 585 | return -ENOMEM; |
|
Line 565... | Line 586... | ||
565 | return -ENOMEM; |
586 | plane_state->plane = plane; |
566 | 587 | ||
Line 567... | Line 588... | ||
567 | plane_state->crtc = NULL; |
588 | plane_state->crtc = NULL; |