/kern_oII/include/media/v4l2-dev.h

http://omnia2droid.googlecode.com/ · C++ Header · 147 lines · 76 code · 27 blank · 44 comment · 0 complexity · 5fcfd0bf66abee16a144c86023f2f341 MD5 · raw file

  1. /*
  2. *
  3. * V 4 L 2 D R I V E R H E L P E R A P I
  4. *
  5. * Moved from videodev2.h
  6. *
  7. * Some commonly needed functions for drivers (v4l2-common.o module)
  8. */
  9. #ifndef _V4L2_DEV_H
  10. #define _V4L2_DEV_H
  11. #include <linux/poll.h>
  12. #include <linux/fs.h>
  13. #include <linux/device.h>
  14. #include <linux/cdev.h>
  15. #include <linux/mutex.h>
  16. #include <linux/videodev2.h>
  17. #define VIDEO_MAJOR 81
  18. #define VFL_TYPE_GRABBER 0
  19. #define VFL_TYPE_VBI 1
  20. #define VFL_TYPE_RADIO 2
  21. #define VFL_TYPE_VTX 3
  22. #define VFL_TYPE_MAX 4
  23. struct v4l2_ioctl_callbacks;
  24. struct video_device;
  25. struct v4l2_device;
  26. /* Flag to mark the video_device struct as unregistered.
  27. Drivers can set this flag if they want to block all future
  28. device access. It is set by video_unregister_device. */
  29. #define V4L2_FL_UNREGISTERED (0)
  30. struct v4l2_file_operations {
  31. struct module *owner;
  32. ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
  33. ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
  34. unsigned int (*poll) (struct file *, struct poll_table_struct *);
  35. long (*ioctl) (struct file *, unsigned int, unsigned long);
  36. long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
  37. unsigned long (*get_unmapped_area) (struct file *, unsigned long,
  38. unsigned long, unsigned long, unsigned long);
  39. int (*mmap) (struct file *, struct vm_area_struct *);
  40. int (*open) (struct file *);
  41. int (*release) (struct file *);
  42. };
  43. /*
  44. * Newer version of video_device, handled by videodev2.c
  45. * This version moves redundant code from video device code to
  46. * the common handler
  47. */
  48. struct video_device
  49. {
  50. /* device ops */
  51. const struct v4l2_file_operations *fops;
  52. /* sysfs */
  53. struct device dev; /* v4l device */
  54. struct cdev *cdev; /* character device */
  55. /* Set either parent or v4l2_dev if your driver uses v4l2_device */
  56. struct device *parent; /* device parent */
  57. struct v4l2_device *v4l2_dev; /* v4l2_device parent */
  58. /* device info */
  59. char name[32];
  60. int vfl_type;
  61. /* 'minor' is set to -1 if the registration failed */
  62. int minor;
  63. u16 num;
  64. /* use bitops to set/clear/test flags */
  65. unsigned long flags;
  66. /* attribute to differentiate multiple indices on one physical device */
  67. int index;
  68. int debug; /* Activates debug level*/
  69. /* Video standard vars */
  70. v4l2_std_id tvnorms; /* Supported tv norms */
  71. v4l2_std_id current_norm; /* Current tvnorm */
  72. /* callbacks */
  73. void (*release)(struct video_device *vdev);
  74. /* ioctl callbacks */
  75. const struct v4l2_ioctl_ops *ioctl_ops;
  76. };
  77. /* dev to video-device */
  78. #define to_video_device(cd) container_of(cd, struct video_device, dev)
  79. /* Register video devices. Note that if video_register_device fails,
  80. the release() callback of the video_device structure is *not* called, so
  81. the caller is responsible for freeing any data. Usually that means that
  82. you call video_device_release() on failure.
  83. Also note that vdev->minor is set to -1 if the registration failed. */
  84. int __must_check video_register_device(struct video_device *vdev, int type, int nr);
  85. int __must_check video_register_device_index(struct video_device *vdev,
  86. int type, int nr, int index);
  87. /* Unregister video devices. Will do nothing if vdev == NULL or
  88. vdev->minor < 0. */
  89. void video_unregister_device(struct video_device *vdev);
  90. /* helper functions to alloc/release struct video_device, the
  91. latter can also be used for video_device->release(). */
  92. struct video_device * __must_check video_device_alloc(void);
  93. /* this release function frees the vdev pointer */
  94. void video_device_release(struct video_device *vdev);
  95. /* this release function does nothing, use when the video_device is a
  96. static global struct. Note that having a static video_device is
  97. a dubious construction at best. */
  98. void video_device_release_empty(struct video_device *vdev);
  99. /* helper functions to access driver private data. */
  100. static inline void *video_get_drvdata(struct video_device *vdev)
  101. {
  102. return dev_get_drvdata(&vdev->dev);
  103. }
  104. static inline void video_set_drvdata(struct video_device *vdev, void *data)
  105. {
  106. dev_set_drvdata(&vdev->dev, data);
  107. }
  108. struct video_device *video_devdata(struct file *file);
  109. /* Combine video_get_drvdata and video_devdata as this is
  110. used very often. */
  111. static inline void *video_drvdata(struct file *file)
  112. {
  113. return video_get_drvdata(video_devdata(file));
  114. }
  115. static inline int video_is_unregistered(struct video_device *vdev)
  116. {
  117. return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags);
  118. }
  119. #endif /* _V4L2_DEV_H */