Kernel Driver for the PlanB Video Input Hardware on PowerMacs ============================================================= Changelog: ---------- 0.05 981023 First public release. 0.06 990404 Second release; updated to kernel 2.2.5 added capture support by Takashi Oe 1.0 990503 Added grayscale support; updated to kernel 2.2.7 What is it? ----------- PlanB is the Apple nickname for the ASIC used in the video input circuitry of the 7x00/8x00 series PowerMacs. This software is a Linux kernel patch that adds a driver for the PlanB hardware under the video4linux (v4l) API, introduced in the development kernels around 2.1.74. The included patch file adds the PlanB driver source, and patches some other kernel files. Requirements: ------------- This patch is designed for the 2.2.7 official kernel release as found on ftp.kernel.org or one of its mirrors. In order to use the PlanB driver, you need a kernel with V4L and PlanB support. You can get both either compiled-in or as modules (called videodev.o and planb.o). To get such a kernel, you can do one of the following: - if you are running kernel 2.2.7, binary modules are included. Insert them like this (as root): make insmod - rebuild the modules, matching them to your kernel version, by executing 'make modules', and install and insmod them (make can do that for you). You need complete kernel sources installed, and already have built a kernel with them (we need some files...). - patch your copy of the kernel sources and rebuild a kernel, either including V4L and PlanB, or compiling them as modules. You can patch your kernel sources by executing 'make patch'. The Makefile contains some configurable options like paths; have a look. Don't forget to create the v4l device special files, like this: lrwxrwxrwx 1 root root 6 Mar 31 01:08 /dev/video -> video0 crw-rw-r-- 1 root users 81, 0 Mar 31 01:08 /dev/video0 The Makefile can do this for you, if you execute (as root): make dev PlanB is verified to work with the control video adapter (i.e the part that drives your monitor) built-in on the 7x00/8x00 series of PowerMacs, and the Matrox Millenium I (using matroxfb). If you have a different video adapter, it should work nevertheless as long as you have a framebuffer driver for it. In order to benefit of PlanB, you need a v4l-compatible application. An example is XawTV, which you can find here: http://www.in-berlin.de/User/kraxel/xawtv.html RPM packages for XawTV can be found on my site: http://www.cpu.lu/~mlan/ftp/xawtv-2.43-1.src.rpm and http://www.cpu.lu/~mlan/ftp/xawtv-2.43-1.ppc.rpm Included in the package is a config file for XawTV (dot.xawtv) that you need to copy to your home directory: cp dot.xawtv ~/.xawtv It will configure XawTV in such a way that sound can be switched on and off with the volume adjustment. Supported functionality: ------------------------ The current release of PlanB (1.0) has support for capture to disk, using apropriate applications like streamer (included with XawTV). Overlay onto the framebuffer was already supported. Overlay means that the planb chip transfers the video data directly into the framebuffer memory of your display adaptor, using DMA, without loading the CPU. Both 32-bpp and 16-bpp colour are supported, as is gray-scale. Norm switching works, with support for PAL, NTSC and SECAM. Picture attributes can be adjusted. Both the Composite and the SVHS inputs are supported. The PlanB driver has no audio support, but with the included .xawtv config file, XawTV can switch audio on and off (audio connected to the Line input of the Mac). Instructions: ------------- Included are binary versions of the required modules (videodev.o and planb.o) for kernel version 2.2.7. You can insert them by running (as root): make insmod 'make patch' will patch your kernel source tree. It assumes certain defaults, like your source tree being in /usr/src/linux. If this is not the case, you can customize the Makefile. You can also do it the old-fashioned manual way and use the diff file directly to patch your kernel sources (something like 'cd /usr/src/linux; patch -p1 < patchfile' ). You might want to check for rejects before going on (make install will do that automatically). Once you got your modules into the kernel, you can start any v4l-compliant application Building a kernel with PlanB: ----------------------------- Go to your kernel source directory, and configure the kernel in your preferred way (make config, make menuconfig, or make xconfig). In order to get PlanB, you need to configure for PowerMacs, and enable video4linux (under 'Character Devices'). Under v4l, there is an option for the PlanB video inputdriver. You might want to chose to build PlanB as a module; that makes debugging easier because you can rebuild only the modules, without touching the kernel proper. Once the build completed (don't forget to make modules; make modules_install), you can insert the planb driver like this: insmod planb (as root) PlanB depends on the V4L API interface; if you compiled that as a module, you need to insert it first: insmod videodev (as root) Setting the initial norm: ------------------------- - either set it in drivers/char/planb.h as a compile-time option: /* Uncomment your preferred norm ;-) */ #define PLANB_DEF_NORM VIDEO_MODE_PAL //#define PLANB_DEF_NORM VIDEO_MODE_NTSC //#define PLANB_DEF_NORM VIDEO_MODE_SECAM - or give it as an option on module insertion: insmod planb.o def_norm= is 0 for PAL, 1 for NTSC, 2 for SECAM planb-conf ---------- Courtesy Takashi Oe If your X does not support XFree86's DGA extension (Xpmac doesn't) or the DGA extension support is non-functioning (XF68_FBDev from ftp.xfree86.org doesn't really support the extension), you will need to run "planb-conf" before using planb in the overlay mode. To run it, just type "planb-conf -s" as root. Currently available command line options for planb-conf: usage: planb-conf [ options ] [addr val] options: -q quiet -r manipulate saa regs -p show planb status -t set planb to TV mode -v set planb to VTR mode -s set frame buffer address -f frame buffer device [/dev/fb0] -c video device [/dev/video0] A binary version of planb-conf is included. If you want to rebuild it, you need the kernel header files installed and set up (symlinks), and then type: make planb-conf As root, you can install planb-conf and its man page with: make install Please note that planb-conf needs a working framebuffer driver for your display adaptor. The kernel includes frmabeuffer drivers for most Apple display adaptors in the PowerMac computers. To compile them in: In either make menuconfig or make xconfig, under 'Console drivers', select 'Open Firmware...' and 'Apple "control"..'. Don't forget to select 'Backward compatibility mode for Xpmac' under 'General Setup'. Recompile, install, and make sure you have the framebuffer device nodes: crw-rw-r-- 1 root root 29, 0 Sep 25 1998 /dev/fb0 lrwxrwxrwx 1 root root 3 Sep 25 1998 /dev/fb0current -> fb0 crw-rw-r-- 1 root root 29, 32 Nov 5 07:38 /dev/fb1 The makefile can create the first framebuffer device file for you; just do: make fbdev (as root) Reboot with newly installed kernel, and you are all set. References and links: --------------------- PlanB home page: http://www.cpu.lu/~mlan/planb.html Alan Cox' v4l page: http://roadrunner.swansea.uk.linux.org/v4l.shtml v4l mailing list archive: http://www.progressive-comp.com/Lists/?l=linux-video&r=1&w=2#linux-video XawTV home page: http://www.in-berlin.de/User/kraxel/xawtv.html v4l API reference: http://roadrunner.swansea.uk.linux.org/v4lapi.shtml Credits: -------- Many thanks to Takashi Oe for his hard work on PlanB, especially to get grabbing going. The source code for this driver is based largely on the bttv driver by Ralph Metzler (rjkm@thp.uni-koeln.de). Hapy hacking, and keep me posted on your experiences! Michel Lanners 990503 mlan@cpu.lu