һ. V4L2: video for linux version 2


Ƶvivi.c:
1video_device
2
3ע᣺video_register_device

vivi_init
    vivi_create_instance
        v4l2_device_register   // Ҫ, ֻڳʼһЩü
        video_device_alloc
        // 
          1. vfd:
            .fops           = &vivi_fops,
            .ioctl_ops 	= &vivi_ioctl_ops,
            .release	= video_device_release,
          2.
            vfd->v4l2_dev = &dev->v4l2_dev;
          3. "ctrl"(APPioctl)
            	v4l2_ctrl_handler_init(hdl, 11);
            	dev->volume = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
            			V4L2_CID_AUDIO_VOLUME, 0, 255, 1, 200);
            	dev->brightness = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
            			V4L2_CID_BRIGHTNESS, 0, 255, 1, 127);
            	dev->contrast = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
            			V4L2_CID_CONTRAST, 0, 255, 1, 16);                        
        video_register_device(video_device, type:VFL_TYPE_GRABBER, nr)
            __video_register_device
                vdev->cdev = cdev_alloc();
                vdev->cdev->ops = &v4l2_fops;
                cdev_add
                
                video_device[vdev->minor] = vdev;

        		if (vdev->ctrl_handler == NULL)
        			vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler;
                
                

vivi.copen,read,write,ioctl
1. open
app:     open("/dev/video0",....)
---------------------------------------------------
drv:     v4l2_fops.v4l2_open
            vdev = video_devdata(filp);  // ݴ豸Ŵеõvideo_device
            ret = vdev->fops->open(filp);
                        vivi_ioctl_ops.open
                            v4l2_fh_open

2. read
app:    read ....
---------------------------------------------------
drv:    v4l2_fops.v4l2_read
            struct video_device *vdev = video_devdata(filp);
            ret = vdev->fops->read(filp, buf, sz, off);

3. ioctl
app:   ioctl
----------------------------------------------------
drv:   v4l2_fops.unlocked_ioctl
            v4l2_ioctl
                struct video_device *vdev = video_devdata(filp);
                ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
                            video_ioctl2
                                video_usercopy(file, cmd, arg, __video_do_ioctl);
                                    __video_do_ioctl
                                        struct video_device *vfd = video_devdata(file);
                                        APPcmdá"ĳЩ"

v4l2_ctrl_handlerʹù:
    __video_do_ioctl
        struct video_device *vfd = video_devdata(file);

    	case VIDIOC_QUERYCTRL:
    	{
    		struct v4l2_queryctrl *p = arg;
    
    		if (vfh && vfh->ctrl_handler)
    			ret = v4l2_queryctrl(vfh->ctrl_handler, p);
    		else if (vfd->ctrl_handler)  // ãvideo_register_device
    			ret = v4l2_queryctrl(vfd->ctrl_handler, p);
    			            // IDctrl_handlerҵv4l2_ctrlֵ
                                                

vivi
׼װxawtv
sudo apt-get install xawtv

Դxawtv-3.95.tar.gz
http://www.kraxel.org/releases/xawtv/

վµsources.list
http://repogen.simplylinux.ch/
1. ѡ
2ѡڵubuntu汾
3. ѡ"Ubuntu Branches"
4. sources.list
5. ѵõ滻/etc/apt/sources.list
6. sudo apt-get update
   sudo apt-get install xawtv

USBͷ
1VMWAERǰ̨USBͷԿ/dev/video0
2ִ xawtv ɿͼ

ͷvivi
1. ȷʵubuntuں˰汾
uname -a
Linux book-desktop 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
2. ȥwww.kernel.orgͬ汾ں
   ѹdrivers/media/videoĿ¼ȡ
   ޸MakefileΪ

KERN_DIR = /usr/src/linux-headers-2.6.31-14-generic

all:
        make -C $(KERN_DIR) M=`pwd` modules 

clean:
        make -C $(KERN_DIR) M=`pwd` modules clean
        rm -rf modules.order

obj-m   += vivi.o
obj-m   += videobuf-core.o
obj-m   += videobuf-vmalloc.o
obj-m   += v4l2-common.o
   
3. make
4. sudo modprobe vivi  
   sudo rmmod vivi
   sudo insmod ./vivi.ko

5. ls /dev/video*
6. xawtv -c /dev/videoX


//
3. ioctl(4, VIDIOC_G_FMT
4. for()
        ioctl(4, VIDIOC_ENUM_FMT
5. ioctl(4, VIDIOC_QUERYCAP    // о
6. ioctl(4, VIDIOC_G_INPUT     // õǰʹԴ
7. ioctl(4, VIDIOC_ENUMINPUT   // оԴ
8. ioctl(4, VIDIOC_QUERYCTRL   // ѯ,ȡԱȶ
9. ioctl(4, VIDIOC_QUERYCAP
10. ioctl(4, VIDIOC_ENUMINPUT

viviʹù̳׷ͷ
// 1~7v4l2_open
1. open
2. ioctl(4, VIDIOC_QUERYCAP

// 3~7 get_device_capabilities
3. for()
        ioctl(4, VIDIOC_ENUMINPUT   // оԴ,VIDIOC_ENUMINPUT/VIDIOC_G_INPUT/VIDIOC_S_INPUTǱ
4. for()
        ioctl(4, VIDIOC_ENUMSTD  // оٱ׼(ʽ), Ǳ
5. for()        
        ioctl(4, VIDIOC_ENUM_FMT // оٸʽ

6. ioctl(4, VIDIOC_G_PARM
7. for()
        ioctl(4, VIDIOC_QUERYCTRL    // ѯ(˵ֵСֵֵĬֵ)

// 8~10ͨv4l2_read_attrõ        
8. ioctl(4, VIDIOC_G_STD            // õǰʹõı׼(ʽ), Ǳ
9. ioctl(4, VIDIOC_G_INPUT 
10. ioctl(4, VIDIOC_G_CTRL           // õǰ, Ƕ

11. ioctl(4, VIDIOC_TRY_FMT          // ܷ֧ĳָʽ
12. ioctl(4, VIDIOC_S_FMT            // ͷʹĳָʽ


// 13~16v4l2_start_streaming
13. ioctl(4, VIDIOC_REQBUFS          // ϵͳ仺
14. for()
        ioctl(4, VIDIOC_QUERYBUF         // ѯĻ
        mmap        
15. for ()
        ioctl(4, VIDIOC_QBUF             // ѻ        
16. ioctl(4, VIDIOC_STREAMON             // ͷ


// 17ﶼͨv4l2_write_attrõ
17. for ()
        ioctl(4, VIDIOC_S_CTRL           // 
    ioctl(4, VIDIOC_S_INPUT              // Դ
    ioctl(4, VIDIOC_S_STD                // ñ׼(ʽ), Ǳ

// v4l2_nextframe > v4l2_waiton    
18. v4l2_queue_all
    v4l2_waiton    
        for ()
        {
            select(5, [4], NULL, NULL, {5, 0})      = 1 (in [4], left {4, 985979})
            ioctl(4, VIDIOC_DQBUF                // de-queue, ѻӶȡ
            // , ֮Ѿͨmmap˻ĵַ, Ϳֱӷ        
            ioctl(4, VIDIOC_QBUF                 // ѻ
        }

xawtvļ
1. v4l2_open
2. v4l2_read_attr/v4l2_write_attr
3. v4l2_start_streaming
4. v4l2_nextframe/v4l2_waiton

ͷ11ioctl:
    // ʾһͷ豸
	.vidioc_querycap      = vidioc_querycap,

    /* о١áԡͷݵĸʽ */
	.vidioc_enum_fmt_vid_cap  = vidioc_enum_fmt_vid_cap,
	.vidioc_g_fmt_vid_cap     = vidioc_g_fmt_vid_cap,
	.vidioc_try_fmt_vid_cap   = vidioc_try_fmt_vid_cap,
	.vidioc_s_fmt_vid_cap     = vidioc_s_fmt_vid_cap,

    /* : /ѯ//ȡ */
	.vidioc_reqbufs       = vidioc_reqbufs,
	.vidioc_querybuf      = vidioc_querybuf,
	.vidioc_qbuf          = vidioc_qbuf,
	.vidioc_dqbuf         = vidioc_dqbuf,

	// /ֹͣ
	.vidioc_streamon      = vidioc_streamon,
	.vidioc_streamoff     = vidioc_streamoff,	
     
ݵĻȡ̣
1. 仺: ioctl(4, VIDIOC_REQBUFS          // ϵͳ仺
                        videobuf_reqbufs(, v4l2_requestbuffers) // openvideobuf_queue_vmalloc_initʼ
                        // ע⣺IOCTLֻǷ仺ͷϢĻ滹ûз

2. ѯӳ仺:
ioctl(4, VIDIOC_QUERYBUF         // ѯĻ
        videobuf_querybuf        // ûݸʽСÿһгȡ߶            
mmap("С")   // ŷ仺
        v4l2_mmap
            vivi_mmap
                videobuf_mmap_mapper
                    videobuf-vmalloc.c__videobuf_mmap_mapper
                            mem->vmalloc = vmalloc_user(pages);   // Ÿռ

3. ѻ:
ioctl(4, VIDIOC_QBUF             // ѻ        
    videobuf_qbuf
        q->ops->buf_prepare(q, buf, field);  // ṩĺЩԤ
        list_add_tail(&buf->stream, &q->stream);  // ѻеβ
        q->ops->buf_queue(q, buf);           // ṩ"к"
        

4. ͷ
ioctl(4, VIDIOC_STREAMON
    videobuf_streamon
        q->streaming = 1;
        

5. selectѯǷ
          // ض: ݡѽ
          v4l2_poll
                vdev->fops->poll
                    vivi_poll   
                        videobuf_poll_stream
                            // Ӷеͷû
                			buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
                            
                            // û                			
                			poll_wait(file, &buf->done, wait);

    ˭ݡ˭
    ں߳vivi_threadÿ30MSִһΣ
    vivi_thread_tick
        vivi_fillbuff(fh, buf);  //  
        wake_up(&buf->vb.done);  // ѽ
          
6. ݺӶȡ
// ô໺APP֪һݣVIDIOC_DQBUF
ioctl(4, VIDIOC_DQBUF 
    vidioc_dqbuf   
        // ڶݵĻ
        retval = stream_next_buffer(q, &buf, nonblocking);
        
        // Ӷɾ
        list_del(&buf->stream);
        
        // ״̬ظAPP
        videobuf_status(q, b, buf, q->type);
        
7. ӦóVIDIOC_DQBUFõ״̬֪һ
   ȥӦĵַ(õַǰmmap)

ôдͷ:
1. video_device:video_device_alloc
2. 
   .fops
   .ioctl_ops (Ҫ11)
   ҪںṩĻҪһvideobuf_queue_ops
3. ע: video_register_device

ġԼдһͷ

塢дһUSBͷ
1.һusb_driver
2.
   probe:
        2.1. video_device:video_device_alloc
        2.2. 
           .fops
           .ioctl_ops (Ҫ11)
           ҪںṩĻҪһvideobuf_queue_ops
        2.3. ע: video_register_device      
  id_table: ʾ֧ЩUSB豸      
3.ע᣺ usb_register
 
UVC: USB Video Class
UVCdrivers\media\video\uvc\

uvc_driver.c:
1. usb_register(&uvc_driver.driver);
2. uvc_probe
        uvc_register_video
            vdev = video_device_alloc();
            vdev->fops = &uvc_fops;
            video_register_device

www.usb.org uvc specification,
UVC 1.5 Class specification.pdf : ϸ
USB_Video_Example 1.5.pdf    : ʾ

ͨVideoControl Interfaceƣ
ͨVideoStreaming InterfaceƵݣ
VCﺬжUnit/Terminalȹģ飬ͨЩģпƣ
            
UVCụ̀
const struct v4l2_file_operations uvc_fops = {
	.owner		= THIS_MODULE,
	.open		= uvc_v4l2_open,
	.release	= uvc_v4l2_release,
	.ioctl		= uvc_v4l2_ioctl,
	.read		= uvc_v4l2_read,
	.mmap		= uvc_v4l2_mmap,
	.poll		= uvc_v4l2_poll,
};

1. open:
        uvc_v4l2_open
2. VIDIOC_QUERYCAP   // video->streaming->type Ӧ豸öʱʱõ
		if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
			cap->capabilities = V4L2_CAP_VIDEO_CAPTURE
					  | V4L2_CAP_STREAMING;
		else
			cap->capabilities = V4L2_CAP_VIDEO_OUTPUT
					  | V4L2_CAP_STREAMING;
3. VIDIOC_ENUM_FMT // formatӦ豸öʱõ
        format = &video->streaming->format[fmt->index];
4. VIDIOC_G_FMT
        uvc_v4l2_get_format  // USBͷֶָ֧ʽfromat, ÿָʽжframe(ֱ)
            	struct uvc_format *format = video->streaming->cur_format;
            	struct uvc_frame *frame = video->streaming->cur_frame;
5. VIDIOC_TRY_FMT
        uvc_v4l2_try_format
            /* Check if the hardware supports the requested format. */

        	/* Find the closest image size. The distance between image sizes is
        	 * the size in pixels of the non-overlapping regions between the
        	 * requested size and the frame-specified size.
        	 */
6. VIDIOC_S_FMT  // ֻǰѲûзUSBͷ
        uvc_v4l2_set_format
            uvc_v4l2_try_format
        	video->streaming->cur_format = format;
        	video->streaming->cur_frame = frame;
7. VIDIOC_REQBUFS
        uvc_alloc_buffers
           	for (; nbuffers > 0; --nbuffers) {
        		mem = vmalloc_32(nbuffers * bufsize);
        		if (mem != NULL)
        			break;
        	}
8. VIDIOC_QUERYBUF
        uvc_query_buffer
            __uvc_query_buffer
                memcpy(v4l2_buf, &buf->buf, sizeof *v4l2_buf);  // Ʋ
9. mmap
        uvc_v4l2_mmap
            
10. VIDIOC_QBUF
        uvc_queue_buffer
        	list_add_tail(&buf->stream, &queue->mainqueue);
        	list_add_tail(&buf->queue, &queue->irqqueue);

11. VIDIOC_STREAMON
        uvc_video_enable(video, 1)  // õĲӲ,Ȼͷ
            /* Commit the streaming parameters. */
            uvc_commit_video
                uvc_set_video_ctrl  /* øʽfromat, frame */
                    	ret = __uvc_query_ctrl(video->dev /* һUSB豸 */, SET_CUR, 0,
                    		video->streaming->intfnum  /* һӿ: VS */,
                    		probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, data, size,
                    		uvc_timeout_param);
                    
            /* Initialize isochronous/bulk URBs and allocate transfer buffers. */
            uvc_init_video(video, GFP_KERNEL);
                    uvc_init_video_isoc / uvc_init_video_bulk
                        urb->complete = uvc_video_complete; (յݺ˺,ֵvideo->decode(urb, video, buf); ==> uvc_video_decode_isoc/uvc_video_encode_bulk => uvc_queue_next_buffer => wake_up(&buf->wait);)
                        
                    usb_submit_urb                    	
12. poll
        uvc_v4l2_poll            
            uvc_queue_poll
                poll_wait(file, &buf->wait, wait);  // ߵȴ

13. VIDIOC_DQBUF
        uvc_dequeue_buffer
        	list_del(&buf->stream);

14. VIDIOC_STREAMOFF            
        uvc_video_enable(video, 0);
    		usb_kill_urb(urb);
    		usb_free_urb(urb);
        
ȹ̣
ioctl: VIDIOC_S_CTRL
            uvc_ctrl_set
            uvc_ctrl_commit
                __uvc_ctrl_commit(video, 0);
                    uvc_ctrl_commit_entity(video->dev, entity, rollback);
                			ret = uvc_query_ctrl(dev  /* һUSB豸 */, SET_CUR, ctrl->entity->id  /* һunit/terminal */,
                				dev->intfnum /* һӿ: VC interface */, ctrl->info->selector,
                				uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
                				ctrl->info->size);
                        
     
ܽ᣺
1. UVC豸2interface: VideoControl Interface, VideoStreaming Interface
2. VideoControl InterfaceڿƣȡڲжUnit/Terminal(ڳUnit/TerminalΪentity)
   ͨƵĺʣ
                			ret = uvc_query_ctrl(dev  /* һUSB豸 */, SET_CUR, ctrl->entity->id  /* һunit/terminal */,
                				dev->intfnum /* һӿ: VC interface */, ctrl->info->selector,
                				uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
                				ctrl->info->size);
3. VideoStreaming InterfaceڻƵݣҲѡfromat/frame(VSжformat, һformatֶ֧frame frameʾֱʵϢ)
   ͨƵĺʣ
                    	ret = __uvc_query_ctrl(video->dev /* һUSB豸 */, SET_CUR, 0,
                    		video->streaming->intfnum  /* һӿ: VS */,
                    		probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, data, size,
                    		uvc_timeout_param);
4. FORMATʱֻǼ򵥵ʹvideo->streaming->format[fmt->index]ݣ
   Щģ
   Ӧ豸öʱõģҲǷʱõġ

5. UVCصڣ
   ķ
   ԵĿ: ͨVideoControl Interface
   ʽѡͨVideoStreaming Interface
   ݵĻãͨVideoStreaming InterfaceURB

дUVC֮

ߡдUVC֮ʵݴ
A. ubuntuӴ0printkϢ
a. vmwareserial port, ʹļΪ
b. ubuntu޸/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"

sudo update-grub
sudo reboot

c. ubuntuֹrootû¼
޸root: sudo passwd root
Ȼִ"su root"Ϳroot¼

d. echo "8 4 1 7" > /proc/sys/kernel/printk

ٴֻҪִ2Ϳԣ
su root
echo "8 4 1 7" > /proc/sys/kernel/printk

B. д룺
1.һusb_driver
2.
   probe:
        2.1. video_device:video_device_alloc
        2.2. 
           .fops
           .ioctl_ops (Ҫ11)
           ҪںṩĻҪһvideobuf_queue_ops
        2.3. ע: video_register_device      
  id_table: ʾ֧ЩUSB豸      
3.ע᣺ usb_register
 
USBͷͺ:
a. Ƶõ:  6190 ,ԭʼYUVݣ֧MJPEGѹ
   35Ԫ
b. ҲʹUVC淶ͷ: ǽӵWINDOWSϺװͷ
   ҪдҪͨ
c. Ҳһͷ, 2ӿڣUSBCMOS(ITU-R BT. 601/656)
   ֧MJPEGʽ, , 2013820һ100ask.taobao.com
   100Ԫ
   , һ¼һƵֳ޸Ĵ

ע⣺ʹ֧MJPEGʽͷҲĿƵʵ飬
      ֻǽԶƵʱҪͼѹƵЩ


ˡдUVC֮ʵ()
1. ȿAPPȷҪʵЩӿ
xawtv.c:
    grabber_scan
        ng_vid_open
            v4l2_driver.open // v4l2_open
                get_device_capabilities(h);
                    // VIDIOC_QUERYCTRL ioctlȷǷ֧ĳ
                    /* controls */
                    for (i = 0; i < MAX_CTRL; i++) {
                	h->ctl[i].id = V4L2_CID_BASE+i;
                	if (-1 == xioctl(h->fd, VIDIOC_QUERYCTRL, &h->ctl[i], EINVAL) ||
                	    (h->ctl[i].flags & V4L2_CTRL_FLAG_DISABLED))
                	    h->ctl[i].id = -1;
                    }
ôȥ/ԣ
drv0-v4l2.c
ɼ2:
v4l2_read_attr  : VIDIOC_G_CTRL
v4l2_write_attr : VIDIOC_S_CTRL

: ƵҪʵ3ioctl:
VIDIOC_QUERYCTRL
VIDIOC_G_CTRL
VIDIOC_S_CTRL


2. Ӳô?
2.1 UVC淶ﶨЩ : uvc_ctrl.c: static struct uvc_control_info uvc_ctrls[]

	{
		.entity		= UVC_GUID_UVC_PROCESSING, // ˸entity(PU)
		.selector	= PU_BRIGHTNESS_CONTROL,   // 
		.index		= 0,                       // ӦProcessing Unit DescriptorbmControls[0]
		.size		= 2,                       // ݳΪ2ֽ
		.flags		= UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
				| UVC_CONTROL_RESTORE,
	},


 
2.2 ǵ豸֧Щ
    Ҫȥ,  Processing Unit DescriptorbmControlsֵΪ7f 14
    ֪BIT0Ϊ1ʾ֧BRIGHTNESS
    
    ڴ
uvc_drvier.c
uvc_ctrl_init_device    
    // ÿһentity(IT,PU,SU,OT)
	list_for_each_entry(entity, &dev->entities, list) {
	    // ȡbmControls
	    bmControls = ....
	    
	    // bmControlsλֵΪ1ĸֵ֧Ը
	    ncontrols += hweight8(bmControls[i]);    
	    
	    // ΪÿһԷһstruct uvc_control
	    entity->controls = kzalloc..
	    
	    // Щstruct uvc_control
	    ctrl = entity->controls;
	    for (...)
	    {
    		ctrl->entity = entity;
    		ctrl->index = i;
		}

        // uvc_controluvc_control_infoҹ
        uvc_ctrl_add_ctrl(dev, info);
            ctrl->info = ĳuvc_control_info(ͬһentity, indexͬ)

2.3 ôȥЩ
    ο uvc_query_v4l2_ctrl
    uvc_find_control
        ҵһuvc_control_mappingṹ: uvc_ctrl.cstatic struct uvc_control_mapping uvc_ctrl_mappings[] 
        	{
        		.id		= V4L2_CID_BRIGHTNESS,  // APPIDҵӦ
        		.name		= "Brightness",
        		.entity		= UVC_GUID_UVC_PROCESSING,  // ˸entity(PU)
        		.selector	= PU_BRIGHTNESS_CONTROL,    // 
        		.size		= 16,                       // ռλ
        		.offset		= 0,                        // λʼ
        		.v4l2_type	= V4L2_CTRL_TYPE_INTEGER,   // 
        		.data_type	= UVC_CTRL_DATA_TYPE_SIGNED,// 
        	},

         uvc_control_mappingṹ ϸµ

    uvc_query_ctrl
        usb_control_msg


˵: Ҫȣô
a. PUbmControls, bit01ֵ֪֧
b. uvc_ctrlsиentityindexҵһ
	{
		.entity		= UVC_GUID_UVC_PROCESSING,
		.selector	= PU_BRIGHTNESS_CONTROL,
		.index		= 0,
		.size		= 2,
		.flags		= UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
				| UVC_CONTROL_RESTORE,
	},

֪ˣ豸֧SET_CUR, GET_CUR, GET_MIN
ҪʱPUselector, 2ֽ

c. uvc_ctrl_mappingsиIDҵӦ
   Ӷ֪˸ϸµϢ
   Ȼʹusb_control_msgд
   

3. ôд룿
ʵ3ioctl: vidioc_queryctrl/vidioc_g_ctrl/vidioc_s_ctrl
vidioc_queryctrl : USBƴȵСֵֵĬֵֵ
vidioc_s_ctrl    : APPֵͨUSB䷢Ӳ
vidioc_g_ctrl    : USBõǰֵ

Ҫ㣺ݷ˭usb_device
                          VideoControl Interface
                                    Processing Unit 
                                            PU_BRIGHTNESS_CONTROL

. ֧"USB/CMOS"һͷ
1. PCϰUSBͷ: ޸PC LINUXUVC
2. "дUVC"޸, ֧ͷ
3. ޸ĿϵUVC, LCDʾͷͼ
4. CMOS,LCDʾͷͼ
















ѡWIFI
Ա: TL-WN721N 9271

TL-WN721N2ַ: realtek, Atheros 9271
realtek : VID 0x0bda  PID 0x8176
Atheros : VID 0x0cf3  PID 0x9271 0x13D3, 0x3327


[585955.047776] usb 1-1: new high speed USB device using ehci_hcd and address 3
[585955.269142] usb 1-1: configuration #1 chosen from 1 choice
[585955.379843] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0102)
[585955.440427] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[585955.554594] input: USB2.0 Camera as /devices/pci0000:00/0000:00:11.0/0000:02:02.0/usb1/1-1/1-1:1.0/input/input5

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so camorama

sudo apt-get install cheese

LINUXµͷ
https://help.ubuntu.com/community/Webcam

http://blog.csdn.net/hongtao_liu/article/details/5867351
http://blog.csdn.net/hongtao_liu/article/details/5894089
V4L2Ƶ


Ƶʽ : NTSC PAL V4L2_STD_NTSC V4L2_STD_PAL
Ƶʽ RGB YCbCr 420,422 V4L2_PIX_FMT_UYVY



 
[Ƶֲ]ĵ5
http://ishare.iask.sina.com.cn/f/21425721.html
http://ishare.iask.sina.com.cn/f/21425722.html


http://www.360doc.com/content/08/0926/11/14148_1678949.shtml

ƵĻ
http://hi.baidu.com/fengbit/item/78a161375067f1c42f8ec24e

USBЭ
http://www.usb.org/developers/devclass_docs

USB Video Class Specification ʼ 
http://blog.csdn.net/chinaunixj/article/details/7394315


ǶʽLinuxƵɼϵͳ---UVCģͽ
http://blog.csdn.net/chinaunixj/article/details/7439870


Class-specific VC Interface Descriptor
e:\kernel_projects\linux-3.4.2\linux-3.4.2\include\linux\usb\Video.h
#define DECLARE_UVC_HEADER_DESCRIPTOR(n)		\
struct UVC_HEADER_DESCRIPTOR(n) {			\
	__u8  bLength;					\
	__u8  bDescriptorType;				\
	__u8  bDescriptorSubType;			\
	__u16 bcdUVC;					\
	__u16 wTotalLength;				\
	__u32 dwClockFrequency;				\
	__u8  bInCollection;				\
	__u8  baInterfaceNr[n];				\
} __attribute__ ((packed))


Input Terminal Descriptor (Camera)


ܷ
Structure of a driver
---------------------

All drivers have the following structure:

1) A struct for each device instance containing the device state.

2) A way of initializing and commanding sub-devices (if any).

3) Creating V4L2 device nodes (/dev/videoX, /dev/vbiX and /dev/radioX)
   and keeping track of device-node specific data.

4) Filehandle-specific structs containing per-filehandle data;

5) video buffer handling.

This is a rough schematic of how it all relates:

    device instances            : v4l2_device
      |
      +-sub-device instances    : v4l2_subdev
      |
      \-V4L2 device nodes       : video_device, stores V4L2 device node data, this will create the character device
	  |
	  \-filehandle instances    : v4l2_fh

The framework closely resembles the driver structure: it has a v4l2_device
struct for the device instance data, a v4l2_subdev struct to refer to
sub-device instances, the video_device struct stores V4L2 device node data
and in the future a v4l2_fh struct will keep track of filehandle instances
(this is not yet implemented).

The V4L2 framework also optionally integrates with the media framework. If a
driver sets the struct v4l2_device mdev field, sub-devices and video nodes
will automatically appear in the media framework as entities.



console/fs.h:2:20: error: FSlib.h: No such file or directory

No package 'fontsproto' found

error: asm/page.h: No such file or directory

asm/page.hΪsys/user.h

sudo apt-get install libxaw7-dev


# libraries
LDLIBS  := -lFS

./configure --x-includes=/usr/local/include/X11/fonts