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