dvbdev.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * dvbdev.h
  3. *
  4. * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
  5. * for convergence integrated media GmbH
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Lesser Public License
  9. * as published by the Free Software Foundation; either version 2.1
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. *
  21. */
  22. #ifndef _DVBDEV_H_
  23. #define _DVBDEV_H_
  24. #include <linux/types.h>
  25. #include <linux/poll.h>
  26. #include <linux/fs.h>
  27. #include <linux/list.h>
  28. #define DVB_MAJOR 212
  29. #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
  30. #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
  31. #else
  32. #define DVB_MAX_ADAPTERS 8
  33. #endif
  34. #define DVB_UNSET (-1)
  35. #define DVB_DEVICE_VIDEO 0
  36. #define DVB_DEVICE_AUDIO 1
  37. #define DVB_DEVICE_SEC 2
  38. #define DVB_DEVICE_FRONTEND 3
  39. #define DVB_DEVICE_DEMUX 4
  40. #define DVB_DEVICE_DVR 5
  41. #define DVB_DEVICE_CA 6
  42. #define DVB_DEVICE_NET 7
  43. #define DVB_DEVICE_OSD 8
  44. #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
  45. static short adapter_nr[] = \
  46. {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
  47. module_param_array(adapter_nr, short, NULL, 0444); \
  48. MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
  49. struct dvb_frontend;
  50. struct dvb_adapter {
  51. int num;
  52. struct list_head list_head;
  53. struct list_head device_list;
  54. const char *name;
  55. u8 proposed_mac [6];
  56. void* priv;
  57. struct device *device;
  58. struct module *module;
  59. int mfe_shared; /* indicates mutually exclusive frontends */
  60. struct dvb_device *mfe_dvbdev; /* frontend device in use */
  61. struct mutex mfe_lock; /* access lock for thread creation */
  62. /* Allow the adapter/bridge driver to perform an action before and/or
  63. * after the core handles an ioctl:
  64. *
  65. * DVB_FE_IOCTL_PRE indicates that the ioctl has not yet been handled.
  66. * DVB_FE_IOCTL_POST indicates that the ioctl has been handled.
  67. *
  68. * When DVB_FE_IOCTL_PRE is passed to the callback as the stage arg:
  69. *
  70. * return 0 to allow dvb-core to handle the ioctl.
  71. * return a positive int to prevent dvb-core from handling the ioctl,
  72. * and exit without error.
  73. * return a negative int to prevent dvb-core from handling the ioctl,
  74. * and return that value as an error.
  75. *
  76. * When DVB_FE_IOCTL_POST is passed to the callback as the stage arg:
  77. *
  78. * return 0 to allow the dvb_frontend ioctl handler to exit normally.
  79. * return a negative int to cause the dvb_frontend ioctl handler to
  80. * return that value as an error.
  81. */
  82. #define DVB_FE_IOCTL_PRE 0
  83. #define DVB_FE_IOCTL_POST 1
  84. int (*fe_ioctl_override)(struct dvb_frontend *fe,
  85. unsigned int cmd, void *parg,
  86. unsigned int stage);
  87. };
  88. struct dvb_device {
  89. struct list_head list_head;
  90. const struct file_operations *fops;
  91. struct dvb_adapter *adapter;
  92. int type;
  93. int minor;
  94. u32 id;
  95. /* in theory, 'users' can vanish now,
  96. but I don't want to change too much now... */
  97. int readers;
  98. int writers;
  99. int users;
  100. wait_queue_head_t wait_queue;
  101. /* don't really need those !? -- FIXME: use video_usercopy */
  102. int (*kernel_ioctl)(struct inode *inode, struct file *file,
  103. unsigned int cmd, void *arg);
  104. void *priv;
  105. };
  106. extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
  107. struct module *module, struct device *device,
  108. short *adapter_nums);
  109. extern int dvb_unregister_adapter (struct dvb_adapter *adap);
  110. extern int dvb_register_device (struct dvb_adapter *adap,
  111. struct dvb_device **pdvbdev,
  112. const struct dvb_device *template,
  113. void *priv,
  114. int type);
  115. extern void dvb_unregister_device (struct dvb_device *dvbdev);
  116. extern int dvb_generic_open (struct inode *inode, struct file *file);
  117. extern int dvb_generic_release (struct inode *inode, struct file *file);
  118. extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
  119. unsigned int cmd, unsigned long arg);
  120. /* we don't mess with video_usercopy() any more,
  121. we simply define out own dvb_usercopy(), which will hopefully become
  122. generic_usercopy() someday... */
  123. extern int dvb_usercopy(struct inode *inode, struct file *file,
  124. unsigned int cmd, unsigned long arg,
  125. int (*func)(struct inode *inode, struct file *file,
  126. unsigned int cmd, void *arg));
  127. /** generic DVB attach function. */
  128. #ifdef CONFIG_MEDIA_ATTACH
  129. #define dvb_attach(FUNCTION, ARGS...) ({ \
  130. void *__r = NULL; \
  131. typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
  132. if (__a) { \
  133. __r = (void *) __a(ARGS); \
  134. if (__r == NULL) \
  135. symbol_put(FUNCTION); \
  136. } else { \
  137. printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
  138. } \
  139. __r; \
  140. })
  141. #else
  142. #define dvb_attach(FUNCTION, ARGS...) ({ \
  143. FUNCTION(ARGS); \
  144. })
  145. #endif
  146. #endif /* #ifndef _DVBDEV_H_ */