blob: 51d4e043716c19f37899566ee0f3bf97539fb685 [file] [log] [blame]
Johannes Stezenbach50b215a2005-05-16 21:54:41 -07001/*
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
Manu Abrahamd28d5762005-11-08 21:35:36 -080025#include <linux/smp_lock.h>
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070026#include <linux/dvb/frontend.h>
27#include <linux/device.h>
Ingo Molnar3593cab2006-02-07 06:49:14 -020028#include <linux/mutex.h>
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070029#include "bt878.h"
30
31#include "dst_ca.h"
32
33
34#define NO_DELAY 0
35#define LONG_DELAY 1
36#define DEVICE_INIT 2
37
38#define DELAY 1
39
40#define DST_TYPE_IS_SAT 0
41#define DST_TYPE_IS_TERR 1
42#define DST_TYPE_IS_CABLE 2
43#define DST_TYPE_IS_ATSC 3
44
45#define DST_TYPE_HAS_NEWTUNE 1
46#define DST_TYPE_HAS_TS204 2
47#define DST_TYPE_HAS_SYMDIV 4
48#define DST_TYPE_HAS_FW_1 8
49#define DST_TYPE_HAS_FW_2 16
50#define DST_TYPE_HAS_FW_3 32
Johannes Stezenbach8385e462005-05-16 21:54:43 -070051#define DST_TYPE_HAS_FW_BUILD 64
Manu Abraham7d534212005-07-07 17:57:50 -070052#define DST_TYPE_HAS_OBS_REGS 128
53#define DST_TYPE_HAS_INC_COUNT 256
Manu Abraham29b2f782005-11-08 21:35:09 -080054#define DST_TYPE_HAS_MULTI_FE 512
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070055
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070056/* Card capability list */
57
58#define DST_TYPE_HAS_MAC 1
59#define DST_TYPE_HAS_DISEQC3 2
60#define DST_TYPE_HAS_DISEQC4 4
61#define DST_TYPE_HAS_DISEQC5 8
62#define DST_TYPE_HAS_MOTO 16
63#define DST_TYPE_HAS_CA 32
64#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
Johannes Stezenbach4a2cc122005-05-16 21:54:45 -070065#define DST_TYPE_HAS_SESSION 128
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070066
Johannes Stezenbach50b215a2005-05-16 21:54:41 -070067#define RDC_8820_PIO_0_DISABLE 0
68#define RDC_8820_PIO_0_ENABLE 1
69#define RDC_8820_INT 2
70#define RDC_8820_RESET 4
71
72/* DST Communication */
73#define GET_REPLY 1
74#define NO_REPLY 0
75
76#define GET_ACK 1
77#define FIXED_COMM 8
78
79#define ACK 0xff
80
81struct dst_state {
82
83 struct i2c_adapter* i2c;
84
85 struct bt878* bt;
86
87 struct dvb_frontend_ops ops;
88
89 /* configuration settings */
90 const struct dst_config* config;
91
92 struct dvb_frontend frontend;
93
94 /* private ASIC data */
95 u8 tx_tuna[10];
96 u8 rx_tuna[10];
97 u8 rxbuffer[10];
98 u8 diseq_flags;
99 u8 dst_type;
100 u32 type_flags;
101 u32 frequency; /* intermediate frequency in kHz for QPSK */
102 fe_spectral_inversion_t inversion;
103 u32 symbol_rate; /* symbol rate in Symbols per second */
104 fe_code_rate_t fec;
105 fe_sec_voltage_t voltage;
106 fe_sec_tone_mode_t tone;
107 u32 decode_freq;
108 u8 decode_lock;
109 u16 decode_strength;
110 u16 decode_snr;
111 unsigned long cur_jiff;
112 u8 k22;
113 fe_bandwidth_t bandwidth;
Johannes Stezenbach4a2cc122005-05-16 21:54:45 -0700114 u32 dst_hw_cap;
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700115 u8 dst_fw_version;
116 fe_sec_mini_cmd_t minicmd;
Manu Abraham7d534212005-07-07 17:57:50 -0700117 fe_modulation_t modulation;
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700118 u8 messages[256];
Manu Abraham62121b12005-09-09 13:03:01 -0700119 u8 mac_address[8];
120 u8 fw_version[8];
121 u8 card_info[8];
122 u8 vendor[8];
Manu Abraham29b2f782005-11-08 21:35:09 -0800123 u8 board_info[8];
Manu Abrahamd28d5762005-11-08 21:35:36 -0800124
Ingo Molnar3593cab2006-02-07 06:49:14 -0200125 struct mutex dst_mutex;
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700126};
127
128struct dst_types {
129 char *device_id;
130 int offset;
131 u8 dst_type;
Johannes Stezenbach4a2cc122005-05-16 21:54:45 -0700132 u32 type_flags;
133 u32 dst_feature;
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700134};
135
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700136struct dst_config
137{
138 /* the ASIC i2c address */
139 u8 demod_address;
140};
141
Johannes Stezenbach50b215a2005-05-16 21:54:41 -0700142int rdc_reset_state(struct dst_state *state);
143int rdc_8820_reset(struct dst_state *state);
144
145int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
146int dst_pio_enable(struct dst_state *state);
147int dst_pio_disable(struct dst_state *state);
148int dst_error_recovery(struct dst_state* state);
149int dst_error_bailout(struct dst_state *state);
150int dst_comm_init(struct dst_state* state);
151
152int write_dst(struct dst_state *state, u8 * data, u8 len);
153int read_dst(struct dst_state *state, u8 * ret, u8 len);
154u8 dst_check_sum(u8 * buf, u32 len);
155struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
156int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
157int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
158
159int dst_command(struct dst_state* state, u8 * data, u8 len);
160
161
162#endif // DST_COMMON_H