Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 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 | |
| 25 | #include <linux/dvb/frontend.h> |
| 26 | #include <linux/device.h> |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 27 | #include <linux/mutex.h> |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 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 | |
Manu Abraham | 7ef53b1 | 2006-06-21 10:41:41 -0300 | [diff] [blame] | 44 | #define DST_TYPE_HAS_TS188 1 |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 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 |
Johannes Stezenbach | 8385e46 | 2005-05-16 21:54:43 -0700 | [diff] [blame] | 50 | #define DST_TYPE_HAS_FW_BUILD 64 |
Manu Abraham | 7d53421 | 2005-07-07 17:57:50 -0700 | [diff] [blame] | 51 | #define DST_TYPE_HAS_OBS_REGS 128 |
| 52 | #define DST_TYPE_HAS_INC_COUNT 256 |
Manu Abraham | 29b2f78 | 2005-11-08 21:35:09 -0800 | [diff] [blame] | 53 | #define DST_TYPE_HAS_MULTI_FE 512 |
Manu Abraham | 1da5e8d | 2006-06-21 10:28:05 -0300 | [diff] [blame] | 54 | #define DST_TYPE_HAS_NEWTUNE_2 1024 |
Manu Abraham | 5aef20a | 2006-06-21 10:28:16 -0300 | [diff] [blame] | 55 | #define DST_TYPE_HAS_DBOARD 2048 |
Manu Abraham | cdd4208 | 2006-06-21 10:41:45 -0300 | [diff] [blame] | 56 | #define DST_TYPE_HAS_VLF 4096 |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 57 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 58 | /* Card capability list */ |
| 59 | |
| 60 | #define DST_TYPE_HAS_MAC 1 |
| 61 | #define DST_TYPE_HAS_DISEQC3 2 |
| 62 | #define DST_TYPE_HAS_DISEQC4 4 |
| 63 | #define DST_TYPE_HAS_DISEQC5 8 |
| 64 | #define DST_TYPE_HAS_MOTO 16 |
| 65 | #define DST_TYPE_HAS_CA 32 |
| 66 | #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ |
Johannes Stezenbach | 4a2cc12 | 2005-05-16 21:54:45 -0700 | [diff] [blame] | 67 | #define DST_TYPE_HAS_SESSION 128 |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 68 | |
Manu Abraham | 396cffd | 2006-06-21 10:27:49 -0300 | [diff] [blame] | 69 | #define TUNER_TYPE_MULTI 1 |
Manu Abraham | 4e7024b | 2006-06-21 10:28:09 -0300 | [diff] [blame] | 70 | #define TUNER_TYPE_UNKNOWN 2 |
Manu Abraham | 364f255 | 2006-06-21 10:28:01 -0300 | [diff] [blame] | 71 | /* DVB-S */ |
Manu Abraham | 4e7024b | 2006-06-21 10:28:09 -0300 | [diff] [blame] | 72 | #define TUNER_TYPE_L64724 4 |
| 73 | #define TUNER_TYPE_STV0299 8 |
| 74 | #define TUNER_TYPE_MB86A15 16 |
| 75 | |
| 76 | /* DVB-T */ |
| 77 | #define TUNER_TYPE_TDA10046 32 |
Manu Abraham | 396cffd | 2006-06-21 10:27:49 -0300 | [diff] [blame] | 78 | |
Manu Abraham | 364f255 | 2006-06-21 10:28:01 -0300 | [diff] [blame] | 79 | /* ATSC */ |
Manu Abraham | 4e7024b | 2006-06-21 10:28:09 -0300 | [diff] [blame] | 80 | #define TUNER_TYPE_NXT200x 64 |
Manu Abraham | 364f255 | 2006-06-21 10:28:01 -0300 | [diff] [blame] | 81 | |
| 82 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 83 | #define RDC_8820_PIO_0_DISABLE 0 |
| 84 | #define RDC_8820_PIO_0_ENABLE 1 |
| 85 | #define RDC_8820_INT 2 |
| 86 | #define RDC_8820_RESET 4 |
| 87 | |
| 88 | /* DST Communication */ |
| 89 | #define GET_REPLY 1 |
| 90 | #define NO_REPLY 0 |
| 91 | |
| 92 | #define GET_ACK 1 |
| 93 | #define FIXED_COMM 8 |
| 94 | |
| 95 | #define ACK 0xff |
| 96 | |
| 97 | struct dst_state { |
| 98 | |
| 99 | struct i2c_adapter* i2c; |
| 100 | |
| 101 | struct bt878* bt; |
| 102 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 103 | /* configuration settings */ |
| 104 | const struct dst_config* config; |
| 105 | |
| 106 | struct dvb_frontend frontend; |
| 107 | |
| 108 | /* private ASIC data */ |
| 109 | u8 tx_tuna[10]; |
| 110 | u8 rx_tuna[10]; |
| 111 | u8 rxbuffer[10]; |
| 112 | u8 diseq_flags; |
| 113 | u8 dst_type; |
| 114 | u32 type_flags; |
| 115 | u32 frequency; /* intermediate frequency in kHz for QPSK */ |
| 116 | fe_spectral_inversion_t inversion; |
| 117 | u32 symbol_rate; /* symbol rate in Symbols per second */ |
| 118 | fe_code_rate_t fec; |
| 119 | fe_sec_voltage_t voltage; |
| 120 | fe_sec_tone_mode_t tone; |
| 121 | u32 decode_freq; |
| 122 | u8 decode_lock; |
| 123 | u16 decode_strength; |
| 124 | u16 decode_snr; |
| 125 | unsigned long cur_jiff; |
| 126 | u8 k22; |
| 127 | fe_bandwidth_t bandwidth; |
Johannes Stezenbach | 4a2cc12 | 2005-05-16 21:54:45 -0700 | [diff] [blame] | 128 | u32 dst_hw_cap; |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 129 | u8 dst_fw_version; |
| 130 | fe_sec_mini_cmd_t minicmd; |
Manu Abraham | 7d53421 | 2005-07-07 17:57:50 -0700 | [diff] [blame] | 131 | fe_modulation_t modulation; |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 132 | u8 messages[256]; |
Manu Abraham | 62121b1 | 2005-09-09 13:03:01 -0700 | [diff] [blame] | 133 | u8 mac_address[8]; |
| 134 | u8 fw_version[8]; |
| 135 | u8 card_info[8]; |
| 136 | u8 vendor[8]; |
Manu Abraham | 29b2f78 | 2005-11-08 21:35:09 -0800 | [diff] [blame] | 137 | u8 board_info[8]; |
Manu Abraham | 396cffd | 2006-06-21 10:27:49 -0300 | [diff] [blame] | 138 | u32 tuner_type; |
Manu Abraham | b633c6d | 2006-06-21 10:27:53 -0300 | [diff] [blame] | 139 | char *tuner_name; |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 140 | struct mutex dst_mutex; |
Manu Abraham | 63ad4e4 | 2006-06-21 10:41:37 -0300 | [diff] [blame] | 141 | u8 fw_name[8]; |
Manu Abraham | bbdd11f | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 142 | struct dvb_device *dst_ca; |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
Manu Abraham | b633c6d | 2006-06-21 10:27:53 -0300 | [diff] [blame] | 145 | struct tuner_types { |
| 146 | u32 tuner_type; |
| 147 | char *tuner_name; |
Manu Abraham | 364f255 | 2006-06-21 10:28:01 -0300 | [diff] [blame] | 148 | char *board_name; |
Manu Abraham | 4e7024b | 2006-06-21 10:28:09 -0300 | [diff] [blame] | 149 | char *fw_name; |
Manu Abraham | b633c6d | 2006-06-21 10:27:53 -0300 | [diff] [blame] | 150 | }; |
| 151 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 152 | struct dst_types { |
| 153 | char *device_id; |
| 154 | int offset; |
| 155 | u8 dst_type; |
Johannes Stezenbach | 4a2cc12 | 2005-05-16 21:54:45 -0700 | [diff] [blame] | 156 | u32 type_flags; |
| 157 | u32 dst_feature; |
Manu Abraham | 396cffd | 2006-06-21 10:27:49 -0300 | [diff] [blame] | 158 | u32 tuner_type; |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 161 | struct dst_config |
| 162 | { |
| 163 | /* the ASIC i2c address */ |
| 164 | u8 demod_address; |
| 165 | }; |
| 166 | |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 167 | int rdc_reset_state(struct dst_state *state); |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 168 | |
| 169 | int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode); |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 170 | int dst_pio_disable(struct dst_state *state); |
| 171 | int dst_error_recovery(struct dst_state* state); |
| 172 | int dst_error_bailout(struct dst_state *state); |
| 173 | int dst_comm_init(struct dst_state* state); |
| 174 | |
| 175 | int write_dst(struct dst_state *state, u8 * data, u8 len); |
| 176 | int read_dst(struct dst_state *state, u8 * ret, u8 len); |
| 177 | u8 dst_check_sum(u8 * buf, u32 len); |
| 178 | struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter); |
Manu Abraham | bbdd11f | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 179 | struct dvb_device *dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter); |
Johannes Stezenbach | 50b215a | 2005-05-16 21:54:41 -0700 | [diff] [blame] | 180 | |
| 181 | |
| 182 | #endif // DST_COMMON_H |