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>
38 #include <linux/mutex.h>
40 #include <linux/dvb/frontend.h>
44 struct dvb_frontend_tune_settings
{
48 struct dvb_frontend_parameters parameters
;
53 struct dvb_tuner_info
{
65 struct dvb_tuner_ops
{
67 struct dvb_tuner_info info
;
69 int (*release
)(struct dvb_frontend
*fe
);
70 int (*init
)(struct dvb_frontend
*fe
);
71 int (*sleep
)(struct dvb_frontend
*fe
);
73 /** This is for simple PLLs - set all parameters in one go. */
74 int (*set_params
)(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*p
);
76 /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
77 int (*calc_regs
)(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*p
, u8
*buf
, int buf_len
);
79 int (*get_frequency
)(struct dvb_frontend
*fe
, u32
*frequency
);
80 int (*get_bandwidth
)(struct dvb_frontend
*fe
, u32
*bandwidth
);
82 #define TUNER_STATUS_LOCKED 1
83 int (*get_status
)(struct dvb_frontend
*fe
, u32
*status
);
85 /** These are provided seperately from set_params in order to facilitate silicon
86 * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
87 int (*set_frequency
)(struct dvb_frontend
*fe
, u32 frequency
);
88 int (*set_bandwidth
)(struct dvb_frontend
*fe
, u32 bandwidth
);
91 struct dvb_frontend_ops
{
93 struct dvb_frontend_info info
;
95 void (*release
)(struct dvb_frontend
* fe
);
96 void (*release_sec
)(struct dvb_frontend
* fe
);
98 int (*init
)(struct dvb_frontend
* fe
);
99 int (*sleep
)(struct dvb_frontend
* fe
);
101 int (*write
)(struct dvb_frontend
* fe
, u8
* buf
, int len
);
103 /* if this is set, it overrides the default swzigzag */
104 int (*tune
)(struct dvb_frontend
* fe
,
105 struct dvb_frontend_parameters
* params
,
106 unsigned int mode_flags
,
108 fe_status_t
*status
);
109 /* get frontend tuning algorithm from the module */
110 int (*get_frontend_algo
)(struct dvb_frontend
*fe
);
112 /* these two are only used for the swzigzag code */
113 int (*set_frontend
)(struct dvb_frontend
* fe
, struct dvb_frontend_parameters
* params
);
114 int (*get_tune_settings
)(struct dvb_frontend
* fe
, struct dvb_frontend_tune_settings
* settings
);
116 int (*get_frontend
)(struct dvb_frontend
* fe
, struct dvb_frontend_parameters
* params
);
118 int (*read_status
)(struct dvb_frontend
* fe
, fe_status_t
* status
);
119 int (*read_ber
)(struct dvb_frontend
* fe
, u32
* ber
);
120 int (*read_signal_strength
)(struct dvb_frontend
* fe
, u16
* strength
);
121 int (*read_snr
)(struct dvb_frontend
* fe
, u16
* snr
);
122 int (*read_ucblocks
)(struct dvb_frontend
* fe
, u32
* ucblocks
);
124 int (*diseqc_reset_overload
)(struct dvb_frontend
* fe
);
125 int (*diseqc_send_master_cmd
)(struct dvb_frontend
* fe
, struct dvb_diseqc_master_cmd
* cmd
);
126 int (*diseqc_recv_slave_reply
)(struct dvb_frontend
* fe
, struct dvb_diseqc_slave_reply
* reply
);
127 int (*diseqc_send_burst
)(struct dvb_frontend
* fe
, fe_sec_mini_cmd_t minicmd
);
128 int (*set_tone
)(struct dvb_frontend
* fe
, fe_sec_tone_mode_t tone
);
129 int (*set_voltage
)(struct dvb_frontend
* fe
, fe_sec_voltage_t voltage
);
130 int (*enable_high_lnb_voltage
)(struct dvb_frontend
* fe
, long arg
);
131 int (*dishnetwork_send_legacy_command
)(struct dvb_frontend
* fe
, unsigned long cmd
);
132 int (*i2c_gate_ctrl
)(struct dvb_frontend
* fe
, int enable
);
133 int (*ts_bus_ctrl
)(struct dvb_frontend
* fe
, int acquire
);
135 struct dvb_tuner_ops tuner_ops
;
140 struct dvb_fe_events
{
141 struct dvb_frontend_event events
[MAX_EVENT
];
145 wait_queue_head_t wait_queue
;
149 struct dvb_frontend
{
150 struct dvb_frontend_ops ops
;
151 struct dvb_adapter
*dvb
;
152 void* demodulator_priv
;
158 extern int dvb_register_frontend(struct dvb_adapter
* dvb
,
159 struct dvb_frontend
* fe
);
161 extern int dvb_unregister_frontend(struct dvb_frontend
* fe
);
163 extern void dvb_frontend_detach(struct dvb_frontend
* fe
);
165 extern void dvb_frontend_reinitialise(struct dvb_frontend
*fe
);
167 extern void dvb_frontend_sleep_until(struct timeval
*waketime
, u32 add_usec
);
168 extern s32
timeval_usec_diff(struct timeval lasttime
, struct timeval curtime
);