Saturday, October 18, 2008

New Sensor + Merge + FAQ [Tascorp 17a1:0128]

During the last months, Jean F. Moine did a lot of work to merge gspca inside the kernel mainstream. You can find gspca included in the kernel since 2.6.27.X. Also the libv4lconvert inclusion ( by Hans de Goede ) allowed to move decoding process from kernel space to user space, and hence , permitted a fast insertion of gspca in the main tree.

Also, libv4lconvert, allow compatibility between older apps ( using v4l1) and new formats conversion ( or specifics decoders that some apps do not include ) for apps that use v4l2.

In the last two days, a new sensor was added to the t613 subdriver ( which i
mantains). The new sensor is reported as OM6802. Thx to the people testing this ( Luiz Gonzaga da Mata, Marc Boettinger and Peter (from Austria ) ), also to J F Moine who developed big part of this sensor and fixes.

A new sensor have appeared too, reported 0x08 : 0x03, if anyone have this sensor, please mail me.

I also attach some little tools to extract image from UsbSnoop logs ( for tascorp / t613 only ) at the end.

So, always checkout the last hg from
if the current version is not working with your device.

[Little FAQ]

1) My webcam is not working, what i can i do?

1.1) Checkout lastest hg and test again. (libv4lconvert is inside v4l2-apps/lib/libv4l/ )

1.2) Check messages to find something relevant, like "sensor not found",
"not supported," usb error",etc.
1.3) Do a # echo 0x3f > /sys/modules/gspca_main/parameters/debug
1.4) Try svv application:
1.4.1 ) ./svv
1.4.2 ) ./svv -r
1.4.3 ) ./svv -g -r ( image.dat sould be created if all goes ok )
1.4.4) If there is some "mode" error, you can also try ./svv -m r

1.5 ) Send all logs files within your email. Also attach the image.dat
if it was created on steps 1.4.x

1.6 ) Try to email the author of the subdriver fist and cc the involved people. If you dont get any response, you should email the current responsible of gspca ( ). Also you can get in touch in the maillist.
If related to t613, mailme to or
1.7) Be prepared to test set of patches.

2) I got asked about win usb traces of my webcam, wtf?

2.1 Get
2.2 Start logging
2.3 Replug the webcam
2.4 Open the video capture application on win.
2.5 What i usually ask is the following for the first time:
1 - Start preview
2 - Stop preview
3 - Change resolution ( 640x480 -> 320x240 if vga, else another resolution )
4 - Do a Reset Defaults settings on controls
5 - Start Preview
6 - Stop Preview.
7 - Close the log file.
2.6 Attach C:\Windows\UsbSnoop.log.
2.7 Usually i dont care about the image frames ( isoch ), but its help to assure the format is the same as expected and we are not dealing with something else. ( anyway, this help for unknown bridges, etc ).
Do not keep long on the preview, or your log file will get really bigger.
2.8 If all goes ok, and you webcam start streaming when you test newer patches, then you could be asked by a new usb trace with differents instructions ( like changing gamma, colors, etc ).

3) Camorama, gcam, skype, etc, etc do not work!

3.0 Check you already have installed or
( /usr/src/gspca-xxxx/v4l2-apps/lib/libv4l )
Also there is a README inside that dir.

3.1 Camorama, GQCam and others apps are older. They still use v4l1. Thnxs to libv4lconvert you can still make use of this apps. Something like
#LD_PRELOAD=/usr/local/libv4l/ camorama
could help.

3.2 Some applications, use v4l2 but do not support some format conversions, in that case you should need this ( for example ) :
#LD_PRELOAD=/usr/local/libv4l/ skype
Tools: Copy and Paste on each file.
The blog will mess all the formats, if you need it let me know, i will send it via email. ( one day i will upload it on some place )
This tool is just for analysis purposed, but if you wanna play, is just a simple parser. Also the code could be reduced to fewer lines, but i don't care, its for my use.

How to use it:
1) ruby extract_sets.rb UsbSnoop.log outdir/
2) ruby extract_image.rb outdir/
Extracting from outdir/
Total: 462 Processed: [5/462] [1%]
3) You should see .dat and jpg files inside outdir.

[BEGIN extract_set.rb ]


if ARGV.length < 2 || ARGV[0].empty? || ARGV[1].empty?
print "Tascorp Image Extract\n"
print "./extract_sets.rb [usbsnoop log file] [sets_dir]"
print "\n"
exit 0

print "Extracting from #{ARGV[0]} to Ouput dir #{ARGV[1]}\n"

archivo =[0],"r")
rescue => err
puts "Error: #{err}"
exit 0

rescue => err
puts "Dir do not exists... creating it..."
rescue => mkdir_err
puts "Error on mkdir #{err}"
exit 0


start = false

out_set = nil
count = 0
while str = archivo.gets
if str.strip.chomp.match('[0-9a-b]+:')

if str =~ /ff d8/
start = true
out_set ="#{ARGV[1]}/#{count}.dat","w")
puts "Extracting set #{count}"
elsif str =~ /ff d9/ && start == true

out_set << str
start = false
if start == true
out_set << str

[ EOF extract_sets.rb ]

[ BEGIN extract_image.rb]


if ARGV.length < 1 || ARGV[0].empty?
puts "./extract_image.rb data_set_dir"
exit 0

print "Extracting from #{ARGV[0]}\n"

count = 0

files = Dir.glob("*.dat").sort

files.each { |fname|

archivo =
final_data =
data =
count += 1
str = "Total: #{files.count} Processed: [#{count}/#{files.count}] [" +
((count*100)/files.count).to_s + "%]"

str.length.times { print "\b"}
print str

while str = archivo.gets

nset =
str.strip.chomp.gsub(/[0-9a-h]+:/,'').strip.gsub(/([A-Z]|\[|-).*/,'').gsub(/^02 a[0-1]/,'').strip

if ! nset.empty?
nset.split(' ').each { |s| data << s}
out ="#{fname.sub(".dat",".jpg")}","wb")
data.each do |byte|
out.print byte.to_a.pack("H*")

puts "done"

[EOF extract_image.rb]

No comments: