Fix HDMI never locking: select the video input before loading the bitstream - #19
Open
ScreenSensitive wants to merge 1 commit into
Open
Fix HDMI never locking: select the video input before loading the bitstream#19ScreenSensitive wants to merge 1 commit into
ScreenSensitive wants to merge 1 commit into
Conversation
HDMI never locks: the panel stays black while DisplayPort over USB-C works. start_display_pipeline() calls restart_fpga() first and apply_input_selection() last. apply_input_selection() runs adv7611_early_init() and adv7611_init(), so the bitstream is loaded and the gateware begins trying to lock before the input is selected, and the decoder is then re-initialised underneath it -- resetting its pixel clock and reasserting HPD. The decoder initialises twice, the second time after "FPGA up", and the input then reports status 01 with measured 0 x 0. DisplayPort is unaffected because the PTN3460 is not disturbed the same way, which is why this appears as an HDMI fault rather than an ordering problem. Split the existing work so the frontend bring-up happens before restart_fpga(), leaving only the CSR_INPUT_CTRL write after it since that register needs the FPGA running. Both frontends stay powered on INPUT_SEL_AUTO and caster_input_request_auto() is still used, so hot-plug auto-switching is unchanged. Also wait for an input to go live before loading the bitstream. Sampling immediately is not enough: 35 ms after adv7611_init() nothing reads as live even against a host already sending, and the decoder took around 1.1s to report lock, so the wrong input gets committed. The wait is generous because it costs nothing when a source is present -- it exits as soon as it sees signal -- and it also covers powering the board and host on together, where the host can take far longer to start driving. The reload path after video loss deliberately does NOT wait, since video has just gone away and there is nothing to wait for; waiting there delayed the no-signal state by the full timeout. It instead honours a minimum interval between reloads, without which a flapping input reloads the bitstream continuously and the panel visibly flashes. Tested on a 13.3" 1600x1200 Paper Dev Kit with fpga-8bit-mono.bit against a macOS host. Before: status 01, measured 0 x 0. After: status 3a [TMDS STABLE SUPPORTED LIVE], measured 1600 x 1200. Auto-switching between USB-C and HDMI verified including hot-plug; unplugging HDMI reloads in 156 ms and replugging recovers automatically.
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.
Problem
HDMI does not work. DisplayPort over USB-C is unaffected, and nothing in the log indicates a failure.
Cause
start_display_pipeline()callsrestart_fpga()first andapply_input_selection()last.apply_input_selection()runsadv7611_early_init()/adv7611_init(), so the bitstream is loaded — and the gateware starts trying to lock — before the input is selected, and the decoder is then re-initialised underneath it, resetting its pixel clock and reassertingHPD_EN.syslog shows the decoder initialising twice, the second time after
FPGA up:DisplayPort is unaffected because the PTN3460 isn't disturbed the same way, which is why this presents as an HDMI fault rather than an ordering problem.
Fix
Split the existing work so the frontend bring-up happens before
restart_fpga(), leaving only theCSR_INPUT_CTRLwrite after it since that register needs the FPGA running. Both frontends stay powered onINPUT_SEL_AUTOandcaster_input_request_auto()is still used, so hot-plug auto-switching is unchanged.Also wait for an input to go live before loading the bitstream. Sampling immediately is not sufficient: 35 ms after
adv7611_init()nothing reads as live even against a host that is already sending, and the decoder took ~1.1 s to report lock — so the wrong input gets committed and HDMI never comes up. The wait costs nothing when a source is present, since it exits as soon as it sees signal, and it also covers powering the board and host on together where the host takes far longer to start driving.The reload path after video loss deliberately does not wait — video has just gone away, so there is nothing to wait for, and waiting there delays the no-signal state by the full timeout. It honours a minimum interval between reloads instead; without that a flapping input reloads the bitstream continuously and the panel visibly flashes.
Testing
13.3" 1600x1200 Paper Dev Kit,
fpga-8bit-mono.bit, macOS host over HDMI.Input status 01, measured 0 x 0Input status 3a [TMDS STABLE SUPPORTED LIVE], measured 1600 x 1200Narrowed by testing the pieces separately: powering down the unselected frontend and requesting TMDS explicitly also fix HDMI, but are unnecessary and would remove auto-switching, so neither is included.
Notes
main(ed94ef7f); it also rebases cleanly onto the1.1tag, which only toucheslog_input_status(). I have not tested against the gateware submodule bump in 1.1.VIDEO_INPUT_WAIT_MSis chosen conservatively rather than derived; the measured requirement was ~1.1 s.