mipidsi – Low-level routines for interacting with MIPI DSI

Available on these boards
  • Adafruit Metro ESP32-P4
  • Adafruit P4 GPIO
  • ESP32-P4 Stamp XL
  • ESP32-P4-Function-EV
  • ESP32-P4X-Function-EV
  • M5Stack Tab5

class mipidsi.Bus(*, minimum_frequency: int = 500000000, num_lanes: int = 2)

Create a MIPI DSI Bus object.

This creates a DSI bus interface. The specific pins used are determined by the board. DSI supports 1-4 data lanes.

The lane bit rate is a bandwidth floor, not an exact clock. The bus runs at a rate the PHY can generate that is at least minimum_frequency, choosing one close to it. Rates within 1 kHz of the minimum count, since the PHY and the reported pixel clock are quantized. The actual rate can be read back from frequency.

Parameters:
  • minimum_frequency (int) – the minimum lane bit rate in Hz (default 500 MHz)

  • num_lanes (int) – the number of data lanes to use (default 2, range 1-4)

Raises:

ValueError – if the PHY cannot reach minimum_frequency

deinit() → None

Free the resources (pins, timers, etc.) associated with this mipidsi.Bus instance. After deinitialization, no further operations may be performed.

frequency: int

The lane bit rate the bus actually runs at, in Hz. This is at least the minimum_frequency passed to the constructor, up to the 1 kHz rounding tolerance, but can be higher because the PHY PLL only produces certain rates.

num_lanes: int

The number of data lanes the bus uses.

class mipidsi.Display(bus: Bus, init_sequence: circuitpython_typing.ReadableBuffer, *, width: int, height: int, hsync_pulse_width: int, hsync_back_porch: int, hsync_front_porch: int, vsync_pulse_width: int, vsync_back_porch: int, vsync_front_porch: int, pixel_clock_frequency: int, virtual_channel: int = 0, rotation: int = 0, color_depth: int = 16, backlight_pin: microcontroller.Pin | None = None, brightness: float = 1.0, native_frames_per_second: int = 60, backlight_on_high: bool = True, low_power_blanking: bool = True)

Create a MIPI DSI Display object connected to the given bus.

This allocates a framebuffer and configures the DSI display to use the specified virtual channel for communication.

The framebuffer pixel format varies depending on color_depth:

  • 16 - Each two bytes is a pixel in RGB565 format.

  • 24 - Each three bytes is a pixel in RGB888 format.

A Display is often used in conjunction with a framebufferio.FramebufferDisplay.

Drivers for DSI bridges can subclass Display. Set up the bridge before calling super().__init__(), which starts DSI video.

Parameters:
  • bus (Bus) – the DSI bus to use

  • init_sequence (ReadableBuffer) – Byte-packed initialization sequence for the display

  • width (int) – the width of the framebuffer in pixels

  • height (int) – the height of the framebuffer in pixels

  • hsync_pulse_width (int) – horizontal sync pulse width in pixel clocks

  • hsync_back_porch (int) – horizontal back porch in pixel clocks

  • hsync_front_porch (int) – horizontal front porch in pixel clocks

  • vsync_pulse_width (int) – vertical sync pulse width in lines

  • vsync_back_porch (int) – vertical back porch in lines

  • vsync_front_porch (int) – vertical front porch in lines

  • pixel_clock_frequency (int) – pixel clock frequency in Hz. The clock actually generated can differ; read it back from pixel_clock_frequency.

  • virtual_channel (int) – the DSI virtual channel (0-3)

  • rotation (int) – the rotation of the display in degrees clockwise (0, 90, 180, 270)

  • color_depth (int) – the color depth of the framebuffer in bits (16 or 24)

  • backlight_pin (microcontroller.Pin) – Pin connected to the display’s backlight

  • brightness (float) – Initial display brightness (0.0 to 1.0)

  • native_frames_per_second (int) – Number of display refreshes per second

  • backlight_on_high (bool) – If True, pulling the backlight pin high turns the backlight on

  • low_power_blanking (bool) – If True, the DSI lanes may drop to low power mode during blanking. Set False to keep them in high speed mode, which bridges that regenerate the pixel clock from the DSI clock (such as the LT8912B) need.

deinit() → None

Free the resources (pins, timers, etc.) associated with this mipidsi.Display instance. After deinitialization, no further operations may be performed.

width: int

The width of the framebuffer, in pixels.

height: int

The height of the framebuffer, in pixels.

color_depth: int

The color depth of the framebuffer.

pixel_clock_frequency: int

The pixel clock frequency the DSI host actually generates, in Hz. This can differ from the requested frequency when the clock source cannot divide down to it exactly.