]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/media/dvb/dvb-core/dvb_frontend.h
V4L/DVB (9219): Kernel config comment corrected (radio-silabs -> radio-si470x)
[mirror_ubuntu-hirsute-kernel.git] / drivers / media / dvb / dvb-core / dvb_frontend.h
CommitLineData
1da177e4
LT
1/*
2 * dvb_frontend.h
3 *
4 * Copyright (C) 2001 convergence integrated media GmbH
5 * Copyright (C) 2004 convergence GmbH
6 *
7 * Written by Ralph Metzler
8 * Overhauled by Holger Waechtler
9 * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
10 *
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.
15 *
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.
20 *
21
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.
25 *
26 */
27
28#ifndef _DVB_FRONTEND_H_
29#define _DVB_FRONTEND_H_
30
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>
03b76123 38#include <linux/mutex.h>
1da177e4
LT
39
40#include <linux/dvb/frontend.h>
41
42#include "dvbdev.h"
43
1da177e4 44struct dvb_frontend_tune_settings {
afd1a0c9
MCC
45 int min_delay_ms;
46 int step_size;
47 int max_drift;
48 struct dvb_frontend_parameters parameters;
1da177e4
LT
49};
50
51struct dvb_frontend;
52
7eef5dd6
AQ
53struct dvb_tuner_info {
54 char name[128];
55
56 u32 frequency_min;
57 u32 frequency_max;
58 u32 frequency_step;
59
60 u32 bandwidth_min;
61 u32 bandwidth_max;
62 u32 bandwidth_step;
63};
64
e18f9444
MK
65struct analog_parameters {
66 unsigned int frequency;
67 unsigned int mode;
68 unsigned int audmode;
69 u64 std;
70};
71
7eef5dd6 72struct dvb_tuner_ops {
f6adb91c 73
7eef5dd6
AQ
74 struct dvb_tuner_info info;
75
7eef5dd6 76 int (*release)(struct dvb_frontend *fe);
7eef5dd6 77 int (*init)(struct dvb_frontend *fe);
7eef5dd6
AQ
78 int (*sleep)(struct dvb_frontend *fe);
79
f6adb91c 80 /** This is for simple PLLs - set all parameters in one go. */
7eef5dd6 81 int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
e18f9444 82 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
7eef5dd6 83
f6adb91c
AQ
84 /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
85 int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
7eef5dd6 86
7f171123
MCC
87 /** This is to allow setting tuner-specific configs */
88 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
89
f6adb91c 90 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
7eef5dd6
AQ
91 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
92
7eef5dd6 93#define TUNER_STATUS_LOCKED 1
e18f9444 94#define TUNER_STATUS_STEREO 2
7eef5dd6 95 int (*get_status)(struct dvb_frontend *fe, u32 *status);
8fb3b9f7 96 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
7eef5dd6 97
f6adb91c
AQ
98 /** These are provided seperately from set_params in order to facilitate silicon
99 * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
7eef5dd6 100 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
7eef5dd6
AQ
101 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
102};
103
807ffe8d
MK
104struct analog_demod_info {
105 char *name;
106};
107
bc3e5c7f 108struct analog_demod_ops {
807ffe8d
MK
109
110 struct analog_demod_info info;
111
112 void (*set_params)(struct dvb_frontend *fe,
113 struct analog_parameters *params);
114 int (*has_signal)(struct dvb_frontend *fe);
115 int (*is_stereo)(struct dvb_frontend *fe);
116 int (*get_afc)(struct dvb_frontend *fe);
117 void (*tuner_status)(struct dvb_frontend *fe);
118 void (*standby)(struct dvb_frontend *fe);
119 void (*release)(struct dvb_frontend *fe);
120 int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
121
122 /** This is to allow setting tuner-specific configuration */
123 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
124};
125
1da177e4
LT
126struct dvb_frontend_ops {
127
128 struct dvb_frontend_info info;
129
130 void (*release)(struct dvb_frontend* fe);
94cbae5a 131 void (*release_sec)(struct dvb_frontend* fe);
1da177e4
LT
132
133 int (*init)(struct dvb_frontend* fe);
134 int (*sleep)(struct dvb_frontend* fe);
135
94cbae5a
AQ
136 int (*write)(struct dvb_frontend* fe, u8* buf, int len);
137
36cb557a
AQ
138 /* if this is set, it overrides the default swzigzag */
139 int (*tune)(struct dvb_frontend* fe,
140 struct dvb_frontend_parameters* params,
141 unsigned int mode_flags,
260f8d7c 142 unsigned int *delay,
36cb557a 143 fe_status_t *status);
0249ef16
MA
144 /* get frontend tuning algorithm from the module */
145 int (*get_frontend_algo)(struct dvb_frontend *fe);
36cb557a
AQ
146
147 /* these two are only used for the swzigzag code */
1da177e4 148 int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
1da177e4
LT
149 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
150
36cb557a
AQ
151 int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
152
1da177e4
LT
153 int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
154 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
155 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
156 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
157 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
158
159 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
160 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
161 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
162 int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
163 int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
164 int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
400b7083
PB
165 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
166 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
611900c1 167 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
ba7e6f3e 168 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
7eef5dd6
AQ
169
170 struct dvb_tuner_ops tuner_ops;
bc3e5c7f 171 struct analog_demod_ops analog_ops;
6b73eeaf 172
e7fee0f3
ST
173 int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
174 int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
1da177e4
LT
175};
176
177#define MAX_EVENT 8
178
179struct dvb_fe_events {
180 struct dvb_frontend_event events[MAX_EVENT];
181 int eventw;
182 int eventr;
183 int overflow;
184 wait_queue_head_t wait_queue;
03b76123 185 struct mutex mtx;
1da177e4
LT
186};
187
56f0680a 188struct dtv_frontend_properties {
6b73eeaf
ST
189
190 /* Cache State */
191 u32 state;
192
193 u32 frequency;
194 fe_modulation_t modulation;
195
196 fe_sec_voltage_t voltage;
197 fe_sec_tone_mode_t sectone;
198 fe_spectral_inversion_t inversion;
199 fe_code_rate_t fec_inner;
200 fe_transmit_mode_t transmission_mode;
75b7f943 201 u32 bandwidth_hz; /* 0 = AUTO */
6b73eeaf
ST
202 fe_guard_interval_t guard_interval;
203 fe_hierarchy_t hierarchy;
204 u32 symbol_rate;
205 fe_code_rate_t code_rate_HP;
206 fe_code_rate_t code_rate_LP;
207
208 fe_pilot_t pilot;
209 fe_rolloff_t rolloff;
210
211 fe_delivery_system_t delivery_system;
6b73eeaf
ST
212};
213
1da177e4 214struct dvb_frontend {
dea74869 215 struct dvb_frontend_ops ops;
1da177e4 216 struct dvb_adapter *dvb;
482b498d
MK
217 void *demodulator_priv;
218 void *tuner_priv;
219 void *frontend_priv;
220 void *sec_priv;
221 void *analog_demod_priv;
56f0680a 222 struct dtv_frontend_properties dtv_property_cache;
ebb8d68a
MK
223#define DVB_FRONTEND_COMPONENT_TUNER 0
224 int (*callback)(void *adapter_priv, int component, int cmd, int arg);
1da177e4
LT
225};
226
482b498d
MK
227extern int dvb_register_frontend(struct dvb_adapter *dvb,
228 struct dvb_frontend *fe);
1da177e4 229
482b498d 230extern int dvb_unregister_frontend(struct dvb_frontend *fe);
1da177e4 231
482b498d 232extern void dvb_frontend_detach(struct dvb_frontend *fe);
f52a838b 233
86f40cc3
AQ
234extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
235
83b75b04
N
236extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
237extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
238
1da177e4 239#endif