Zoran devices (zr36057, zr36067)

From LinuxTVWiki
Jump to navigation Jump to search

Cards supported by the zoran driver

Taken from the mjpeg zoran-driverpage :

Also see the unified Zoran driver documentation file (found within /usr/src/linux/Documentation/video4linux/Zoran) A current copy can also be found online here.

Hardware configuration, known caveats

  • The zoran boards are quite picky, at least compared to most other PCI boards. Ideally, the mainboard should use an Intel or SiS chipset, VIA-based boards are known to cause trouble.
  • When selecting a PCI slot to install a zoran-based card, check that this slot does not share an interrupt with other devices or other slots. Doing "cat /proc/interrupts" will tell you about devices on your system and their interrupts. Your mainboard's manual should help in selecting a good (i.e. not shared) PCI slot.

Example output :

# cat /proc/interrupts 
          CPU0       
 0:     297527    IO-APIC-edge  timer
 1:          9    IO-APIC-edge  i8042
 8:          2    IO-APIC-edge  rtc
14:       5228    IO-APIC-edge  ide0
15:         12    IO-APIC-edge  ide1
18:       2566   IO-APIC-level  DC10plus[0]
19:         40   IO-APIC-level  uhci_hcd
20:      33244   IO-APIC-level  acpi, eth0
22:       1092   IO-APIC-level  Ensoniq AudioPCI
23:          0   IO-APIC-level  uhci_hcd
  • Zoran devices using the (older) zr36057 PCI controller have two known, documented (by Zoran) hardware bugs, mostly requiring the driver to be unloaded then reloaded after each use (this information may be wrong and / or out of date).
  • The Iomega Buz is more likely to drop frames than other zoran boards (but works perfectly in some cases). Lowering the size of the capture might help if you get dropped frames (at the obvious expense of image quality).

What these cards can do

  • Capturing video and displaying it _raw_ on the screen, via overlay (using PCI-PCI transfer). You have to use xawtv or motv for that, and use Load "v4l" in your xorg.conf Modules section. My experience is that the image quality using that mode is terrible, but maybe I missed something in my setup.
  • Capturing video (Composite or S-Video) and writing it to disk using the (hardware) MJPEG codec. You have to install the mjpegtools for that, and use lavrec. Having good disk I/O and is essential, BTW, since capturing at the maximum supported resolution and JPEG quality means writing about 6MB/s to the hard drive. In this mode, image quality is perfect (after all, zoran boards are high-end framegrabbers).
From mplayer, during playback :
VIDEO:  [MJPG]  768x576  24bpp  25.000 fps  47699.1 kbps (5822.6 kbyte/s)
  • Sending a MJPEG avi to the card, using lavplay, and selecting either S-Video or Composite input (man lavplay).

What these cards cannot (yet) do

  • Capturing video at high res and displaying it immediately (framegrabber mode) - or at least I haven't been able to do it.

A brief overview of the (weird) software configuration needed to make these cards work

(Or what to do during a rainy afternoon)

Kernel setup

This is for a DC10+ :
Device drivers > Multimedia devices > <M> Video For Linux
Device drivers > Multimedia devices > Video For Linux > <M> Zoran ZR36057/36067 Video For Linux
Device drivers > Multimedia devices > Video For Linux > <M> Pinnacle/Miro DC10(+) support
Device drivers > I2C support > <M> I2C support Device drivers > I2C support > <M> I2C device interface


(pb12) I had trouble building a 2.6.11 kernel on Debian unstable. i2c-core.o would not build. Had success with 2.6.12

The 128KB buffer problem and a workaround

NB : I'm using 512MB of SDRAM. You'll have to adapt the numbers here to your configuration.
The Linux kernel (even 2.6) will not give access to a contiguous memory block larger than 128KB. The problem is, to capture a 768x576 image (PAL), zoran cards need larger buffers (512KB). There are two workarounds : the first is to reserve some memory at boot time, and to tell the zoran driver to use that memory as capture buffers. For a good capture (without any dropped frames), 32 buffers is a large enough number (but YMMV) ; 32x512KB = 16MB, 512-16 = 496MB.
In lilo.conf (I'm sure this is exactly the same for grub, but feel free to edit this page if you know how to do it), use append="mem=496M" like in :

image=/boot/vmlinuz-2.6.11.7
   label=g2611-7 
   root=/dev/whatever 
   read-only 
   append="mem=496M" 

Additionally, you probably need to recompile the driver with -DBUZ_USE_HIMEM in the gcc commandline for it to use the high memory that you reserved by using the "mem" kernel parameter.

The second way to do the same thing is to use the bigphysmem kernel patch. I've never attempted to do that, since loosing 16MB of system ram looked like a decent solution (and the only bigphysmem patches available are for 2.2 or 2.4 kernels).

module loading options

With a DC10+ (zr36067 PCI controller), the module to load is "zr36067". There are several options to know about, namely :
card=$number where $number is the corresponding number for your card in "Cards supported by the zoran driver"
v4l_bufsize=$number where $number is the size of one buffer
v4l_nbufs=$number where $number is the number of the buffers reserved for the card
Ideally, (v4l_nbufs * v4l_bufsize) = (totalmem - append= in your lilo.conf)

What I'm using (DC10+) : modprobe zr36067 v4l_bufsize=512 card=2 v4l_nbufs=32

Other (useful) options are debug=2 if you're having trouble, and low_bitrate=1 if you experience frame drops with a Buz card.

You'll have to figure out how to load the module properly with your distribution's documentation, of course.

User space setup

Applications known to work with these cards

The most obvious one are xawtv and motv which give you full screen, overlay, realtime playback.
kdetv is known to work (but not here).
lavrec, lavplay : the mjpegtools

TODO

I'm working on merging lavrec and lavplay to be able to display a high-res MJPEG capture in real time.

Sources

MJPEG project : driver-zoran

tvtime's page about zoran boards