1 From a51e4acdab01540e1006e43f38e5befb40002de0 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 27 Apr 2023 09:47:54 +0200
4 Subject: [PATCH] drm/vc4: txp: Add horizontal and vertical size offset toggle
7 The new writeback controllers that can be found on the BCM2712 require
8 to have their horizontal and vertical size reduced by one.
10 Let's tie that behaviour to the compatible so we can support both the
11 new and old controllers.
13 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 drivers/gpu/drm/vc4/vc4_drv.h | 1 +
16 drivers/gpu/drm/vc4/vc4_txp.c | 14 ++++++++++++--
17 2 files changed, 13 insertions(+), 2 deletions(-)
19 --- a/drivers/gpu/drm/vc4/vc4_drv.h
20 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
21 @@ -564,6 +564,7 @@ struct vc4_crtc_data {
23 struct vc4_crtc_data base;
24 unsigned int has_byte_enable:1;
25 + unsigned int size_minus_one:1;
28 extern const struct vc4_txp_data bcm2835_txp_data;
29 --- a/drivers/gpu/drm/vc4/vc4_txp.c
30 +++ b/drivers/gpu/drm/vc4/vc4_txp.c
31 @@ -295,6 +295,8 @@ static void vc4_txp_connector_atomic_com
32 struct drm_gem_dma_object *gem;
33 struct drm_display_mode *mode;
34 struct drm_framebuffer *fb;
35 + unsigned int hdisplay;
36 + unsigned int vdisplay;
40 @@ -334,9 +336,17 @@ static void vc4_txp_connector_atomic_com
41 gem = drm_fb_dma_get_gem_obj(fb, 0);
42 TXP_WRITE(TXP_DST_PTR, gem->dma_addr + fb->offsets[0]);
43 TXP_WRITE(TXP_DST_PITCH, fb->pitches[0]);
45 + hdisplay = mode->hdisplay ?: 1;
46 + vdisplay = mode->vdisplay ?: 1;
47 + if (txp_data->size_minus_one) {
53 - VC4_SET_FIELD(mode->hdisplay, TXP_WIDTH) |
54 - VC4_SET_FIELD(mode->vdisplay, TXP_HEIGHT));
55 + VC4_SET_FIELD(hdisplay, TXP_WIDTH) |
56 + VC4_SET_FIELD(vdisplay, TXP_HEIGHT));
58 TXP_WRITE(TXP_DST_CTRL, ctrl);