Ben Cox Revives Epiphan's VGA Capture Cards with Custom Reverse-Engineered Linux Driver

Having picked up a bulk supply of VGA capture cards for pennies on the dollar, Cox sets out to get them working on a modern Linux build.

Gareth Halfacree
4 years ago β€’ HW101
With some reverse engineering, these capture cards live another day. (πŸ“·: Cox)

Developer Ben Cox has written of his experience in developing userspace Linux drivers for a long-abandoned video capture device, acquired in bulk for pennies on the dollar, through reverse-engineering and a modicum of guesswork.

"I recently found some USB devices on eBay (Epiphan VGA2USB LR) that could take VGA as input and present the output as a webcam," Cox explains. "Given that I was keen on the idea of not needing to lug out a VGA monitor ever again and there was claimed Linux support I took the risk and bought the whole job lot for about Β£20 ($25)."

There was a reason the devices were so cheap, however. Since discontinued by their creators, the boxes required a proprietary driver to operate and while a Linux version had been provided at launch it was only compatible up to Linux 4.9 β€” leaving modern Linux distributions in the cold. Any hopes of tweaking the provided files were dashed, too, by the discovery that they were provided as pre-compiled binaries β€” ripe for reverse engineering.

"To observe the driver in its normal operating environment, I made a Debian 9 (the last supported release) VM, and did a KVM USB Passthrough to give it direct access to the device. I then installed the driver and confirmed that it worked," Cox explains. What followed was a range of reverse-engineering hacks starting with packet capture over USB via Wireshark and moving onto physical disassembly to verify that the hardware was, in fact, based on a Xilinx Spartan-6 field-programmable gate array (FPGA), extraction of the bitstream, timing analysis, and then the tricky process of figuring out how the data from the camera was encoded.

"After analysis it appeared that the data was not obviously encoded in any way," Cox explains. Using a variety of tools, Cox eventually had a rough idea of how things worked: "I replicated the USB packet sequence to obtain these uncompressed blobs, and looking at the byte counts, it matched with getting around 3 bytes (RGB) per pixel. Initial processing of these images (just taking the output and writing it as RGB pixels) resulted in something roughly inspired by the input I was giving to the device over VGA."

A little more tweaking resulted in an image which looked correct bar the colors. "At this point I had a flashback to some 3D rendering/shader work I did long ago," Cox explains. "This looked a lot like YUV color. After using Go’s built in YCbCrToRGB the image suddenly looked much closer to the original. We did it! Despite the 'WIP' quality we were able to do 7 FPS. Honestly, for me that was good enough, since my use for these are as an emergency VGA screen rather than anything else."

Cox's full write-up is available on his personal blog, while the resulting driver β€” should anyone else have an Epiphan VGA2USB LR in their drawer β€” can be found on GitHub.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire:
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles