1fada1935SMauro Carvalho Chehab /*
2fada1935SMauro Carvalho Chehab * dvbdev.h
3fada1935SMauro Carvalho Chehab *
4fada1935SMauro Carvalho Chehab * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
5fada1935SMauro Carvalho Chehab * for convergence integrated media GmbH
6fada1935SMauro Carvalho Chehab *
7fada1935SMauro Carvalho Chehab * This program is free software; you can redistribute it and/or
8fada1935SMauro Carvalho Chehab * modify it under the terms of the GNU General Lesser Public License
9fada1935SMauro Carvalho Chehab * as published by the Free Software Foundation; either version 2.1
10fada1935SMauro Carvalho Chehab * of the License, or (at your option) any later version.
11fada1935SMauro Carvalho Chehab *
12fada1935SMauro Carvalho Chehab * This program is distributed in the hope that it will be useful,
13fada1935SMauro Carvalho Chehab * but WITHOUT ANY WARRANTY; without even the implied warranty of
14fada1935SMauro Carvalho Chehab * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15fada1935SMauro Carvalho Chehab * GNU General Public License for more details.
16fada1935SMauro Carvalho Chehab *
17fada1935SMauro Carvalho Chehab */
18fada1935SMauro Carvalho Chehab
19fada1935SMauro Carvalho Chehab #ifndef _DVBDEV_H_
20fada1935SMauro Carvalho Chehab #define _DVBDEV_H_
21fada1935SMauro Carvalho Chehab
22fada1935SMauro Carvalho Chehab #include <linux/types.h>
23fada1935SMauro Carvalho Chehab #include <linux/poll.h>
24fada1935SMauro Carvalho Chehab #include <linux/fs.h>
25fada1935SMauro Carvalho Chehab #include <linux/list.h>
26fada1935SMauro Carvalho Chehab #include <media/media-device.h>
27fada1935SMauro Carvalho Chehab
28fada1935SMauro Carvalho Chehab #define DVB_MAJOR 212
29fada1935SMauro Carvalho Chehab
30fada1935SMauro Carvalho Chehab #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
31fada1935SMauro Carvalho Chehab #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
32fada1935SMauro Carvalho Chehab #else
33fada1935SMauro Carvalho Chehab #define DVB_MAX_ADAPTERS 16
34fada1935SMauro Carvalho Chehab #endif
35fada1935SMauro Carvalho Chehab
36fada1935SMauro Carvalho Chehab #define DVB_UNSET (-1)
37fada1935SMauro Carvalho Chehab
38fada1935SMauro Carvalho Chehab /* List of DVB device types */
39fada1935SMauro Carvalho Chehab
40fada1935SMauro Carvalho Chehab /**
41fada1935SMauro Carvalho Chehab * enum dvb_device_type - type of the Digital TV device
42fada1935SMauro Carvalho Chehab *
43fada1935SMauro Carvalho Chehab * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI)
44fada1935SMauro Carvalho Chehab * @DVB_DEVICE_FRONTEND: Digital TV frontend.
45fada1935SMauro Carvalho Chehab * @DVB_DEVICE_DEMUX: Digital TV demux.
46fada1935SMauro Carvalho Chehab * @DVB_DEVICE_DVR: Digital TV digital video record (DVR).
47fada1935SMauro Carvalho Chehab * @DVB_DEVICE_CA: Digital TV Conditional Access (CA).
48fada1935SMauro Carvalho Chehab * @DVB_DEVICE_NET: Digital TV network.
49fada1935SMauro Carvalho Chehab *
50fada1935SMauro Carvalho Chehab * @DVB_DEVICE_VIDEO: Digital TV video decoder.
51fada1935SMauro Carvalho Chehab * Deprecated. Used only on av7110-av.
52fada1935SMauro Carvalho Chehab * @DVB_DEVICE_AUDIO: Digital TV audio decoder.
53fada1935SMauro Carvalho Chehab * Deprecated. Used only on av7110-av.
54fada1935SMauro Carvalho Chehab * @DVB_DEVICE_OSD: Digital TV On Screen Display (OSD).
55fada1935SMauro Carvalho Chehab * Deprecated. Used only on av7110.
56fada1935SMauro Carvalho Chehab */
57fada1935SMauro Carvalho Chehab enum dvb_device_type {
58fada1935SMauro Carvalho Chehab DVB_DEVICE_SEC,
59fada1935SMauro Carvalho Chehab DVB_DEVICE_FRONTEND,
60fada1935SMauro Carvalho Chehab DVB_DEVICE_DEMUX,
61fada1935SMauro Carvalho Chehab DVB_DEVICE_DVR,
62fada1935SMauro Carvalho Chehab DVB_DEVICE_CA,
63fada1935SMauro Carvalho Chehab DVB_DEVICE_NET,
64fada1935SMauro Carvalho Chehab
65fada1935SMauro Carvalho Chehab DVB_DEVICE_VIDEO,
66fada1935SMauro Carvalho Chehab DVB_DEVICE_AUDIO,
67fada1935SMauro Carvalho Chehab DVB_DEVICE_OSD,
68fada1935SMauro Carvalho Chehab };
69fada1935SMauro Carvalho Chehab
70fada1935SMauro Carvalho Chehab #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
71fada1935SMauro Carvalho Chehab static short adapter_nr[] = \
72fada1935SMauro Carvalho Chehab {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
73fada1935SMauro Carvalho Chehab module_param_array(adapter_nr, short, NULL, 0444); \
74fada1935SMauro Carvalho Chehab MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
75fada1935SMauro Carvalho Chehab
76fada1935SMauro Carvalho Chehab struct dvb_frontend;
77fada1935SMauro Carvalho Chehab
78fada1935SMauro Carvalho Chehab /**
79fada1935SMauro Carvalho Chehab * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API
80fada1935SMauro Carvalho Chehab *
81fada1935SMauro Carvalho Chehab * @num: Number of the adapter
82fada1935SMauro Carvalho Chehab * @list_head: List with the DVB adapters
83fada1935SMauro Carvalho Chehab * @device_list: List with the DVB devices
84fada1935SMauro Carvalho Chehab * @name: Name of the adapter
85fada1935SMauro Carvalho Chehab * @proposed_mac: proposed MAC address for the adapter
86fada1935SMauro Carvalho Chehab * @priv: private data
87fada1935SMauro Carvalho Chehab * @device: pointer to struct device
88fada1935SMauro Carvalho Chehab * @module: pointer to struct module
89e96a8819SMarc Gonzalez * @mfe_shared: indicates mutually exclusive frontends.
90e704b44bSRobert Schlabbach * 1 = legacy exclusion behavior: blocking any open() call
91e704b44bSRobert Schlabbach * 2 = enhanced exclusion behavior, emulating the standard
92e704b44bSRobert Schlabbach * behavior of busy frontends: allowing read-only sharing
93e704b44bSRobert Schlabbach * and otherwise returning immediately with -EBUSY when any
94e704b44bSRobert Schlabbach * of the frontends is already opened with write access.
95fada1935SMauro Carvalho Chehab * @mfe_dvbdev: Frontend device in use, in the case of MFE
96fada1935SMauro Carvalho Chehab * @mfe_lock: Lock to prevent using the other frontends when MFE is
97fada1935SMauro Carvalho Chehab * used.
98f17c403aSMax Kellermann * @mdev_lock: Protect access to the mdev pointer.
99fada1935SMauro Carvalho Chehab * @mdev: pointer to struct media_device, used when the media
100fada1935SMauro Carvalho Chehab * controller is used.
101fada1935SMauro Carvalho Chehab * @conn: RF connector. Used only if the device has no separate
102fada1935SMauro Carvalho Chehab * tuner.
103fada1935SMauro Carvalho Chehab * @conn_pads: pointer to struct media_pad associated with @conn;
104fada1935SMauro Carvalho Chehab */
105fada1935SMauro Carvalho Chehab struct dvb_adapter {
106fada1935SMauro Carvalho Chehab int num;
107fada1935SMauro Carvalho Chehab struct list_head list_head;
108fada1935SMauro Carvalho Chehab struct list_head device_list;
109fada1935SMauro Carvalho Chehab const char *name;
110fada1935SMauro Carvalho Chehab u8 proposed_mac [6];
111fada1935SMauro Carvalho Chehab void* priv;
112fada1935SMauro Carvalho Chehab
113fada1935SMauro Carvalho Chehab struct device *device;
114fada1935SMauro Carvalho Chehab
115fada1935SMauro Carvalho Chehab struct module *module;
116fada1935SMauro Carvalho Chehab
117fada1935SMauro Carvalho Chehab int mfe_shared; /* indicates mutually exclusive frontends */
118fada1935SMauro Carvalho Chehab struct dvb_device *mfe_dvbdev; /* frontend device in use */
119fada1935SMauro Carvalho Chehab struct mutex mfe_lock; /* access lock for thread creation */
120fada1935SMauro Carvalho Chehab
121fada1935SMauro Carvalho Chehab #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
122f17c403aSMax Kellermann struct mutex mdev_lock;
123fada1935SMauro Carvalho Chehab struct media_device *mdev;
124fada1935SMauro Carvalho Chehab struct media_entity *conn;
125fada1935SMauro Carvalho Chehab struct media_pad *conn_pads;
126fada1935SMauro Carvalho Chehab #endif
127fada1935SMauro Carvalho Chehab };
128fada1935SMauro Carvalho Chehab
129fada1935SMauro Carvalho Chehab /**
130fada1935SMauro Carvalho Chehab * struct dvb_device - represents a DVB device node
131fada1935SMauro Carvalho Chehab *
132fada1935SMauro Carvalho Chehab * @list_head: List head with all DVB devices
1333edfd14bSLin Ma * @ref: reference count for this device
134fada1935SMauro Carvalho Chehab * @fops: pointer to struct file_operations
135fada1935SMauro Carvalho Chehab * @adapter: pointer to the adapter that holds this device node
136fada1935SMauro Carvalho Chehab * @type: type of the device, as defined by &enum dvb_device_type.
137fada1935SMauro Carvalho Chehab * @minor: devnode minor number. Major number is always DVB_MAJOR.
138fada1935SMauro Carvalho Chehab * @id: device ID number, inside the adapter
139fada1935SMauro Carvalho Chehab * @readers: Initialized by the caller. Each call to open() in Read Only mode
140fada1935SMauro Carvalho Chehab * decreases this counter by one.
141fada1935SMauro Carvalho Chehab * @writers: Initialized by the caller. Each call to open() in Read/Write
142fada1935SMauro Carvalho Chehab * mode decreases this counter by one.
143fada1935SMauro Carvalho Chehab * @users: Initialized by the caller. Each call to open() in any mode
144fada1935SMauro Carvalho Chehab * decreases this counter by one.
145fada1935SMauro Carvalho Chehab * @wait_queue: wait queue, used to wait for certain events inside one of
146fada1935SMauro Carvalho Chehab * the DVB API callers
147fada1935SMauro Carvalho Chehab * @kernel_ioctl: callback function used to handle ioctl calls from userspace.
148fada1935SMauro Carvalho Chehab * @name: Name to be used for the device at the Media Controller
149fada1935SMauro Carvalho Chehab * @entity: pointer to struct media_entity associated with the device node
150fada1935SMauro Carvalho Chehab * @pads: pointer to struct media_pad associated with @entity;
151fada1935SMauro Carvalho Chehab * @priv: private data
152fada1935SMauro Carvalho Chehab * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to
153fada1935SMauro Carvalho Chehab * store the MC device node interface
154fada1935SMauro Carvalho Chehab * @tsout_num_entities: Number of Transport Stream output entities
155fada1935SMauro Carvalho Chehab * @tsout_entity: array with MC entities associated to each TS output node
156fada1935SMauro Carvalho Chehab * @tsout_pads: array with the source pads for each @tsout_entity
157fada1935SMauro Carvalho Chehab *
158fada1935SMauro Carvalho Chehab * This structure is used by the DVB core (frontend, CA, net, demux) in
159fada1935SMauro Carvalho Chehab * order to create the device nodes. Usually, driver should not initialize
160fada1935SMauro Carvalho Chehab * this struct diretly.
161fada1935SMauro Carvalho Chehab */
162fada1935SMauro Carvalho Chehab struct dvb_device {
163fada1935SMauro Carvalho Chehab struct list_head list_head;
1640fc044b2SLin Ma struct kref ref;
165fada1935SMauro Carvalho Chehab const struct file_operations *fops;
166fada1935SMauro Carvalho Chehab struct dvb_adapter *adapter;
167fada1935SMauro Carvalho Chehab enum dvb_device_type type;
168fada1935SMauro Carvalho Chehab int minor;
169fada1935SMauro Carvalho Chehab u32 id;
170fada1935SMauro Carvalho Chehab
171fada1935SMauro Carvalho Chehab /* in theory, 'users' can vanish now,
172fada1935SMauro Carvalho Chehab but I don't want to change too much now... */
173fada1935SMauro Carvalho Chehab int readers;
174fada1935SMauro Carvalho Chehab int writers;
175fada1935SMauro Carvalho Chehab int users;
176fada1935SMauro Carvalho Chehab
177fada1935SMauro Carvalho Chehab wait_queue_head_t wait_queue;
178fada1935SMauro Carvalho Chehab /* don't really need those !? -- FIXME: use video_usercopy */
179fada1935SMauro Carvalho Chehab int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
180fada1935SMauro Carvalho Chehab
181fada1935SMauro Carvalho Chehab /* Needed for media controller register/unregister */
182fada1935SMauro Carvalho Chehab #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
183fada1935SMauro Carvalho Chehab const char *name;
184fada1935SMauro Carvalho Chehab
185fada1935SMauro Carvalho Chehab /* Allocated and filled inside dvbdev.c */
186fada1935SMauro Carvalho Chehab struct media_intf_devnode *intf_devnode;
187fada1935SMauro Carvalho Chehab
188fada1935SMauro Carvalho Chehab unsigned tsout_num_entities;
189fada1935SMauro Carvalho Chehab struct media_entity *entity, *tsout_entity;
190fada1935SMauro Carvalho Chehab struct media_pad *pads, *tsout_pads;
191fada1935SMauro Carvalho Chehab #endif
192fada1935SMauro Carvalho Chehab
193fada1935SMauro Carvalho Chehab void *priv;
194fada1935SMauro Carvalho Chehab };
195fada1935SMauro Carvalho Chehab
196fada1935SMauro Carvalho Chehab /**
197*627bb528SHyunwoo Kim * struct dvbdevfops_node - fops nodes registered in dvbdevfops_list
198*627bb528SHyunwoo Kim *
199*627bb528SHyunwoo Kim * @fops: Dynamically allocated fops for ->owner registration
200*627bb528SHyunwoo Kim * @type: type of dvb_device
201*627bb528SHyunwoo Kim * @template: dvb_device used for registration
202*627bb528SHyunwoo Kim * @list_head: list_head for dvbdevfops_list
203*627bb528SHyunwoo Kim */
204*627bb528SHyunwoo Kim struct dvbdevfops_node {
205*627bb528SHyunwoo Kim struct file_operations *fops;
206*627bb528SHyunwoo Kim enum dvb_device_type type;
207*627bb528SHyunwoo Kim const struct dvb_device *template;
208*627bb528SHyunwoo Kim struct list_head list_head;
209*627bb528SHyunwoo Kim };
210*627bb528SHyunwoo Kim
211*627bb528SHyunwoo Kim /**
2120fc044b2SLin Ma * dvb_device_get - Increase dvb_device reference
2130fc044b2SLin Ma *
2140fc044b2SLin Ma * @dvbdev: pointer to struct dvb_device
2150fc044b2SLin Ma */
2160fc044b2SLin Ma struct dvb_device *dvb_device_get(struct dvb_device *dvbdev);
2170fc044b2SLin Ma
2180fc044b2SLin Ma /**
2193edfd14bSLin Ma * dvb_device_put - Decrease dvb_device reference
2200fc044b2SLin Ma *
2210fc044b2SLin Ma * @dvbdev: pointer to struct dvb_device
2220fc044b2SLin Ma */
2230fc044b2SLin Ma void dvb_device_put(struct dvb_device *dvbdev);
2240fc044b2SLin Ma
2250fc044b2SLin Ma /**
226fada1935SMauro Carvalho Chehab * dvb_register_adapter - Registers a new DVB adapter
227fada1935SMauro Carvalho Chehab *
228fada1935SMauro Carvalho Chehab * @adap: pointer to struct dvb_adapter
229fada1935SMauro Carvalho Chehab * @name: Adapter's name
230fada1935SMauro Carvalho Chehab * @module: initialized with THIS_MODULE at the caller
231fada1935SMauro Carvalho Chehab * @device: pointer to struct device that corresponds to the device driver
232fada1935SMauro Carvalho Chehab * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter;
233fada1935SMauro Carvalho Chehab * to select among them. Typically, initialized with:
234fada1935SMauro Carvalho Chehab * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums)
235fada1935SMauro Carvalho Chehab */
236fada1935SMauro Carvalho Chehab int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
237fada1935SMauro Carvalho Chehab struct module *module, struct device *device,
238fada1935SMauro Carvalho Chehab short *adapter_nums);
239fada1935SMauro Carvalho Chehab
240fada1935SMauro Carvalho Chehab /**
241fada1935SMauro Carvalho Chehab * dvb_unregister_adapter - Unregisters a DVB adapter
242fada1935SMauro Carvalho Chehab *
243fada1935SMauro Carvalho Chehab * @adap: pointer to struct dvb_adapter
244fada1935SMauro Carvalho Chehab */
245fada1935SMauro Carvalho Chehab int dvb_unregister_adapter(struct dvb_adapter *adap);
246fada1935SMauro Carvalho Chehab
247fada1935SMauro Carvalho Chehab /**
248fada1935SMauro Carvalho Chehab * dvb_register_device - Registers a new DVB device
249fada1935SMauro Carvalho Chehab *
250fada1935SMauro Carvalho Chehab * @adap: pointer to struct dvb_adapter
251fada1935SMauro Carvalho Chehab * @pdvbdev: pointer to the place where the new struct dvb_device will be
252fada1935SMauro Carvalho Chehab * stored
253fada1935SMauro Carvalho Chehab * @template: Template used to create &pdvbdev;
254fada1935SMauro Carvalho Chehab * @priv: private data
255fada1935SMauro Carvalho Chehab * @type: type of the device, as defined by &enum dvb_device_type.
256fada1935SMauro Carvalho Chehab * @demux_sink_pads: Number of demux outputs, to be used to create the TS
257fada1935SMauro Carvalho Chehab * outputs via the Media Controller.
258fada1935SMauro Carvalho Chehab */
259fada1935SMauro Carvalho Chehab int dvb_register_device(struct dvb_adapter *adap,
260fada1935SMauro Carvalho Chehab struct dvb_device **pdvbdev,
261fada1935SMauro Carvalho Chehab const struct dvb_device *template,
262fada1935SMauro Carvalho Chehab void *priv,
263fada1935SMauro Carvalho Chehab enum dvb_device_type type,
264fada1935SMauro Carvalho Chehab int demux_sink_pads);
265fada1935SMauro Carvalho Chehab
266fada1935SMauro Carvalho Chehab /**
267fada1935SMauro Carvalho Chehab * dvb_remove_device - Remove a registered DVB device
268fada1935SMauro Carvalho Chehab *
2690fc044b2SLin Ma * @dvbdev: pointer to struct dvb_device
2700fc044b2SLin Ma *
271fada1935SMauro Carvalho Chehab * This does not free memory. dvb_free_device() will do that when
272fada1935SMauro Carvalho Chehab * reference counter is empty
273fada1935SMauro Carvalho Chehab */
274fada1935SMauro Carvalho Chehab void dvb_remove_device(struct dvb_device *dvbdev);
275fada1935SMauro Carvalho Chehab
276fada1935SMauro Carvalho Chehab
277fada1935SMauro Carvalho Chehab /**
278fada1935SMauro Carvalho Chehab * dvb_unregister_device - Unregisters a DVB device
279fada1935SMauro Carvalho Chehab *
280fada1935SMauro Carvalho Chehab * @dvbdev: pointer to struct dvb_device
281fada1935SMauro Carvalho Chehab */
282fada1935SMauro Carvalho Chehab void dvb_unregister_device(struct dvb_device *dvbdev);
283fada1935SMauro Carvalho Chehab
284fada1935SMauro Carvalho Chehab #ifdef CONFIG_MEDIA_CONTROLLER_DVB
285fada1935SMauro Carvalho Chehab /**
286fada1935SMauro Carvalho Chehab * dvb_create_media_graph - Creates media graph for the Digital TV part of the
287fada1935SMauro Carvalho Chehab * device.
288fada1935SMauro Carvalho Chehab *
289fada1935SMauro Carvalho Chehab * @adap: pointer to &struct dvb_adapter
290fada1935SMauro Carvalho Chehab * @create_rf_connector: if true, it creates the RF connector too
291fada1935SMauro Carvalho Chehab *
292fada1935SMauro Carvalho Chehab * This function checks all DVB-related functions at the media controller
293fada1935SMauro Carvalho Chehab * entities and creates the needed links for the media graph. It is
294fada1935SMauro Carvalho Chehab * capable of working with multiple tuners or multiple frontends, but it
295fada1935SMauro Carvalho Chehab * won't create links if the device has multiple tuners and multiple frontends
296fada1935SMauro Carvalho Chehab * or if the device has multiple muxes. In such case, the caller driver should
297fada1935SMauro Carvalho Chehab * manually create the remaining links.
298fada1935SMauro Carvalho Chehab */
299fada1935SMauro Carvalho Chehab __must_check int dvb_create_media_graph(struct dvb_adapter *adap,
300fada1935SMauro Carvalho Chehab bool create_rf_connector);
301fada1935SMauro Carvalho Chehab
302fada1935SMauro Carvalho Chehab /**
303fada1935SMauro Carvalho Chehab * dvb_register_media_controller - registers a media controller at DVB adapter
304fada1935SMauro Carvalho Chehab *
305fada1935SMauro Carvalho Chehab * @adap: pointer to &struct dvb_adapter
306fada1935SMauro Carvalho Chehab * @mdev: pointer to &struct media_device
307fada1935SMauro Carvalho Chehab */
dvb_register_media_controller(struct dvb_adapter * adap,struct media_device * mdev)308fada1935SMauro Carvalho Chehab static inline void dvb_register_media_controller(struct dvb_adapter *adap,
309fada1935SMauro Carvalho Chehab struct media_device *mdev)
310fada1935SMauro Carvalho Chehab {
311fada1935SMauro Carvalho Chehab adap->mdev = mdev;
312fada1935SMauro Carvalho Chehab }
313fada1935SMauro Carvalho Chehab
314fada1935SMauro Carvalho Chehab /**
315fada1935SMauro Carvalho Chehab * dvb_get_media_controller - gets the associated media controller
316fada1935SMauro Carvalho Chehab *
317fada1935SMauro Carvalho Chehab * @adap: pointer to &struct dvb_adapter
318fada1935SMauro Carvalho Chehab */
3198f2a4a9dSHans Verkuil static inline struct media_device *
dvb_get_media_controller(struct dvb_adapter * adap)3208f2a4a9dSHans Verkuil dvb_get_media_controller(struct dvb_adapter *adap)
321fada1935SMauro Carvalho Chehab {
322fada1935SMauro Carvalho Chehab return adap->mdev;
323fada1935SMauro Carvalho Chehab }
324fada1935SMauro Carvalho Chehab #else
325fada1935SMauro Carvalho Chehab static inline
dvb_create_media_graph(struct dvb_adapter * adap,bool create_rf_connector)326fada1935SMauro Carvalho Chehab int dvb_create_media_graph(struct dvb_adapter *adap,
327fada1935SMauro Carvalho Chehab bool create_rf_connector)
328fada1935SMauro Carvalho Chehab {
329fada1935SMauro Carvalho Chehab return 0;
330fada1935SMauro Carvalho Chehab };
331fada1935SMauro Carvalho Chehab #define dvb_register_media_controller(a, b) {}
332fada1935SMauro Carvalho Chehab #define dvb_get_media_controller(a) NULL
333fada1935SMauro Carvalho Chehab #endif
334fada1935SMauro Carvalho Chehab
335fada1935SMauro Carvalho Chehab /**
336fada1935SMauro Carvalho Chehab * dvb_generic_open - Digital TV open function, used by DVB devices
337fada1935SMauro Carvalho Chehab *
338fada1935SMauro Carvalho Chehab * @inode: pointer to &struct inode.
339fada1935SMauro Carvalho Chehab * @file: pointer to &struct file.
340fada1935SMauro Carvalho Chehab *
341fada1935SMauro Carvalho Chehab * Checks if a DVB devnode is still valid, and if the permissions are
342fada1935SMauro Carvalho Chehab * OK and increment negative use count.
343fada1935SMauro Carvalho Chehab */
344fada1935SMauro Carvalho Chehab int dvb_generic_open(struct inode *inode, struct file *file);
345fada1935SMauro Carvalho Chehab
346fada1935SMauro Carvalho Chehab /**
347b0649455SMauro Carvalho Chehab * dvb_generic_release - Digital TV close function, used by DVB devices
348fada1935SMauro Carvalho Chehab *
349fada1935SMauro Carvalho Chehab * @inode: pointer to &struct inode.
350fada1935SMauro Carvalho Chehab * @file: pointer to &struct file.
351fada1935SMauro Carvalho Chehab *
352fada1935SMauro Carvalho Chehab * Checks if a DVB devnode is still valid, and if the permissions are
353fada1935SMauro Carvalho Chehab * OK and decrement negative use count.
354fada1935SMauro Carvalho Chehab */
355fada1935SMauro Carvalho Chehab int dvb_generic_release(struct inode *inode, struct file *file);
356fada1935SMauro Carvalho Chehab
357fada1935SMauro Carvalho Chehab /**
358fada1935SMauro Carvalho Chehab * dvb_generic_ioctl - Digital TV close function, used by DVB devices
359fada1935SMauro Carvalho Chehab *
360fada1935SMauro Carvalho Chehab * @file: pointer to &struct file.
361fada1935SMauro Carvalho Chehab * @cmd: Ioctl name.
362fada1935SMauro Carvalho Chehab * @arg: Ioctl argument.
363fada1935SMauro Carvalho Chehab *
364fada1935SMauro Carvalho Chehab * Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid.
365fada1935SMauro Carvalho Chehab * If so, calls dvb_usercopy().
366fada1935SMauro Carvalho Chehab */
367fada1935SMauro Carvalho Chehab long dvb_generic_ioctl(struct file *file,
368fada1935SMauro Carvalho Chehab unsigned int cmd, unsigned long arg);
369fada1935SMauro Carvalho Chehab
370fada1935SMauro Carvalho Chehab /**
371fada1935SMauro Carvalho Chehab * dvb_usercopy - copies data from/to userspace memory when an ioctl is
372fada1935SMauro Carvalho Chehab * issued.
373fada1935SMauro Carvalho Chehab *
374fada1935SMauro Carvalho Chehab * @file: Pointer to struct &file.
375fada1935SMauro Carvalho Chehab * @cmd: Ioctl name.
376fada1935SMauro Carvalho Chehab * @arg: Ioctl argument.
377fada1935SMauro Carvalho Chehab * @func: function that will actually handle the ioctl
378fada1935SMauro Carvalho Chehab *
379fada1935SMauro Carvalho Chehab * Ancillary function that uses ioctl direction and size to copy from
380fada1935SMauro Carvalho Chehab * userspace. Then, it calls @func, and, if needed, data is copied back
381fada1935SMauro Carvalho Chehab * to userspace.
382fada1935SMauro Carvalho Chehab */
383fada1935SMauro Carvalho Chehab int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
384fada1935SMauro Carvalho Chehab int (*func)(struct file *file, unsigned int cmd, void *arg));
385fada1935SMauro Carvalho Chehab
3861980bfa6SMauro Carvalho Chehab #if IS_ENABLED(CONFIG_I2C)
3878f569c0bSMauro Carvalho Chehab
3888f569c0bSMauro Carvalho Chehab struct i2c_adapter;
3898f569c0bSMauro Carvalho Chehab struct i2c_client;
3908f569c0bSMauro Carvalho Chehab /**
3918f569c0bSMauro Carvalho Chehab * dvb_module_probe - helper routine to probe an I2C module
3928f569c0bSMauro Carvalho Chehab *
3938f569c0bSMauro Carvalho Chehab * @module_name:
3948f569c0bSMauro Carvalho Chehab * Name of the I2C module to be probed
3958f569c0bSMauro Carvalho Chehab * @name:
3968f569c0bSMauro Carvalho Chehab * Optional name for the I2C module. Used for debug purposes.
3978f569c0bSMauro Carvalho Chehab * If %NULL, defaults to @module_name.
3988f569c0bSMauro Carvalho Chehab * @adap:
3998f569c0bSMauro Carvalho Chehab * pointer to &struct i2c_adapter that describes the I2C adapter where
4008f569c0bSMauro Carvalho Chehab * the module will be bound.
4018f569c0bSMauro Carvalho Chehab * @addr:
4028f569c0bSMauro Carvalho Chehab * I2C address of the adapter, in 7-bit notation.
4038f569c0bSMauro Carvalho Chehab * @platform_data:
4048f569c0bSMauro Carvalho Chehab * Platform data to be passed to the I2C module probed.
4058f569c0bSMauro Carvalho Chehab *
4068f569c0bSMauro Carvalho Chehab * This function binds an I2C device into the DVB core. Should be used by
4078f569c0bSMauro Carvalho Chehab * all drivers that use I2C bus to control the hardware. A module bound
4088f569c0bSMauro Carvalho Chehab * with dvb_module_probe() should use dvb_module_release() to unbind.
4098f569c0bSMauro Carvalho Chehab *
4108f569c0bSMauro Carvalho Chehab * Return:
411ffb18971SRandy Dunlap * On success, return an &struct i2c_client, pointing to the bound
4128f569c0bSMauro Carvalho Chehab * I2C device. %NULL otherwise.
4138f569c0bSMauro Carvalho Chehab *
4148f569c0bSMauro Carvalho Chehab * .. note::
4158f569c0bSMauro Carvalho Chehab *
4168f569c0bSMauro Carvalho Chehab * In the past, DVB modules (mainly, frontends) were bound via dvb_attach()
4178f569c0bSMauro Carvalho Chehab * macro, with does an ugly hack, using I2C low level functions. Such
4188f569c0bSMauro Carvalho Chehab * usage is deprecated and will be removed soon. Instead, use this routine.
4198f569c0bSMauro Carvalho Chehab */
4208f569c0bSMauro Carvalho Chehab struct i2c_client *dvb_module_probe(const char *module_name,
4218f569c0bSMauro Carvalho Chehab const char *name,
4228f569c0bSMauro Carvalho Chehab struct i2c_adapter *adap,
4238f569c0bSMauro Carvalho Chehab unsigned char addr,
4248f569c0bSMauro Carvalho Chehab void *platform_data);
4258f569c0bSMauro Carvalho Chehab
4268f569c0bSMauro Carvalho Chehab /**
4278f569c0bSMauro Carvalho Chehab * dvb_module_release - releases an I2C device allocated with
4288f569c0bSMauro Carvalho Chehab * dvb_module_probe().
4298f569c0bSMauro Carvalho Chehab *
4308f569c0bSMauro Carvalho Chehab * @client: pointer to &struct i2c_client with the I2C client to be released.
4318f569c0bSMauro Carvalho Chehab * can be %NULL.
4328f569c0bSMauro Carvalho Chehab *
4338f569c0bSMauro Carvalho Chehab * This function should be used to free all resources reserved by
4348f569c0bSMauro Carvalho Chehab * dvb_module_probe() and unbinding the I2C hardware.
4358f569c0bSMauro Carvalho Chehab */
4368f569c0bSMauro Carvalho Chehab void dvb_module_release(struct i2c_client *client);
4378f569c0bSMauro Carvalho Chehab
4388f569c0bSMauro Carvalho Chehab #endif /* CONFIG_I2C */
4398f569c0bSMauro Carvalho Chehab
4408f569c0bSMauro Carvalho Chehab /* Legacy generic DVB attach function. */
441fada1935SMauro Carvalho Chehab #ifdef CONFIG_MEDIA_ATTACH
442fada1935SMauro Carvalho Chehab
443fada1935SMauro Carvalho Chehab /**
444fada1935SMauro Carvalho Chehab * dvb_attach - attaches a DVB frontend into the DVB core.
445fada1935SMauro Carvalho Chehab *
446fada1935SMauro Carvalho Chehab * @FUNCTION: function on a frontend module to be called.
4476f097ddbSJonathan Neuschäfer * @ARGS: @FUNCTION arguments.
448fada1935SMauro Carvalho Chehab *
449fada1935SMauro Carvalho Chehab * This ancillary function loads a frontend module in runtime and runs
450fada1935SMauro Carvalho Chehab * the @FUNCTION function there, with @ARGS.
451fada1935SMauro Carvalho Chehab * As it increments symbol usage cont, at unregister, dvb_detach()
452fada1935SMauro Carvalho Chehab * should be called.
4538f569c0bSMauro Carvalho Chehab *
4548f569c0bSMauro Carvalho Chehab * .. note::
4558f569c0bSMauro Carvalho Chehab *
4568f569c0bSMauro Carvalho Chehab * In the past, DVB modules (mainly, frontends) were bound via dvb_attach()
4578f569c0bSMauro Carvalho Chehab * macro, with does an ugly hack, using I2C low level functions. Such
4588f569c0bSMauro Carvalho Chehab * usage is deprecated and will be removed soon. Instead, you should use
4598f569c0bSMauro Carvalho Chehab * dvb_module_probe().
460fada1935SMauro Carvalho Chehab */
461fada1935SMauro Carvalho Chehab #define dvb_attach(FUNCTION, ARGS...) ({ \
462fada1935SMauro Carvalho Chehab void *__r = NULL; \
463fada1935SMauro Carvalho Chehab typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
464fada1935SMauro Carvalho Chehab if (__a) { \
465fada1935SMauro Carvalho Chehab __r = (void *) __a(ARGS); \
466fada1935SMauro Carvalho Chehab if (__r == NULL) \
467fada1935SMauro Carvalho Chehab symbol_put(FUNCTION); \
468fada1935SMauro Carvalho Chehab } else { \
469fada1935SMauro Carvalho Chehab printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
470fada1935SMauro Carvalho Chehab } \
471fada1935SMauro Carvalho Chehab __r; \
472fada1935SMauro Carvalho Chehab })
473fada1935SMauro Carvalho Chehab
474fada1935SMauro Carvalho Chehab /**
475fada1935SMauro Carvalho Chehab * dvb_detach - detaches a DVB frontend loaded via dvb_attach()
476fada1935SMauro Carvalho Chehab *
477fada1935SMauro Carvalho Chehab * @FUNC: attach function
478fada1935SMauro Carvalho Chehab *
479fada1935SMauro Carvalho Chehab * Decrements usage count for a function previously called via dvb_attach().
480fada1935SMauro Carvalho Chehab */
481fada1935SMauro Carvalho Chehab
482fada1935SMauro Carvalho Chehab #define dvb_detach(FUNC) symbol_put_addr(FUNC)
483fada1935SMauro Carvalho Chehab
484fada1935SMauro Carvalho Chehab #else
485fada1935SMauro Carvalho Chehab #define dvb_attach(FUNCTION, ARGS...) ({ \
486fada1935SMauro Carvalho Chehab FUNCTION(ARGS); \
487fada1935SMauro Carvalho Chehab })
488fada1935SMauro Carvalho Chehab
489fada1935SMauro Carvalho Chehab #define dvb_detach(FUNC) {}
490fada1935SMauro Carvalho Chehab
4918f569c0bSMauro Carvalho Chehab #endif /* CONFIG_MEDIA_ATTACH */
492fada1935SMauro Carvalho Chehab
493fada1935SMauro Carvalho Chehab #endif /* #ifndef _DVBDEV_H_ */
494