4 * Copyright (C) 2001 convergence integrated media GmbH
5 * Copyright (C) 2004 convergence GmbH
7 * Written by Ralph Metzler
8 * Overhauled by Holger Waechtler
9 * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #ifndef _DVB_FRONTEND_H_
29 #define _DVB_FRONTEND_H_
31 #include <linux/types.h>
32 #include <linux/sched.h>
33 #include <linux/ioctl.h>
34 #include <linux/i2c.h>
35 #include <linux/module.h>
36 #include <linux/errno.h>
37 #include <linux/delay.h>
39 #include <linux/dvb/frontend.h>
43 struct dvb_frontend_tune_settings {
47 struct dvb_frontend_parameters parameters;
52 struct dvb_tuner_info {
64 struct dvb_tuner_ops {
66 * Description of the tuner.
68 struct dvb_tuner_info info;
71 * Cleanup an attached tuner.
73 * @param fe dvb_frontend structure to clean it up from.
74 * @return 0 on success, <0 on failure.
76 int (*release)(struct dvb_frontend *fe);
81 * @param fe dvb_frontend structure.
82 * @return 0 on success, <0 on failure.
84 int (*init)(struct dvb_frontend *fe);
87 * Set a tuner into low power mode.
89 * @param fe dvb_frontend structure.
90 * @return 0 on success, <0 on failure.
92 int (*sleep)(struct dvb_frontend *fe);
95 * This is for simple PLLs - set all parameters in one go.
97 * @param fe The dvb_frontend structure.
98 * @param p The parameters to set.
99 * @return 0 on success, <0 on failure.
101 int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
104 * This is support for demods like the mt352 - fills out the supplied buffer with what to write.
106 * @param fe The dvb_frontend structure.
107 * @param p The parameters to set.
108 * @param buf The buffer to fill with data. For an i2c tuner, the first byte should be the tuner i2c address in linux format.
109 * @param buf_len Size of buffer in bytes.
110 * @return Number of bytes used, or <0 on failure.
112 int (*pllbuf)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
115 * Get the frequency the tuner was actually set to.
117 * @param fe The dvb_frontend structure.
118 * @param frequency Where to put it.
119 * @return 0 on success, or <0 on failure.
121 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
124 * Get the bandwidth the tuner was actually set to.
126 * @param fe The dvb_frontend structure.
127 * @param bandwidth Where to put it.
128 * @return 0 on success, or <0 on failure.
130 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
133 * Get the tuner's status.
135 * @param fe The dvb_frontend structure.
136 * @param status Where to put it.
137 * @return 0 on success, or <0 on failure.
139 #define TUNER_STATUS_LOCKED 1
140 int (*get_status)(struct dvb_frontend *fe, u32 *status);
143 * Set the frequency of the tuner - for complex tuners.
145 * @param fe The dvb_frontend structure.
146 * @param frequency What to set.
147 * @return 0 on success, or <0 on failure.
149 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
152 * Set the bandwidth of the tuner - for complex tuners.
154 * @param fe The dvb_frontend structure.
155 * @param bandwidth What to set.
156 * @return 0 on success, or <0 on failure.
158 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
161 struct dvb_frontend_ops {
163 struct dvb_frontend_info info;
165 void (*release)(struct dvb_frontend* fe);
167 int (*init)(struct dvb_frontend* fe);
168 int (*sleep)(struct dvb_frontend* fe);
170 /* if this is set, it overrides the default swzigzag */
171 int (*tune)(struct dvb_frontend* fe,
172 struct dvb_frontend_parameters* params,
173 unsigned int mode_flags,
175 fe_status_t *status);
177 /* these two are only used for the swzigzag code */
178 int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
179 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
181 int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
183 int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
184 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
185 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
186 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
187 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
189 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
190 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
191 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
192 int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
193 int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
194 int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
195 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
196 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
197 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
199 struct dvb_tuner_ops tuner_ops;
204 struct dvb_fe_events {
205 struct dvb_frontend_event events[MAX_EVENT];
209 wait_queue_head_t wait_queue;
210 struct semaphore sem;
213 struct dvb_frontend {
214 struct dvb_frontend_ops* ops;
215 struct dvb_adapter *dvb;
216 void* demodulator_priv;
222 extern int dvb_register_frontend(struct dvb_adapter* dvb,
223 struct dvb_frontend* fe);
225 extern int dvb_unregister_frontend(struct dvb_frontend* fe);
227 extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
229 extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
230 extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);