summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-08-15 14:29:19 +0000
committerOmar Rizwan <omar@omar.website>2023-08-15 14:29:19 +0000
commit330a2f7b72d56c841e2d99d1cbea4cc837bce641 (patch)
treeed3e7c2a1121dfe76a0cc857172ad79ba953a292
parentUse old positions so tags move 'monotonically' (diff)
downloadfolk-330a2f7b72d56c841e2d99d1cbea4cc837bce641.tar.gz
folk-330a2f7b72d56c841e2d99d1cbea4cc837bce641.zip
Use CPU copy to drive display
-rw-r--r--pi/Display.tcl30
1 files changed, 14 insertions, 16 deletions
diff --git a/pi/Display.tcl b/pi/Display.tcl
index 2c7c50ef..93e86739 100644
--- a/pi/Display.tcl
+++ b/pi/Display.tcl
@@ -54,12 +54,12 @@ dc code {
static void commitThenClearStaging();
pixel_t* staging;
+ pixel_t* fbmem;
struct {
pixel_t* mem;
uint32_t id;
} fbs[2];
- int currentFbIndex;
int fbwidth;
int fbheight;
@@ -197,12 +197,19 @@ dc proc setupGpu {} void {
}
setupFb(0);
+ fbmem = fbs[0].mem;
setupFb(1);
+ staging = fbs[1].mem;
- // Can't drop master if we're going to flip buffers at runtime.
- // drmDropMaster(gpuFd);
-
- commitThenClearStaging();
+ int ret = drmModeSetCrtc(gpuFd, gpuEnc->crtc_id, fbs[0].id, 0, 0,
+ &gpuConn->connector_id, 1, &gpuConn->modes[0]);
+ if (ret) {
+ fprintf(stderr, "Display: cannot flip CRTC to %d for connector %u (%d): %m\n",
+ 0, gpuConn->connector_id, errno);
+ exit(1);
+ }
+
+ drmDropMaster(gpuFd);
}
dc proc setupFb {int idx} void [csubst {
struct drm_mode_create_dumb dumb;
@@ -238,19 +245,10 @@ dc proc setupFb {int idx} void [csubst {
}]
# Hack to support old stuff that uses framebuffer directly and doesn't commit.
dc proc getFbPointer {} pixel_t* {
- return fbs[currentFbIndex].mem;
+ return fbmem;
}
dc proc commitThenClearStaging {} void {
- currentFbIndex = !currentFbIndex;
- int ret = drmModeSetCrtc(gpuFd, gpuEnc->crtc_id, fbs[currentFbIndex].id, 0, 0,
- &gpuConn->connector_id, 1, &gpuConn->modes[0]);
- if (ret) {
- fprintf(stderr, "Display: cannot flip CRTC to %d for connector %u (%d): %m\n",
- currentFbIndex,
- gpuConn->connector_id, errno);
- exit(1);
- }
- staging = fbs[!currentFbIndex].mem;
+ memcpy(fbmem, staging, fbwidth * fbheight * sizeof(pixel_t));
// This memset takes ~2ms on 1080p on a Pi 4.
memset(staging, 0, fbwidth * fbheight * sizeof(pixel_t));
}