Skip to content

lt8912b: HDMI and DVI out through a Lontium LT8912B, with Adafruit's API (needs first light) - #688

Draft
bdbarnett wants to merge 8 commits into
mainfrom
lt8912b-hdmi
Draft

bdbarnett wants to merge 8 commits into
mainfrom
lt8912b-hdmi

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

Needs first light on a board before review ends. Nothing here has run on hardware yet; every example's Tested on: line says so.

This adds lt8912b, a driver for the Lontium LT8912B MIPI DSI to HDMI/DVI bridge (Adafruit 6539 and others), two board configs for Waveshare's ESP32-P4-WIFI6 and ESP32-P4-WIFI6-DEV-KIT with Adafruit's board, a guide (docs/guides/hdmi-out.md) and two examples. LT8912B is a subclass of mipidsi.Display with the same constructor, properties and order of work as Adafruit's CircuitPython adafruit_lt8912b.LT8912B, so a program written for that keeps its LT8912B(bus, i2c, width=..., ...) call. On top of that it adds mode fitting for the P4's divided pixel clock (fit, check, Mode.timing()), EDID reading (read_edid, parse_edid, best_mode), experimental HDMI audio over I2S, status(), and Bridge, the I2C side alone, which shows the bridge's own test pattern with no DSI video. The framebuffer is RGB565 and the P4 sends RGB888; color_depth=24 is passed to mipidsi as asked and refused with a clear message where mipidsi has no RGB888 framebuffer. Because this mipidsi.Bus doesn't report its lanes or rate, LT8912B takes them as num_lanes= and bus_frequency=, and says so when they're missing.

Real video needs a firmware whose mipidsi.Display takes output_color_depth and low_power_blanking; older firmware raises a TypeError naming the argument. The test-pattern example runs on any firmware with machine.I2C.

What was run: tests/test_lt8912b.py runs the driver contract (118 checks against the register tables of Espressif's and Adafruit's drivers, a real monitor's EDID, and LT8912B against a fake mipidsi.Display) on CPython and unix MicroPython, and six planted faults each fail it, among them video starting before the bridge is set up and color_depth=24 quietly remapped. Adafruit's driver and this one, run on the same fake bus with Adafruit's 720p call, write the same registers in the same order, except that this one writes the TX-off and sync-polarity bytes whole, checks the chip ID first, and resets the receiver again after video starts. Both board configs and both examples ran on unix MicroPython against fake machine and mipidsi modules. Subclassing a native type from Python was checked on unix MicroPython with another native type, not yet with mipidsi.Display on a P4. libbuild.py check, installers --check, the style check and a -W docs build are clean.

Not verified: anything on a board, including the bridge locking to the P4's video, the padded timings on real monitors, the cable orientation on the DEV-KIT, and every audio register.

A driver for the LT8912B bridge on Adafruit's, Olimex's and M5Stack's
boards: chip detection, hot-plug, EDID read and parse, a table of
standard modes fitted to a host that divides a fixed clock, a lane-rate
check that refuses what the lanes can't carry with the numbers, one to
four lanes, HDMI or DVI with LVDS off, the bridge's own test pattern,
read-back of the sync counts it measures, and experimental I2S audio.

The register tables are Espressif's and Adafruit's (Apache-2.0). The
contract runs on CPython and unix MicroPython: 86 checks, including each
mode's writes in order against those tables and a real monitor's EDID,
and four planted faults each fail it. Not yet run on hardware.
720p60 at 80 MHz with a wider front porch, 960 Mbps on two lanes. Pins,
mode and audio sit in one block at the top of each config. When the
firmware's mipidsi can't send RGB888 with the lanes kept in high speed,
the config shows the bridge's test pattern and raises NotImplementedError
naming what's missing.

Run on unix MicroPython against fake machine and mipidsi modules, one
refusing the options as today's firmware does and one accepting them.
Not yet run on hardware.
How to wire Adafruit's board to an ESP32-P4, see colour bars before any
DSI video, pick a mode the two lanes carry, and what isn't proven yet.
fit() takes vic=, and both HDMI board configs have a VIC setting. A padded
mode still announces 0 by default, since its timing isn't the CEA one; some
sinks may handle it better with the standard code, such as 4 for 720p60.

The contract gains two checks (88 pass on CPython and unix MicroPython).
Not run on a board.
RST goes from the LT8912B adapter's pad to the Pico header's pin 22 (GPIO 47), free on the board and unused by the other ESP32-P4-WIFI6 configs. tests/lt8912b_contract.py passes on CPython and MicroPython (88 each).
A program written for Adafruit's CircuitPython adafruit_lt8912b keeps its
LT8912B(bus, i2c, width=..., pixel_clock_frequency=..., reset=...,
hsync_positive=..., vic=..., aspect_ratio=...) call, and width, height and
hot_plug_detected read the same. Like Adafruit's, it resets and configures
the bridge over I2C, starts DSI video, checks the bus rate against the
pixel clock, then reseeds the bridge's clock from the running video.

What stays this driver's own: fit(), check(), read_edid(), parse_edid()
and best_mode(), Mode.timing() for LT8912B(bus, i2c, **mode.timing()),
audio= and hdmi=, hpd=, status(), and Bridge, the I2C side alone, with the
test pattern, clashes() and detect(). The framebuffer stays RGB565 with
RGB888 on the wire; color_depth=24 goes to mipidsi as asked, and where
mipidsi has no RGB888 framebuffer the error says to leave it out. A
mipidsi.Bus that doesn't report its lanes and rate takes num_lanes= and
bus_frequency= instead, and says so when they're missing.

The board configs build on LT8912B. The simpletest now draws bars over
DSI with Adafruit's call; the bridge-only test pattern moves to
lt8912b_test_pattern.py.

Checked: the contract (118 checks) passes on CPython and unix MicroPython,
and each of six planted faults fails it, including video starting before
the bridge is set up and color_depth=24 quietly remapped. Adafruit's
driver and this one, run on the same fake bus with Adafruit's 720p call,
write the same registers in the same order, except that this one writes
the TX-off and sync-polarity bytes whole and resets the receiver again
after video starts. Both board configs and both examples run on unix
MicroPython against fake machine and mipidsi modules. Nothing has run on
a board.
mipidsi.Bus(minimum_frequency=) now reports num_lanes and frequency, as
CircuitPython's does, so LT8912B reads them and drops the num_lanes= and
bus_frequency= stand-ins. A 24-bit framebuffer is accepted by mipidsi too,
so color_depth=24 is passed on as Adafruit's driver does. The contract test
fakes a bus that reports its figures, and every planted fault still fails.
@bdbarnett

Copy link
Copy Markdown
Contributor Author

The driver now takes the bus's lanes and rate from mipidsi.Bus.num_lanes and frequency, as Adafruit's does, so the num_lanes= and bus_frequency= stand-ins are gone. The board config, the example and the HDMI guide use Bus(minimum_frequency=), and color_depth=24 goes straight to mipidsi. The contract test passes on CPython and MicroPython, and every planted fault still fails.

This needs firmware with omnipython-builds#557 (the mipidsi read-backs and 24-bit framebuffers), so it still waits on first light as well.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant