Bt878 and example btvid3.c Driver Tips
The btvid3.c code is known to work with the systems we have in the lab and has been used successfully by students for the past several years, but will require that you study and understand the hardware, example code, carefully verify in a stepwise fashion the PCI config space, MMU programming, and Interrupts as well as careful verification of your camera, board, and careful handling of the hardware.
Early versions of code have been used with the Hauppauge cards and x86 PCI platforms successfully with only minor modification, again for config space MMIO/IRQ assignment, for the past 10 years!!
The btvid3.c just provides better sync with the newer VxWorks BSP and automatic PCI bus enumeration and MMU programming features of the newer BSP.
For those of you working with Bt878 and driver, please consider the following carefully as you unit test the card, driver, and camera:
- Use code from web page rather than older code in book - btvid3.c
- You can get help from the TA during office hours - they have used this driver successfully (or similiar PCI) in the past on the exact same systems we are using when he took the class
- Please pre-test your camera and focus it using the LCD in the lab which has a power supply right next to it and YELLOW composite RCA input (select input using front panel).
- Install Bt878 with POWER OFF (pull the power cord) and NEVER hot plug PCI cards in our lab.
- Make sure working camera is plugged into Bt878
- Verify the interrupt and BAR assigned by the BSP by reading config space (you did this in labs) and read the code carefully to make sure you are connecting the correct IRQ and verify that the MMIO address makes sense.
- Verify that the MMIO address in the code is the same as the config space BAR, and also that you can do "d 0x" on a Wind Shell command line without MMU exception - i.e. the BSP should program the MMU to allow for addresses in this same range to be put out on the bus - verify that you can read the status registers on the Bt878 using this MMIO BAR (base address) using the example code. One of the best ways to verify the PCI device BAR for a given function on a given bus is to use the VxWorks built-in "pci" helper functions. The BSP enumerates the bus and fills out data structures with the overall configuration of all buses, devices, functions and the BARs, IRQs, etc.
Verify the VxWorks BSP configuration space programming (NOTE Bt878 is vendorID=0x109e) using:
- pciAllHeaderShow - this should give you a very complete high level view of all PCI headers for all buses on the system. Which looks like this for the Bt878 for example:
vendor ID = 0x109e
device ID = 0x036e
command register = 0x0106
status register = 0x8290
revision ID = 0x11
class code = 0x04
sub class code = 0x00
programming interface = 0x00
cache line = 0x00
latency time = 0x42
header type = 0x80
BIST = 0x00
base address 0 = 0xfca00008
base address 1 = 0x00000000
base address 2 = 0x00000000
base address 3 = 0x00000000
base address 4 = 0x00000000
base address 5 = 0x00000000
cardBus CIS pointer = 0x00000000
sub system vendor ID = 0x0070
sub system ID = 0x13eb
expansion ROM base address = 0x00000000
interrupt line = 0x0a
interrupt pin = 0x01
min Grant = 0x10
max Latency = 0x28
Capabilities - Vital Product Data
Capabilities - Power Management
OR INSTEAD USE:
- pciConfigTopoShow - this should give you a very complete high level view of the overall PCI topology
- Now that you know how many PCI buses are built into the target, use pciDeviceShow(BUSNO) where BUSNO is the bus number where you found the Bt878 deviceID and vendorID.
- Finally, to verify the BAR0...BARn for your device functions, use pciFuncBarShow(BUSNO, DEVNO) where DEVNO is the device number as parsed by the BSP for the vendorID/deviceID for your device. Note that the device may have multiple functions - the Bt878 has a video encoding function as well as an audio encoding function - you want the first function.
- Now, set your MMIO address in the btvid3.c code to match what the BSP programmed the MMU for and make sure that the MMU address and PCI device BAR match.
- To further verify, use d 0xBACEADD0 where 0xBACEADD0 is the base address that was programmed by the BSP. Likewise, you should be able to dump and modify a RAM address such as 0x04000000 (which is 64MB from address 0x00000000) using "d" and "m" in the windshell.
- Read the chipset manual carefully and make sure you understand device operation, micro code, registers, interrupt errors and status, NTSC signalling and encoding with luminance and chromanence ADC channels - Bt878 Video Decoder Chipset Manual
For background on NTSC signals, these links are helpful:
However, NOTE that we are dealing with baseband and not MODULATED NTSC - that's why you plug your CCTV into composite input rather than the TUNER.
- Read the driver source carefully, make sure you understand it based on the chipset documentation. Ask TA or myself if you have questions on the code. We will expect you to have read the code and chipset manual. You may also find the Linux version of this driver in V4Linux useful as a reference, but reference to this driver is not required -
Video 4 Linux
NOTE Bt8x8 driver code for Linux that works with same Hauppauge card and Bt878 chip.
- Make use of built-in status and debug functions (or add your own) in btvid3.c and read all README files carefully - for example reset_status function.
- See TA during office hours to get help if you are still stuck.
- Schedule debug session with Dr. Siewert if you are still stuck. Remember, the example code is not "plug and play" solution that you mindlessly INSTALL - you must read, understand, master, modify, and make this your own -- the example code will save you about 15 weeks of work if you had to code this driver from chipset manual alone. So invest some time, but if you are stuck and you have read the background, then please do ask for help.