Linux 2.6.35 kernel porting-USB camera function added

Source: Internet
Author: User
Tags deprecated

I. Environment
Host environment: ubuntu 10.10
Target machine: FS2410 (S3C2410)
Host tool chain: gcc-4.4.5
Cross tool chain: arm-none-linux-gnueabi-gcc-4.3.2
Camera: ZC301
Ii. porting process
1. Configure the kernel as the kernel supporting the ZC301 camera.
Make menuconfig
Device Drivers --->
<*> Multimedia support --->
<*> Video For Linux
[*] Enable Video For Linux API 1 (DEPRECATED) (NEW)
[*] Video capture adapters (NEW) --->
[*] V4L USB devices (NEW) --->
<*> USB Video Class (UVC)
[*] UVC input events device support (NEW)
<*> USB ZC0301 [P] webcam support (DEPRECATED)
2. recompile the kernel
Make zImage
We can use the above two steps to drive our camera. However, this driver is based on V4l2. In the past, some upper-layer applications based on V4L could not be used, or a lot of modifications were required! Here we want to implement the network video function. Previously we used the network video server servfox, but this server is based on V4L. If we want to use it, we have to modify the source code of servfox. Here we use another scheme, mjpg-stream.
3. Transplantation of mjpg-stream
About mjpg-stream information you can view at the following URL: http://www.eefocus.com/blog/link2url.php? Link = http % 3A % 2F % 2Fsourceforge.net % 2 Fapps % 2 Fmediawiki % 2Fmjpg-streamer % 2Findex. php % 3 Ftitle % 3DMain_Page
The jpeg library is required for mjpg-stream porting. Therefore, we need to first transplant the jpeg library.
(1) jpeg library porting
1) download the jpeg source package from the following URL:
Http://www.ijg.org/files/jpegsrc.v8b.tar.gz
2) decompress the source code package
Tar xvf jpegsrc.v8b.tar.gz
3) configuration source code
Cd jpeg-8b
./Configure -- prefix =/home/linux/s3c2410-2.6.35/video/jpeg -- host = arm-none-linux-gnueabi
4) Compile
Make
5) Installation
Make install
6) copy the database to the file system.
Cp // home/linux/s3c2410-2.6.35/video/jpeg/lib/libjpeg. so.8/source/rootfs/lib
(2) transplantation of mjpg-stream
1) download the mjpg-stream source code package from the URL below
Http://sourceforge.net/projects/mjpg-streamer/
2) decompress the source code
Tar xvf mjpg-streamer-r63.tar.gz
3) modify source code
Cd mjpg-streamer-r63
Modify makefile at all levels in the top-level makefile and plugins directory
CC = gcc
Change
CC = arm-none-linux-gnueabi-gcc
Modify plugins/input_uvc/Makfile
Modify
CFLAGS + =-O2-DLINUX-D_GNU_SOURCE-Wall-shared-fPIC
Is
CFLAGS + =-O2-DLINUX-D_GNU_SOURCE-Wall-shared-fPIC-I/home/linux/s3c2410-2.6.35/video/jpeg/include
Modify
$ (CC) $ (CFLAGS)-ljpeg-o $ @ input_uvc.c v4l2uvc. lo jpeg_utils.lo dynctrl. lo
Is
$ (CC) $ (CFLAGS)-ljpeg-L/home/linux/s3c2410-2.6.35/video/jpeg/lib-o $ @ input_uvc.c v4l2uvc. lo jpeg_utils.lo dynctrl. lo
Pai_utils.c: 27: fatal error: Using Lib. h: No such file or directory
4) Compile
Make
Supplement: If the linux kernel is later than 29, modify drivers/media/video/gspca before this step. in the c file, add a row to the end of goto error_buff;} in row 220th. The final effect is as follows:
220 goto error_buffer;
221}
222 urb-> transfer_flags = URB_NO_TRANSFER_DMA_MAP;
223 usb_fill_int_urb (urb, dev,
... This is omitted
5) test
Mkdir/source/rootfs/mjpg
Cp *. so/source/rootfs/mjpg
Cp mjpg-stream/source/rootfs/bin
Open the Development Board to run
Mjpg_streamer-I "/mjpg/input_uvc.so"-o "/mjpg/output_http.so-w/www"
Start. sh is available in the source code directory. This script contains some mjpg-stream usage methods and instructions.
Open a webpage and enter the following address to view a video (the IP address of the Development Board is 192.168.1.202 ):
Http: // 192.168.1.202: 8080 /? Action = stream
Open a webpage and enter the following address to see a static image:
Http: // 192.168.1.202: 8080 /? Action = snapshot
6) There is a www directory under the mjpg source code. This network uses the mjpg instance, and some other related functions can be implemented with the web server (boa.
Supplement: This experiment focuses on the unified use of cross-tool chains and whether the root file system functions are complete.

From my embedded

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.