From 2f8484e65d707da05aaeb912fa5a8f791a33b273 Mon Sep 17 00:00:00 2001 From: yours3lf <0.tamas.marton@gmail.com> Date: Wed, 3 Jun 2020 22:40:58 +0100 Subject: [PATCH] backup --- driver/modeset.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/driver/modeset.c b/driver/modeset.c index 932f755..08d7cb6 100644 --- a/driver/modeset.c +++ b/driver/modeset.c @@ -19,40 +19,50 @@ typedef struct vsyncData static uint32_t refCount = 0; static pthread_t flipQueueThread = 0; -static Fifo flipQueueFifo = {}; +static Fifo flipQueueFifo; static vsyncData dataMem[FLIP_FIFO_SIZE]; static FifoElem fifoMem[FLIP_FIFO_SIZE]; static atomic_int flip_queue_guard = 0; -static void flipQueueThreadFunction(void* vargp) +static void* flipQueueThreadFunction(void* vargp) { uint32_t run = 1; uint64_t lastFinishedSeqno = 0; - int fd = *(int*)vargp; + int threadFD = *(int*)vargp; while(run) { - vsyncData* d = 0; - while(flip_queue_guard); - flip_queue_guard = 1; - d = fifoGetLast(&flipQueueFifo); + uint64_t seqno = 0; - run = refCount; + { + while(flip_queue_guard); + flip_queue_guard = 1; - flip_queue_guard = 0; + vsyncData* d = fifoGetLast(&flipQueueFifo); + if(d) + { + seqno = d->seqno; + } - if(d && d->seqno) + run = refCount; + + flip_queue_guard = 0; + } + + if(seqno) { uint64_t timeOut = 1000000; //1 ms in ns - int ret = vc4_seqno_wait(controlFd, &lastFinishedSeqno, d->seqno, &timeOut); + int ret = vc4_seqno_wait(threadFD, &lastFinishedSeqno, seqno, &timeOut); if(ret > 0) { while(flip_queue_guard); flip_queue_guard = 1; + vsyncData* d = fifoGetLast(&flipQueueFifo); + fprintf(stderr, "seqno finished, flipping %llu image %p\n", d->seqno, d->i); d->seqno = 0; //done! @@ -61,15 +71,17 @@ static void flipQueueThreadFunction(void* vargp) if(d->i->presentMode == VK_PRESENT_MODE_FIFO_KHR) { - drmModePageFlip(fd, d->s->crtc->crtc_id, d->i->fb, DRM_MODE_PAGE_FLIP_EVENT, d); + drmModePageFlip(threadFD, d->s->crtc->crtc_id, d->i->fb, DRM_MODE_PAGE_FLIP_EVENT, d); } else if(d->i->presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) { - drmModePageFlip(fd, d->s->crtc->crtc_id, d->i->fb, DRM_MODE_PAGE_FLIP_ASYNC, 0); + drmModePageFlip(threadFD, d->s->crtc->crtc_id, d->i->fb, DRM_MODE_PAGE_FLIP_ASYNC, 0); } } } } + + return 0; } void modeset_enum_displays(int fd, uint32_t* numDisplays, modeset_display* displays)