Using Magix USB-Videowandler 2 on Linux

 Author:   Posted on:   Updated on:  2017-10-29T13:23:00Z
Videowandler 2 is an USB analog video capture card. There is no official driver support for Linux and the device does not work when you plug it in. According to lsusb, the device is Afatech, which is totally wrong. The kernel only loads modules for USB audio - and this is the only thing that works (the audio input appears as a separate sound card).

Videowandler 2 is based on eMPIA 2861 USB chip. Video conversion is done by SAA7113 and audio conversion by EMP202. The IDs of the device are 1B80:E349. When opening the case, you may find printed on the board UB317 Ver:A or UB315 Ver:C. The latter my be identical to Kworld UB315 but I’m not sure.

Magix USB-Videowandler 2 board. Photo by Christian Enders.

Looking at Linux supported devices with EM2861, EMP202 and SAA7113H, I found Honestech Vidbox NW03. It has a totally different board layout, but I decided to force Honestech drivers for Videowandler on Windows. And the capture worked.

Now, all that’s needed to make this work on Linux is to compile V4L drivers from source after some minor additions to em28xx supported devices. I followed with success the official LinuxTV instructions on how to compile and install V4L device drivers. Here is what I did.
git clone --depth=1 git://linuxtv.org/media_build.git
cd media_build 
./build --main-git --depth 1
This will download and build all drivers. The process takes a long time, so be patient. Once it’s done, go to media_build/media/drivers/media/usb/em28xx/. Open em28xx.h with a text editor, find the Boards supported by driver definitions and at the end add yours:
#define EM2861_BOARD_MAGIX_VIDEOWANDLER2   101
As new boards are added, make sure you use an unique number for your board. When I edited this, the last board had 100, so I used 101. Save and close. Open em28xx-cards.c and locate the array declaration: struct em28xx_board em28xx_boards[]. Add a new element into this array, like this:
 /* 1b80:e349 Magix USB Videowandler-2 (same chips as Honestech VIDBOX NW03)
  * Empia EM2860, Philips SAA7113, Empia EMP202, No Tuner */
 [EM2861_BOARD_MAGIX_VIDEOWANDLER2] = {
  .name                = "Magix USB Videowandler-2",
  .tuner_type          = TUNER_ABSENT,
  .decoder             = EM28XX_SAA711X,
  .input               = { {
   .type     = EM28XX_VMUX_COMPOSITE,
   .vmux     = SAA7115_COMPOSITE0,
   .amux     = EM28XX_AMUX_LINE_IN,
  }, {
   .type     = EM28XX_VMUX_SVIDEO,
   .vmux     = SAA7115_SVIDEO3,  /* S-VIDEO needs confirming */
   .amux     = EM28XX_AMUX_LINE_IN,
  } },
 },
Just below the board definitions should be USB IDs table in an array named em28xx_id_table[]. Add a new element in this array (at the end, before the NULL element):
{ USB_DEVICE(0x1b80, 0xe349), /* Magix USB Videowandler-2 */
   .driver_info = EM2861_BOARD_MAGIX_VIDEOWANDLER2 },
That’s it! Save and close. To compile and install the modified driver, do (terminal in media_build directory):
make -C ./v4l
sudo make -C ./ install
sudo make -C . rmmod
Plug in the Magix device. If you check dmesg, you should see:
[  389.864046] usb 2-1: new high-speed USB device number 3 using ehci-pci
[  390.015409] usb 2-1: New USB device found, idVendor=1b80, idProduct=e349
[  390.015412] usb 2-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[  390.015414] usb 2-1: Product: USB 2861 Device
[  390.171845] media: loading out-of-tree module taints kernel.
[  390.171936] media: module verification failed: signature and/or required key missing - tainting kernel
[  390.172837] media: Linux media interface: v0.10
[  390.209897] Linux video capture interface: v2.00
[  390.209900] WARNING: You are using an experimental version of the media stack.
                As the driver is backported to an older kernel, it doesn't offer
                enough quality for its usage in production.
                Use it with care.
               Latest git patches (needed if you report a bug to linux-media@vger.kernel.org):
                3622d3e77ecef090b5111e3c5423313f11711dfa [media] ov2640: print error if devm_*_optional*() fails
[  390.239546] em28xx 2-1:1.0: New device  USB 2861 Device @ 480 Mbps (1b80:e349, interface 0, class 0)
[  390.239551] em28xx 2-1:1.0: Video interface 0 found: isoc
[  390.239648] em28xx 2-1:1.0: chip ID is em2860
[  390.381140] em28xx 2-1:1.0: EEPROM ID = 1a eb 67 95, EEPROM hash = 0xa99a2140
[  390.381143] em28xx 2-1:1.0: EEPROM info:
[  390.381145] em28xx 2-1:1.0:  AC97 audio (5 sample rates)
[  390.381146] em28xx 2-1:1.0:  500mA max power
[  390.381149] em28xx 2-1:1.0:  Table at offset 0x04, strings=0x206a, 0x0000, 0x0000
[  390.381152] em28xx 2-1:1.0: Identified as Magix USB Videowandler-2 (card=101)
[  390.381154] em28xx 2-1:1.0: analog set to isoc mode.
[  390.381277] em28xx 2-1:1.1: audio device (1b80:e349): interface 1, class 1
[  390.381287] em28xx 2-1:1.2: audio device (1b80:e349): interface 2, class 1
[  390.381302] usbcore: registered new interface driver em28xx
[  390.528984] em28xx 2-1:1.0: Registering V4L2 extension
[  391.064485] saa7115 3-0025: saa7113 found @ 0x4a (2-1:1.0)
[  392.124443] em28xx 2-1:1.0: Config register raw data: 0x50
[  392.156221] em28xx 2-1:1.0: AC97 vendor ID = 0xffffffff
[  392.172190] em28xx 2-1:1.0: AC97 features = 0x6a90
[  392.172193] em28xx 2-1:1.0: Empia 202 AC97 audio processor detected
[  395.425425] em28xx 2-1:1.0: V4L2 video device registered as video0
[  395.425427] em28xx 2-1:1.0: V4L2 VBI device registered as vbi0
[  395.425430] em28xx 2-1:1.0: V4L2 extension successfully initialized
[  395.425431] em28xx: Registered (Em28xx v4l2 Extension) extension
[  395.504874] usbcore: registered new interface driver snd-usb-audio
There are some warning messages because you are using an experimental V4L driver version, but the important thing is that the kernel registers video0 device.

tvtime using Magix Videowandler 2 as input source
tvtime using Magix Videowandler 2 as input source
You can view video using tvtime, VLC etc. Note that you may lose the changed em28xx kernel module after updating the system.

No comments :

Post a Comment

Please read the comments policy before posting.