Video for Linux Two
1.V4l2_device
- struct v4l2_device{
- /*->to.
- :NULLifis
- iscase.g..*/
- *dev;
- /*to*/
- ;
- /*;if
- is.*/
- ;
- /*,+*/
- [V4L2_DEVICE_NAME_SIZE];
- /*sub-devices.*/
- (*notify)(*sd,
- int,*arg);
- };
- int(*dev,*v4l2_dev)
- {
- if(==NULL)
- -EINVAL;
- (&v4l2_dev->subdevs);
- (&v4l2_dev->lock);
- ->=;
- if(==NULL){
- /*If==NULL,thenin*/
- (!v4l2_dev->name[0]);
- ;
- }
- /*Setto+ifisempty.*/
- if(!v4l2_dev->name[0])
- (v4l2_dev->name,(v4l2_dev->name),"%s %s",
- ->driver->name,(dev));
- if(dev_get_drvdata(dev))
- (v4l2_dev,"Non-NULL drvdata on register\n");
- (dev,);
- ;
- }
- EXPORT_SYMBOL_GPL(v4l2_device_register);
- void v4l2_device_unregister(*v4l2_dev)
- {
- *sd,*next;
- if(==NULL)
- ;
- (v4l2_dev);
- /**/
- (sd,next,&v4l2_dev->subdevs,){
- (sd);
- #if(CONFIG_I2C)||(defined(CONFIG_I2C_MODULE)&&(MODULE))
- if(sd->&){
- *=(sd);
- /*to.
- onto
- for,if
- is,thenis.*/
- if(client)
- (client);
- }
- #endif
- }
- }
- EXPORT_SYMBOL_GPL(v4l2_device_unregister);
- /*
- *,.c
- *to
- *
- */
- struct video_device
- {
- /**/
- const*fops;
- /**/
- ;/**/
- *cdev;/**/
- /*Setorif*/
- *parent;/**/
- *v4l2_dev;/**/
- /**/
- [32];
- int;
- /*'minor'issetto-if*/
- int;
- ;
- /*toset/clear/*/
- ;
- /*toon*/
- int;
- int;/**/
- /**/
- ;/**/
- ;/**/
- /**/
- (*release)(*vdev);
- /**/
- const*ioctl_ops;
- };
- /**
- *-
- *:to
- *:to
- *:(==/dev/video0,==/dev/video1,...
- *-==)
- *:if
- *inand.
- *
- *and
- *onand
- *.
- *errorisifor
- *,orif.
- *
- *ison.
- *
- *
- *
- *%-
- *
- *%-
- *
- *%-(undecoded)
- *
- *%-
- */
- int(*vdev,int,int,
- int)
- {
- int=;
- int;
- int=;
- int=;
- const*name_base;
- *=(vdev);
- /*-1 marks this video device as never
- */
- ->=-1;
- /**/
- (!vdev->release);
- if(!vdev->release)
- -EINVAL;
- /*:*/
- (type){
- case:
- ="video";
- ;
- case:
- ="vtx";
- ;
- case:
- ="vbi";
- ;
- case:
- ="radio";
- ;
- :
- ("%s called with unknown type: %d\n",
- ,);
- -EINVAL;
- }
- ->=;
- ->=NULL;
- if(vdev->&&->v4l2_dev->dev)
- ->=->v4l2_dev->dev;
- /*:,and.*/
- #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
- /*forfor
- *.
- *(notin)
- *-and
- *(new style).*/
- (type){
- case:
- =;
- =;
- ;
- case:
- =;
- =;
- ;
- case:
- =;
- =;
- ;
- case:
- =;
- =;
- ;
- :
- =;
- =;
- ;
- }
- #endif
- /**/
- (&videodev_lock);
- =(vdev,==-?:,);
- if(==)
- =(vdev,,);
- if(==){
- ("could not get a free device node number\n");
- (&videodev_lock);
- -ENFILE;
- }
- #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
- /*-on-to*/
- =;
- #else
- /*and,
- .*/
- for(=;<;++)
- if(video_device[i]==NULL)
- ;
- if(==){
- (&videodev_lock);
- ("could not get a free minor\n");
- -ENFILE;
- }
- #endif
- ->=+;
- ->=;
- (vdev);
- /*not*/
- (video_device[vdev->minor]!=NULL);
- ->=(vdev);
- (&videodev_lock);
- /*:*/
- ->=();
- if(vdev->==NULL){
- =-ENOMEM;
- ;
- }
- if(vdev->fops->unlocked_ioctl)
- ->cdev->=&v4l2_unlocked_fops;
- else
- ->cdev->=&v4l2_fops;
- ->cdev->=->fops->owner;
- =(vdev->cdev,(VIDEO_MAJOR,->minor),);
- if(<){
- ("%s: cdev_add failed\n",);
- (vdev->cdev);
- ->=NULL;
- ;
- }
- /*:*/
- (&vdev->dev,,(vdev->dev));
- /*'s drvdata,
- .*/
- (vdev,);
- ->dev.class=&video_class;
- ->dev.=(VIDEO_MAJOR,->minor);
- if(vdev->parent)
- ->dev.=->parent;
- (&vdev->dev,"%s%d",,->num);
- =(&vdev->dev);
- if(<){
- ("%s: device_register failed\n",);
- ;
- }
- /*
- to.*/
- ->dev.=;
- if(!=-&&!=->&&)
- ("%s: requested %s%d, got %s%d\n",
- ,,,,->num);
- /*:.now.*/
- (&videodev_lock);
- [vdev->minor]=;
- (&videodev_lock);
- ;
- cleanup:
- (&videodev_lock);
- if(vdev->cdev)
- (vdev->cdev);
- (vdev);
- (&videodev_lock);
- /*.*/
- ->=-1;
- ;
- }
- int(*vdev,int,int)
- {
- (vdev,,,);
- }
- EXPORT_SYMBOL(video_register_device);
- /**
- *-
- *:to
- *
- *.
- *.
- */
- void video_unregister_device(*vdev)
- {
- /*if*/
- if(!||-><)
- ;
- (&videodev_lock);
- (V4L2_FL_UNREGISTERED,&vdev->flags);
- (&videodev_lock);
- (&vdev->dev);
- }
- EXPORT_SYMBOL(video_unregister_device);
- /*Each,
- -orin.
- */
- {
- ;
- *owner;
- ;
- *v4l2_dev;
- const*ops;
- /**/
- [V4L2_SUBDEV_NAME_SIZE];
- /*to,is-*/
- ;
- /*toprivate*/
- *priv;
- };
- {
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- /*location*/
- ;
- {
- ;
- ;
- };
- ;
- ;
- ;
- };