ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / media / dvb / dvb-core / dvb_frontend.h
1 /* 
2  * dvb_frontend.h
3  *
4  * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
5  *                    overhauled by Holger Waechtler for Convergence GmbH
6  *
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  */
24
25 #ifndef _DVB_FRONTEND_H_
26 #define _DVB_FRONTEND_H_
27
28 #include <linux/types.h>
29 #include <linux/sched.h>
30 #include <linux/ioctl.h>
31 #include <linux/i2c.h>
32 #include <linux/module.h>
33 #include <linux/errno.h>
34
35 #include <linux/dvb/frontend.h>
36
37 #include "dvb_i2c.h"
38 #include "dvbdev.h"
39
40
41
42
43 /**
44  *   when before_ioctl is registered and returns value 0, ioctl and after_ioctl
45  *   are not executed.
46  */
47
48 struct dvb_frontend {
49         int (*before_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
50         int (*ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
51         int (*after_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
52         void (*notifier_callback) (fe_status_t s, void *data);
53         struct dvb_i2c_bus *i2c;
54         void *before_after_data;   /*  can be used by hardware module... */
55         void *notifier_data;       /*  can be used by hardware module... */
56         void *data;                /*  can be used by hardware module... */
57 };
58
59 struct dvb_frontend_tune_settings {
60         int min_delay_ms;
61         int step_size;
62         int max_drift;
63         struct dvb_frontend_parameters parameters;
64 };
65
66
67 /**
68  *   private frontend command ioctl's.
69  *   keep them in sync with the public ones defined in linux/dvb/frontend.h
70  * 
71  *   FE_SLEEP. Ioctl used to put frontend into a low power mode.
72  *   FE_INIT. Ioctl used to initialise the frontend.
73  *   FE_GET_TUNE_SETTINGS. Get the frontend-specific tuning loop settings for the supplied set of parameters.
74  */
75 #define FE_SLEEP              _IO('v', 80)
76 #define FE_INIT               _IO('v', 81)
77 #define FE_GET_TUNE_SETTINGS  _IOWR('v', 83, struct dvb_frontend_tune_settings)
78
79
80 extern int
81 dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
82                                      unsigned int cmd, void *arg),
83                        struct dvb_i2c_bus *i2c,
84                        void *data,
85                        struct dvb_frontend_info *info);
86
87 extern int
88 dvb_unregister_frontend (int (*ioctl) (struct dvb_frontend *frontend,
89                                        unsigned int cmd, void *arg),
90                          struct dvb_i2c_bus *i2c);
91
92
93 /**
94  *  Add special ioctl code performed before and after the main ioctl
95  *  to all frontend devices on the specified DVB adapter.
96  *  This is necessairy because the 22kHz/13V-18V/DiSEqC stuff depends
97  *  heavily on the hardware around the frontend, the same tuner can create 
98  *  these signals on about a million different ways...
99  *
100  *  Return value: number of frontends where the ioctl's were applied.
101  */
102 extern int
103 dvb_add_frontend_ioctls (struct dvb_adapter *adapter,
104                          int (*before_ioctl) (struct dvb_frontend *frontend,
105                                               unsigned int cmd, void *arg),
106                          int (*after_ioctl)  (struct dvb_frontend *frontend,
107                                               unsigned int cmd, void *arg),
108                          void *before_after_data);
109
110
111 extern void
112 dvb_remove_frontend_ioctls (struct dvb_adapter *adapter,
113                             int (*before_ioctl) (struct dvb_frontend *frontend,
114                                                  unsigned int cmd, void *arg),
115                             int (*after_ioctl)  (struct dvb_frontend *frontend,
116                                                  unsigned int cmd, void *arg));
117
118 extern int
119 dvb_add_frontend_notifier (struct dvb_adapter *adapter,
120                            void (*callback) (fe_status_t s, void *data),
121                            void *data);
122 extern void
123 dvb_remove_frontend_notifier (struct dvb_adapter *adapter,
124                               void (*callback) (fe_status_t s, void *data));
125
126 #endif
127