[media] dvb_frontend: document dvb_frontend_tune_settings
[deliverable/linux.git] / drivers / media / 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>
5a0e3ad6 39#include <linux/slab.h>
1da177e4
LT
40
41#include <linux/dvb/frontend.h>
42
43#include "dvbdev.h"
44
eeacf147
MCC
45/*
46 * Maximum number of Delivery systems per frontend. It
47 * should be smaller or equal to 32
48 */
49#define MAX_DELSYS 8
50
b9de1726
MCC
51/**
52 * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
53 *
54 * @min_delay_ms: minimum delay for tuning, in ms
55 * @step_size: step size between two consecutive frequencies
56 * @max_drift: maximum drift
57 *
58 * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
59 */
1da177e4 60struct dvb_frontend_tune_settings {
afd1a0c9
MCC
61 int min_delay_ms;
62 int step_size;
63 int max_drift;
1da177e4
LT
64};
65
66struct dvb_frontend;
67
7eef5dd6
AQ
68struct dvb_tuner_info {
69 char name[128];
70
71 u32 frequency_min;
72 u32 frequency_max;
73 u32 frequency_step;
74
75 u32 bandwidth_min;
76 u32 bandwidth_max;
77 u32 bandwidth_step;
78};
79
e18f9444
MK
80struct analog_parameters {
81 unsigned int frequency;
82 unsigned int mode;
83 unsigned int audmode;
84 u64 std;
85};
86
c59e7870
MA
87enum dvbfe_modcod {
88 DVBFE_MODCOD_DUMMY_PLFRAME = 0,
89 DVBFE_MODCOD_QPSK_1_4,
90 DVBFE_MODCOD_QPSK_1_3,
91 DVBFE_MODCOD_QPSK_2_5,
92 DVBFE_MODCOD_QPSK_1_2,
93 DVBFE_MODCOD_QPSK_3_5,
94 DVBFE_MODCOD_QPSK_2_3,
95 DVBFE_MODCOD_QPSK_3_4,
96 DVBFE_MODCOD_QPSK_4_5,
97 DVBFE_MODCOD_QPSK_5_6,
98 DVBFE_MODCOD_QPSK_8_9,
99 DVBFE_MODCOD_QPSK_9_10,
100 DVBFE_MODCOD_8PSK_3_5,
101 DVBFE_MODCOD_8PSK_2_3,
102 DVBFE_MODCOD_8PSK_3_4,
103 DVBFE_MODCOD_8PSK_5_6,
104 DVBFE_MODCOD_8PSK_8_9,
105 DVBFE_MODCOD_8PSK_9_10,
106 DVBFE_MODCOD_16APSK_2_3,
107 DVBFE_MODCOD_16APSK_3_4,
108 DVBFE_MODCOD_16APSK_4_5,
109 DVBFE_MODCOD_16APSK_5_6,
110 DVBFE_MODCOD_16APSK_8_9,
111 DVBFE_MODCOD_16APSK_9_10,
112 DVBFE_MODCOD_32APSK_3_4,
113 DVBFE_MODCOD_32APSK_4_5,
114 DVBFE_MODCOD_32APSK_5_6,
115 DVBFE_MODCOD_32APSK_8_9,
116 DVBFE_MODCOD_32APSK_9_10,
117 DVBFE_MODCOD_RESERVED_1,
118 DVBFE_MODCOD_BPSK_1_3,
119 DVBFE_MODCOD_BPSK_1_4,
120 DVBFE_MODCOD_RESERVED_2
121};
122
123enum tuner_param {
124 DVBFE_TUNER_FREQUENCY = (1 << 0),
125 DVBFE_TUNER_TUNERSTEP = (1 << 1),
126 DVBFE_TUNER_IFFREQ = (1 << 2),
127 DVBFE_TUNER_BANDWIDTH = (1 << 3),
128 DVBFE_TUNER_REFCLOCK = (1 << 4),
129 DVBFE_TUNER_IQSENSE = (1 << 5),
130 DVBFE_TUNER_DUMMY = (1 << 31)
131};
132
4f1c1868
MCC
133/**
134 * enum dvbfe_algo - defines the algorithm used to tune into a channel
135 *
136 * @DVBFE_ALGO_HW: (Hardware Algorithm)
137 * Devices that support this algorithm do everything in hardware
138 * and no software support is needed to handle them.
139 * Requesting these devices to LOCK is the only thing required,
140 * device is supposed to do everything in the hardware.
141 *
142 * @DVBFE_ALGO_SW: (Software Algorithm)
c59e7870
MA
143 * These are dumb devices, that require software to do everything
144 *
4f1c1868
MCC
145 * @DVBFE_ALGO_CUSTOM: (Customizable Agorithm)
146 * Devices having this algorithm can be customized to have specific
147 * algorithms in the frontend driver, rather than simply doing a
148 * software zig-zag. In this case the zigzag maybe hardware assisted
149 * or it maybe completely done in hardware. In all cases, usage of
150 * this algorithm, in conjunction with the search and track
151 * callbacks, utilizes the driver specific algorithm.
152 *
153 * @DVBFE_ALGO_RECOVERY: (Recovery Algorithm)
154 * These devices have AUTO recovery capabilities from LOCK failure
c59e7870
MA
155 */
156enum dvbfe_algo {
157 DVBFE_ALGO_HW = (1 << 0),
158 DVBFE_ALGO_SW = (1 << 1),
159 DVBFE_ALGO_CUSTOM = (1 << 2),
160 DVBFE_ALGO_RECOVERY = (1 << 31)
161};
162
163struct tuner_state {
164 u32 frequency;
165 u32 tunerstep;
166 u32 ifreq;
167 u32 bandwidth;
168 u32 iqsense;
169 u32 refclock;
170};
171
4f1c1868
MCC
172/**
173 * enum dvbfe_search - search callback possible return status
c59e7870 174 *
4f1c1868
MCC
175 * @DVBFE_ALGO_SEARCH_SUCCESS:
176 * The frontend search algorithm completed and returned successfully
c59e7870 177 *
4f1c1868
MCC
178 * @DVBFE_ALGO_SEARCH_ASLEEP:
179 * The frontend search algorithm is sleeping
c59e7870 180 *
4f1c1868
MCC
181 * @DVBFE_ALGO_SEARCH_FAILED:
182 * The frontend search for a signal failed
c59e7870 183 *
4f1c1868
MCC
184 * @DVBFE_ALGO_SEARCH_INVALID:
185 * The frontend search algorith was probably supplied with invalid
186 * parameters and the search is an invalid one
c59e7870 187 *
4f1c1868
MCC
188 * @DVBFE_ALGO_SEARCH_ERROR:
189 * The frontend search algorithm failed due to some error
c59e7870 190 *
4f1c1868
MCC
191 * @DVBFE_ALGO_SEARCH_AGAIN:
192 * The frontend search algorithm was requested to search again
c59e7870
MA
193 */
194enum dvbfe_search {
195 DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0),
196 DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1),
197 DVBFE_ALGO_SEARCH_FAILED = (1 << 2),
198 DVBFE_ALGO_SEARCH_INVALID = (1 << 3),
199 DVBFE_ALGO_SEARCH_AGAIN = (1 << 4),
200 DVBFE_ALGO_SEARCH_ERROR = (1 << 31),
201};
202
203
7eef5dd6 204struct dvb_tuner_ops {
f6adb91c 205
7eef5dd6
AQ
206 struct dvb_tuner_info info;
207
7eef5dd6 208 int (*release)(struct dvb_frontend *fe);
7eef5dd6 209 int (*init)(struct dvb_frontend *fe);
7eef5dd6 210 int (*sleep)(struct dvb_frontend *fe);
59d7889a
MCC
211 int (*suspend)(struct dvb_frontend *fe);
212 int (*resume)(struct dvb_frontend *fe);
7eef5dd6 213
f6adb91c 214 /** This is for simple PLLs - set all parameters in one go. */
14d24d14 215 int (*set_params)(struct dvb_frontend *fe);
e18f9444 216 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
7eef5dd6 217
f6adb91c 218 /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
249fa0b0 219 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
7eef5dd6 220
7f171123
MCC
221 /** This is to allow setting tuner-specific configs */
222 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
223
f6adb91c 224 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
7eef5dd6 225 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
8513e144 226 int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
7eef5dd6 227
7eef5dd6 228#define TUNER_STATUS_LOCKED 1
e18f9444 229#define TUNER_STATUS_STEREO 2
7eef5dd6 230 int (*get_status)(struct dvb_frontend *fe, u32 *status);
8fb3b9f7 231 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
1d432a3d 232 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
7eef5dd6 233
3ad2f3fb
DM
234 /** These are provided separately from set_params in order to facilitate silicon
235 * tuners which require sophisticated tuning loops, controlling each parameter separately. */
7eef5dd6 236 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
7eef5dd6 237 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
c59e7870
MA
238
239 /*
3ad2f3fb
DM
240 * These are provided separately from set_params in order to facilitate silicon
241 * tuners which require sophisticated tuning loops, controlling each parameter separately.
c59e7870
MA
242 */
243 int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
244 int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
7eef5dd6
AQ
245};
246
807ffe8d
MK
247struct analog_demod_info {
248 char *name;
249};
250
bc3e5c7f 251struct analog_demod_ops {
807ffe8d
MK
252
253 struct analog_demod_info info;
254
255 void (*set_params)(struct dvb_frontend *fe,
256 struct analog_parameters *params);
dfc2e12d 257 int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
a2192cf4 258 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
807ffe8d
MK
259 void (*tuner_status)(struct dvb_frontend *fe);
260 void (*standby)(struct dvb_frontend *fe);
261 void (*release)(struct dvb_frontend *fe);
262 int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
263
264 /** This is to allow setting tuner-specific configuration */
265 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
266};
267
a689e365
MCC
268struct dtv_frontend_properties;
269
1da177e4
LT
270struct dvb_frontend_ops {
271
272 struct dvb_frontend_info info;
273
eeacf147
MCC
274 u8 delsys[MAX_DELSYS];
275
1da177e4 276 void (*release)(struct dvb_frontend* fe);
94cbae5a 277 void (*release_sec)(struct dvb_frontend* fe);
1da177e4
LT
278
279 int (*init)(struct dvb_frontend* fe);
280 int (*sleep)(struct dvb_frontend* fe);
281
2e4e98e7 282 int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
94cbae5a 283
36cb557a
AQ
284 /* if this is set, it overrides the default swzigzag */
285 int (*tune)(struct dvb_frontend* fe,
7e072221 286 bool re_tune,
36cb557a 287 unsigned int mode_flags,
260f8d7c 288 unsigned int *delay,
0df289a2 289 enum fe_status *status);
0249ef16 290 /* get frontend tuning algorithm from the module */
c59e7870 291 enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
36cb557a
AQ
292
293 /* these two are only used for the swzigzag code */
bc9cd273 294 int (*set_frontend)(struct dvb_frontend *fe);
1da177e4
LT
295 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
296
7c61d80a 297 int (*get_frontend)(struct dvb_frontend *fe);
36cb557a 298
0df289a2 299 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
1da177e4
LT
300 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
301 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
302 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
303 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
304
305 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
306 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
307 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
0df289a2
MCC
308 int (*diseqc_send_burst)(struct dvb_frontend *fe,
309 enum fe_sec_mini_cmd minicmd);
310 int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
311 int (*set_voltage)(struct dvb_frontend *fe,
312 enum fe_sec_voltage voltage);
400b7083
PB
313 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
314 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
611900c1 315 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
ba7e6f3e 316 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
33eebec5 317 int (*set_lna)(struct dvb_frontend *);
7eef5dd6 318
c59e7870
MA
319 /* These callbacks are for devices that implement their own
320 * tuning algorithms, rather than a simple swzigzag
321 */
41da5320 322 enum dvbfe_search (*search)(struct dvb_frontend *fe);
c59e7870 323
7eef5dd6 324 struct dvb_tuner_ops tuner_ops;
bc3e5c7f 325 struct analog_demod_ops analog_ops;
6b73eeaf 326
e7fee0f3
ST
327 int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
328 int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
1da177e4
LT
329};
330
8de8594a 331#ifdef __DVB_CORE__
1da177e4
LT
332#define MAX_EVENT 8
333
334struct dvb_fe_events {
335 struct dvb_frontend_event events[MAX_EVENT];
336 int eventw;
337 int eventr;
338 int overflow;
339 wait_queue_head_t wait_queue;
03b76123 340 struct mutex mtx;
1da177e4 341};
8de8594a 342#endif
1da177e4 343
56f0680a 344struct dtv_frontend_properties {
6b73eeaf
ST
345
346 /* Cache State */
347 u32 state;
348
349 u32 frequency;
0df289a2 350 enum fe_modulation modulation;
6b73eeaf 351
0df289a2
MCC
352 enum fe_sec_voltage voltage;
353 enum fe_sec_tone_mode sectone;
354 enum fe_spectral_inversion inversion;
355 enum fe_code_rate fec_inner;
356 enum fe_transmit_mode transmission_mode;
75b7f943 357 u32 bandwidth_hz; /* 0 = AUTO */
0df289a2
MCC
358 enum fe_guard_interval guard_interval;
359 enum fe_hierarchy hierarchy;
6b73eeaf 360 u32 symbol_rate;
0df289a2
MCC
361 enum fe_code_rate code_rate_HP;
362 enum fe_code_rate code_rate_LP;
6b73eeaf 363
0df289a2
MCC
364 enum fe_pilot pilot;
365 enum fe_rolloff rolloff;
6b73eeaf 366
0df289a2 367 enum fe_delivery_system delivery_system;
b6e760f3 368
224b6642
AP
369 enum fe_interleaving interleaving;
370
b6e760f3
PB
371 /* ISDB-T specifics */
372 u8 isdbt_partial_reception;
373 u8 isdbt_sb_mode;
374 u8 isdbt_sb_subchannel;
375 u32 isdbt_sb_segment_idx;
376 u32 isdbt_sb_segment_count;
377 u8 isdbt_layer_enabled;
378 struct {
379 u8 segment_count;
0df289a2
MCC
380 enum fe_code_rate fec;
381 enum fe_modulation modulation;
b6e760f3
PB
382 u8 interleaving;
383 } layer[3];
98293ef3 384
287cefd0
EP
385 /* Multistream specifics */
386 u32 stream_id;
ca689488
MK
387
388 /* ATSC-MH specifics */
389 u8 atscmh_fic_ver;
390 u8 atscmh_parade_id;
391 u8 atscmh_nog;
392 u8 atscmh_tnog;
393 u8 atscmh_sgn;
394 u8 atscmh_prc;
395
396 u8 atscmh_rs_frame_mode;
397 u8 atscmh_rs_frame_ensemble;
398 u8 atscmh_rs_code_mode_pri;
399 u8 atscmh_rs_code_mode_sec;
400 u8 atscmh_sccc_block_mode;
401 u8 atscmh_sccc_code_mode_a;
402 u8 atscmh_sccc_code_mode_b;
403 u8 atscmh_sccc_code_mode_c;
404 u8 atscmh_sccc_code_mode_d;
33eebec5
AP
405
406 u32 lna;
7cd4ece5
MCC
407
408 /* statistics data */
409 struct dtv_fe_stats strength;
410 struct dtv_fe_stats cnr;
411 struct dtv_fe_stats pre_bit_error;
412 struct dtv_fe_stats pre_bit_count;
413 struct dtv_fe_stats post_bit_error;
414 struct dtv_fe_stats post_bit_count;
415 struct dtv_fe_stats block_error;
416 struct dtv_fe_stats block_count;
6b73eeaf
ST
417};
418
18ed2860
SK
419#define DVB_FE_NO_EXIT 0
420#define DVB_FE_NORMAL_EXIT 1
421#define DVB_FE_DEVICE_REMOVED 2
87cd0fa8 422#define DVB_FE_DEVICE_RESUME 3
18ed2860 423
1da177e4 424struct dvb_frontend {
dea74869 425 struct dvb_frontend_ops ops;
1da177e4 426 struct dvb_adapter *dvb;
482b498d
MK
427 void *demodulator_priv;
428 void *tuner_priv;
429 void *frontend_priv;
430 void *sec_priv;
431 void *analog_demod_priv;
56f0680a 432 struct dtv_frontend_properties dtv_property_cache;
ebb8d68a 433#define DVB_FRONTEND_COMPONENT_TUNER 0
b748e6a9 434#define DVB_FRONTEND_COMPONENT_DEMOD 1
ebb8d68a 435 int (*callback)(void *adapter_priv, int component, int cmd, int arg);
363c35fc 436 int id;
18ed2860 437 unsigned int exit;
1da177e4
LT
438};
439
482b498d
MK
440extern int dvb_register_frontend(struct dvb_adapter *dvb,
441 struct dvb_frontend *fe);
1da177e4 442
482b498d 443extern int dvb_unregister_frontend(struct dvb_frontend *fe);
1da177e4 444
482b498d 445extern void dvb_frontend_detach(struct dvb_frontend *fe);
f52a838b 446
86f40cc3 447extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
06bae122
AP
448extern int dvb_frontend_suspend(struct dvb_frontend *fe);
449extern int dvb_frontend_resume(struct dvb_frontend *fe);
86f40cc3 450
9056a23b 451extern void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
83b75b04 452
1da177e4 453#endif
This page took 0.829246 seconds and 5 git commands to generate.