Re: [PATCH v3 0/2] drm/mipi-dbi: display a cropped region of an oversized framebuffer

From: Jonathan Frazin

Date: Fri Oct 30 2026 - 11:34:54 EST


Friendly ping on this series - v3 addressed the review feedback from
v1/v2 (added the missing st7735r driver). Happy to rebase and resend
if anything's changed on drm-misc-next since September, or if there's
any other feedback.

On Wed, Sep 23, 2026 at 3:58 PM Jonathan Frazin
<frazinjonathan@xxxxxxxxx> wrote:
>
> A drm/tiny MIPI DBI panel can currently only scan out a framebuffer that is exactly panel-sized, always from the origin. This series lets a client allocate a larger framebuffer and choose the displayed region via the plane source rectangle - a crop / pan with no scaling.
>
> Motivation: feeding hardware-decoded video to a small SPI panel. The video decoder emits a fixed frame size; being able to point the panel at a panel-sized window of that buffer avoids a full-frame CPU copy on every flush and lets userspace pan/centre the image.
>
> Patch 1 is the actual fix - mipi_dbi_fb_dirty() addressed the controller in framebuffer coordinates, which is only correct while src_x/src_y are zero. It now subtracts the plane source origin.
>
> Patch 2 raises mode_config.max_width/height (pinned to the panel size) on the six drm/tiny drivers that flush through the shared drm_mipi_dbi_plane_helper_atomic_update(). ili9225 is excluded - it has its own flush path that does not carry the source offset.
>
> Open question for patch 2: the six drivers each set the limits identically in their probe. This could instead be a shared helper (or folded into drm_mipi_dbi_dev_init / the DRM_MIPI_DBI_MODE_CONFIG_* macros) so future drivers get it for free. Happy to respin that way if preferred - the per-driver form is what is shown here because it is the smaller diff and easier to review a first pass.
>
> The min_width/min_height, the fixed mode, the connector and the mode-sized transfer buffer are all unchanged, and drm_mipi_dbi_plane_helper_atomic_check() still enforces DRM_PLANE_NO_SCALING and no repositioning, so the flushed rectangle stays bounded by the panel regardless of the framebuffer dimensions.
>
> Tested on hardware: ILI9341 and ST7789V (through panel-mipi-dbi), both 240x320 - an oversized framebuffer is accepted and a non-zero-offset panel-sized window scans out correctly; a panel-sized framebuffer is unchanged. HX8357D was tested during the downstream review by Dave Stevenson (Cc'd). ili9486, mi0283qt, ili9163 and st7735r are build-tested only.
>
> Both patches have been carried in the Raspberry Pi kernel (rpi-7.2.y) and in use there: https://github.com/raspberrypi/linux/pull/7589. The v1/v2 heap-overflow fix (see below) has also been folded back into that downstream kernel: https://github.com/raspberrypi/linux/pull/7643.
>
> Applies to current mainline / drm-misc-next; the touched files are identical there.
>
> Changes since v2:
> - Patch 1: a damage clip that lies entirely within the one-pixel sliver
> the v2 clamp cuts off collapses the clamped rectangle to zero width or
> height. That was still being passed to mipi_dbi_set_window_address(),
> producing an inverted (start past end) address window ahead of a
> zero-length write - undefined behaviour per the MIPI DCS spec. Skip
> the flush when the clamped rectangle is empty.
> - Patch 2: st7735r also flushes through the shared
> drm_mipi_dbi_plane_helper_atomic_update() but was missed from the
> original list - it lives under drivers/gpu/drm/sitronix/ rather than
> drivers/gpu/drm/tiny/. Added it, and confirmed by grepping the whole
> tree for DRM_MIPI_DBI_PLANE_HELPER_FUNCS that no other driver shares
> this path. Thanks again to the automated review for catching both of
> these on v2.
>
> Changes since v1:
> - Patch 1: clamp the damage rectangle to the panel's fixed mode before
> using it, instead of trusting it to already be panel-sized. src_x/src_y
> are the plane source origin truncated to whole pixels, but the
> rectangle from drm_atomic_helper_damage_merged() is clipped against
> that origin's exact 16.16 fixed-point value - when the origin has a
> fractional part, the rectangle's far edge could land up to a pixel past
> where the truncated origin would place the panel's own width/height,
> overflowing the panel-sized tx_buf. Thanks to the automated review for
> catching this.
> - Patch 2: unchanged.
>
> Jonathan Frazin (2):
> drm/mipi-dbi: honour the plane source offset when flushing
> drm/tiny: allow a framebuffer larger than the panel on MIPI DBI
> drivers
>
> drivers/gpu/drm/drm_mipi_dbi.c | 43 +++++++++++++++++++++++----
> drivers/gpu/drm/sitronix/st7735r.c | 8 +++--
> drivers/gpu/drm/tiny/hx8357d.c | 8 +++--
> drivers/gpu/drm/tiny/ili9163.c | 8 +++--
> drivers/gpu/drm/tiny/ili9341.c | 8 +++--
> drivers/gpu/drm/tiny/ili9486.c | 8 +++--
> drivers/gpu/drm/tiny/mi0283qt.c | 8 +++--
> drivers/gpu/drm/tiny/panel-mipi-dbi.c | 8 +++--
> 8 files changed, 80 insertions(+), 19 deletions(-)
>
> --
> 2.53.0