v4l2-dev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #define OBSOLETE_DEVDATA 1 /* to be removed soon */
  12. #include <linux/poll.h>
  13. #include <linux/fs.h>
  14. #include <linux/device.h>
  15. #include <linux/mutex.h>
  16. #include <linux/compiler.h> /* need __user */
  17. #include <linux/videodev2.h>
  18. #define VIDEO_MAJOR 81
  19. /* Minor device allocation */
  20. #define MINOR_VFL_TYPE_GRABBER_MIN 0
  21. #define MINOR_VFL_TYPE_GRABBER_MAX 63
  22. #define MINOR_VFL_TYPE_RADIO_MIN 64
  23. #define MINOR_VFL_TYPE_RADIO_MAX 127
  24. #define MINOR_VFL_TYPE_VTX_MIN 192
  25. #define MINOR_VFL_TYPE_VTX_MAX 223
  26. #define MINOR_VFL_TYPE_VBI_MIN 224
  27. #define MINOR_VFL_TYPE_VBI_MAX 255
  28. #define VFL_TYPE_GRABBER 0
  29. #define VFL_TYPE_VBI 1
  30. #define VFL_TYPE_RADIO 2
  31. #define VFL_TYPE_VTX 3
  32. struct v4l2_ioctl_callbacks;
  33. /*
  34. * Newer version of video_device, handled by videodev2.c
  35. * This version moves redundant code from video device code to
  36. * the common handler
  37. */
  38. struct video_device
  39. {
  40. /* device ops */
  41. const struct file_operations *fops;
  42. /* sysfs */
  43. struct device dev; /* v4l device */
  44. struct device *parent; /* device parent */
  45. /* device info */
  46. char name[32];
  47. int type; /* v4l1 */
  48. int type2; /* v4l2 */
  49. int minor;
  50. /* attribute to diferentiate multiple indexs on one physical device */
  51. int index;
  52. int debug; /* Activates debug level*/
  53. /* Video standard vars */
  54. v4l2_std_id tvnorms; /* Supported tv norms */
  55. v4l2_std_id current_norm; /* Current tvnorm */
  56. /* callbacks */
  57. void (*release)(struct video_device *vfd);
  58. /* ioctl callbacks */
  59. const struct v4l2_ioctl_ops *ioctl_ops;
  60. #ifdef OBSOLETE_DEVDATA /* to be removed soon */
  61. /* dev->driver_data will be used instead some day.
  62. * Use the video_{get|set}_drvdata() helper functions,
  63. * so the switch over will be transparent for you.
  64. * Or use {pci|usb}_{get|set}_drvdata() directly. */
  65. void *priv;
  66. #endif
  67. /* for videodev.c intenal usage -- please don't touch */
  68. int users; /* video_exclusive_{open|close} ... */
  69. struct mutex lock; /* ... helper function uses these */
  70. };
  71. /* Class-dev to video-device */
  72. #define to_video_device(cd) container_of(cd, struct video_device, dev)
  73. /* Version 2 functions */
  74. extern int video_register_device(struct video_device *vfd, int type, int nr);
  75. int video_register_device_index(struct video_device *vfd, int type, int nr,
  76. int index);
  77. void video_unregister_device(struct video_device *);
  78. /* helper functions to alloc / release struct video_device, the
  79. later can be used for video_device->release() */
  80. struct video_device *video_device_alloc(void);
  81. void video_device_release(struct video_device *vfd);
  82. #ifdef OBSOLETE_DEVDATA /* to be removed soon */
  83. /* helper functions to access driver private data. */
  84. static inline void *video_get_drvdata(struct video_device *dev)
  85. {
  86. return dev->priv;
  87. }
  88. static inline void video_set_drvdata(struct video_device *dev, void *data)
  89. {
  90. dev->priv = data;
  91. }
  92. /* Obsolete stuff - Still needed for radio devices and obsolete drivers */
  93. extern struct video_device* video_devdata(struct file*);
  94. extern int video_exclusive_open(struct inode *inode, struct file *file);
  95. extern int video_exclusive_release(struct inode *inode, struct file *file);
  96. #endif
  97. #endif /* _V4L2_DEV_H */