Archived:Development: USB based video drivers: Difference between revisions

From LinuxTVWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 25: Line 25:
==== USBView output ====
==== USBView output ====


[[Image:sniffer06.png]]
[[Image:usbview.png]]



We also need the linux usbview output of your device
We also need the linux usbview output of your device
Line 48: Line 49:
attach the sniffer to your device and start logging:
attach the sniffer to your device and start logging:


[[Image:sniffer05.png]]
[[Image:sniffer06.png]]





Revision as of 00:43, 20 October 2005

USB Video

see Em2820 for more information about how to write an usb video driver

What we need from you to get your USB Device work

Requested Devices

Device Status
Genius TVGO u202 (bigger USBSnoop Logs are required)
ALI Corp 1.3M Pixel USB 2.0 Bad quality video yet
uli-m9205 Driver is in development, quality will be good
Aiptek USB DualCam

Requirements

this site explains how to get empiatech devices or similar running with linux by applying changes which might only work with your device.

USBView output

Usbview.png


We also need the linux usbview output of your device


Get usbsnoop for windows

http://benoit.papillault.free.fr/usbsnoop/

http://benoit.papillault.free.fr/stats/get.php?location=../usbsnoop/sniff-bin-1.8.zip

Set up usbsnoop and start sniffing

Before starting to sniff start up your TV application and set it to the highest resolution (for em2820/em2840 devices the highest resolution should be 720x576 or 720x480 or 640x480?)


also tell us which resolution you used for it


attach the sniffer to your device and start logging:

Sniffer06.png


Finally start up your TV application again, everything will slow down after it's started but it's worth doing it that way hardware analyzers cost a few thousand dollars... please sniff about 200 - 300 MB! it will be easier for analyzing. after the sniffer recorded a few videoframes close the application again, compress the logfile, upload it somewhere or mail it to mrechberger@gmail.com. we'll then have a look at what's different with your device.

I wrote the parser below for generating code from the logfile,

a quick hack would be to paste the generated "em2820_write_regs_req()" codelines (which show up before UNABLE TO HANDLE ISOC TRANSFERS) at the end of the "static int em2820_config(struct em2820* dev)" function but before the return 0; line if you have any questions about it just join the #v4l on irc.freenode.org

hope everything's confusing enough now :)

#!/usr/bin/perl         
use Switch;     
$urbrequest=0;          
                
$enabled=1;
$setuppacket=0;
while (<>){     
#  <<<  URB 1 coming back  <<<
        if(/>>>/){
                if(/URB (\d{1,})/){
                        $urbrequest=sprintf("%06d",$1);
                }       
                $enabled=1;
                $setuppacket=0;
        }               
        if(/<<</){      
                if(/URB (\d{1,})/){
                        $urbrequest=sprintf("%06d",$1);
                }                       
                $enabled=1;     
                $setuppacket=0;
        }       
        if(/ISOCH_TRANSFER/){
                $enabled=0;
        }       
        if(/URB_FUNCTION_SELECT_INTERFACE/){
                $selectinterface=1;
        }       
        if($enabled==1){
                if(/AlternateSetting  = 0x(\d{1,})/){
                        push(@{$urbhash{$urbrequest}{'remark'}},"Changing to Alternative Setting 0x$1\n");
                }       
                if($setuppacket==1){
                        if(/0000: (.*)/){
                                if (@{$urbhash{$urbrequest}{'out'}} eq ""){
                                        push(@{$urbhash{$urbrequest}{'out'}},$1);
                                } else {
                                        push(@{$urbhash{$urbrequest+1000}{'out'}},$1);
                                }
                        }
                } else {
                        if(/0000: (.*)/){
                                if (@{$urbhash{$urbrequest}{'in'}} eq ""){
                                        push(@{$urbhash{$urbrequest}{'in'}},$1);
                                } else {
                                        push(@{$urbhash{$urbrequest+1000}{'in'}},$1);
                                }
                        }
                }
                if(/SetupPacket.*/){
                        $setuppacket=1;
                }
        } else {
                ${$urbhash{$urbrequest}{'remark'}}[0]="don't know how to handle ISOCH_TRANSFER\n";
        }       
                
}               
                
foreach $indexkey (sort keys %urbhash){
        if($urbhash{$indexkey}{'remark'}[0] ne ""){ 
                print $urbhash{$indexkey}{'remark'}[0];
                next;
        }       
        foreach $outkey (@{$urbhash{$indexkey}{'out'}}){
                if(substr($outkey,0,1) eq "4"){
                        $outgoing=1;
                        $wval=substr($outkey,9,2);
                        $wval.=substr($outkey,6,2);
                        $reg=substr($outkey,15,2);
                        $reg.=substr($outkey,12,2);
                        $breq=substr($outkey,3,2);
                } else {
                        $outgoing=0;
                }
        }
        if($outgoing == 1){
                $outstrng="em2820_write_regs_req(dev,0x$breq,0x$reg";
                $regvals="";
                foreach $inkey (@{$urbhash{$indexkey}{'in'}}){
                        $fullinkey=$inkey;
                        $inkey=~s/[^A-Za-z0-9 ]//g;
                        $inkey=~s/ *$//;

                        @inarray=split(/ /,$inkey);
                        $cntx=0;
                        foreach $value (@inarray){
                                if(substr($value,0,1) ne " "){
                                        $regvals.="\\x$value";
                                        $cntx++;
                                }
                        }
                }
                if($regvals ne ""){
                        $outstrng.=",0x$wval,\"$regvals\",$cntx);";
                } else {
                        $outstrng.=",0x$wval,\"\",0x0);";
                }
                print $outstrng;
#               &comment($reg,"write");
        } else {
                if($reg ne "" and $breq ne ""){
                        print "em2820_read_reg(dev,0x$breq,0x$wval,0x$reg);";
#                       &comment($reg,"read");
                }

        }
        print "\n";
}

Markus Rechberger/irc mrec