drm/vc4: txp: Add horizontal and vertical size offset toggle bit
authorMaxime Ripard <mripard@kernel.org>
Fri, 25 Oct 2024 17:15:47 +0000 (18:15 +0100)
committerDave Stevenson <dave.stevenson@raspberrypi.com>
Wed, 27 Nov 2024 14:37:20 +0000 (14:37 +0000)
The new writeback controllers that can be found on the BCM2712 require
to have their horizontal and vertical size reduced by one.

Let's tie that behaviour to the compatible so we can support both the
new and old controllers.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241025-drm-vc4-2712-support-v2-16-35efa83c8fc0@raspberrypi.com
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_txp.c

index 27deb4cde02d13ae51f5b7ffb9d145ea18e91316..984fddae00485d29d4d03e51cdbeab43d24d82d1 100644 (file)
@@ -539,6 +539,7 @@ struct vc4_crtc_data {
 struct vc4_txp_data {
        struct vc4_crtc_data    base;
        unsigned int has_byte_enable:1;
+       unsigned int size_minus_one:1;
 };
 
 extern const struct vc4_txp_data bcm2835_txp_data;
index eaf30b2cfb5b8127f4f9bce314c1147ec37a8f0c..d2ee872e9c0bc1a50fbeac3b1a22ee60ee462bbd 100644 (file)
@@ -291,6 +291,8 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
        struct drm_gem_dma_object *gem;
        struct drm_display_mode *mode;
        struct drm_framebuffer *fb;
+       unsigned int hdisplay;
+       unsigned int vdisplay;
        u32 ctrl;
        int idx;
        int i;
@@ -330,9 +332,17 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
        gem = drm_fb_dma_get_gem_obj(fb, 0);
        TXP_WRITE(TXP_DST_PTR, gem->dma_addr + fb->offsets[0]);
        TXP_WRITE(TXP_DST_PITCH, fb->pitches[0]);
+
+       hdisplay = mode->hdisplay ?: 1;
+       vdisplay = mode->vdisplay ?: 1;
+       if (txp_data->size_minus_one) {
+               hdisplay -= 1;
+               vdisplay -= 1;
+       }
+
        TXP_WRITE(TXP_DIM,
-                 VC4_SET_FIELD(mode->hdisplay, TXP_WIDTH) |
-                 VC4_SET_FIELD(mode->vdisplay, TXP_HEIGHT));
+                 VC4_SET_FIELD(hdisplay, TXP_WIDTH) |
+                 VC4_SET_FIELD(vdisplay, TXP_HEIGHT));
 
        TXP_WRITE(TXP_DST_CTRL, ctrl);