Design and implementation of video acquisition system based on VxWorks
[Copy link]
Abstract The video acquisition system is implemented on the Intel x86 platform and the real-time operating system VxWorks using Bt848. The highly integrated nature of Bt848 makes its peripheral circuits extremely simple, facilitating hardware design and integration of additional functions while ensuring performance. The excellent performance and convenient interface of VxWorks make it easy to write device drivers and application software. Keywords: video capture, Bt848, VxWorks, PCI device driver 1 Introduction The development of multimedia communication technology has provided a wealth of means for the acquisition and transmission of information. Video data is an indispensable and important component of it, and the acquisition of video data is inseparable from the video acquisition system. At present, the application of video acquisition systems is extremely extensive. Many products and facilities, such as remote monitoring, videophones, conference televisions, etc., require the acquisition of video information. Moreover, with the popularization of PCs, people can directly use PCs to collect videos. The collected video data is processed and saved locally or sent to a distant place. Since the acquisition, processing and transmission of video are all completed on a PC, the complexity and price of the system can be greatly reduced. The video acquisition system we designed is based on the Intel x86 platform and the real-time operating system VxWorks. It consists of two parts: a video acquisition card and a driver, as shown in Figure 1. The video acquisition card completes video data acquisition and format conversion. The driver initializes the hardware when the system starts and realizes data interaction between the hardware and application software after the system starts. Considering the huge amount of video data, the video acquisition card is connected to the computer through the PCI high-speed bus. 2 Design of video capture card | | 500)this.style.width=500;"> Figure 1: Desktop video acquisition system structure diagram | In order to convert the analog video input by the camera into a digital video that can be accepted and processed by the computer, multiple steps such as analog-to-digital conversion, synchronization extraction, and brightness and color separation are required. In order to transmit the digital video to the memory of the PC, a certain number of FIFOs, bus interfaces, and corresponding control logic are also required. This was originally a relatively complicated process, but with the development of semiconductor technology, various semiconductor manufacturers have been able to realize all these functions on a single chip through continuous innovation and improvement. Conexant's Bt848 is such a chip, and Figure 2 shows its functional block diagram. 500)this.style.width=500;"> Figure 2 BT848 functional block diagram Bt848 is a complete low-cost solution for NTSC/PAL/SECAM video capture applications on the PCI bus. As a bus master device, Bt848 does not require any local cache to store video pixel data, which greatly reduces the hardware price. Bt848 can fully utilize the high bandwidth and inherent multimedia capabilities of PCI bus-based systems, and can interoperate with other multimedia devices, so that video capture and overlay functions can be added to the system in a modular manner at a very low cost. The use of Bt848 is independent of the topology of the PCI system bus and can be used in various system bus organizational structures. It can be directly integrated on the motherboard or made into a plug-in card inserted in the PCI bus slot. The main features of Bt848 are: fully compatible with PCI 2.1 specification, with auxiliary GPIO data port and video data port, supported image resolution up to 768×576, support for complex cropping function, zero wait state PCI burst write operation, support field/frame masking to reduce bandwidth, support multiple YCbCr and RGB pixel formats in output, support NTSC/SECAM/PAL analog input, can use vertical/horizontal interpolation filtering to reduce image size to icon size, with multiple composite and S video inputs, support odd and even fields with different destination addresses, support odd and even fields with different color space/scaling factors, support video mapping of 225 color palettes, with VBI video capture function for teletext. These features make Bt848 suitable for application fields such as PC TV, desktop videophone, motion video capture, still image acquisition and VBI data service. The highly integrated structure of Bt848 makes its peripheral circuits extremely simple, and it is also convenient to add more functions on the same card, such as video data encryption. The structure of the video capture card is shown in Figure 3. A Bt848 supports up to 4 analog video inputs, of which 3 are composite video signals and 1 is an S-video signal. The 4 video inputs are multiplexed inside the Bt848. The Bt848 is directly connected to the PCI bus through the internal PCI interface. The microcontroller is connected to the GPIO port of the Bt848 through the FIFO, and the microcontroller software and the software on the host together implement the encryption of the video acquisition system. The control logic controls the timing of the Bt848 and the FIFO, and synchronizes the operation of the PCI bus, the Bt848 and the microcontroller. | | 500)this.style.width=500;"> Figure 3 Video capture card structure diagram | 3 Driver Programming The application must communicate with the hardware through the driver, and the writing of the driver is closely related to the operating system. The operating system used in this system is the real-time operating system VxWorks. VxWorks is a microkernel high-performance scalable real-time operating system developed by WRS (Wind River Systems). It supports a wide range of network communication protocols and can be combined according to user needs. Its open structure and support for industrial standards allow developers to design effective real-time operating systems that meet the requirements of different users with minimal work. The main features of VxWorks are: microkernel structure (minimum structure <8KB), efficient task management, flexible inter-task communication, microsecond interrupt processing, compliance with POSIX 1003.1b real-time extension standard, TCP/IP network standard, flexible boot capability from ROM, disk or network, multi-processor support, fast and flexible I/O system, MS-DOS and RT-11 file system, full compliance with ANSI C standard, more than 1100 function routines. In addition to the outstanding operating system, WRS also provides an excellent real-time operating system development tool Tornado. Tornado consists of three highly integrated parts: Tornado tools, which are a set of powerful cross-development tools; VxWorks runtime system, which is a high-performance, customizable real-time operating system running on the target machine; and communication options that connect the target machine and the host machine, such as Ethernet, serial line, online simulation or ROM simulation. Tornado can support almost all working platforms and target processors. The tools provided can be used for all target machines and have two debugging modes (system and task mode). In addition to basic functions and development tools, Tornado also has an advanced series of network products, which greatly expands Tornado's network features and enhances the network features of embedded microprocessors. All mechanisms and functions of VxWorks are based on the simple structure of "C subroutine", that is, all functions of VxWorks are provided by C program library, any C program can be interactively called from Tornado command and debugging environment, any C program can be generated from Tornado host tool or application as a VxWorks task, and C program can be connected to interrupt, watchdog timer or auxiliary timer. This unity of VxWorks makes Tornado an effective development system, because users no longer need to write special code to interface with system traps, nor do they need to perform special processing to establish a task, nor do they need to write special user interface programs or interactive test programs to test new codes. Users can complete all these tasks by writing subroutines. These features of VxWorks provide great convenience for writing applications and device drivers. Under VxWorks, device drivers can be embedded in the kernel and started with the system, or they can be run as loadable modules after the system starts. The former method requires modifying and recompiling the kernel, which requires familiarity with the kernel structure and is difficult to implement. The latter method is relatively simple and similar to writing general applications. However, no matter which method is used to write the driver, its basic structure is the same, as shown in Figure 4. The PCI bus is a plug-and-play bus that can automatically assign appropriate memory mapping addresses, I/O ports, and inputs (IRQs) to the system interrupt controller with the support of the BIOS and operating system. Bt848 supports two types of address spaces: configuration address space and memory address space. The configuration address space includes predefined PCI configuration registers, while the memory address space includes all local registers used by Bt848. Initializing the PCI bus means setting the registers defined in the PCI configuration space to implement the interface between the host and the PCI local bus. The process is: first, find the location of the device in the system according to the device identifier (Bt848) and the vendor identifier (Brooktree), and determine its bus number, device number and function number; then determine the base address and IRQ of the device according to the bus number, device number and function number. This base address is the starting address of the Bt848 local register, and the IRQ is used when connecting to the interrupt service program; then map the local register of the device to the system memory for later use in setting the local register; finally, set the command register to control the ability of Bt848 to generate and respond to PCI cycles, such as enabling the system to respond to access to memory space, making Bt848 the initiator of bus operations, and making the system report parity errors, etc. The settings in the interrupt mask register INT_MASK of Bt848 determine which interrupts the system can respond to. The interrupt service program provides corresponding processing codes for different interrupt sources. The writing of the interrupt service program must follow certain rules. The most important point is that it cannot cause system blocking and affect system performance. The interrupt service program should be as concise and short as possible so that it can return as quickly as possible. There should be no code that runs too long in the interrupt service program, and there should be no code that accesses certain shared resources (such as trying to obtain semaphores). After writing the interrupt service program, use the IRQ obtained when initializing the PCI bus and the function provided by the operating system to connect the interrupt service program to the interrupt vector. | | 500)this.style.width=500;"> Figure 4 Device driver flow chart | The local registers of Bt848 reside in the 4KB memory addressing space and must be accessed through the PCI bus. By setting the corresponding registers, the behavior of Bt848 can be controlled. Usually, the contents that need to be set include: input TV signal format (PAL or NTSC), input signal source (MUX0, MUX1 or MUX2), line synchronization, field synchronization, output format (CCIR 601, CIF or QCIF), image enlargement or reduction parameters, image filtering parameters, brightness, chroma and contrast adjustment, etc. The DMA controller integrated in t848 is very unique. It is actually a small RISC processor. The instructions it runs (i.e., RISC programs) are located in the host memory and provided by the device driver of Bt848. Since this structure can transfer the acquired video data to the memory, it greatly facilitates the implementation of the video acquisition system. In this structure, DMA can dynamically change the target memory address line by line, which enables users to divide each frame of video data into different parts and place them in multiple memory areas. The starting address of the RISC program is placed in the RISC program starting address register RISC_STRT_ADD of Bt848. The RISC instructions provided by Bt848 include: write WRITE, skip SKIP, synchronize SYNC and jump JUMP. These instructions can be used to control the data flow and obtain the required data. The basic flow of RISC program is: frame synchronization 500)this.style.width=500;">write odd field 500) this.style.width=500;">even field synchronization 500)this.style.width=500;">write even field 500)this.style.width=500;">odd field synchronization 500)this.style.width=500;">jump to write odd field. System startup is achieved by setting the RISC enable bit and FIFO enable bit in the GPIO and DMA control registers. Setting the RISC enable bit to 1 enables the DMA controller to process RISC instructions, and setting the FIFO enable bit to 1 enables the data FIFO. After setting these two bits to 1, video acquisition begins. In the whole system, since the speed of video acquisition is usually higher than the speed at which the application software obtains and processes data, a three-buffer structure is used to ensure the continuity of video data. Cache A is the target address of Bt848 video acquisition. Under the direct control of RISC instructions, the acquired data is first stored in this cache. Caches B and C form a "ping-pong" structure and are used repeatedly: when a frame of data is acquired, an interrupt is generated. In the interrupt service program, the data in cache A is copied to cache B (or C), and then the next frame is acquired; when the next frame of data is acquired, the data in cache A is copied to cache C (or B). When the application needs data, the latest frame of image is read from cache B or C. The alternating use of caches B and C can ensure that the operation of the application reading data from the cache and the operation of the driver writing data to the cache will not conflict, avoiding data damage and delay. 4 Conclusion Using Bt848, a video acquisition system was implemented on the Intel x86 platform and the real-time operating system VxWorks. Due to the highly integrated characteristics of Bt848, its peripheral circuits are extremely simple, which makes it extremely convenient to design hardware circuits. At the same time, the performance can be guaranteed, and other functions can be added flexibly. The excellent performance and convenient interface of VxWorks also make it easy to write device drivers and application software, and its performance can fully meet the requirements. At present, the implemented video acquisition system has been applied in video surveillance and videophones. References 1 Bt848 Single-Chip Video Capture for PCI, Brooktree Corporation, Aug. 1996 2 VxWorks Programmer's Guide 5.3.1, WindRiver systems Inc., May 1997 3 PCI Local Bus Specification Production Version Revision 2.1, PCI Special Interest Group, June 1,
|