dvbdev.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. #include <media/media-device.h>
  29. #define DVB_MAJOR 212
  30. #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
  31. #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
  32. #else
  33. #define DVB_MAX_ADAPTERS 8
  34. #endif
  35. #define DVB_UNSET (-1)
  36. #define DVB_DEVICE_VIDEO 0
  37. #define DVB_DEVICE_AUDIO 1
  38. #define DVB_DEVICE_SEC 2
  39. #define DVB_DEVICE_FRONTEND 3
  40. #define DVB_DEVICE_DEMUX 4
  41. #define DVB_DEVICE_DVR 5
  42. #define DVB_DEVICE_CA 6
  43. #define DVB_DEVICE_NET 7
  44. #define DVB_DEVICE_OSD 8
  45. #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
  46. static short adapter_nr[] = \
  47. {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
  48. module_param_array(adapter_nr, short, NULL, 0444); \
  49. MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
  50. struct dvb_frontend;
  51. /**
  52. * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API
  53. *
  54. * @num: Number of the adapter
  55. * @list_head: List with the DVB adapters
  56. * @device_list: List with the DVB devices
  57. * @name: Name of the adapter
  58. * @proposed_mac: proposed MAC address for the adapter
  59. * @priv: private data
  60. * @device: pointer to struct device
  61. * @module: pointer to struct module
  62. * @mfe_shared: mfe shared: indicates mutually exclusive frontends
  63. * Thie usage of this flag is currently deprecated
  64. * @mfe_dvbdev: Frontend device in use, in the case of MFE
  65. * @mfe_lock: Lock to prevent using the other frontends when MFE is
  66. * used.
  67. * @mdev: pointer to struct media_device, used when the media
  68. * controller is used.
  69. */
  70. struct dvb_adapter {
  71. int num;
  72. struct list_head list_head;
  73. struct list_head device_list;
  74. const char *name;
  75. u8 proposed_mac [6];
  76. void* priv;
  77. struct device *device;
  78. struct module *module;
  79. int mfe_shared; /* indicates mutually exclusive frontends */
  80. struct dvb_device *mfe_dvbdev; /* frontend device in use */
  81. struct mutex mfe_lock; /* access lock for thread creation */
  82. #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
  83. struct media_device *mdev;
  84. #endif
  85. };
  86. /**
  87. * struct dvb_device - represents a DVB device node
  88. *
  89. * @list_head: List head with all DVB devices
  90. * @fops: pointer to struct file_operations
  91. * @adapter: pointer to the adapter that holds this device node
  92. * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND,
  93. * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET
  94. * @minor: devnode minor number. Major number is always DVB_MAJOR.
  95. * @id: device ID number, inside the adapter
  96. * @readers: Initialized by the caller. Each call to open() in Read Only mode
  97. * decreases this counter by one.
  98. * @writers: Initialized by the caller. Each call to open() in Read/Write
  99. * mode decreases this counter by one.
  100. * @users: Initialized by the caller. Each call to open() in any mode
  101. * decreases this counter by one.
  102. * @wait_queue: wait queue, used to wait for certain events inside one of
  103. * the DVB API callers
  104. * @kernel_ioctl: callback function used to handle ioctl calls from userspace.
  105. * @name: Name to be used for the device at the Media Controller
  106. * @entity: pointer to struct media_entity associated with the device node
  107. * @pads: pointer to struct media_pad associated with @entity;
  108. * @priv: private data
  109. *
  110. * This structure is used by the DVB core (frontend, CA, net, demux) in
  111. * order to create the device nodes. Usually, driver should not initialize
  112. * this struct diretly.
  113. */
  114. struct dvb_device {
  115. struct list_head list_head;
  116. const struct file_operations *fops;
  117. struct dvb_adapter *adapter;
  118. int type;
  119. int minor;
  120. u32 id;
  121. /* in theory, 'users' can vanish now,
  122. but I don't want to change too much now... */
  123. int readers;
  124. int writers;
  125. int users;
  126. wait_queue_head_t wait_queue;
  127. /* don't really need those !? -- FIXME: use video_usercopy */
  128. int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
  129. /* Needed for media controller register/unregister */
  130. #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
  131. const char *name;
  132. /* Allocated and filled inside dvbdev.c */
  133. struct media_entity *entity;
  134. struct media_pad *pads;
  135. #endif
  136. void *priv;
  137. };
  138. /**
  139. * dvb_register_adapter - Registers a new DVB adapter
  140. *
  141. * @adap: pointer to struct dvb_adapter
  142. * @name: Adapter's name
  143. * @module: initialized with THIS_MODULE at the caller
  144. * @device: pointer to struct device that corresponds to the device driver
  145. * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter;
  146. * to select among them. Typically, initialized with:
  147. * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums)
  148. */
  149. int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
  150. struct module *module, struct device *device,
  151. short *adapter_nums);
  152. /**
  153. * dvb_unregister_adapter - Unregisters a DVB adapter
  154. *
  155. * @adap: pointer to struct dvb_adapter
  156. */
  157. int dvb_unregister_adapter(struct dvb_adapter *adap);
  158. /**
  159. * dvb_register_device - Registers a new DVB device
  160. *
  161. * @adap: pointer to struct dvb_adapter
  162. * @pdvbdev: pointer to the place where the new struct dvb_device will be
  163. * stored
  164. * @template: Template used to create &pdvbdev;
  165. * @priv: private data
  166. * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND,
  167. * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET
  168. */
  169. int dvb_register_device(struct dvb_adapter *adap,
  170. struct dvb_device **pdvbdev,
  171. const struct dvb_device *template,
  172. void *priv,
  173. int type);
  174. /**
  175. * dvb_unregister_device - Unregisters a DVB device
  176. *
  177. * @dvbdev: pointer to struct dvb_device
  178. */
  179. void dvb_unregister_device(struct dvb_device *dvbdev);
  180. #ifdef CONFIG_MEDIA_CONTROLLER_DVB
  181. void dvb_create_media_graph(struct dvb_adapter *adap);
  182. static inline void dvb_register_media_controller(struct dvb_adapter *adap,
  183. struct media_device *mdev)
  184. {
  185. adap->mdev = mdev;
  186. }
  187. #else
  188. static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
  189. #define dvb_register_media_controller(a, b) {}
  190. #endif
  191. int dvb_generic_open (struct inode *inode, struct file *file);
  192. int dvb_generic_release (struct inode *inode, struct file *file);
  193. long dvb_generic_ioctl (struct file *file,
  194. unsigned int cmd, unsigned long arg);
  195. /* we don't mess with video_usercopy() any more,
  196. we simply define out own dvb_usercopy(), which will hopefully become
  197. generic_usercopy() someday... */
  198. int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
  199. int (*func)(struct file *file, unsigned int cmd, void *arg));
  200. /** generic DVB attach function. */
  201. #ifdef CONFIG_MEDIA_ATTACH
  202. #define dvb_attach(FUNCTION, ARGS...) ({ \
  203. void *__r = NULL; \
  204. typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
  205. if (__a) { \
  206. __r = (void *) __a(ARGS); \
  207. if (__r == NULL) \
  208. symbol_put(FUNCTION); \
  209. } else { \
  210. printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
  211. } \
  212. __r; \
  213. })
  214. #define dvb_detach(FUNC) symbol_put_addr(FUNC)
  215. #else
  216. #define dvb_attach(FUNCTION, ARGS...) ({ \
  217. FUNCTION(ARGS); \
  218. })
  219. #define dvb_detach(FUNC) {}
  220. #endif
  221. #endif /* #ifndef _DVBDEV_H_ */