Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #ifndef _DVBDEV_H_ |
| 20 | #define _DVBDEV_H_ |
| 21 | |
| 22 | #include <linux/types.h> |
| 23 | #include <linux/poll.h> |
| 24 | #include <linux/fs.h> |
| 25 | #include <linux/list.h> |
Mauro Carvalho Chehab | a0246e0 | 2015-01-02 12:19:51 -0300 | [diff] [blame] | 26 | #include <media/media-device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #define DVB_MAJOR 212 |
| 29 | |
Janne Grunau | 4457ef1 | 2009-09-01 19:15:39 -0300 | [diff] [blame] | 30 | #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 |
Mauro Carvalho Chehab | d4c02ef | 2009-09-19 09:45:22 -0300 | [diff] [blame] | 31 | #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS |
Janne Grunau | 4457ef1 | 2009-09-01 19:15:39 -0300 | [diff] [blame] | 32 | #else |
Буди Романто, AreMa Inc | 90866b3 | 2016-04-05 13:14:10 -0300 | [diff] [blame] | 33 | #define DVB_MAX_ADAPTERS 16 |
Janne Grunau | 4457ef1 | 2009-09-01 19:15:39 -0300 | [diff] [blame] | 34 | #endif |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 35 | |
| 36 | #define DVB_UNSET (-1) |
| 37 | |
Mauro Carvalho Chehab | 6bbf7a8 | 2017-09-19 14:22:19 -0400 | [diff] [blame] | 38 | /* List of DVB device types */ |
| 39 | |
| 40 | /** |
| 41 | * enum dvb_device_type - type of the Digital TV device |
| 42 | * |
| 43 | * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI) |
| 44 | * @DVB_DEVICE_FRONTEND: Digital TV frontend. |
| 45 | * @DVB_DEVICE_DEMUX: Digital TV demux. |
| 46 | * @DVB_DEVICE_DVR: Digital TV digital video record (DVR). |
| 47 | * @DVB_DEVICE_CA: Digital TV Conditional Access (CA). |
| 48 | * @DVB_DEVICE_NET: Digital TV network. |
| 49 | * |
| 50 | * @DVB_DEVICE_VIDEO: Digital TV video decoder. |
| 51 | * Deprecated. Used only on av7110-av. |
| 52 | * @DVB_DEVICE_AUDIO: Digital TV audio decoder. |
| 53 | * Deprecated. Used only on av7110-av. |
| 54 | * @DVB_DEVICE_OSD: Digital TV On Screen Display (OSD). |
| 55 | * Deprecated. Used only on av7110. |
| 56 | */ |
| 57 | enum dvb_device_type { |
| 58 | DVB_DEVICE_SEC, |
| 59 | DVB_DEVICE_FRONTEND, |
| 60 | DVB_DEVICE_DEMUX, |
| 61 | DVB_DEVICE_DVR, |
| 62 | DVB_DEVICE_CA, |
| 63 | DVB_DEVICE_NET, |
| 64 | |
| 65 | DVB_DEVICE_VIDEO, |
| 66 | DVB_DEVICE_AUDIO, |
| 67 | DVB_DEVICE_OSD, |
| 68 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 70 | #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ |
| 71 | static short adapter_nr[] = \ |
| 72 | {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ |
| 73 | module_param_array(adapter_nr, short, NULL, 0444); \ |
| 74 | MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Michael Krufky | 9133aee | 2009-05-23 18:00:59 -0300 | [diff] [blame] | 76 | struct dvb_frontend; |
| 77 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 78 | /** |
| 79 | * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API |
| 80 | * |
| 81 | * @num: Number of the adapter |
| 82 | * @list_head: List with the DVB adapters |
| 83 | * @device_list: List with the DVB devices |
| 84 | * @name: Name of the adapter |
| 85 | * @proposed_mac: proposed MAC address for the adapter |
| 86 | * @priv: private data |
| 87 | * @device: pointer to struct device |
| 88 | * @module: pointer to struct module |
| 89 | * @mfe_shared: mfe shared: indicates mutually exclusive frontends |
| 90 | * Thie usage of this flag is currently deprecated |
| 91 | * @mfe_dvbdev: Frontend device in use, in the case of MFE |
| 92 | * @mfe_lock: Lock to prevent using the other frontends when MFE is |
| 93 | * used. |
| 94 | * @mdev: pointer to struct media_device, used when the media |
| 95 | * controller is used. |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 96 | * @conn: RF connector. Used only if the device has no separate |
| 97 | * tuner. |
| 98 | * @conn_pads: pointer to struct media_pad associated with @conn; |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 99 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | struct dvb_adapter { |
| 101 | int num; |
| 102 | struct list_head list_head; |
| 103 | struct list_head device_list; |
| 104 | const char *name; |
| 105 | u8 proposed_mac [6]; |
| 106 | void* priv; |
| 107 | |
Andrew de Quincey | d09dbf9 | 2006-04-10 09:27:37 -0300 | [diff] [blame] | 108 | struct device *device; |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | struct module *module; |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 111 | |
| 112 | int mfe_shared; /* indicates mutually exclusive frontends */ |
| 113 | struct dvb_device *mfe_dvbdev; /* frontend device in use */ |
| 114 | struct mutex mfe_lock; /* access lock for thread creation */ |
Mauro Carvalho Chehab | a0246e0 | 2015-01-02 12:19:51 -0300 | [diff] [blame] | 115 | |
| 116 | #if defined(CONFIG_MEDIA_CONTROLLER_DVB) |
| 117 | struct media_device *mdev; |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 118 | struct media_entity *conn; |
| 119 | struct media_pad *conn_pads; |
Mauro Carvalho Chehab | a0246e0 | 2015-01-02 12:19:51 -0300 | [diff] [blame] | 120 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | }; |
| 122 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 123 | /** |
| 124 | * struct dvb_device - represents a DVB device node |
| 125 | * |
| 126 | * @list_head: List head with all DVB devices |
| 127 | * @fops: pointer to struct file_operations |
| 128 | * @adapter: pointer to the adapter that holds this device node |
Mauro Carvalho Chehab | 6bbf7a8 | 2017-09-19 14:22:19 -0400 | [diff] [blame] | 129 | * @type: type of the device, as defined by &enum dvb_device_type. |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 130 | * @minor: devnode minor number. Major number is always DVB_MAJOR. |
| 131 | * @id: device ID number, inside the adapter |
| 132 | * @readers: Initialized by the caller. Each call to open() in Read Only mode |
| 133 | * decreases this counter by one. |
| 134 | * @writers: Initialized by the caller. Each call to open() in Read/Write |
| 135 | * mode decreases this counter by one. |
| 136 | * @users: Initialized by the caller. Each call to open() in any mode |
| 137 | * decreases this counter by one. |
| 138 | * @wait_queue: wait queue, used to wait for certain events inside one of |
| 139 | * the DVB API callers |
| 140 | * @kernel_ioctl: callback function used to handle ioctl calls from userspace. |
| 141 | * @name: Name to be used for the device at the Media Controller |
| 142 | * @entity: pointer to struct media_entity associated with the device node |
| 143 | * @pads: pointer to struct media_pad associated with @entity; |
| 144 | * @priv: private data |
Mauro Carvalho Chehab | fdc40b5 | 2015-12-12 08:25:44 -0200 | [diff] [blame] | 145 | * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to |
| 146 | * store the MC device node interface |
| 147 | * @tsout_num_entities: Number of Transport Stream output entities |
| 148 | * @tsout_entity: array with MC entities associated to each TS output node |
| 149 | * @tsout_pads: array with the source pads for each @tsout_entity |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 150 | * |
| 151 | * This structure is used by the DVB core (frontend, CA, net, demux) in |
| 152 | * order to create the device nodes. Usually, driver should not initialize |
| 153 | * this struct diretly. |
| 154 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | struct dvb_device { |
| 156 | struct list_head list_head; |
Jan Engelhardt | 784e29d | 2009-01-11 06:12:43 -0300 | [diff] [blame] | 157 | const struct file_operations *fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | struct dvb_adapter *adapter; |
Mauro Carvalho Chehab | 6bbf7a8 | 2017-09-19 14:22:19 -0400 | [diff] [blame] | 159 | enum dvb_device_type type; |
Andreas Oberritter | 5dd3f30 | 2008-10-23 12:11:19 -0300 | [diff] [blame] | 160 | int minor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | u32 id; |
| 162 | |
| 163 | /* in theory, 'users' can vanish now, |
| 164 | but I don't want to change too much now... */ |
| 165 | int readers; |
| 166 | int writers; |
| 167 | int users; |
| 168 | |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 169 | wait_queue_head_t wait_queue; |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 170 | /* don't really need those !? -- FIXME: use video_usercopy */ |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 171 | int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Mauro Carvalho Chehab | a0246e0 | 2015-01-02 12:19:51 -0300 | [diff] [blame] | 173 | /* Needed for media controller register/unregister */ |
| 174 | #if defined(CONFIG_MEDIA_CONTROLLER_DVB) |
| 175 | const char *name; |
| 176 | |
Mauro Carvalho Chehab | 172e9d3 | 2015-01-03 01:59:53 -0300 | [diff] [blame] | 177 | /* Allocated and filled inside dvbdev.c */ |
Mauro Carvalho Chehab | 8211b18 | 2015-08-21 08:20:22 -0300 | [diff] [blame] | 178 | struct media_intf_devnode *intf_devnode; |
Mauro Carvalho Chehab | df2f94e | 2015-08-21 16:18:18 -0300 | [diff] [blame] | 179 | |
| 180 | unsigned tsout_num_entities; |
| 181 | struct media_entity *entity, *tsout_entity; |
| 182 | struct media_pad *pads, *tsout_pads; |
Mauro Carvalho Chehab | a0246e0 | 2015-01-02 12:19:51 -0300 | [diff] [blame] | 183 | #endif |
| 184 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | void *priv; |
| 186 | }; |
| 187 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 188 | /** |
| 189 | * dvb_register_adapter - Registers a new DVB adapter |
| 190 | * |
| 191 | * @adap: pointer to struct dvb_adapter |
| 192 | * @name: Adapter's name |
| 193 | * @module: initialized with THIS_MODULE at the caller |
| 194 | * @device: pointer to struct device that corresponds to the device driver |
| 195 | * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter; |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 196 | * to select among them. Typically, initialized with: |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 197 | * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums) |
| 198 | */ |
| 199 | int dvb_register_adapter(struct dvb_adapter *adap, const char *name, |
| 200 | struct module *module, struct device *device, |
| 201 | short *adapter_nums); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 203 | /** |
| 204 | * dvb_unregister_adapter - Unregisters a DVB adapter |
| 205 | * |
| 206 | * @adap: pointer to struct dvb_adapter |
| 207 | */ |
| 208 | int dvb_unregister_adapter(struct dvb_adapter *adap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 210 | /** |
| 211 | * dvb_register_device - Registers a new DVB device |
| 212 | * |
| 213 | * @adap: pointer to struct dvb_adapter |
| 214 | * @pdvbdev: pointer to the place where the new struct dvb_device will be |
| 215 | * stored |
| 216 | * @template: Template used to create &pdvbdev; |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 217 | * @priv: private data |
Mauro Carvalho Chehab | 6bbf7a8 | 2017-09-19 14:22:19 -0400 | [diff] [blame] | 218 | * @type: type of the device, as defined by &enum dvb_device_type. |
Mauro Carvalho Chehab | fdc40b5 | 2015-12-12 08:25:44 -0200 | [diff] [blame] | 219 | * @demux_sink_pads: Number of demux outputs, to be used to create the TS |
| 220 | * outputs via the Media Controller. |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 221 | */ |
| 222 | int dvb_register_device(struct dvb_adapter *adap, |
| 223 | struct dvb_device **pdvbdev, |
| 224 | const struct dvb_device *template, |
| 225 | void *priv, |
Mauro Carvalho Chehab | 6bbf7a8 | 2017-09-19 14:22:19 -0400 | [diff] [blame] | 226 | enum dvb_device_type type, |
Mauro Carvalho Chehab | df2f94e | 2015-08-21 16:18:18 -0300 | [diff] [blame] | 227 | int demux_sink_pads); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 229 | /** |
Max Kellermann | 1f4ed6c | 2016-08-09 18:32:11 -0300 | [diff] [blame] | 230 | * dvb_remove_device - Remove a registered DVB device |
| 231 | * |
| 232 | * This does not free memory. To do that, call dvb_free_device(). |
| 233 | * |
| 234 | * @dvbdev: pointer to struct dvb_device |
| 235 | */ |
| 236 | void dvb_remove_device(struct dvb_device *dvbdev); |
| 237 | |
| 238 | /** |
| 239 | * dvb_free_device - Free memory occupied by a DVB device. |
| 240 | * |
| 241 | * Call dvb_unregister_device() before calling this function. |
| 242 | * |
| 243 | * @dvbdev: pointer to struct dvb_device |
| 244 | */ |
| 245 | void dvb_free_device(struct dvb_device *dvbdev); |
| 246 | |
| 247 | /** |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 248 | * dvb_unregister_device - Unregisters a DVB device |
| 249 | * |
Max Kellermann | 1f4ed6c | 2016-08-09 18:32:11 -0300 | [diff] [blame] | 250 | * This is a combination of dvb_remove_device() and dvb_free_device(). |
| 251 | * Using this function is usually a mistake, and is often an indicator |
| 252 | * for a use-after-free bug (when a userspace process keeps a file |
| 253 | * handle to a detached device). |
| 254 | * |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 255 | * @dvbdev: pointer to struct dvb_device |
| 256 | */ |
| 257 | void dvb_unregister_device(struct dvb_device *dvbdev); |
Mauro Carvalho Chehab | 480884b | 2015-03-02 10:49:04 -0300 | [diff] [blame] | 258 | |
| 259 | #ifdef CONFIG_MEDIA_CONTROLLER_DVB |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 260 | /** |
| 261 | * dvb_create_media_graph - Creates media graph for the Digital TV part of the |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 262 | * device. |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 263 | * |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 264 | * @adap: pointer to &struct dvb_adapter |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 265 | * @create_rf_connector: if true, it creates the RF connector too |
Mauro Carvalho Chehab | a0cce2a | 2015-12-30 10:11:53 -0200 | [diff] [blame] | 266 | * |
| 267 | * This function checks all DVB-related functions at the media controller |
| 268 | * entities and creates the needed links for the media graph. It is |
| 269 | * capable of working with multiple tuners or multiple frontends, but it |
| 270 | * won't create links if the device has multiple tuners and multiple frontends |
| 271 | * or if the device has multiple muxes. In such case, the caller driver should |
| 272 | * manually create the remaining links. |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 273 | */ |
| 274 | __must_check int dvb_create_media_graph(struct dvb_adapter *adap, |
| 275 | bool create_rf_connector); |
| 276 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 277 | /** |
| 278 | * dvb_register_media_controller - registers a media controller at DVB adapter |
| 279 | * |
| 280 | * @adap: pointer to &struct dvb_adapter |
| 281 | * @mdev: pointer to &struct media_device |
| 282 | */ |
Mauro Carvalho Chehab | 89a2c1d | 2015-03-02 11:26:14 -0300 | [diff] [blame] | 283 | static inline void dvb_register_media_controller(struct dvb_adapter *adap, |
| 284 | struct media_device *mdev) |
| 285 | { |
| 286 | adap->mdev = mdev; |
| 287 | } |
| 288 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 289 | /** |
| 290 | * dvb_get_media_controller - gets the associated media controller |
| 291 | * |
| 292 | * @adap: pointer to &struct dvb_adapter |
| 293 | */ |
Mauro Carvalho Chehab | ce084d4 | 2015-12-30 11:09:39 -0200 | [diff] [blame] | 294 | static inline struct media_device |
| 295 | *dvb_get_media_controller(struct dvb_adapter *adap) |
| 296 | { |
| 297 | return adap->mdev; |
| 298 | } |
Mauro Carvalho Chehab | 480884b | 2015-03-02 10:49:04 -0300 | [diff] [blame] | 299 | #else |
Mauro Carvalho Chehab | 0230d60 | 2015-12-29 11:52:23 -0200 | [diff] [blame] | 300 | static inline |
| 301 | int dvb_create_media_graph(struct dvb_adapter *adap, |
| 302 | bool create_rf_connector) |
Mauro Carvalho Chehab | f50d516 | 2015-09-04 15:10:29 -0300 | [diff] [blame] | 303 | { |
| 304 | return 0; |
| 305 | }; |
Mauro Carvalho Chehab | 89a2c1d | 2015-03-02 11:26:14 -0300 | [diff] [blame] | 306 | #define dvb_register_media_controller(a, b) {} |
Mauro Carvalho Chehab | ce084d4 | 2015-12-30 11:09:39 -0200 | [diff] [blame] | 307 | #define dvb_get_media_controller(a) NULL |
Mauro Carvalho Chehab | 480884b | 2015-03-02 10:49:04 -0300 | [diff] [blame] | 308 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 310 | /** |
| 311 | * dvb_generic_open - Digital TV open function, used by DVB devices |
| 312 | * |
| 313 | * @inode: pointer to &struct inode. |
| 314 | * @file: pointer to &struct file. |
| 315 | * |
| 316 | * Checks if a DVB devnode is still valid, and if the permissions are |
| 317 | * OK and increment negative use count. |
| 318 | */ |
| 319 | int dvb_generic_open(struct inode *inode, struct file *file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 321 | /** |
| 322 | * dvb_generic_close - Digital TV close function, used by DVB devices |
| 323 | * |
| 324 | * @inode: pointer to &struct inode. |
| 325 | * @file: pointer to &struct file. |
| 326 | * |
| 327 | * Checks if a DVB devnode is still valid, and if the permissions are |
| 328 | * OK and decrement negative use count. |
| 329 | */ |
| 330 | int dvb_generic_release(struct inode *inode, struct file *file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 332 | /** |
| 333 | * dvb_generic_ioctl - Digital TV close function, used by DVB devices |
| 334 | * |
| 335 | * @file: pointer to &struct file. |
| 336 | * @cmd: Ioctl name. |
| 337 | * @arg: Ioctl argument. |
| 338 | * |
| 339 | * Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid. |
| 340 | * If so, calls dvb_usercopy(). |
| 341 | */ |
| 342 | long dvb_generic_ioctl(struct file *file, |
| 343 | unsigned int cmd, unsigned long arg); |
| 344 | |
| 345 | /** |
| 346 | * dvb_usercopy - copies data from/to userspace memory when an ioctl is |
| 347 | * issued. |
| 348 | * |
| 349 | * @file: Pointer to struct &file. |
| 350 | * @cmd: Ioctl name. |
| 351 | * @arg: Ioctl argument. |
| 352 | * @func: function that will actually handle the ioctl |
| 353 | * |
| 354 | * Ancillary function that uses ioctl direction and size to copy from |
| 355 | * userspace. Then, it calls @func, and, if needed, data is copied back |
| 356 | * to userspace. |
| 357 | */ |
Mauro Carvalho Chehab | d071c833 | 2015-08-22 19:39:38 -0300 | [diff] [blame] | 358 | int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg, |
| 359 | int (*func)(struct file *file, unsigned int cmd, void *arg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Mauro Carvalho Chehab | 1980bfa | 2018-03-07 04:11:50 -0500 | [diff] [blame] | 361 | #if IS_ENABLED(CONFIG_I2C) |
Mauro Carvalho Chehab | 8f569c0 | 2018-03-02 10:21:16 -0500 | [diff] [blame] | 362 | |
| 363 | struct i2c_adapter; |
| 364 | struct i2c_client; |
| 365 | /** |
| 366 | * dvb_module_probe - helper routine to probe an I2C module |
| 367 | * |
| 368 | * @module_name: |
| 369 | * Name of the I2C module to be probed |
| 370 | * @name: |
| 371 | * Optional name for the I2C module. Used for debug purposes. |
| 372 | * If %NULL, defaults to @module_name. |
| 373 | * @adap: |
| 374 | * pointer to &struct i2c_adapter that describes the I2C adapter where |
| 375 | * the module will be bound. |
| 376 | * @addr: |
| 377 | * I2C address of the adapter, in 7-bit notation. |
| 378 | * @platform_data: |
| 379 | * Platform data to be passed to the I2C module probed. |
| 380 | * |
| 381 | * This function binds an I2C device into the DVB core. Should be used by |
| 382 | * all drivers that use I2C bus to control the hardware. A module bound |
| 383 | * with dvb_module_probe() should use dvb_module_release() to unbind. |
| 384 | * |
| 385 | * Return: |
| 386 | * On success, return an &struct i2c_client, pointing the the bound |
| 387 | * I2C device. %NULL otherwise. |
| 388 | * |
| 389 | * .. note:: |
| 390 | * |
| 391 | * In the past, DVB modules (mainly, frontends) were bound via dvb_attach() |
| 392 | * macro, with does an ugly hack, using I2C low level functions. Such |
| 393 | * usage is deprecated and will be removed soon. Instead, use this routine. |
| 394 | */ |
| 395 | struct i2c_client *dvb_module_probe(const char *module_name, |
| 396 | const char *name, |
| 397 | struct i2c_adapter *adap, |
| 398 | unsigned char addr, |
| 399 | void *platform_data); |
| 400 | |
| 401 | /** |
| 402 | * dvb_module_release - releases an I2C device allocated with |
| 403 | * dvb_module_probe(). |
| 404 | * |
| 405 | * @client: pointer to &struct i2c_client with the I2C client to be released. |
| 406 | * can be %NULL. |
| 407 | * |
| 408 | * This function should be used to free all resources reserved by |
| 409 | * dvb_module_probe() and unbinding the I2C hardware. |
| 410 | */ |
| 411 | void dvb_module_release(struct i2c_client *client); |
| 412 | |
| 413 | #endif /* CONFIG_I2C */ |
| 414 | |
| 415 | /* Legacy generic DVB attach function. */ |
Mauro Carvalho Chehab | 149ef72 | 2008-04-29 21:38:46 -0300 | [diff] [blame] | 416 | #ifdef CONFIG_MEDIA_ATTACH |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * dvb_attach - attaches a DVB frontend into the DVB core. |
| 420 | * |
| 421 | * @FUNCTION: function on a frontend module to be called. |
| 422 | * @ARGS...: @FUNCTION arguments. |
| 423 | * |
| 424 | * This ancillary function loads a frontend module in runtime and runs |
| 425 | * the @FUNCTION function there, with @ARGS. |
| 426 | * As it increments symbol usage cont, at unregister, dvb_detach() |
| 427 | * should be called. |
Mauro Carvalho Chehab | 8f569c0 | 2018-03-02 10:21:16 -0500 | [diff] [blame] | 428 | * |
| 429 | * .. note:: |
| 430 | * |
| 431 | * In the past, DVB modules (mainly, frontends) were bound via dvb_attach() |
| 432 | * macro, with does an ugly hack, using I2C low level functions. Such |
| 433 | * usage is deprecated and will be removed soon. Instead, you should use |
| 434 | * dvb_module_probe(). |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 435 | */ |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 436 | #define dvb_attach(FUNCTION, ARGS...) ({ \ |
| 437 | void *__r = NULL; \ |
| 438 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ |
| 439 | if (__a) { \ |
| 440 | __r = (void *) __a(ARGS); \ |
| 441 | if (__r == NULL) \ |
| 442 | symbol_put(FUNCTION); \ |
| 443 | } else { \ |
| 444 | printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \ |
| 445 | } \ |
| 446 | __r; \ |
| 447 | }) |
| 448 | |
Mauro Carvalho Chehab | 400efa8 | 2017-09-19 16:11:55 -0400 | [diff] [blame] | 449 | /** |
| 450 | * dvb_detach - detaches a DVB frontend loaded via dvb_attach() |
| 451 | * |
| 452 | * @FUNC: attach function |
| 453 | * |
| 454 | * Decrements usage count for a function previously called via dvb_attach(). |
| 455 | */ |
| 456 | |
Mauro Carvalho Chehab | 4647f48 | 2014-05-29 09:20:13 -0300 | [diff] [blame] | 457 | #define dvb_detach(FUNC) symbol_put_addr(FUNC) |
| 458 | |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 459 | #else |
| 460 | #define dvb_attach(FUNCTION, ARGS...) ({ \ |
| 461 | FUNCTION(ARGS); \ |
| 462 | }) |
| 463 | |
Mauro Carvalho Chehab | 4647f48 | 2014-05-29 09:20:13 -0300 | [diff] [blame] | 464 | #define dvb_detach(FUNC) {} |
| 465 | |
Mauro Carvalho Chehab | 8f569c0 | 2018-03-02 10:21:16 -0500 | [diff] [blame] | 466 | #endif /* CONFIG_MEDIA_ATTACH */ |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 467 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | #endif /* #ifndef _DVBDEV_H_ */ |