drm/trigger5: Add MCT Trigger 5 USB display driver
Subsystems (2)
PATCH v4 1/1 drm/trigger5: Add MCT Trigger 5 USB display driver
Add a DRM driver for MCT Trigger 5 USB display adapters. 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.
---
Changes in v4:
- Move the driver to drm/tiny
- Remove the buffer resizing to reduce size of file
Changes in v3:
- Flush the vmalloc buffer before submitting the USB transfer.
- Support display panning by using the source offset
Changes in v2:
- Move the buffer resizing to crtc_* functions so that we can report out of memory errors to userspace
- Change the PLL search function so that it is faster and doesn't produce checkpatch warnings
- Update drm functions: crtc reset becomes create_state
- Fix warnings reported by kernel test robot
sashiko review false positives in v1/v2/v3:
- atomic in these function names mean that the changes should go through through at once or not at all, nothing to do with atomic context. Furthermore other drivers also have similar patterns
- drm_gem_fb_begin_cpu_access is also required
MAINTAINERS | 7 + drivers/gpu/drm/tiny/Kconfig | 14 + drivers/gpu/drm/tiny/Makefile | 1 + drivers/gpu/drm/tiny/trigger5.c | 1115 +++++++++++++++++++++++++++++++ 4 files changed, 1137 insertions(+) create mode 100644 drivers/gpu/drm/tiny/trigger5.c
MAINTAINERS +7 -0
@@ -8250,6 +8250,13 @@ S: Maintained F: Documentation/devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml F: drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c +DRM DRIVER FOR MCT TRIGGER 5 USB DISPLAY ADAPTERS +M: Ho Jie Feng <[email protected]> +L: [email protected] +S: Maintained +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git +F: drivers/gpu/drm/tiny/trigger5.c + DRM DRIVER FOR MGA G200 GRAPHICS CHIPS M: Dave Airlie <[email protected]> R: Thomas Zimmermann <[email protected]>
drivers/gpu/drm/tiny/Kconfig +14 -0
@@ -98,6 +98,20 @@ config DRM_PIXPAPER If M is selected, the module will be built as pixpaper.ko. +config DRM_TRIGGER5 + tristate "MCT Trigger 5 USB display adapters" + depends on DRM && USB && MMU + select DRM_CLIENT_SELECTION + select DRM_GEM_SHMEM_HELPER + select DRM_KMS_HELPER + help + DRM driver for USB display adapters based on the MCT Trigger 5 + chipset, including the StarTech USB32VGAES and USB32HDES and the + j5create JUA310 and JUA350. + + To compile this driver as a module, choose M here: the module + will be called trigger5. + config TINYDRM_HX8357D tristate "DRM support for HX8357D display panels" depends on DRM && SPI
drivers/gpu/drm/tiny/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus-qemu.o obj-$(CONFIG_DRM_GM12U320) += gm12u320.o obj-$(CONFIG_DRM_PANEL_MIPI_DBI) += panel-mipi-dbi.o obj-$(CONFIG_DRM_PIXPAPER) += pixpaper.o +obj-$(CONFIG_DRM_TRIGGER5) += trigger5.o obj-$(CONFIG_TINYDRM_HX8357D) += hx8357d.o obj-$(CONFIG_TINYDRM_ILI9163) += ili9163.o obj-$(CONFIG_TINYDRM_ILI9225) += ili9225.o
drivers/gpu/drm/tiny/trigger5.c new file +1115 -0
1,115 lines not on this page · raw message
base-commit: 73df79cceb8c01f311055a61794e229dc81546cb
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] drm: sleeping in atomic context in plane and CRTC callbacks - [Medium] drm/trigger5: deferred…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm: sleeping in atomic context in plane and CRTC callbacks
- [Medium] drm/trigger5: deferred display damage is never flushed if userspace goes idle --
commit 12d04056078c58dc5db832cf84f326c797a58e7c
Author: Ho Jie Feng <[email protected]>
drm/trigger5: Add MCT Trigger 5 USB display driver
This commit introduces a new DRM driver for MCT Trigger 5 USB display adapters. It implements modesetting, USB framebuffer updates, connector detection, and EDID retrieval based on reverse-engineered protocols.
Quoted 5 lines
drivers/gpu/drm/tiny/trigger5.c new file +0
-0
[ ... ]
Quoted 2 lines
drivers/gpu/drm/tiny/trigger5.c new file +2
-0+static void trigger5_transfer_work (struct work_struct *work) +{
[ ... ]
Quoted 9 lines
drivers/gpu/drm/tiny/trigger5.c new file +9
-0+if (transfer->sgr.status) +drm_err_ratelimited (&trigger5->drm, +"USB transfer failed: %d\n" , + transfer->sgr.status); +else if (transfer->sgr.bytes != transfer->frame_len) +drm_err_ratelimited (&trigger5->drm, +"short USB transfer: %zu/%zu bytes\n" , + transfer->sgr.bytes, transfer->frame_len); +else if (READ_ONCE (trigger5->display_enabled))
drivers/gpu/drm/tiny/trigger5.c line 307
Quoted 10 lines
drivers/gpu/drm/tiny/trigger5.c new file +10
-0+/* Keepalive must only be sent after a frame has been sent */ +queue_delayed_work (trigger5->transfer_wq, + &trigger5->keepalive_work, +msecs_to_jiffies (TRIGGER5_KEEPALIVE_INTERVAL_MS )); + +exit: +drm_dev_exit (idx); +complete: +complete (&transfer->frame_complete); +}
[Severity: Medium]
Does this transfer completion need to check for or schedule any work to handle damage deferred in pending_rect?
If userspace stops sending new frames (e.g., when the system goes idle), the deferred damage might never get flushed to the screen.
[ ... ]
Quoted 3 lines
drivers/gpu/drm/tiny/trigger5.c new file +3
-0+static void trigger5_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_atomic_commit *state) +{
[ ... ]
drivers/gpu/drm/tiny/trigger5.c line 429
Quoted 9 lines
drivers/gpu/drm/tiny/trigger5.c new file +9
-0+trigger5_stop_io (trigger5); + +/* Sequence recovered from USB captures. */ + ret =usb_control_msg_recv (udev,0 , +TRIGGER5_REQUEST_FIRMWARE_RESET , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE , +0x0000 ,0x0000 , data,1 , +USB_CTRL_GET_TIMEOUT ,GFP_KERNEL );
[Severity: High]
Is it safe to use GFP_KERNEL and blocking USB functions here?
CRTC atomic enable callbacks are atomic context paths where sleeping is strictly forbidden. Calling blocking USB transfers with the GFP_KERNEL flag in this path violates DRM invariants and can cause kernel warnings or deadlocks.
[ ... ]
Quoted 3 lines
drivers/gpu/drm/tiny/trigger5.c new file +3
-0+static void trigger5_crtc_atomic_disable (struct drm_crtc *crtc, +struct drm_atomic_commit *state) +{
[ ... ]
drivers/gpu/drm/tiny/trigger5.c line 534
Quoted 8 lines
drivers/gpu/drm/tiny/trigger5.c new file +8
-0+trigger5_stop_io (trigger5); + + ret =usb_control_msg_recv (udev,0 , +TRIGGER5_REQUEST_FIRMWARE_RESET , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE , +0x0001 ,0x0000 , &data,1 , +USB_CTRL_GET_TIMEOUT ,GFP_KERNEL );
[Severity: High]
Similarly to the atomic enable callback, is it safe to use a blocking USB function with GFP_KERNEL allocation here?
CRTC atomic disable callbacks are also atomic contexts where sleeping is prohibited.
[ ... ]
Quoted 3 lines
drivers/gpu/drm/tiny/trigger5.c new file +3
-0+static void trigger5_plane_atomic_update (struct drm_plane *plane, +struct drm_atomic_commit *atomic_state) +{
[ ... ]
drivers/gpu/drm/tiny/trigger5.c line 701
Quoted 8 lines
drivers/gpu/drm/tiny/trigger5.c new file +8
-0+/* +* This should almost never wait because we have should have a +* pending transfer ready to be de-queued above in case the transfer +* hasn't finished, but do a bounded wait just in case it gets stuck +*/ +if (!wait_for_completion_timeout (¤t_transfer->frame_complete, +msecs_to_jiffies (20 ))) + goto exit_save_pending;
[Severity: High]
Can wait_for_completion_timeout() sleep in this context?
Plane atomic update callbacks execute in atomic context where sleeping is forbidden. Blocking for up to 20ms here will cause system instability.
[Severity: Medium]
When this timeout occurs, the damage is saved to pending_rect, but no asynchronous flush is queued to present it later.
As mentioned above in trigger5_transfer_work(), if the display update aborts here and userspace stops sending new frames, the screen might permanently display stale content.
[ ... ]
drivers/gpu/drm/tiny/trigger5.c line 725
Quoted 4 lines
drivers/gpu/drm/tiny/trigger5.c new file +4
-0+iosys_map_set_vaddr (&data_map, + current_transfer->buf.data +sizeof (*header)); + + ret =drm_gem_fb_begin_cpu_access (state->fb,DMA_FROM_DEVICE );
[Severity: High]
Could this function acquire DMA reservation locks that might sleep?
Since this is still within the plane atomic update callback, calling a function that can sleep violates the DRM atomic context rules.
Quoted 11 lines
drivers/gpu/drm/tiny/trigger5.c new file +11
-0+if (ret <0 ) { +complete (¤t_transfer->frame_complete); + goto exit_save_pending; + } + +drm_fb_xrgb8888_to_rgb888 (&data_map,NULL , + &shadow_plane_state->data[0 ], + state->fb, ¤t_rect, + &shadow_plane_state->fmtcnv_state); + +drm_gem_fb_end_cpu_access (state->fb,DMA_FROM_DEVICE );
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Ho,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 73df79cceb8c01f311055a61794e229dc81546cb]
url: https://github.com/intel-lab-lkp/linux/commits/Ho-Jie-Feng/drm-trigger5-Add-MCT-Trigger-5-USB-display-driver/20261012-211537 base: 73df79cceb8c01f311055a61794e229dc81546cb patch link: https://lore.kernel.org/r/20261012131539.67790-1-hjf3108%40gmail.com patch subject: [PATCH v4] drm/trigger5: Add MCT Trigger 5 USB display driver config: powerpc-randconfig-1000-20261014 (https://download.01.org/0day-ci/archive/20261014/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261014/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/tiny/trigger5.c:550:19: warning: result of comparison of constant 65536 with expression of type 'const u16' (aka 'const unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
550 | mode->htotal > U16_MAX + 1)
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~
drivers/gpu/drm/tiny/trigger5.c:555:19: warning: result of comparison of constant 65536 with expression of type 'const u16' (aka 'const unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
555 | mode->vtotal > U16_MAX + 1)
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~2 warnings generated.
vim +550 drivers/gpu/drm/tiny/trigger5.c
540
541 static enum drm_mode_status
542 trigger5_crtc_mode_valid(struct drm_crtc *crtc,
543 const struct drm_display_mode *mode)
544 {
545 struct trigger5_pll pll;
546 u64 err, ppm;
547
548 if (mode->hsync_end <= mode->hsync_start ||
549 mode->htotal <= mode->hsync_end ||
> 550 mode->htotal > U16_MAX + 1)
551 return MODE_H_ILLEGAL;
552
553 if (mode->vsync_end <= mode->vsync_start ||
554 mode->vtotal <= mode->vsync_end ||
555 mode->vtotal > U16_MAX + 1)
556 return MODE_V_ILLEGAL;
557
558 if (trigger5_mode_buf_len(mode) > TRIGGER5_TRANSFER_BUF_SIZE)
559 return MODE_MEM;
560
561 err = trigger5_calculate_pll(&pll, mode->clock);
562 ppm = div64_u64(err * 1000, mode->clock);
563 if (ppm > 10000)
564 return MODE_CLOCK_RANGE;
565
566 return MODE_OK;
567 }
568
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki