Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/fb-helper: Prepare to move out commit code

This makes the necessary changes so the commit code can be moved out to
drm_client as-is in the next patch. It's split up to ease review.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190531140117.37751-4-noralf@tronnes.org

+81 -41
+81 -41
drivers/gpu/drm/drm_fb_helper.c
··· 393 393 } 394 394 EXPORT_SYMBOL(drm_fb_helper_debug_leave); 395 395 396 - /* Check if the plane can hw rotate to match panel orientation */ 397 - static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset, 398 - unsigned int *rotation) 396 + /** 397 + * drm_client_panel_rotation() - Check panel orientation 398 + * @modeset: DRM modeset 399 + * @rotation: Returned rotation value 400 + * 401 + * This function checks if the primary plane in @modeset can hw rotate to match 402 + * the panel orientation on its connector. 403 + * 404 + * Note: Currently only 0 and 180 degrees are supported. 405 + * 406 + * Return: 407 + * True if the plane can do the rotation, false otherwise. 408 + */ 409 + bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int *rotation) 399 410 { 400 411 struct drm_connector *connector = modeset->connectors[0]; 401 412 struct drm_plane *plane = modeset->crtc->primary; ··· 447 436 return true; 448 437 } 449 438 450 - static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool active) 439 + static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active) 451 440 { 452 - struct drm_client_dev *client = &fb_helper->client; 453 - struct drm_device *dev = fb_helper->dev; 441 + struct drm_device *dev = client->dev; 454 442 struct drm_plane_state *plane_state; 455 443 struct drm_plane *plane; 456 444 struct drm_atomic_state *state; ··· 489 479 struct drm_plane *primary = mode_set->crtc->primary; 490 480 unsigned int rotation; 491 481 492 - if (drm_fb_helper_panel_rotation(mode_set, &rotation)) { 482 + if (drm_client_panel_rotation(mode_set, &rotation)) { 493 483 /* Cannot fail as we've already gotten the plane state above */ 494 484 plane_state = drm_atomic_get_new_plane_state(state, primary); 495 485 plane_state->rotation = rotation; ··· 531 521 goto retry; 532 522 } 533 523 534 - static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper) 524 + static int drm_client_modeset_commit_legacy(struct drm_client_dev *client) 535 525 { 536 - struct drm_client_dev *client = &fb_helper->client; 537 - struct drm_device *dev = fb_helper->dev; 526 + struct drm_device *dev = client->dev; 538 527 struct drm_mode_set *mode_set; 539 528 struct drm_plane *plane; 540 529 int ret = 0; 541 530 542 - drm_modeset_lock_all(fb_helper->dev); 531 + drm_modeset_lock_all(dev); 543 532 drm_for_each_plane(plane, dev) { 544 533 if (plane->type != DRM_PLANE_TYPE_PRIMARY) 545 534 drm_plane_force_disable(plane); ··· 567 558 goto out; 568 559 } 569 560 out: 570 - drm_modeset_unlock_all(fb_helper->dev); 561 + drm_modeset_unlock_all(dev); 571 562 572 563 return ret; 573 564 } 574 565 575 - static int restore_fbdev_mode_force(struct drm_fb_helper *fb_helper) 566 + /** 567 + * drm_client_modeset_commit_force() - Force commit CRTC configuration 568 + * @client: DRM client 569 + * 570 + * Commit modeset configuration to crtcs without checking if there is a DRM master. 571 + * 572 + * Returns: 573 + * Zero on success or negative error code on failure. 574 + */ 575 + int drm_client_modeset_commit_force(struct drm_client_dev *client) 576 576 { 577 - struct drm_device *dev = fb_helper->dev; 577 + struct drm_device *dev = client->dev; 578 578 int ret; 579 579 580 - mutex_lock(&fb_helper->client.modeset_mutex); 580 + mutex_lock(&client->modeset_mutex); 581 581 if (drm_drv_uses_atomic_modeset(dev)) 582 - ret = restore_fbdev_mode_atomic(fb_helper, true); 582 + ret = drm_client_modeset_commit_atomic(client, true); 583 583 else 584 - ret = restore_fbdev_mode_legacy(fb_helper); 585 - mutex_unlock(&fb_helper->client.modeset_mutex); 584 + ret = drm_client_modeset_commit_legacy(client); 585 + mutex_unlock(&client->modeset_mutex); 586 586 587 587 return ret; 588 588 } 589 589 590 - static int restore_fbdev_mode(struct drm_fb_helper *fb_helper) 590 + /** 591 + * drm_client_modeset_commit() - Commit CRTC configuration 592 + * @client: DRM client 593 + * 594 + * Commit modeset configuration to crtcs. 595 + * 596 + * Returns: 597 + * Zero on success or negative error code on failure. 598 + */ 599 + int drm_client_modeset_commit(struct drm_client_dev *client) 591 600 { 592 - struct drm_device *dev = fb_helper->dev; 601 + struct drm_device *dev = client->dev; 593 602 int ret; 594 603 595 604 if (!drm_master_internal_acquire(dev)) 596 605 return -EBUSY; 597 606 598 - ret = restore_fbdev_mode_force(fb_helper); 607 + ret = drm_client_modeset_commit_force(client); 599 608 600 609 drm_master_internal_release(dev); 601 610 ··· 653 626 * So first these tests need to be fixed so they drop master or don't 654 627 * have an fd open. 655 628 */ 656 - ret = restore_fbdev_mode_force(fb_helper); 629 + ret = drm_client_modeset_commit_force(&fb_helper->client); 657 630 658 631 do_delayed = fb_helper->delayed_hotplug; 659 632 if (do_delayed) ··· 687 660 continue; 688 661 689 662 mutex_lock(&helper->lock); 690 - ret = restore_fbdev_mode_force(helper); 663 + ret = drm_client_modeset_commit_force(&helper->client); 691 664 if (ret) 692 665 error = true; 693 666 mutex_unlock(&helper->lock); ··· 719 692 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; 720 693 #endif 721 694 722 - static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode) 695 + static void drm_client_modeset_dpms_legacy(struct drm_client_dev *client, int dpms_mode) 723 696 { 724 - struct drm_client_dev *client = &fb_helper->client; 725 - struct drm_device *dev = fb_helper->dev; 697 + struct drm_device *dev = client->dev; 726 698 struct drm_connector *connector; 727 699 struct drm_mode_set *modeset; 728 700 int j; ··· 741 715 drm_modeset_unlock_all(dev); 742 716 } 743 717 744 - static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) 718 + /** 719 + * drm_client_modeset_dpms() - Set DPMS mode 720 + * @client: DRM client 721 + * @mode: DPMS mode 722 + * 723 + * Note: For atomic drivers @mode is reduced to on/off. 724 + * 725 + * Returns: 726 + * Zero on success or negative error code on failure. 727 + */ 728 + int drm_client_modeset_dpms(struct drm_client_dev *client, int mode) 745 729 { 746 - struct drm_fb_helper *fb_helper = info->par; 747 - struct drm_client_dev *client = &fb_helper->client; 748 - struct drm_device *dev = fb_helper->dev; 730 + struct drm_device *dev = client->dev; 731 + int ret = 0; 749 732 750 - /* 751 - * For each CRTC in this fb, turn the connectors on/off. 752 - */ 753 - mutex_lock(&fb_helper->lock); 754 733 if (!drm_master_internal_acquire(dev)) 755 - goto unlock; 734 + return -EBUSY; 756 735 757 736 mutex_lock(&client->modeset_mutex); 758 737 if (drm_drv_uses_atomic_modeset(dev)) 759 - restore_fbdev_mode_atomic(fb_helper, dpms_mode == DRM_MODE_DPMS_ON); 738 + ret = drm_client_modeset_commit_atomic(client, mode == DRM_MODE_DPMS_ON); 760 739 else 761 - dpms_legacy(fb_helper, dpms_mode); 740 + drm_client_modeset_dpms_legacy(client, mode); 762 741 mutex_unlock(&client->modeset_mutex); 763 742 764 743 drm_master_internal_release(dev); 765 - unlock: 744 + 745 + return ret; 746 + } 747 + 748 + static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) 749 + { 750 + struct drm_fb_helper *fb_helper = info->par; 751 + 752 + mutex_lock(&fb_helper->lock); 753 + drm_client_modeset_dpms(&fb_helper->client, dpms_mode); 766 754 mutex_unlock(&fb_helper->lock); 767 755 } 768 756 ··· 1850 1810 1851 1811 pan_set(fb_helper, var->xoffset, var->yoffset); 1852 1812 1853 - ret = restore_fbdev_mode_force(fb_helper); 1813 + ret = drm_client_modeset_commit_force(&fb_helper->client); 1854 1814 if (!ret) { 1855 1815 info->var.xoffset = var->xoffset; 1856 1816 info->var.yoffset = var->yoffset; ··· 2076 2036 2077 2037 /* First time: disable all crtc's.. */ 2078 2038 if (!fb_helper->deferred_setup) 2079 - restore_fbdev_mode(fb_helper); 2039 + drm_client_modeset_commit(client); 2080 2040 return -EAGAIN; 2081 2041 } 2082 2042 ··· 2850 2810 2851 2811 modeset->fb = fb_helper->fb; 2852 2812 2853 - if (drm_fb_helper_panel_rotation(modeset, &rotation)) 2813 + if (drm_client_panel_rotation(modeset, &rotation)) 2854 2814 /* Rotating in hardware, fbcon should not rotate */ 2855 2815 sw_rotations |= DRM_MODE_ROTATE_0; 2856 2816 else