Generic USB Display Driver Published For Linux - Allowing Nifty Possibilities With Raspberry Pi, Etc
Longtime Linux DRM developer Noralf Trønnes has written a new driver for Linux to serve generic USB display purposes. This driver was written following his idea of turning a Raspberry Pi Zero into a USB to HDMI display adapter.
The Generic USB Display Driver is a generic solution for using the likes of the Raspberry Pi SBCs into converting them into makeshift USB display adapters via a new USB host driver and a device/gadget driver. Noralf noted, "The reason for calling it 'Generic' is so anyone can make a USB display/adapter against this driver, all that's needed is to add a USB vid:pid. I was hoping to have someone working on a microcontroller based USB display by now, but unfortunately that has been delayed. It would have been nice to have a microcontroller implementation to ensure that I haven't made things unnecessary difficult to implement."
Performance is obviously a big concern for USB-based displays but even for low-end Raspberry Pi hardware he's been getting some promising results. A video embedded below shows the Generic USB display driver in action with different hosts/devices.
The generic USB display driver patch explains all the interesting technical details:
This adds a generic USB display driver with the intention that it can be used with future USB interfaced low end displays/adapters. The Linux gadget device driver will serve as the canonical device implementation.
The following DRM properties are supported:
- Plane rotation
- Connector TV properties
There is also support for backlight brightness exposed as a backlight device.
Display modes can be made available to the host driver either as DRM display modes or through EDID. If both are present, EDID is just passed on to userspace.
Performance is preferred over color depth, so if the device supports RGB565, DRM_CAP_DUMB_PREFERRED_DEPTH will return 16.
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Optimal user experience is achieved by providing damage reports either by setting FB_DAMAGE_CLIPS on pageflips or calling DRM_IOCTL_MODE_DIRTYFB.
LZ4 compression is used if the device supports it.
The driver supports a one bit monochrome transfer format: R1. This is not implemented in the gadget driver. It is added in preparation for future monochrome e-ink displays.
The driver is MIT licensed to smooth the path for any BSD port of the driver.
And then on the USB gadget side:
This adds the gadget side support for the Generic USB Display. It presents a DRM display device as a USB Display configured through configfs.
The display is implemented as a vendor type USB interface with one bulk out endpoint. The protocol is implemented using control requests. lz4 compressed framebuffer data/pixels are sent over the bulk endpoint.
The DRM part of the gadget is placed in the DRM subsystem since it reaches into the DRM internals.
Those wanting to learn more can do so via this patch series.