Re: [PATCH v6] drm/tiny: trigger5: Add MCT Trigger 5 USB display driver
From: Jie Feng
Date: Mon Nov 30 2026 - 08:51:48 EST
Hi,
On Fri, 27 Nov 2026 at 17:49, Thomas Zimmermann <tzimmermann@xxxxxxx> wrote:
>
> Hi,
>
> I think the driver looks much better now. I left a few notes below that
> you might want to address.
>
>
> Am 12.11.26 um 16:45 schrieb Jie Feng:
> > From: Ho Jie Feng <hjf3108@xxxxxxxxx>
> >
> > Add a DRM driver for MCT Trigger 5 USB display adapters.
> > This supports USB 3 to HDMI/VGA displays adapters with
> > trigger5 chipsets from j5create, StarTech and various others.
> >
> > The driver implements modesetting and USB framebuffer updates,
> > connector detection, and EDID retrieval.
> >
> > The protocol is based on reverse-engineering work by Forest Crossman
> > (cyrozap) at: https://github.com/cyrozap/mct-usb-display-adapter-re
> > and usb packet captures between the Windows driver and the device.
> >
> > Only the HDMI path has been tested. VGA selection is inferred from the
> > absence of USB audio interfaces.
> >
> > Tested on JUA355. The list of USB device IDs are taken from the
> > Windows driver INF.
> >
> > Signed-off-by: Ho Jie Feng <hjf3108@xxxxxxxxx>
> > ---
...
> > +static void trigger5_plane_atomic_update(struct drm_plane *plane,
> > + struct drm_atomic_commit *atomic_state)
> > +{
> > + struct drm_plane_state *old_state =
> > + drm_atomic_get_old_plane_state(atomic_state, plane);
> > + struct drm_plane_state *state =
> > + drm_atomic_get_new_plane_state(atomic_state, plane);
> > + struct drm_shadow_plane_state *shadow_plane_state =
> > + to_drm_shadow_plane_state(state);
> > + struct trigger5_device *trigger5 = to_trigger5(plane->dev);
> > + struct trigger5_transfer *transfer;
> > + struct trigger5_bulk_header *header;
> > + struct drm_rect current_rect, src_rect, clip;
> > + struct iosys_map data_map;
> > + size_t payload_len;
> > + int width, height, lines_per_urb;
> > + int idx, y;
> > +
> > + if (!drm_atomic_helper_damage_merged(old_state, state, ¤t_rect))
> > + return;
>
> Never use _damage_merged in your display update code. (^1) Userspace
> supplies damage rectangles for ares that have changed in the current
> frame. Merging them creates a bounding box around all of them. IOW you
> add areas that have not changed. For example, have a blinking cursor
> near the lower left corner and move the mouse around the window's
> menubar, and your driver easily transfers half of the screen or more for
> nothing.
>
> Therefore always iterate over the damage rectangles and handle them one
> by one. Don't be concerned with overlapping damage regions. I did some
> tests with Gnome and could not find any operlaps. It appears that Gnome
> already submits an optimized list damage regions. Overlapping can also
> be detected algorithmically and filtered out by our damage handlers.
> But a merged bounding box cannot be optimized.
>
> ^1: White lie, as we use _damage_merged for ast's cursor. But this code
> really is different.
After some testing, it does not just accept 3 rects per vblank, that
was me misremembering the tests for full screen updates. It can accept
many small rects per screen update. However, I could not find a way to
make sure a batch of rects is sent atomically, but it is guaranteed
that tearing will not occur within a rect update, so I think it should
keep _damaged_merged in this case?
...
> > + if (mode->hsync_end <= mode->hsync_start ||
> > + mode->htotal <= mode->hsync_end)
> > + return MODE_H_ILLEGAL;
> > +
> > + if (mode->vsync_end <= mode->vsync_start ||
> > + mode->vtotal <= mode->vsync_end)
> > + return MODE_V_ILLEGAL;
>
> You don't nee that basic stuff. See [2]. Just test for hardware specifics.
>
> [2]
> https://elixir.bootlin.com/linux/v7.3.4/source/drivers/gpu/drm/drm_modes.c#L1652
If I understand this correctly, the check here is only for < and not
<=, so I need to keep the = since hardware doesn't support zero sync
or zero back porch? I can switch this to a == in v7.
> > +
> > + if (trigger5_mode_buf_len(mode) > TRIGGER5_MAX_FRAME_SIZE)
> > +
...
Best regards,
Jie Feng