Repository navigation
feat(graphics): reported output changes to gfxfb's clients as events - #464
Merged
Merged
Conversation
A display could not report an output that lit or went dark, so programs kept drawing to a primary output no monitor showed. Each change reaches every client as an event, and the primary moves to a lit output.
FlareCoding
force-pushed
the
pr/gfxfb-output-events
branch
from
October 25, 2026 23:18
08919d9 to
4d6b837
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gfxfb learns when an output (what shows one monitor's picture) lights, goes dark or relights at another mode, tells every open file of /dev/gfxfb through an output event (a record
readreturns naming the output), and moves the primary, the role of the output a one-screen program draws on, off an output that goes dark.Changes
gfxfb::output_changed()reads the output again, records a lit output's base buffer (the buffer it was lit with, which offset 0 maps on the primary output) and queues aGFXFB_EVENT_OUTPUTevent naming the output in every open file, andoutput_state.relightingmarks an output taken dark to be lit again at another mode. A failed display's reports change nothing, and neither the boot display nor virtio-gpu reports a change.queue_output_event()puts a newer output event at the tail of the file's queue in place of the one the file holds for that output, so the queue's 2 xGFXFB_OUTPUTS_MAXrecords always suffice and, since a display ends an output's present before reporting it dark, a file reads that present'sGFXFB_PRESENT_DARKend before the output's event. The event wakesreadandpoll, and only an unread present event, never an output event, fails the file's next present on that output with EBUSY.GFXFB_GET_INFOandGFXFB_FLUSHfail with EAGAIN and mmap at offset 0 is refused, each reading the primary under the node's outputs lock.flip_presenter::take_end()returns at an event that is not a present event, leavingend_fd()set, so an output event never reads as a present that latched.GFXFB_PRESENT_DARKend, a blocking read woken by a change, a close kept waiting through an output change, a queue holding a present event and an output event for each of 16 outputs, a replaced output event keeping a wrapped queue in order, the primary staying on a relighting output and moving off a dark one from output 1 to output 0 and back and to the lowest of several lit outputs, a lit output without a recorded base buffer counted as dark, a dark output's buffers handed back, a program's buffer shown before a lit report kept, a relit output's stale mark cleared and its cursor hidden, the stale mark kept through reports that keep the base buffer, a failed display's reports ignored, and reports for another display or a missing output dropped.Note
Medium Risk
Changes primary-output selection, buffer lifetime, and client event queues in the kernel graphics path; behavior is heavily tested but any future driver calling
output_changed()must follow the new ordering and relighting contract.Overview
Adds runtime hotplug-style output notifications for
/dev/gfxfb: displays call newgfxfb::output_changed(), gfxfb re-reads the output, updates per-output base/shown buffer records, moves or retains the primary output (including relighting viaoutput_state.relighting), and deliversGFXFB_EVENT_OUTPUTto every open client—replacing any prior output event for that output and wakingread/poll.Primary drawing path no longer uses a fixed
m_primary_record;GFXFB_GET_INFO,GFXFB_FLUSH, and mmap offset 0 go throughprimary_base()and return EAGAIN while there is no primary or the primary is relighting. Present-event tracking is tightened so onlyGFXFB_EVENT_PRESENTblocks the next present on an output.stlxdm ignores non-present events in
take_end()so output events do not look like latched presents. virtio-gpu and boot display only setrelighting = false(no reports yet). ABI/kernel docs and a large gfxfb test suite cover primary moves, buffer drops on dark, failed-display no-ops, and event ordering.Reviewed by Cursor Bugbot for commit 08919d9. Bugbot is set up for automated code reviews on this repo. Configure here.