r/coolgithubprojects • u/Merwanted-linux • 17h ago
I ported USBCD to Linux (KDE Plasma 6 / Wayland) — Turn an Android tablet into a low-latency 120Hz second monitor over USB-C
Hey everyone!
Recently I came across **USBCD** by Samuel E. Ramirez — an awesome open-source (GPL-3.0) tool that turns an Android tablet into a wired USB-C second monitor, except the host only existed for Windows 11.
Since I use **KDE Plasma 6 on Wayland**, I built **`usbcd-linux`**: a native Rust Linux host implementation that works directly with KWin and PipeWire without VNC, KRFB, or Wi-Fi lag.
### How it works under the hood
- **Native Wayland Virtual Output (`60 / 90 / 120 Hz`):** Uses KWin's `zkde_screencast_unstable_v1` protocol and `kscreen-doctor` to dynamically create a virtual monitor to the right of your main screen in the tablet's native aspect ratio, and removes it cleanly when you stop.
- **Zero-Copy Capture & Multi-GPU Hardware Encoding:** Captures frames via PipeWire `DMA-BUF` and encodes in hardware using:
- **NVIDIA NVENC** (including hybrid Intel + NVIDIA Optimus laptops via `vapostproc` + `cudaupload` surface isolation),
- **Intel VA-API / VDENC** (`vah265lpenc` fixed-function ASIC so 3D GPU cores stay free for desktop effects),
- **AMD Radeon VA-API** (`Mesa`), or multi-threaded `x264` CPU fallback.
- **Low-Latency Pipeline:** Immediate per-frame dispatch (`gdppay` AU framing with zero next-frame hold), H.264/HEVC SPS bitstream patching (`max_dec_frame_buffering=1` / zero reorder), Qualcomm Venus high-clock hints, and `TCP_NODELAY` + `TCP_QUICKACK` over ADB USB.
- **Optional Stylus, Touch & Audio:** Pure display streaming by default for minimum overhead, with opt-in `/dev/uinput` stylus (pressure + tilt + hover) / multi-touch forwarding (`USBCD_INPUT=1`) and PipeWire virtual speakers (`USBCD_AUDIO=1`).
### Links
- **GitHub (`usbcd-linux`):** https://github.com/merwanted/usbcd-linux
- **Original Windows USBCD project (credit to Samuel E. Ramirez):** https://github.com/samuelgoestomars2607/USBCD
Currently tested on Arch Linux (KDE Plasma 6 Wayland, Intel TigerLake + RTX 3050 hybrid laptop) with a 120 Hz Android tablet (Honor Pad X9). Feedback, benchmarks on AMD/Intel setups, and PRs (especially for GNOME / wlroots virtual output backends!) are very welcome!



