Skip to content

Commit d560ab1

Browse files
committed
Add Actions Micro backend and usage examples
1 parent 350a3c1 commit d560ab1

29 files changed

Lines changed: 3262 additions & 31 deletions

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/build/
44
/dist/
5+
/graphify-out/
56
*.o
67
*.ko
78
*.mod
@@ -14,6 +15,8 @@ modules.order
1415
Module.symvers
1516
__pycache__/
1617
*.pyc
18+
bin/
19+
obj/
1720
.vscode/
1821
.idea/
1922
.DS_Store

‎CHANGELOG.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Add the experimental Actions Micro `185b:2d1d` live backend with replay-
6+
derived initialization and heartbeat templates, FFmpeg H.264 encoding, and
7+
dual-hidraw video delivery.
8+
- Extend backend ABI v1 with an optional idle tick callback.
9+
- Add LVGL 9 and C# examples for both fbdev and DRM/KMS.
10+
- Add the Simplified Chinese README.
11+
- Normalize live H.264 NAL units to the adapter's four-byte Annex-B framing.
12+
- Mark live H.264 as square-pixel video so its SPS matches the stream accepted
13+
by the Actions Micro firmware.
14+
- Add an opt-in Actions Micro full-replay bootstrap that preserves transport
15+
sequence and HID alternation when handing off to live H.264 video.
16+
- Continue post-template Actions Micro keepalives on alternating command HID
17+
endpoints with matching report IDs.
18+
- Visually verify the Actions Micro full-bootstrap handoff with live 1920x1080
19+
LVGL output on the reference adapter after a physical USB power cycle.
20+
321
## v0.1.0-alpha.1 - 2026-08-07
422

523
- Add a Linux 4.15 virtual DRM/KMS card with one fixed virtual connector.

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BUILD_DIR ?= $(CURDIR)/build
44

5-
.PHONY: all userspace module clean
5+
.PHONY: all userspace module examples-lvgl clean
66

77
all: userspace
88

@@ -13,7 +13,11 @@ userspace:
1313
module:
1414
$(MAKE) -C kernel
1515

16+
examples-lvgl:
17+
$(MAKE) -C examples/lvgl BUILD_DIR=$(BUILD_DIR)/examples
18+
1619
clean:
1720
$(MAKE) -C userspace BUILD_DIR=$(BUILD_DIR) clean
1821
$(MAKE) -C tools BUILD_DIR=$(BUILD_DIR) clean
22+
$(MAKE) -C examples/lvgl BUILD_DIR=$(BUILD_DIR)/examples clean
1923
$(MAKE) -C kernel clean

‎README.md‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# USBDisplayStack
22

3+
English | [简体中文](README.zh-CN.md)
4+
35
USBDisplayStack is a GPL-2.0-only Linux display stack for USB display
46
adapters that use vendor-specific transport protocols. Applications render to
57
normal framebuffer or DRM/KMS devices; protocol, compression, and USB details
68
stay in replaceable userspace backends.
79

810
> **Alpha status:** the virtual DRM/fbdev frontend and userspace frame path are
9-
> working on Linux 4.15. The Actions Micro `185b:2d1d` hardware transport is
10-
> still experimental and is not enabled by default.
11+
> working on Linux 4.15. The Actions Micro `185b:2d1d` live backend is
12+
> implemented but remains experimental and is not enabled by default.
1113
1214
## Architecture
1315

@@ -46,11 +48,15 @@ See [architecture](docs/architecture.md), [ABI](docs/abi.md), and
4648
- `userspace/usb-displayd.c`: single-consumer frame dispatcher.
4749
- `backends/null`: diagnostics and throughput testing.
4850
- `backends/ppm`: writes the latest frame as a PPM image.
51+
- `backends/actions-micro`: initialization, heartbeat, FFmpeg H.264, and HID
52+
video transport for Actions Micro `185b:2d1d`.
4953
- `tools/fb-test-pattern`: writes a color pattern through `/dev/fbN`.
5054
- `tools/drm-probe`: checks connectors and modes using DRM ioctls without
5155
requiring libdrm.
5256
- `tools/actions-micro-replay`: validates and explicitly replays captured
5357
`185b:2d1d` HID reports for protocol research.
58+
- `examples/lvgl`: LVGL 9 applications for fbdev and DRM/KMS.
59+
- `examples/csharp`: .NET 8 applications for fbdev and DRM/KMS.
5460

5561
## Requirements
5662

@@ -68,11 +74,17 @@ CONFIG_FB_DEFERRED_IO
6874
Install the compiler, make, and headers matching the running kernel before
6975
building.
7076

77+
The experimental Actions Micro backend requires `ffmpeg` built with the
78+
`libx264` encoder. The optional examples require LVGL 9/libdrm or .NET 8 as
79+
described in their local READMEs.
80+
7181
## Build
7282

7383
```bash
7484
make userspace
7585
make module
86+
# Optional, when LVGL 9 and libdrm development files are installed:
87+
make examples-lvgl
7688
```
7789

7890
The userspace binaries are written to `build/`; the module is
@@ -101,6 +113,24 @@ sudo rmmod usbdisplay
101113
Do not assume the secondary nodes are always numbered `1`; discover them by
102114
the `usbdisplay` framebuffer name and DRM driver name in production scripts.
103115

116+
## Application examples
117+
118+
Run only one producer at a time. Both LVGL examples render the same dashboard:
119+
120+
```bash
121+
make -C examples/lvgl
122+
sudo build/examples/lvgl-fbdev-example /dev/fb1
123+
sudo build/examples/lvgl-drm-example /dev/dri/card1
124+
```
125+
126+
The C# examples render animated XRGB8888 patterns and refuse devices that are
127+
not owned by USBDisplayStack:
128+
129+
```bash
130+
dotnet run --project examples/csharp/Fbdev -- /dev/fb1
131+
dotnet run --project examples/csharp/Drm -- /dev/dri/card1
132+
```
133+
104134
## Install
105135

106136
`scripts/install.sh` installs the module built for the running kernel,
@@ -115,12 +145,32 @@ sudo systemctl enable --now usb-displayd.service
115145
Set the virtual resolution in `/etc/modprobe.d/usbdisplay.conf` and select a
116146
backend in `/etc/default/usb-displayd` before enabling the service.
117147

148+
## Actions Micro activation
149+
150+
The live backend requires an authorized `DPRPL001` replay template containing
151+
the adapter's initialization and heartbeat commands. Captured video is ignored
152+
by default; `bootstrap=full` explicitly sends it once on firmware that requires
153+
a full captured stream to leave its waiting page. Replay data is never
154+
distributed by this project. Configure the reference adapter with:
155+
156+
```text
157+
USBDISPLAY_BACKEND=/usr/lib/usbdisplay/usbdisplay-actions-micro.so
158+
USBDISPLAY_BACKEND_ARGS=--backend-option template=/var/lib/usbdisplay/actions-micro.replay,bootstrap=full
159+
```
160+
161+
The backend discovers and verifies both `185b:2d1d` hidraw interfaces, sends
162+
initialization, maintains heartbeats while idle, and converts new fbdev or DRM
163+
frames into baseline H.264 and vendor HID reports. With the module and service
164+
running, an LVGL write to the USBDisplayStack framebuffer automatically enters
165+
that pipeline. See [Actions Micro 185b:2d1d](docs/actions-micro-185b-2d1d.md)
166+
for options and current validation limits.
167+
118168
## Experimental hardware work
119169

120-
The Actions Micro research notes and replay safety rules are documented in
121-
[Actions Micro 185b:2d1d](docs/actions-micro-185b-2d1d.md). Captured Windows
122-
output has displayed successfully, but this does not yet prove that live
123-
frames generated by USBDisplayStack are accepted by the device.
170+
The Actions Micro research notes and replay safety rules are documented in the
171+
link above. Both captured Windows output and live generated LVGL output have
172+
displayed successfully on the reference unit. The backend remains experimental
173+
until repeated reconnect and long-running tests are complete.
124174

125175
## License
126176

‎README.zh-CN.md‎

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# USBDisplayStack
2+
3+
[English](README.md) | 简体中文
4+
5+
USBDisplayStack 是一个采用 `GPL-2.0-only` 许可证的 Linux USB 显示栈,面向
6+
使用厂商私有传输协议的 USB 显示适配器。应用只需向标准 framebuffer 或
7+
DRM/KMS 设备渲染;协议、压缩和 USB 传输由可替换的用户态后端负责。
8+
9+
> **Alpha 状态:**虚拟 DRM/fbdev 前端和用户态帧通路已在 Linux 4.15
10+
> 工作。Actions Micro `185b:2d1d` 实时后端已经实现,但仍处于实验阶段,
11+
> 默认不启用。
12+
13+
## 架构
14+
15+
```text
16+
LVGL 或其他应用
17+
|
18+
+----> /dev/fbN(固定 XRGB8888 framebuffer)
19+
|
20+
+----> /dev/dri/cardN(DRM/KMS 虚拟连接器)
21+
|
22+
v
23+
usbdisplay 内核模块
24+
三缓冲快照 ABI
25+
|
26+
/dev/usbdisplay0
27+
|
28+
v
29+
usb-displayd
30+
|
31+
动态加载的后端
32+
|
33+
编码 / HID / USB 传输
34+
```
35+
36+
模块绝不会回退到 `/dev/fb0`。USB 传输或后端缺失时,仅第二显示设备停止,
37+
主显示设备不会受到影响。层间契约参见 [架构](docs/architecture.md)、
38+
[ABI](docs/abi.md) 和 [兼容性](docs/compatibility.md)。
39+
40+
## 组件
41+
42+
- `kernel/usbdisplay_drv.c`:虚拟 DRM/KMS、独立 fbdev 和只读三缓冲帧流。
43+
- `userspace/usb-displayd.c`:单消费者帧调度守护进程。
44+
- `backends/null`:吞吐和链路诊断。
45+
- `backends/ppm`:把最新帧写成 PPM 图片。
46+
- `backends/actions-micro`:Actions Micro `185b:2d1d` 的初始化、心跳、
47+
FFmpeg H.264 编码和 HID 视频传输。
48+
- `tools/fb-test-pattern`:向 `/dev/fbN` 写入测试图案。
49+
- `tools/drm-probe`:不依赖 libdrm,通过 DRM ioctl 检查连接器和模式。
50+
- `tools/actions-micro-replay`:验证并显式回放捕获的 HID 报文,用于协议研究。
51+
- `examples/lvgl`:LVGL 9 的 fbdev 和 DRM/KMS 示例。
52+
- `examples/csharp`:.NET 8 的 fbdev 和 DRM/KMS 示例。
53+
54+
## 环境要求
55+
56+
当前内核实现针对 Linux 4.15 的 TinyDRM API,需要以下内核配置:
57+
58+
```text
59+
CONFIG_DRM
60+
CONFIG_DRM_KMS_HELPER
61+
CONFIG_DRM_TINYDRM
62+
CONFIG_FB
63+
CONFIG_FB_DEFERRED_IO
64+
```
65+
66+
构建前需安装 C 编译器、make 和与运行内核匹配的头文件。Actions Micro 后端
67+
还需要启用了 `libx264` 编码器的 `ffmpeg`。可选示例分别需要 LVGL 9、
68+
libdrm 开发文件或 .NET 8。
69+
70+
## 构建
71+
72+
```bash
73+
make userspace
74+
make module
75+
# 已安装 LVGL 9 和 libdrm 开发文件时可选:
76+
make examples-lvgl
77+
```
78+
79+
用户态产物位于 `build/`,内核模块为 `kernel/usbdisplay.ko`。
80+
81+
## 手工冒烟测试
82+
83+
```bash
84+
sudo modprobe tinydrm
85+
sudo insmod kernel/usbdisplay.ko width=640 height=360
86+
87+
build/drm-probe /dev/dri/card1 640 360
88+
build/usb-displayd \
89+
--backend build/usbdisplay-ppm.so \
90+
--backend-option /tmp/usbdisplay.ppm &
91+
daemon_pid=$!
92+
93+
sudo build/fb-test-pattern /dev/fb1
94+
sleep 1
95+
kill "$daemon_pid"
96+
sudo rmmod usbdisplay
97+
```
98+
99+
第二设备的编号不保证为 `1`。生产脚本应通过 sysfs 中的 `usbdisplay`
100+
framebuffer 名称和 DRM 驱动名称发现节点。
101+
102+
## 应用示例
103+
104+
同一时间只运行一个渲染生产者。两个 LVGL 示例显示同一套仪表盘:
105+
106+
```bash
107+
make -C examples/lvgl
108+
sudo build/examples/lvgl-fbdev-example /dev/fb1
109+
sudo build/examples/lvgl-drm-example /dev/dri/card1
110+
```
111+
112+
C# 示例绘制动态 XRGB8888 图案,并会拒绝不属于 USBDisplayStack 的设备:
113+
114+
```bash
115+
dotnet run --project examples/csharp/Fbdev -- /dev/fb1
116+
dotnet run --project examples/csharp/Drm -- /dev/dri/card1
117+
```
118+
119+
## 安装
120+
121+
`scripts/install.sh` 安装当前内核的模块、用户态程序、后端、udev 规则和
122+
systemd 文件,但不会自动加载模块或启用服务。
123+
124+
```bash
125+
sudo ./scripts/install.sh
126+
sudo systemctl enable --now usb-displayd.service
127+
```
128+
129+
启动前请在 `/etc/modprobe.d/usbdisplay.conf` 设置虚拟分辨率,并在
130+
`/etc/default/usb-displayd` 选择后端。
131+
132+
## Actions Micro 激活
133+
134+
实时后端需要用户有权使用的 `DPRPL001` replay 模板,其中包含适配器的
135+
初始化和心跳命令。默认模式会忽略捕获的视频;对于只有完整捕获流才能退出
136+
等待页的固件,`bootstrap=full` 会明确地发送一次捕获视频。本项目不分发
137+
replay 数据。参考适配器配置如下:
138+
139+
```text
140+
USBDISPLAY_BACKEND=/usr/lib/usbdisplay/usbdisplay-actions-micro.so
141+
USBDISPLAY_BACKEND_ARGS=--backend-option template=/var/lib/usbdisplay/actions-micro.replay,bootstrap=full
142+
```
143+
144+
后端会自动发现并校验两个 `185b:2d1d` hidraw 接口,发送初始化序列,在
145+
静止画面期间持续发送心跳,并将新的 fbdev 或 DRM 帧编码成 baseline H.264
146+
和厂商 HID 报文。模块和服务启动后,LVGL 写入 USBDisplayStack framebuffer
147+
就会自动进入这条激活与显示通路。
148+
149+
完整选项、安全规则和当前验证边界参见
150+
[Actions Micro 185b:2d1d](docs/actions-micro-185b-2d1d.md)。已捕获的 Windows
151+
画面和实时生成的 LVGL 画面均已在参考设备上显示;后端仍需完成重复重连和
152+
长时间运行验证,因此继续标记为实验性。
153+
154+
## 许可证
155+
156+
USBDisplayStack 使用 `GPL-2.0-only` 许可证,详见 [LICENSE](LICENSE)。

0 commit comments

Comments
 (0)