In recent years, the market for network cameras (IP camera) options abound, but these programmes there is a problem: either it is high-end products, the price is high or low end product, poor performance, is not conducive to marketing.
This article discusses the MPEG-4 network cameras (IP camera) design based on Atmel Corporation's master CPU chip AT91SAM9260 and vimicro MPEG-4 video decoder (CODEC), supports VC0762MPEG-4 RTP/RTSP streaming protocol for real-time MPEG-4 network cameras (IP camera) design. This paper first provides an overview of the system's features and performance as well as the main characteristics of the chip, and then focus on the interface between the chip and driver development, and application profiles.The design master CPU chips and hardware adopts MPEG-4 chips are more advanced semiconductor process design of high integration, low-cost chip, while reducing system costs while not only failed to reduce system performance, but significantly improved.
The system is running an optimized Linux kernel version 2.6.20 is stable, the root file system uses YAFFS2 NAND Flash file system that supports logging. It also transplanted LIVE555 streaming media servers, support, but not limited to, the following open source or part of the open source client: VLC Media Player, QuickTime Player, Amino, openRTSP, Mplayer.Other characteristics of the system also includes: 1. Support PPPoE, DDNS, TCP, UDP, ICMPv4/v6 and MLDv1, ARP, DHCP, DNS, NDP, IGMP network communication protocol;
2. support for RTP/RTSP real-time streaming media protocols;
3. support for SD cards, USB hard drives local storage MPEG-4 media files;
4. supported resolutions including 160 x 120, 320 x 240, 640 x 480, 352 x 288, 702 × 576;
5. support USB interface and Wi-Fi;
6. supports the JPEG picture with GPRS transmission;
7. the use of the operating system is Linux 2.6.20;
8. the use of the media server is a mediaServer.
Main features and functionality of the chip
Atmel Corporation's master CPU chip AT91SAM9260 adopts ARM926EJ-S kernel of industrial grade CPU chip, to 200MHz, DSP instruction extensions and JAVA acceleration technology.
It supports SDRAM, NAND FLASH, SRAM, CF card interface, support for NAND Flash, with a USB2.0 device interface (full speed), 2 x USB2.0 host interface (full speed), Adaptive 10/100 Ethernet port, and supports MII and RMII interface physical transceiver, total integration up to 7 a UART interface, 1 x SPI, I2C.In this design, the AT91SAM9260 is used to run the Linux operating system, provides human-machine interface and the streaming server running environment, handle network communication protocols, and provides access to the file system and mass storage device support.
Vimicro MPEG-4 video decoder (CODEC) is a high-performance VC0762 MPEG-4 hardware codec, which directly support the CMOS image sensor (CMOS sensor than CCD low cost), as a result of the vimicro CMOS image processing patent technology, image sharpness is good.
The chip supports CCIR656, CCIR601 video data interface; support auto exposure, auto white balance, automatic gain control, auto focus, the programming focus, configurable gamma correction, configurable color correction, white balance, you can configure with backlight compensation, image noise control, image sharpness control, etc; support; support for the JPEG codec H.263 codec MPEG-4/; support true color, pseudo color LCD screen; support OSD; supports CVBS TV output interface.In this design, VC0762 is used to get from a CMOS sensor, the original data and accept the instructions of the streaming media server, on the original image data after image processing and compression systems specify the parameters of MPEG-4 video stream, and then pass the MPEG-4 video, handed down by the AT91SAM9260 streaming server for further processing, and in accordance with the RTP/RTSP protocol to the network.
It also uses the Atmel Corporation's 8-bit AVR Microcontroller ATMEG48 for infrared remote control of pulse decoding, query the keyboard button, switch quantity input detection, relay output control, etc., help to complete some real-time Linux system.
Hardware design
MPEG-4 IP camera system hardware diagram as shown in Figure 1, it adopts 64MB 64MB SDRAM, NAND Flash memory and 64 MB of image cache.
Figure 1: MPEG-4 IP camera system hardware diagram.
Video codec VC0762 through CMOS image data interface and two I2C interface connection Micron company MT9V011 CMOS image sensor.
AT91SAM9260 through the 8-bit data bus connection VC0762, read the MPEG-4 video or JPEG picture data flow, or write to VC0762 control command. AT91SAM9260 external connection Ethernet physical transceiver DM9161, through RJ45 connection to the Internet, send and receive network access streaming media data.CMOS image sensor MT9V011 and video codec VC0762 between two interfaces, one is to pass the image data of the parallel interface, the other is a delivery order for I2C interface, specific circuit diagram shown in Figure 2.
Figure 2: CMOS image sensor and video codec interfaces between VC0762. circuit diagram
Please note that the clock MT9V011 PIXCLK VC0762 GPIO2 of you want to connect (H2 PIN) VC0762 image processing logic unit provides the pixel clock.
The CLKIN connection MT9V011 VC0762 of CS_CLK (27MHz master clock), or you can directly connect 27MHz active oscillator. FRAME_VALID and LINE_VALID namely MT9V011 output field sync signal and line sync signal, connected to, and of CS_VSYNC VC0762 CS_HSYNC signal-to-end.VC0762 through 8 bit parallel data bus connection AT91SAM9260, interface circuit shown in Figure 3.
VC0762 of CPU_OEN received the AT91SAM9260, VC0762 CFOE_NRD CPU_WEN received the AT91SAM9260 of CFWE_NWE_NWR0, VC0762 of CPU_CS2N received high level, the NCS5 CPU_CS1N received AT91SAM9260, VC0762 of CPU_RS received the A19 AT91SAM9260, to achieve control command data and image data of the address. VC0752 data bus CPU_D0 ~ CPU_D7 directly connected AT91SAM9260 data bus D0 ~ D7.
Figure 3: video codec VC0762 and interface between the AT91SAM9260. circuit diagram
Software on the chip selected 5 (NCS5) and address line A19 operates on VC0762 AT91SAM9260 CS5 address 0x6000 0000, VC0762 is the CPU_RS low level commands to read and write, read and write data of high level.
Write command address is defined as:
#define V0762_PHY_BASE_ADDR 0x60000000
Write data address is defined as:
#define V0762_PHY_BASE_DATA 0x60080000
SCM ATmeg48 and interface circuits AT91SAM9260 is relatively simple, because the design here, using 3.3V ATmeg48 and AT91SAM9260-level compatibility.
Software development
Hardware platform determines the selection of the software platform, so you can freely choose software space is not very big.
The AT91SAM9260 platform operating system is running on Linux, WinCE, uCOS, FreeRTOS, etc., for the function and price considerations, selection of Linux here. Linux has a well-developed network protocol stack, and file system, to design and provide a wide range of powerful features. In addition, Linux has a large number of drivers and applications of open source, reducing their development driver and application software.Here you need to develop software including: linux-2.6 core architecture of RS232 infrared keyboard driver, based on the V4L compliant VC0762 driver, local storage for video applications, streaming media server, etc.
1.RS232 interface infrared keyboard driven RS232KBD software development
Linux2.6 keyboard driven development under it is relatively simple, especially new 2.6 later kernel, already includes many embedded platform support, these embedded platforms, there are some similar infrared keyboard driver can be used to reference and graft, such as I2C or I/O driver and thus to enhance keyboard driven development speed.
RS232KBD driver structure is divided into the following sections:
(A) in a entry RS232KBD (module_init) use platform_driver_register (& rs232kbd_driver) function to the system to register our keyboard driver.
Rs232kbd_driver structure is as follows:
static struct platform_driver rs232kbd_driver = {
.probe = rs232kbd_probe,
.remove = __devexit_p(rs232kbd_remove),
.driver = {
.name = "rs232_keyboard",
},
};
Where is the kernel to .probe we registered our driver to the system's startup function an interface, we specify a function, that is when rs232kbd_probe we loaded RS232KBD function platform_driver_
Register (& rs232kbd_driver) will be called kernel received this registration will call .probe specified rs232kbd_probe function to start our RS232KBD drivers (note because we used the platform-driven approach, we also need the kernel arch directory at91sam9260_devices.c define:static struct platform_device rs232_keyboard = {
.name = "rs232_keyboard",
.id = -1,
};
void __init at91_rs232_kbd(struct at91_rs232_keyboard *kbd, int nr)
{
printk("at91_rs232_keyboard\r\n");
rs232_keyboard.dev.platform_data = kbd;
platform_device_register(&rs232_keyboard);
}
And in the directory in the file board-sam9260ek.c ek_board_init (void) function was last added code: at91_rs232_kbd (kbd, ARRAY_SIZE (kbd)).
So we loaded RS232KBD module kernel will call our rs232kbd_probe function.(B) rs232kbd_probe is our RS232KBD driven portal functions, we are here to create an input device, specify the input devices, keyboard, open interface function rs232kbd_open, close function rs232kbd_close, last registered this input device.
(C) in the initialization of the serial port in rs232kbd_probe AT91SAM9260, and apply for UART1 receive interrupts.
(D) in the UART1 receive interrupts from the MCU sends to keys or decoded IR keyboard data, use code: after encoding
input_report_key(rs232kbd->input, rs232kbd->keycode[scancode], pressed);
The keyboard value sent to the tty device.
(E) the driving test, when the drive to write, test, because the embedded devices typically use HyperTerminal or telnet to log on, the keyboard driver is not very good test, we use Web-based open source libkbd code keyboard driven test, download libkbd after a slightly modified can either run in arm-linux.
2.VC0762 V4L driver development:
IC manufacturers to provide us with a platform based on linux VC0762 V4L prototype driver, we need to do is to our AT91SAM9260 linux platform.
(A) first to modify address macro definitions to suit our hardware design:
Write command address definitions:
#define V0762_PHY_BASE_ADDR 0x60000000
Write data address definitions:
#define V0762_PHY_BASE_DATA 0x60080000
AT91SAM9260 read-write VC0762 timing control register address definitions:
#define AT91_BASE_CS5_SMC (0xffffec00 + (0x10 * 5))
(b) Linux virtual address of the reasons we need to map the physical address of the kernel virtual address space, as follows:
pSMC5 = (void*)ioremap(AT91_BASE_CS5_SMC, 0762_REMAP_RANGE);
v0762_virt_base_addr = (void*)ioremap(V0762_PHY_BASE_ADDR, V0762_REMAP_RANGE); v0762_virt_base_data = (void*)ioremap(V0762_PHY_BASE_DATA, V0762_REMAP_RANGE);
(C) the configuration of the AT91SAM9260 access VC0762 static timing:
void Init_smc(void){
pSMC5->SMC_SETUP = 0x20302030;
pSMC5->SMC_PULSE = 0x3F1F3F1F;
pSMC5->SMC_CYCLE = 0x00C
000C0;pSMC5->SMC_CTRL = 0x00000003;
}
(D) define the read-write VC0762 function:
#define V0762_HOSTSETVAL8(addr, val) WriteMemory8(addr, val)
#define V0762_HOSTGETVAL8(addr) ReadMemory8(addr)
#define V0762_WriteMul8Addr(addr) \
{
V0762_HOSTSETADDR8(v0762_virt_base_addr, ((addr &0xff000000) >> 24)); \
V0762_HOSTSETADDR8(v0762_virt_base_addr, ((addr &0xff0000) >> 16)); \
V0762_HOSTSETADDR8(v0762_virt_base_addr, ((addr &0xff00) >> 8)); \
V0762_HOSTSETADDR8(v0762_virt_base_addr, (addr &0xff)); \
}
#define V0762_WriteMul8Dat(dat) \
{
V0762_HOSTSETVAL8(v0762_virt_base_data, ((dat &0xff000000) >> 24)); \
V0762_HOSTSETVAL8(v0762_virt_base_data, ((dat &0xff0000) >> 16)); \
V0762_HOSTSETVAL8(v0762_virt_base_data, ((dat &0xff00) >> 8)); \
V0762_HOSTSETVAL8(v0762_virt_base_data, (dat &0xff)); \
}
In accordance with the above method to handle, you can manipulate VC0762, but in fact we get to a prototype drive also spent a lot of time debugging and transplants, above all is the essence of our debugging.
3. local storage for video applications on:
Local storage-video application that is using the SD card or mobile hard drive storage VC0762 compressed MPEG-4 video application data files.
SD card driver and mobile hard disk drive our system has very good support, and we have to do is open the corresponding device video0 VC0762, setting the video parameters, and reads data from a video device through avilib library functions written in avi files stored on SD card or USB hard drive. The main function call is:Create AVI files:
AVI_open_output_file("cap.avi");
Open VC0762 video devices:
vfd = open("/dev/v4l/video0",O_RDWR);
Set the baud rate: ioctl (vfd, IOCTL_MPEG-4_BITRATE, 8192);
Start collecting images: ioctl (vfd, VIDIOCCAPTURE, 1);
Read a frame MPEG-4 raw data: read (vfd, fbuf, 128000);
Write MPEG-4 video streams to the AVI file: AVI_write_frame (avifile, fbuf, flen);
Closes the avi file: AVI_close ("cap.avi");
Close VC0762 video equipment: close (vfd);
4. streaming media server program
Streaming media server role to read from a video device to the MPEG-4 formats of streaming through the RTP/RTSP protocol to transfer to the Internet, the client can be anywhere in the world through a network connection to our streaming media server, live view is monitoring the situation of the site.
This design is the route of the transplantations, from http://www.live555.com website gets to LIVsE555 Media Server code, and then depending on your system characteristics for transplantation and modify it to support our MPEG-4 stream files.
LIVE555 Media Server transplantation after you can use VLC, mplayer, player or for testing purposes.
A brief summary of this article
>This design successfully using Linux system with a feature-rich IP camera.
Although adopted MPEG-4 encoding, but because of its low overall cost and superior system performance, the programme highly market vitality.Author: Zhang post wind, Zheng is Xin, Liu Yang sheng
Hong Kong baite Shanghai Technical Center
This article uses Haina sharp editing and reprint, copyright the original author.
No comments:
Post a Comment