0282-drm-vc4-Add-more-display-planes-to-each-CRTC.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 5735ac96c821e3caf84de2d2358d0993130bc999 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Tue, 20 Oct 2015 14:18:56 +0100
  4. Subject: [PATCH 282/381] drm/vc4: Add more display planes to each CRTC.
  5. Previously we only did the primary and cursor plane, but overlay
  6. planes are useful and just require this setup to add, since all planes
  7. go into the HVS display list in the same way.
  8. Signed-off-by: Eric Anholt <eric@anholt.net>
  9. (cherry picked from commit fc2d6f1eabee9d971453da2a27a72471c2a347dd)
  10. ---
  11. drivers/gpu/drm/vc4/vc4_crtc.c | 56 ++++++++++++++++++++++++++++++------------
  12. 1 file changed, 40 insertions(+), 16 deletions(-)
  13. --- a/drivers/gpu/drm/vc4/vc4_crtc.c
  14. +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
  15. @@ -677,9 +677,9 @@ static int vc4_crtc_bind(struct device *
  16. struct vc4_dev *vc4 = to_vc4_dev(drm);
  17. struct vc4_crtc *vc4_crtc;
  18. struct drm_crtc *crtc;
  19. - struct drm_plane *primary_plane, *cursor_plane;
  20. + struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
  21. const struct of_device_id *match;
  22. - int ret;
  23. + int ret, i;
  24. vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL);
  25. if (!vc4_crtc)
  26. @@ -708,27 +708,49 @@ static int vc4_crtc_bind(struct device *
  27. goto err;
  28. }
  29. - cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
  30. - if (IS_ERR(cursor_plane)) {
  31. - dev_err(dev, "failed to construct cursor plane\n");
  32. - ret = PTR_ERR(cursor_plane);
  33. - goto err_primary;
  34. - }
  35. -
  36. - drm_crtc_init_with_planes(drm, crtc, primary_plane, cursor_plane,
  37. + drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
  38. &vc4_crtc_funcs);
  39. drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
  40. primary_plane->crtc = crtc;
  41. - cursor_plane->crtc = crtc;
  42. vc4->crtc[drm_crtc_index(crtc)] = vc4_crtc;
  43. vc4_crtc->channel = vc4_crtc->data->hvs_channel;
  44. + /* Set up some arbitrary number of planes. We're not limited
  45. + * by a set number of physical registers, just the space in
  46. + * the HVS (16k) and how small an plane can be (28 bytes).
  47. + * However, each plane we set up takes up some memory, and
  48. + * increases the cost of looping over planes, which atomic
  49. + * modesetting does quite a bit. As a result, we pick a
  50. + * modest number of planes to expose, that should hopefully
  51. + * still cover any sane usecase.
  52. + */
  53. + for (i = 0; i < 8; i++) {
  54. + struct drm_plane *plane =
  55. + vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
  56. +
  57. + if (IS_ERR(plane))
  58. + continue;
  59. +
  60. + plane->possible_crtcs = 1 << drm_crtc_index(crtc);
  61. + }
  62. +
  63. + /* Set up the legacy cursor after overlay initialization,
  64. + * since we overlay planes on the CRTC in the order they were
  65. + * initialized.
  66. + */
  67. + cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
  68. + if (!IS_ERR(cursor_plane)) {
  69. + cursor_plane->possible_crtcs = 1 << drm_crtc_index(crtc);
  70. + cursor_plane->crtc = crtc;
  71. + crtc->cursor = cursor_plane;
  72. + }
  73. +
  74. CRTC_WRITE(PV_INTEN, 0);
  75. CRTC_WRITE(PV_INTSTAT, PV_INT_VFP_START);
  76. ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
  77. vc4_crtc_irq_handler, 0, "vc4 crtc", vc4_crtc);
  78. if (ret)
  79. - goto err_cursor;
  80. + goto err_destroy_planes;
  81. vc4_set_crtc_possible_masks(drm, crtc);
  82. @@ -736,10 +758,12 @@ static int vc4_crtc_bind(struct device *
  83. return 0;
  84. -err_cursor:
  85. - cursor_plane->funcs->destroy(cursor_plane);
  86. -err_primary:
  87. - primary_plane->funcs->destroy(primary_plane);
  88. +err_destroy_planes:
  89. + list_for_each_entry_safe(destroy_plane, temp,
  90. + &drm->mode_config.plane_list, head) {
  91. + if (destroy_plane->possible_crtcs == 1 << drm_crtc_index(crtc))
  92. + destroy_plane->funcs->destroy(destroy_plane);
  93. + }
  94. err:
  95. return ret;
  96. }