18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * dvbdev.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2000 Ralph Metzler & Marcus Metzler 58c2ecf20Sopenharmony_ci * for convergence integrated media GmbH 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 88c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Lesser Public License 98c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 2.1 108c2ecf20Sopenharmony_ci * of the License, or (at your option) any later version. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 138c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 148c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 158c2ecf20Sopenharmony_ci * GNU General Public License for more details. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef _DVBDEV_H_ 208c2ecf20Sopenharmony_ci#define _DVBDEV_H_ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <linux/types.h> 238c2ecf20Sopenharmony_ci#include <linux/poll.h> 248c2ecf20Sopenharmony_ci#include <linux/fs.h> 258c2ecf20Sopenharmony_ci#include <linux/list.h> 268c2ecf20Sopenharmony_ci#include <media/media-device.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define DVB_MAJOR 212 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 318c2ecf20Sopenharmony_ci #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS 328c2ecf20Sopenharmony_ci#else 338c2ecf20Sopenharmony_ci #define DVB_MAX_ADAPTERS 16 348c2ecf20Sopenharmony_ci#endif 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define DVB_UNSET (-1) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* List of DVB device types */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/** 418c2ecf20Sopenharmony_ci * enum dvb_device_type - type of the Digital TV device 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI) 448c2ecf20Sopenharmony_ci * @DVB_DEVICE_FRONTEND: Digital TV frontend. 458c2ecf20Sopenharmony_ci * @DVB_DEVICE_DEMUX: Digital TV demux. 468c2ecf20Sopenharmony_ci * @DVB_DEVICE_DVR: Digital TV digital video record (DVR). 478c2ecf20Sopenharmony_ci * @DVB_DEVICE_CA: Digital TV Conditional Access (CA). 488c2ecf20Sopenharmony_ci * @DVB_DEVICE_NET: Digital TV network. 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * @DVB_DEVICE_VIDEO: Digital TV video decoder. 518c2ecf20Sopenharmony_ci * Deprecated. Used only on av7110-av. 528c2ecf20Sopenharmony_ci * @DVB_DEVICE_AUDIO: Digital TV audio decoder. 538c2ecf20Sopenharmony_ci * Deprecated. Used only on av7110-av. 548c2ecf20Sopenharmony_ci * @DVB_DEVICE_OSD: Digital TV On Screen Display (OSD). 558c2ecf20Sopenharmony_ci * Deprecated. Used only on av7110. 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_cienum dvb_device_type { 588c2ecf20Sopenharmony_ci DVB_DEVICE_SEC, 598c2ecf20Sopenharmony_ci DVB_DEVICE_FRONTEND, 608c2ecf20Sopenharmony_ci DVB_DEVICE_DEMUX, 618c2ecf20Sopenharmony_ci DVB_DEVICE_DVR, 628c2ecf20Sopenharmony_ci DVB_DEVICE_CA, 638c2ecf20Sopenharmony_ci DVB_DEVICE_NET, 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci DVB_DEVICE_VIDEO, 668c2ecf20Sopenharmony_ci DVB_DEVICE_AUDIO, 678c2ecf20Sopenharmony_ci DVB_DEVICE_OSD, 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ 718c2ecf20Sopenharmony_ci static short adapter_nr[] = \ 728c2ecf20Sopenharmony_ci {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ 738c2ecf20Sopenharmony_ci module_param_array(adapter_nr, short, NULL, 0444); \ 748c2ecf20Sopenharmony_ci MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistruct dvb_frontend; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/** 798c2ecf20Sopenharmony_ci * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * @num: Number of the adapter 828c2ecf20Sopenharmony_ci * @list_head: List with the DVB adapters 838c2ecf20Sopenharmony_ci * @device_list: List with the DVB devices 848c2ecf20Sopenharmony_ci * @name: Name of the adapter 858c2ecf20Sopenharmony_ci * @proposed_mac: proposed MAC address for the adapter 868c2ecf20Sopenharmony_ci * @priv: private data 878c2ecf20Sopenharmony_ci * @device: pointer to struct device 888c2ecf20Sopenharmony_ci * @module: pointer to struct module 898c2ecf20Sopenharmony_ci * @mfe_shared: indicates mutually exclusive frontends. 908c2ecf20Sopenharmony_ci * Use of this flag is currently deprecated. 918c2ecf20Sopenharmony_ci * @mfe_dvbdev: Frontend device in use, in the case of MFE 928c2ecf20Sopenharmony_ci * @mfe_lock: Lock to prevent using the other frontends when MFE is 938c2ecf20Sopenharmony_ci * used. 948c2ecf20Sopenharmony_ci * @mdev_lock: Protect access to the mdev pointer. 958c2ecf20Sopenharmony_ci * @mdev: pointer to struct media_device, used when the media 968c2ecf20Sopenharmony_ci * controller is used. 978c2ecf20Sopenharmony_ci * @conn: RF connector. Used only if the device has no separate 988c2ecf20Sopenharmony_ci * tuner. 998c2ecf20Sopenharmony_ci * @conn_pads: pointer to struct media_pad associated with @conn; 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_cistruct dvb_adapter { 1028c2ecf20Sopenharmony_ci int num; 1038c2ecf20Sopenharmony_ci struct list_head list_head; 1048c2ecf20Sopenharmony_ci struct list_head device_list; 1058c2ecf20Sopenharmony_ci const char *name; 1068c2ecf20Sopenharmony_ci u8 proposed_mac [6]; 1078c2ecf20Sopenharmony_ci void* priv; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci struct device *device; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci struct module *module; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci int mfe_shared; /* indicates mutually exclusive frontends */ 1148c2ecf20Sopenharmony_ci struct dvb_device *mfe_dvbdev; /* frontend device in use */ 1158c2ecf20Sopenharmony_ci struct mutex mfe_lock; /* access lock for thread creation */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#if defined(CONFIG_MEDIA_CONTROLLER_DVB) 1188c2ecf20Sopenharmony_ci struct mutex mdev_lock; 1198c2ecf20Sopenharmony_ci struct media_device *mdev; 1208c2ecf20Sopenharmony_ci struct media_entity *conn; 1218c2ecf20Sopenharmony_ci struct media_pad *conn_pads; 1228c2ecf20Sopenharmony_ci#endif 1238c2ecf20Sopenharmony_ci}; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/** 1268c2ecf20Sopenharmony_ci * struct dvb_device - represents a DVB device node 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * @list_head: List head with all DVB devices 1298c2ecf20Sopenharmony_ci * @ref: reference counter 1308c2ecf20Sopenharmony_ci * @fops: pointer to struct file_operations 1318c2ecf20Sopenharmony_ci * @adapter: pointer to the adapter that holds this device node 1328c2ecf20Sopenharmony_ci * @type: type of the device, as defined by &enum dvb_device_type. 1338c2ecf20Sopenharmony_ci * @minor: devnode minor number. Major number is always DVB_MAJOR. 1348c2ecf20Sopenharmony_ci * @id: device ID number, inside the adapter 1358c2ecf20Sopenharmony_ci * @readers: Initialized by the caller. Each call to open() in Read Only mode 1368c2ecf20Sopenharmony_ci * decreases this counter by one. 1378c2ecf20Sopenharmony_ci * @writers: Initialized by the caller. Each call to open() in Read/Write 1388c2ecf20Sopenharmony_ci * mode decreases this counter by one. 1398c2ecf20Sopenharmony_ci * @users: Initialized by the caller. Each call to open() in any mode 1408c2ecf20Sopenharmony_ci * decreases this counter by one. 1418c2ecf20Sopenharmony_ci * @wait_queue: wait queue, used to wait for certain events inside one of 1428c2ecf20Sopenharmony_ci * the DVB API callers 1438c2ecf20Sopenharmony_ci * @kernel_ioctl: callback function used to handle ioctl calls from userspace. 1448c2ecf20Sopenharmony_ci * @name: Name to be used for the device at the Media Controller 1458c2ecf20Sopenharmony_ci * @entity: pointer to struct media_entity associated with the device node 1468c2ecf20Sopenharmony_ci * @pads: pointer to struct media_pad associated with @entity; 1478c2ecf20Sopenharmony_ci * @priv: private data 1488c2ecf20Sopenharmony_ci * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to 1498c2ecf20Sopenharmony_ci * store the MC device node interface 1508c2ecf20Sopenharmony_ci * @tsout_num_entities: Number of Transport Stream output entities 1518c2ecf20Sopenharmony_ci * @tsout_entity: array with MC entities associated to each TS output node 1528c2ecf20Sopenharmony_ci * @tsout_pads: array with the source pads for each @tsout_entity 1538c2ecf20Sopenharmony_ci * 1548c2ecf20Sopenharmony_ci * This structure is used by the DVB core (frontend, CA, net, demux) in 1558c2ecf20Sopenharmony_ci * order to create the device nodes. Usually, driver should not initialize 1568c2ecf20Sopenharmony_ci * this struct diretly. 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_cistruct dvb_device { 1598c2ecf20Sopenharmony_ci struct list_head list_head; 1608c2ecf20Sopenharmony_ci struct kref ref; 1618c2ecf20Sopenharmony_ci const struct file_operations *fops; 1628c2ecf20Sopenharmony_ci struct dvb_adapter *adapter; 1638c2ecf20Sopenharmony_ci enum dvb_device_type type; 1648c2ecf20Sopenharmony_ci int minor; 1658c2ecf20Sopenharmony_ci u32 id; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci /* in theory, 'users' can vanish now, 1688c2ecf20Sopenharmony_ci but I don't want to change too much now... */ 1698c2ecf20Sopenharmony_ci int readers; 1708c2ecf20Sopenharmony_ci int writers; 1718c2ecf20Sopenharmony_ci int users; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci wait_queue_head_t wait_queue; 1748c2ecf20Sopenharmony_ci /* don't really need those !? -- FIXME: use video_usercopy */ 1758c2ecf20Sopenharmony_ci int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci /* Needed for media controller register/unregister */ 1788c2ecf20Sopenharmony_ci#if defined(CONFIG_MEDIA_CONTROLLER_DVB) 1798c2ecf20Sopenharmony_ci const char *name; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci /* Allocated and filled inside dvbdev.c */ 1828c2ecf20Sopenharmony_ci struct media_intf_devnode *intf_devnode; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci unsigned tsout_num_entities; 1858c2ecf20Sopenharmony_ci struct media_entity *entity, *tsout_entity; 1868c2ecf20Sopenharmony_ci struct media_pad *pads, *tsout_pads; 1878c2ecf20Sopenharmony_ci#endif 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci void *priv; 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci/** 1938c2ecf20Sopenharmony_ci * struct dvbdevfops_node - fops nodes registered in dvbdevfops_list 1948c2ecf20Sopenharmony_ci * 1958c2ecf20Sopenharmony_ci * @fops: Dynamically allocated fops for ->owner registration 1968c2ecf20Sopenharmony_ci * @type: type of dvb_device 1978c2ecf20Sopenharmony_ci * @template: dvb_device used for registration 1988c2ecf20Sopenharmony_ci * @list_head: list_head for dvbdevfops_list 1998c2ecf20Sopenharmony_ci */ 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_cistruct dvbdevfops_node { 2028c2ecf20Sopenharmony_ci struct file_operations *fops; 2038c2ecf20Sopenharmony_ci enum dvb_device_type type; 2048c2ecf20Sopenharmony_ci const struct dvb_device *template; 2058c2ecf20Sopenharmony_ci struct list_head list_head; 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/** 2098c2ecf20Sopenharmony_ci * dvb_device_get - Increase dvb_device reference 2108c2ecf20Sopenharmony_ci * 2118c2ecf20Sopenharmony_ci * @dvbdev: pointer to struct dvb_device 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_cistruct dvb_device *dvb_device_get(struct dvb_device *dvbdev); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/** 2168c2ecf20Sopenharmony_ci * dvb_device_put - Decrease dvb_device reference 2178c2ecf20Sopenharmony_ci * 2188c2ecf20Sopenharmony_ci * @dvbdev: pointer to struct dvb_device 2198c2ecf20Sopenharmony_ci */ 2208c2ecf20Sopenharmony_civoid dvb_device_put(struct dvb_device *dvbdev); 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci/** 2238c2ecf20Sopenharmony_ci * dvb_register_adapter - Registers a new DVB adapter 2248c2ecf20Sopenharmony_ci * 2258c2ecf20Sopenharmony_ci * @adap: pointer to struct dvb_adapter 2268c2ecf20Sopenharmony_ci * @name: Adapter's name 2278c2ecf20Sopenharmony_ci * @module: initialized with THIS_MODULE at the caller 2288c2ecf20Sopenharmony_ci * @device: pointer to struct device that corresponds to the device driver 2298c2ecf20Sopenharmony_ci * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter; 2308c2ecf20Sopenharmony_ci * to select among them. Typically, initialized with: 2318c2ecf20Sopenharmony_ci * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums) 2328c2ecf20Sopenharmony_ci */ 2338c2ecf20Sopenharmony_ciint dvb_register_adapter(struct dvb_adapter *adap, const char *name, 2348c2ecf20Sopenharmony_ci struct module *module, struct device *device, 2358c2ecf20Sopenharmony_ci short *adapter_nums); 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci/** 2388c2ecf20Sopenharmony_ci * dvb_unregister_adapter - Unregisters a DVB adapter 2398c2ecf20Sopenharmony_ci * 2408c2ecf20Sopenharmony_ci * @adap: pointer to struct dvb_adapter 2418c2ecf20Sopenharmony_ci */ 2428c2ecf20Sopenharmony_ciint dvb_unregister_adapter(struct dvb_adapter *adap); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/** 2458c2ecf20Sopenharmony_ci * dvb_register_device - Registers a new DVB device 2468c2ecf20Sopenharmony_ci * 2478c2ecf20Sopenharmony_ci * @adap: pointer to struct dvb_adapter 2488c2ecf20Sopenharmony_ci * @pdvbdev: pointer to the place where the new struct dvb_device will be 2498c2ecf20Sopenharmony_ci * stored 2508c2ecf20Sopenharmony_ci * @template: Template used to create &pdvbdev; 2518c2ecf20Sopenharmony_ci * @priv: private data 2528c2ecf20Sopenharmony_ci * @type: type of the device, as defined by &enum dvb_device_type. 2538c2ecf20Sopenharmony_ci * @demux_sink_pads: Number of demux outputs, to be used to create the TS 2548c2ecf20Sopenharmony_ci * outputs via the Media Controller. 2558c2ecf20Sopenharmony_ci */ 2568c2ecf20Sopenharmony_ciint dvb_register_device(struct dvb_adapter *adap, 2578c2ecf20Sopenharmony_ci struct dvb_device **pdvbdev, 2588c2ecf20Sopenharmony_ci const struct dvb_device *template, 2598c2ecf20Sopenharmony_ci void *priv, 2608c2ecf20Sopenharmony_ci enum dvb_device_type type, 2618c2ecf20Sopenharmony_ci int demux_sink_pads); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci/** 2648c2ecf20Sopenharmony_ci * dvb_remove_device - Remove a registered DVB device 2658c2ecf20Sopenharmony_ci * 2668c2ecf20Sopenharmony_ci * This does not free memory. dvb_free_device() will do that when 2678c2ecf20Sopenharmony_ci * reference counter is empty 2688c2ecf20Sopenharmony_ci * 2698c2ecf20Sopenharmony_ci * @dvbdev: pointer to struct dvb_device 2708c2ecf20Sopenharmony_ci */ 2718c2ecf20Sopenharmony_civoid dvb_remove_device(struct dvb_device *dvbdev); 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci/** 2758c2ecf20Sopenharmony_ci * dvb_unregister_device - Unregisters a DVB device 2768c2ecf20Sopenharmony_ci * 2778c2ecf20Sopenharmony_ci * @dvbdev: pointer to struct dvb_device 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_civoid dvb_unregister_device(struct dvb_device *dvbdev); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci#ifdef CONFIG_MEDIA_CONTROLLER_DVB 2828c2ecf20Sopenharmony_ci/** 2838c2ecf20Sopenharmony_ci * dvb_create_media_graph - Creates media graph for the Digital TV part of the 2848c2ecf20Sopenharmony_ci * device. 2858c2ecf20Sopenharmony_ci * 2868c2ecf20Sopenharmony_ci * @adap: pointer to &struct dvb_adapter 2878c2ecf20Sopenharmony_ci * @create_rf_connector: if true, it creates the RF connector too 2888c2ecf20Sopenharmony_ci * 2898c2ecf20Sopenharmony_ci * This function checks all DVB-related functions at the media controller 2908c2ecf20Sopenharmony_ci * entities and creates the needed links for the media graph. It is 2918c2ecf20Sopenharmony_ci * capable of working with multiple tuners or multiple frontends, but it 2928c2ecf20Sopenharmony_ci * won't create links if the device has multiple tuners and multiple frontends 2938c2ecf20Sopenharmony_ci * or if the device has multiple muxes. In such case, the caller driver should 2948c2ecf20Sopenharmony_ci * manually create the remaining links. 2958c2ecf20Sopenharmony_ci */ 2968c2ecf20Sopenharmony_ci__must_check int dvb_create_media_graph(struct dvb_adapter *adap, 2978c2ecf20Sopenharmony_ci bool create_rf_connector); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci/** 3008c2ecf20Sopenharmony_ci * dvb_register_media_controller - registers a media controller at DVB adapter 3018c2ecf20Sopenharmony_ci * 3028c2ecf20Sopenharmony_ci * @adap: pointer to &struct dvb_adapter 3038c2ecf20Sopenharmony_ci * @mdev: pointer to &struct media_device 3048c2ecf20Sopenharmony_ci */ 3058c2ecf20Sopenharmony_cistatic inline void dvb_register_media_controller(struct dvb_adapter *adap, 3068c2ecf20Sopenharmony_ci struct media_device *mdev) 3078c2ecf20Sopenharmony_ci{ 3088c2ecf20Sopenharmony_ci adap->mdev = mdev; 3098c2ecf20Sopenharmony_ci} 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci/** 3128c2ecf20Sopenharmony_ci * dvb_get_media_controller - gets the associated media controller 3138c2ecf20Sopenharmony_ci * 3148c2ecf20Sopenharmony_ci * @adap: pointer to &struct dvb_adapter 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_cistatic inline struct media_device * 3178c2ecf20Sopenharmony_cidvb_get_media_controller(struct dvb_adapter *adap) 3188c2ecf20Sopenharmony_ci{ 3198c2ecf20Sopenharmony_ci return adap->mdev; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci#else 3228c2ecf20Sopenharmony_cistatic inline 3238c2ecf20Sopenharmony_ciint dvb_create_media_graph(struct dvb_adapter *adap, 3248c2ecf20Sopenharmony_ci bool create_rf_connector) 3258c2ecf20Sopenharmony_ci{ 3268c2ecf20Sopenharmony_ci return 0; 3278c2ecf20Sopenharmony_ci}; 3288c2ecf20Sopenharmony_ci#define dvb_register_media_controller(a, b) {} 3298c2ecf20Sopenharmony_ci#define dvb_get_media_controller(a) NULL 3308c2ecf20Sopenharmony_ci#endif 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci/** 3338c2ecf20Sopenharmony_ci * dvb_generic_open - Digital TV open function, used by DVB devices 3348c2ecf20Sopenharmony_ci * 3358c2ecf20Sopenharmony_ci * @inode: pointer to &struct inode. 3368c2ecf20Sopenharmony_ci * @file: pointer to &struct file. 3378c2ecf20Sopenharmony_ci * 3388c2ecf20Sopenharmony_ci * Checks if a DVB devnode is still valid, and if the permissions are 3398c2ecf20Sopenharmony_ci * OK and increment negative use count. 3408c2ecf20Sopenharmony_ci */ 3418c2ecf20Sopenharmony_ciint dvb_generic_open(struct inode *inode, struct file *file); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci/** 3448c2ecf20Sopenharmony_ci * dvb_generic_close - Digital TV close function, used by DVB devices 3458c2ecf20Sopenharmony_ci * 3468c2ecf20Sopenharmony_ci * @inode: pointer to &struct inode. 3478c2ecf20Sopenharmony_ci * @file: pointer to &struct file. 3488c2ecf20Sopenharmony_ci * 3498c2ecf20Sopenharmony_ci * Checks if a DVB devnode is still valid, and if the permissions are 3508c2ecf20Sopenharmony_ci * OK and decrement negative use count. 3518c2ecf20Sopenharmony_ci */ 3528c2ecf20Sopenharmony_ciint dvb_generic_release(struct inode *inode, struct file *file); 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci/** 3558c2ecf20Sopenharmony_ci * dvb_generic_ioctl - Digital TV close function, used by DVB devices 3568c2ecf20Sopenharmony_ci * 3578c2ecf20Sopenharmony_ci * @file: pointer to &struct file. 3588c2ecf20Sopenharmony_ci * @cmd: Ioctl name. 3598c2ecf20Sopenharmony_ci * @arg: Ioctl argument. 3608c2ecf20Sopenharmony_ci * 3618c2ecf20Sopenharmony_ci * Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid. 3628c2ecf20Sopenharmony_ci * If so, calls dvb_usercopy(). 3638c2ecf20Sopenharmony_ci */ 3648c2ecf20Sopenharmony_cilong dvb_generic_ioctl(struct file *file, 3658c2ecf20Sopenharmony_ci unsigned int cmd, unsigned long arg); 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci/** 3688c2ecf20Sopenharmony_ci * dvb_usercopy - copies data from/to userspace memory when an ioctl is 3698c2ecf20Sopenharmony_ci * issued. 3708c2ecf20Sopenharmony_ci * 3718c2ecf20Sopenharmony_ci * @file: Pointer to struct &file. 3728c2ecf20Sopenharmony_ci * @cmd: Ioctl name. 3738c2ecf20Sopenharmony_ci * @arg: Ioctl argument. 3748c2ecf20Sopenharmony_ci * @func: function that will actually handle the ioctl 3758c2ecf20Sopenharmony_ci * 3768c2ecf20Sopenharmony_ci * Ancillary function that uses ioctl direction and size to copy from 3778c2ecf20Sopenharmony_ci * userspace. Then, it calls @func, and, if needed, data is copied back 3788c2ecf20Sopenharmony_ci * to userspace. 3798c2ecf20Sopenharmony_ci */ 3808c2ecf20Sopenharmony_ciint dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg, 3818c2ecf20Sopenharmony_ci int (*func)(struct file *file, unsigned int cmd, void *arg)); 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_I2C) 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_cistruct i2c_adapter; 3868c2ecf20Sopenharmony_cistruct i2c_client; 3878c2ecf20Sopenharmony_ci/** 3888c2ecf20Sopenharmony_ci * dvb_module_probe - helper routine to probe an I2C module 3898c2ecf20Sopenharmony_ci * 3908c2ecf20Sopenharmony_ci * @module_name: 3918c2ecf20Sopenharmony_ci * Name of the I2C module to be probed 3928c2ecf20Sopenharmony_ci * @name: 3938c2ecf20Sopenharmony_ci * Optional name for the I2C module. Used for debug purposes. 3948c2ecf20Sopenharmony_ci * If %NULL, defaults to @module_name. 3958c2ecf20Sopenharmony_ci * @adap: 3968c2ecf20Sopenharmony_ci * pointer to &struct i2c_adapter that describes the I2C adapter where 3978c2ecf20Sopenharmony_ci * the module will be bound. 3988c2ecf20Sopenharmony_ci * @addr: 3998c2ecf20Sopenharmony_ci * I2C address of the adapter, in 7-bit notation. 4008c2ecf20Sopenharmony_ci * @platform_data: 4018c2ecf20Sopenharmony_ci * Platform data to be passed to the I2C module probed. 4028c2ecf20Sopenharmony_ci * 4038c2ecf20Sopenharmony_ci * This function binds an I2C device into the DVB core. Should be used by 4048c2ecf20Sopenharmony_ci * all drivers that use I2C bus to control the hardware. A module bound 4058c2ecf20Sopenharmony_ci * with dvb_module_probe() should use dvb_module_release() to unbind. 4068c2ecf20Sopenharmony_ci * 4078c2ecf20Sopenharmony_ci * Return: 4088c2ecf20Sopenharmony_ci * On success, return an &struct i2c_client, pointing to the bound 4098c2ecf20Sopenharmony_ci * I2C device. %NULL otherwise. 4108c2ecf20Sopenharmony_ci * 4118c2ecf20Sopenharmony_ci * .. note:: 4128c2ecf20Sopenharmony_ci * 4138c2ecf20Sopenharmony_ci * In the past, DVB modules (mainly, frontends) were bound via dvb_attach() 4148c2ecf20Sopenharmony_ci * macro, with does an ugly hack, using I2C low level functions. Such 4158c2ecf20Sopenharmony_ci * usage is deprecated and will be removed soon. Instead, use this routine. 4168c2ecf20Sopenharmony_ci */ 4178c2ecf20Sopenharmony_cistruct i2c_client *dvb_module_probe(const char *module_name, 4188c2ecf20Sopenharmony_ci const char *name, 4198c2ecf20Sopenharmony_ci struct i2c_adapter *adap, 4208c2ecf20Sopenharmony_ci unsigned char addr, 4218c2ecf20Sopenharmony_ci void *platform_data); 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/** 4248c2ecf20Sopenharmony_ci * dvb_module_release - releases an I2C device allocated with 4258c2ecf20Sopenharmony_ci * dvb_module_probe(). 4268c2ecf20Sopenharmony_ci * 4278c2ecf20Sopenharmony_ci * @client: pointer to &struct i2c_client with the I2C client to be released. 4288c2ecf20Sopenharmony_ci * can be %NULL. 4298c2ecf20Sopenharmony_ci * 4308c2ecf20Sopenharmony_ci * This function should be used to free all resources reserved by 4318c2ecf20Sopenharmony_ci * dvb_module_probe() and unbinding the I2C hardware. 4328c2ecf20Sopenharmony_ci */ 4338c2ecf20Sopenharmony_civoid dvb_module_release(struct i2c_client *client); 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci#endif /* CONFIG_I2C */ 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci/* Legacy generic DVB attach function. */ 4388c2ecf20Sopenharmony_ci#ifdef CONFIG_MEDIA_ATTACH 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/** 4418c2ecf20Sopenharmony_ci * dvb_attach - attaches a DVB frontend into the DVB core. 4428c2ecf20Sopenharmony_ci * 4438c2ecf20Sopenharmony_ci * @FUNCTION: function on a frontend module to be called. 4448c2ecf20Sopenharmony_ci * @ARGS...: @FUNCTION arguments. 4458c2ecf20Sopenharmony_ci * 4468c2ecf20Sopenharmony_ci * This ancillary function loads a frontend module in runtime and runs 4478c2ecf20Sopenharmony_ci * the @FUNCTION function there, with @ARGS. 4488c2ecf20Sopenharmony_ci * As it increments symbol usage cont, at unregister, dvb_detach() 4498c2ecf20Sopenharmony_ci * should be called. 4508c2ecf20Sopenharmony_ci * 4518c2ecf20Sopenharmony_ci * .. note:: 4528c2ecf20Sopenharmony_ci * 4538c2ecf20Sopenharmony_ci * In the past, DVB modules (mainly, frontends) were bound via dvb_attach() 4548c2ecf20Sopenharmony_ci * macro, with does an ugly hack, using I2C low level functions. Such 4558c2ecf20Sopenharmony_ci * usage is deprecated and will be removed soon. Instead, you should use 4568c2ecf20Sopenharmony_ci * dvb_module_probe(). 4578c2ecf20Sopenharmony_ci */ 4588c2ecf20Sopenharmony_ci#define dvb_attach(FUNCTION, ARGS...) ({ \ 4598c2ecf20Sopenharmony_ci void *__r = NULL; \ 4608c2ecf20Sopenharmony_ci typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ 4618c2ecf20Sopenharmony_ci if (__a) { \ 4628c2ecf20Sopenharmony_ci __r = (void *) __a(ARGS); \ 4638c2ecf20Sopenharmony_ci if (__r == NULL) \ 4648c2ecf20Sopenharmony_ci symbol_put(FUNCTION); \ 4658c2ecf20Sopenharmony_ci } else { \ 4668c2ecf20Sopenharmony_ci printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \ 4678c2ecf20Sopenharmony_ci } \ 4688c2ecf20Sopenharmony_ci __r; \ 4698c2ecf20Sopenharmony_ci}) 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci/** 4728c2ecf20Sopenharmony_ci * dvb_detach - detaches a DVB frontend loaded via dvb_attach() 4738c2ecf20Sopenharmony_ci * 4748c2ecf20Sopenharmony_ci * @FUNC: attach function 4758c2ecf20Sopenharmony_ci * 4768c2ecf20Sopenharmony_ci * Decrements usage count for a function previously called via dvb_attach(). 4778c2ecf20Sopenharmony_ci */ 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci#define dvb_detach(FUNC) symbol_put_addr(FUNC) 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci#else 4828c2ecf20Sopenharmony_ci#define dvb_attach(FUNCTION, ARGS...) ({ \ 4838c2ecf20Sopenharmony_ci FUNCTION(ARGS); \ 4848c2ecf20Sopenharmony_ci}) 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci#define dvb_detach(FUNC) {} 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci#endif /* CONFIG_MEDIA_ATTACH */ 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci#endif /* #ifndef _DVBDEV_H_ */ 491