V4L/DVB (4028): Change dvb_frontend_ops to be a real field instead of a pointer field...
[linux-block.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>
38
39#include <linux/dvb/frontend.h>
40
41#include "dvbdev.h"
42
1da177e4 43struct dvb_frontend_tune_settings {
afd1a0c9
MCC
44 int min_delay_ms;
45 int step_size;
46 int max_drift;
47 struct dvb_frontend_parameters parameters;
1da177e4
LT
48};
49
50struct dvb_frontend;
51
7eef5dd6
AQ
52struct dvb_tuner_info {
53 char name[128];
54
55 u32 frequency_min;
56 u32 frequency_max;
57 u32 frequency_step;
58
59 u32 bandwidth_min;
60 u32 bandwidth_max;
61 u32 bandwidth_step;
62};
63
64struct dvb_tuner_ops {
f6adb91c 65
7eef5dd6
AQ
66 struct dvb_tuner_info info;
67
7eef5dd6 68 int (*release)(struct dvb_frontend *fe);
7eef5dd6 69 int (*init)(struct dvb_frontend *fe);
7eef5dd6
AQ
70 int (*sleep)(struct dvb_frontend *fe);
71
f6adb91c 72 /** This is for simple PLLs - set all parameters in one go. */
7eef5dd6
AQ
73 int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
74
f6adb91c
AQ
75 /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
76 int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
7eef5dd6 77
f6adb91c 78 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
7eef5dd6
AQ
79 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
80
7eef5dd6
AQ
81#define TUNER_STATUS_LOCKED 1
82 int (*get_status)(struct dvb_frontend *fe, u32 *status);
83
f6adb91c
AQ
84 /** These are provided seperately from set_params in order to facilitate silicon
85 * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
7eef5dd6 86 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
7eef5dd6
AQ
87 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
88};
89
1da177e4
LT
90struct dvb_frontend_ops {
91
92 struct dvb_frontend_info info;
93
94 void (*release)(struct dvb_frontend* fe);
95
96 int (*init)(struct dvb_frontend* fe);
97 int (*sleep)(struct dvb_frontend* fe);
98
36cb557a
AQ
99 /* if this is set, it overrides the default swzigzag */
100 int (*tune)(struct dvb_frontend* fe,
101 struct dvb_frontend_parameters* params,
102 unsigned int mode_flags,
103 int *delay,
104 fe_status_t *status);
105
106 /* these two are only used for the swzigzag code */
1da177e4 107 int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
1da177e4
LT
108 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
109
36cb557a
AQ
110 int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
111
1da177e4
LT
112 int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
113 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
114 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
115 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
116 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
117
118 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
119 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
120 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
121 int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
122 int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
123 int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
400b7083
PB
124 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
125 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
611900c1 126 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
7eef5dd6
AQ
127
128 struct dvb_tuner_ops tuner_ops;
1da177e4
LT
129};
130
131#define MAX_EVENT 8
132
133struct dvb_fe_events {
134 struct dvb_frontend_event events[MAX_EVENT];
135 int eventw;
136 int eventr;
137 int overflow;
138 wait_queue_head_t wait_queue;
139 struct semaphore sem;
140};
141
142struct dvb_frontend {
dea74869 143 struct dvb_frontend_ops ops;
1da177e4
LT
144 struct dvb_adapter *dvb;
145 void* demodulator_priv;
7eef5dd6 146 void* tuner_priv;
1da177e4 147 void* frontend_priv;
2f27bdce 148 void* misc_priv;
1da177e4
LT
149};
150
151extern int dvb_register_frontend(struct dvb_adapter* dvb,
152 struct dvb_frontend* fe);
153
154extern int dvb_unregister_frontend(struct dvb_frontend* fe);
155
86f40cc3
AQ
156extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
157
83b75b04
N
158extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
159extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
160
1da177e4 161#endif