video capture (em28xx) not working on arm?


8 posts
by cowpat » Tue Jun 26, 2012 10:15 pm
Hello,
I have a growing pile of SD cards next to my Raspberry Pi - but I'm currently using the wheezy-beta. I have rebuilt the kernel to include support for em28xx and cx231xx, which wasn't very successful - the cards were identified, but didn't work. I then built the 'media_build.git' linuxtv drivers - and that, to some extent, has worked.

However, both my ex28xx devices (easycap dc60 and kworld 2800) are coming up with green screens, and the hauppage usb live 2 is freezing when motion starts up. (I've only had motion to test them with thus far - the em28xx devices i have seen working on motion on an old debian laptop).

Ignoring the hauppage device for now - I'm worried that I might be wasted my time with the em28xx driver. (mainly because of this comment - http://comments.gmane.org/gmane.linux.d ... ture/48009 - in which Devin Heitmueller states 'analog support for the em28xx is known to be broken'.

A support question on http://www.lavrsen.dk/foswiki/bin/view/ ... x10x101207 would seem to confirm this.

Not being in the loop it's very hard to discern what the state of play is here.. but it would appear that em28xx devices are not going to work on a raspberry pi yet.

Does anyone know any different?
User avatar
Posts: 90
Joined: Sat Apr 14, 2012 12:13 pm
Location: London
by JeremyF » Wed Jun 27, 2012 12:01 am
(I don't mean to derail, but I've never even gotten the em28xx devices [particularly the ones branded as Easycap] to work even on x86. Could you message me the instructions?)
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge
Posts: 522
Joined: Wed Jan 25, 2012 9:06 pm
by cowpat » Fri Jun 29, 2012 9:36 pm
Ok - my apologies - this is nothing to do with wheezy, this IS an issue with the portability of the em28xx under ARM. The answer was sitting under my nose; http://comments.gmane.org/gmane.linux.d ... ture/48009
(follow Devin's link - the rest of it is background to the problem)

I don't pretend to understand the intricacies of maintaining up to date source trees and all that, so the procedure could probably do with some fine tuning - essentially changing "height = norm_maxh(dev) >> 1" in my em28xx-core.c file has made it work. My em28xx folder came from the 'latest' drivers tar file at linuxtv.org. I don't know how to install a driver so I replaced the em28xx folder in the media-build.git folder and did and a 'make' and a 'make install' (instead of ./build that the linuxtv site recommends - as that would then pull down the current drivers and blow away the changes I made.

This assumes a recompiled kernel with i2c and em28xx enabled - I found this procedure the easiest way to populate the /lib/modules/build/ folder that the media-build requires.

There are significant horizontal artefacts on my pictures, lines and blocks. so i am certain this is not the whole story - but it's a picture and, while I can take no credit for the fix, I still believe it warrants a bottle of black sheep before bed. 'Here's to clever people with a social conscience, Cheers!'

It may be that the em28xx could be doctored in the raspberry pi linux sources at the kernel compilation point - doing away with the media-build procedure, but in either case, I expect it's a precarious fix that is likely to get blow any in the face of updates et al; although hopefully at some point one of these updates will hold the solution anyway.
User avatar
Posts: 90
Joined: Sat Apr 14, 2012 12:13 pm
Location: London
by xernobyl » Tue Jul 17, 2012 12:24 am
Did you manage to get easycap working?
I'm trying to get an easycap thing working on the RPi, using a kernel compiled with easycap support but I had no success so far. The device gets detected, it gets listed on usb-devices output, but no /dev/video* appears. Any hints on how to get it working?
Posts: 26
Joined: Tue Oct 25, 2011 2:03 pm
by cowpat » Tue Jul 17, 2012 7:25 am
Yes - i did. My method was probably a bit crude. I got the drivers from linuxtv.org but had to change a line in em28xx-core.c (none of which I can take any credit for!)

I wrote some notes up http://bufobufomagic.blogspot.co.uk/2012/07/make-disk-image-mac-diskutil-list-sudo.html in case I'd ever need to do it again but I've shelved the raspberry pi for now until the webcam/USB issues are resolved. I'm waiting for a beaglebone to turn up to get me to the point where I have a working solution - then maybe I'll have time to look at it again.

The notes are a bit sketchy - they are the product of much fumbling around - but hopefully they will be of some help.
User avatar
Posts: 90
Joined: Sat Apr 14, 2012 12:13 pm
Location: London
by orokusaki » Mon Nov 05, 2012 2:43 pm
I can confirm that this fix does work..

I did this on my Touchpad with Android and I no longer have a green screen when viewing the CORRECT INPUT.

Now.. I just get a green stripe at the bottom of my image.. I bet it has something to do with the rest of the code. I changed 720 to 640... that did not help. changed 18 to 12.. that did not help. Bet its something else. Did this with the tenderloin cm9 kernel. I also changed the card.c file and told it to be a Typhoon card #35 as that works in Ubuntu 12.04 on X86 just fine.. Card#19 detects the wrong input order. Even with Card #35 being used, my image is in Black and White and on Ubuntu its color. I could not recompile CM9 so I just recompiled em28xx inside the kernel without being a loadable module but had to alter the card.c file in the em28xx folder to force the kernel to do what I want regarding automatic card detection.

Got me! Here is the code that allowed me to view an image with SimpleWebCam.apk and chmod 666 /dev/video0 before running it.

int width, height;
width = norm_maxw(dev);
height = norm_maxh(dev) >> 1;

/* Properly setup VBI */
dev->vbi_width = 720;
if (dev->norm & V4L2_STD_525_60)
dev->vbi_height = 18;
else
dev->vbi_height = 12;

em28xx_set_outfmt(dev);


em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
Posts: 6
Joined: Tue Oct 16, 2012 3:48 am
by Nando » Sat Dec 22, 2012 9:03 pm
orokusaki wrote:Now.. I just get a green stripe at the bottom of my image.. I bet it has something to do with the rest of the code.

I got the same problem when using my device on the mac with EasyCapViewer.

orokusaki wrote:Got me! Here is the code that allowed me to view an image with SimpleWebCam.apk and chmod 666 /dev/video0 before running it.

int width, height;
width = norm_maxw(dev);
height = norm_maxh(dev) >> 1;

/* Properly setup VBI */
dev->vbi_width = 720;
if (dev->norm & V4L2_STD_525_60)
dev->vbi_height = 18;
else
dev->vbi_height = 12;

em28xx_set_outfmt(dev);


em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);


Was trying the same making a em2860 device work on a Android Tablet.
Using the cross-compile module and the SimpleWebCam.apk all I would get would be some random pixels blinking here and there in the screen.
Tried now with this change and nothing, it started getting errors:
---
VIDIOC_QBUF error 12, Out of memory
device resetted
VIDIOC_G_INPUT error 9, Bad file number
---

Only change I'ce made to the SimpleWebCam.apk was on the JNI to add code to change the input , as by default it uses the S-VIDEO and I need the Composite.
Any idea what might this be?
Posts: 2
Joined: Sat Dec 22, 2012 8:56 pm
by Nando » Sun Dec 23, 2012 11:16 am
Ok, problem solved. I was missing to load one module.

As for the green lines I searched a bit and found a couple of threads talking about it.
Seems it's related to the implementation of the code that handles the VBI data.
The oldest thread I saw was from 2010 so it seems the issue is still there.
(for reference: http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/17331)
Posts: 2
Joined: Sat Dec 22, 2012 8:56 pm