Linux is known for its good hardware support of even ancient pieces of kit. Sure, from time to time the kernel devs deprecate drivers and architectures that are no longer supported, but for the most part, you can pick-up an old piece of hardware and get it running on a major release or two from the current release.
Yesterday I attempted this. At Leigh Hackspace we wanted a webcam on our out-of-band access box, just so we (as in the infra guys) can look at the status of the rack without visiting the space. After having a dig around our electronics area I found a box of old Trust WB-1200P webcams, they’re from 2009 and barely scrape out at 0.1 megapixel, but they should be good enough to see the blinkenlights in the rack to see if we have an issue (e.g. a server doesn’t have power).
I grab one, plug it into the OOB Raspberry Pi running the latest, Debian 11, Raspian and it is detected and loads the drivers! It works??? Wow.
The Trust WB-1200P is a rebadged ‘Pixart Imaging Inc.’ PAC207, a pre-UVC webcam that is part of the
gspca driver set in the kernel. Support for it is included in the current upstream
main, and support V4L2. But, getting it to load a driver is only the first step of the battle. Pre-UVC devices have their own special quirks and issues, usually related to the pixel and video formats they output.
In this case, the PAC207 has its own special pixel format that the application you wish to use needs to understand and handle. While backward-compatible kernel drivers are there, application support moves on. Most of the V4L2 tools I attempted to use would either throw an error, crash or cause the driver to spit out some errors into
[39011.323706] gspca_main: set alt 0 err -32 [39011.323771] pac207 1-1.2:1.0: submit int URB failed with error -2 [39181.529143] Transfer to device 5 endpoint 0x5 frame 1542 failed - FIQ reported NYET. Data may have been lost. [39191.828144] Transfer to device 5 endpoint 0x5 frame 1601 failed - FIQ reported NYET. Data may have been lost. [39450.446323] gspca_main: set alt 0 err -22 [39454.058295] gspca_main: pac207-2.14.0 probing 093a:2468
I suspected it may be due to the output format of the camera, most applications expect
YUV or Motion JPEG, neither of which this camera supported. I attempted to Google the camera’s model to try and find some more information, then tried Github to see if anything caught my eye.
#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */ #define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */ #define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */ #define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */ #define V4L2_PIX_FMT_JL2005BCD v4l2_fourcc('J', 'L', '2', '0') /* compressed RGGB bayer */
V4L2_PIX_FMT_PAC207? That is a special format that so happens to have the same name as the model of the webcam.
Further splunking using this value directed me to a configuration file for Motion, a relatively old application for streaming webcams
# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. # Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 # instead. # V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' # V4L2_PIX_FMT_PAC207 : 6 'P207' # V4L2_PIX_FMT_PJPG : 7 'PJPG'
Motion is still maintained, and still available in most OS repositories, and it did exactly what I needed it to do; export a camera to a URL so we can look at it. Win-win. I installed Motion, added
v4l2_palette 6 to the configuration file, started up the daemon and hit the URL, it loaded and…. showed a green image and more
As it turns out, not everything is still compatible. the
pac207 driver is a V4Lv1 type driver and requires a small amount of wrangling to get working correctly. Thankfully, the V4L2 developers provide a compatibility library that can be loaded using
LD_PRELOAD to fix the major issues.
All thats needed is the
libv4l-0 library on Debian, then using a
systemd service override I was able to insert the environment variable into the startup:
Restart the service and…
Right, 0.1MP, and probably not focused correctly, autofocus wasn’t a thing on this!
I found out later that Trust still has this device listed on their website’s support section, from 2009! It also has Windows 8 drivers!