v4l2-dev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 vfl_type;
  48. int minor;
  49. /* attribute to differentiate multiple indices on one physical device */
  50. int index;
  51. int debug; /* Activates debug level*/
  52. /* Video standard vars */
  53. v4l2_std_id tvnorms; /* Supported tv norms */
  54. v4l2_std_id current_norm; /* Current tvnorm */
  55. /* callbacks */
  56. void (*release)(struct video_device *vfd);
  57. /* ioctl callbacks */
  58. const struct v4l2_ioctl_ops *ioctl_ops;
  59. #ifdef OBSOLETE_DEVDATA /* to be removed soon */
  60. /* dev->driver_data will be used instead some day.
  61. * Use the video_{get|set}_drvdata() helper functions,
  62. * so the switch over will be transparent for you.
  63. * Or use {pci|usb}_{get|set}_drvdata() directly. */
  64. void *priv;
  65. #endif
  66. /* for videodev.c internal usage -- please don't touch */
  67. int users; /* video_exclusive_{open|close} ... */
  68. struct mutex lock; /* ... helper function uses these */
  69. };
  70. /* Class-dev to video-device */
  71. #define to_video_device(cd) container_of(cd, struct video_device, dev)
  72. /* Version 2 functions */
  73. extern int video_register_device(struct video_device *vfd, int type, int nr);
  74. int video_register_device_index(struct video_device *vfd, int type, int nr,
  75. int index);
  76. void video_unregister_device(struct video_device *);
  77. /* helper functions to alloc / release struct video_device, the
  78. later can be used for video_device->release() */
  79. struct video_device *video_device_alloc(void);
  80. void video_device_release(struct video_device *vfd);
  81. #ifdef OBSOLETE_DEVDATA /* to be removed soon */
  82. /* helper functions to access driver private data. */
  83. static inline void *video_get_drvdata(struct video_device *dev)
  84. {
  85. return dev->priv;
  86. }
  87. static inline void video_set_drvdata(struct video_device *dev, void *data)
  88. {
  89. dev->priv = data;
  90. }
  91. /* Obsolete stuff - Still needed for radio devices and obsolete drivers */
  92. extern struct video_device* video_devdata(struct file*);
  93. extern int video_exclusive_open(struct inode *inode, struct file *file);
  94. extern int video_exclusive_release(struct inode *inode, struct file *file);
  95. #endif
  96. #endif /* _V4L2_DEV_H */