[PATCH] dvb: dst: protect the read/write commands with a mutex
[linux-2.6-block.git] / drivers / media / dvb / bt8xx / dst_common.h
CommitLineData
50b215a0
JS
1/*
2 Frontend-driver for TwinHan DST Frontend
3
4 Copyright (C) 2003 Jamie Honan
5 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef DST_COMMON_H
23#define DST_COMMON_H
24
d28d5762 25#include <linux/smp_lock.h>
50b215a0
JS
26#include <linux/dvb/frontend.h>
27#include <linux/device.h>
28#include "bt878.h"
29
30#include "dst_ca.h"
31
32
33#define NO_DELAY 0
34#define LONG_DELAY 1
35#define DEVICE_INIT 2
36
37#define DELAY 1
38
39#define DST_TYPE_IS_SAT 0
40#define DST_TYPE_IS_TERR 1
41#define DST_TYPE_IS_CABLE 2
42#define DST_TYPE_IS_ATSC 3
43
44#define DST_TYPE_HAS_NEWTUNE 1
45#define DST_TYPE_HAS_TS204 2
46#define DST_TYPE_HAS_SYMDIV 4
47#define DST_TYPE_HAS_FW_1 8
48#define DST_TYPE_HAS_FW_2 16
49#define DST_TYPE_HAS_FW_3 32
8385e46f 50#define DST_TYPE_HAS_FW_BUILD 64
7d53421c
MA
51#define DST_TYPE_HAS_OBS_REGS 128
52#define DST_TYPE_HAS_INC_COUNT 256
29b2f784 53#define DST_TYPE_HAS_MULTI_FE 512
50b215a0 54
50b215a0
JS
55/* Card capability list */
56
57#define DST_TYPE_HAS_MAC 1
58#define DST_TYPE_HAS_DISEQC3 2
59#define DST_TYPE_HAS_DISEQC4 4
60#define DST_TYPE_HAS_DISEQC5 8
61#define DST_TYPE_HAS_MOTO 16
62#define DST_TYPE_HAS_CA 32
63#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
4a2cc126 64#define DST_TYPE_HAS_SESSION 128
50b215a0 65
50b215a0
JS
66#define RDC_8820_PIO_0_DISABLE 0
67#define RDC_8820_PIO_0_ENABLE 1
68#define RDC_8820_INT 2
69#define RDC_8820_RESET 4
70
71/* DST Communication */
72#define GET_REPLY 1
73#define NO_REPLY 0
74
75#define GET_ACK 1
76#define FIXED_COMM 8
77
78#define ACK 0xff
79
80struct dst_state {
81
82 struct i2c_adapter* i2c;
83
84 struct bt878* bt;
85
86 struct dvb_frontend_ops ops;
87
88 /* configuration settings */
89 const struct dst_config* config;
90
91 struct dvb_frontend frontend;
92
93 /* private ASIC data */
94 u8 tx_tuna[10];
95 u8 rx_tuna[10];
96 u8 rxbuffer[10];
97 u8 diseq_flags;
98 u8 dst_type;
99 u32 type_flags;
100 u32 frequency; /* intermediate frequency in kHz for QPSK */
101 fe_spectral_inversion_t inversion;
102 u32 symbol_rate; /* symbol rate in Symbols per second */
103 fe_code_rate_t fec;
104 fe_sec_voltage_t voltage;
105 fe_sec_tone_mode_t tone;
106 u32 decode_freq;
107 u8 decode_lock;
108 u16 decode_strength;
109 u16 decode_snr;
110 unsigned long cur_jiff;
111 u8 k22;
112 fe_bandwidth_t bandwidth;
4a2cc126 113 u32 dst_hw_cap;
50b215a0
JS
114 u8 dst_fw_version;
115 fe_sec_mini_cmd_t minicmd;
7d53421c 116 fe_modulation_t modulation;
50b215a0 117 u8 messages[256];
62121b1f
MA
118 u8 mac_address[8];
119 u8 fw_version[8];
120 u8 card_info[8];
121 u8 vendor[8];
29b2f784 122 u8 board_info[8];
d28d5762
MA
123
124 struct semaphore dst_mutex;
50b215a0
JS
125};
126
127struct dst_types {
128 char *device_id;
129 int offset;
130 u8 dst_type;
4a2cc126
JS
131 u32 type_flags;
132 u32 dst_feature;
50b215a0
JS
133};
134
50b215a0
JS
135struct dst_config
136{
137 /* the ASIC i2c address */
138 u8 demod_address;
139};
140
50b215a0
JS
141int rdc_reset_state(struct dst_state *state);
142int rdc_8820_reset(struct dst_state *state);
143
144int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
145int dst_pio_enable(struct dst_state *state);
146int dst_pio_disable(struct dst_state *state);
147int dst_error_recovery(struct dst_state* state);
148int dst_error_bailout(struct dst_state *state);
149int dst_comm_init(struct dst_state* state);
150
151int write_dst(struct dst_state *state, u8 * data, u8 len);
152int read_dst(struct dst_state *state, u8 * ret, u8 len);
153u8 dst_check_sum(u8 * buf, u32 len);
154struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
155int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
156int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
157
158int dst_command(struct dst_state* state, u8 * data, u8 len);
159
160
161#endif // DST_COMMON_H