Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1 | /* |
| 2 | * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver |
| 3 | * |
| 4 | * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | * |
| 20 | * TODO: |
| 21 | * - add smart card reader support for Conditional Access (CA) |
| 22 | * |
| 23 | * Card reader in Anysee is nothing more than ISO 7816 card reader. |
| 24 | * There is no hardware CAM in any Anysee device sold. |
| 25 | * In my understanding it should be implemented by making own module |
Antti Palosaari | 9fdd9ca | 2008-06-11 11:43:19 -0300 | [diff] [blame] | 26 | * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This |
| 27 | * module registers serial interface that can be used to communicate |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 28 | * with any ISO 7816 smart card. |
| 29 | * |
| 30 | * Any help according to implement serial smart card reader support |
| 31 | * is highly welcome! |
| 32 | */ |
| 33 | |
| 34 | #ifndef _DVB_USB_ANYSEE_H_ |
| 35 | #define _DVB_USB_ANYSEE_H_ |
| 36 | |
| 37 | #define DVB_USB_LOG_PREFIX "anysee" |
| 38 | #include "dvb-usb.h" |
| 39 | |
| 40 | #define deb_info(args...) dprintk(dvb_usb_anysee_debug, 0x01, args) |
| 41 | #define deb_xfer(args...) dprintk(dvb_usb_anysee_debug, 0x02, args) |
| 42 | #define deb_rc(args...) dprintk(dvb_usb_anysee_debug, 0x04, args) |
| 43 | #define deb_reg(args...) dprintk(dvb_usb_anysee_debug, 0x08, args) |
| 44 | #define deb_i2c(args...) dprintk(dvb_usb_anysee_debug, 0x10, args) |
| 45 | #define deb_fw(args...) dprintk(dvb_usb_anysee_debug, 0x20, args) |
| 46 | |
| 47 | enum cmd { |
| 48 | CMD_I2C_READ = 0x33, |
| 49 | CMD_I2C_WRITE = 0x31, |
| 50 | CMD_REG_READ = 0xb0, |
| 51 | CMD_REG_WRITE = 0xb1, |
| 52 | CMD_STREAMING_CTRL = 0x12, |
| 53 | CMD_LED_AND_IR_CTRL = 0x16, |
| 54 | CMD_GET_IR_CODE = 0x41, |
| 55 | CMD_GET_HW_INFO = 0x19, |
| 56 | CMD_SMARTCARD = 0x34, |
| 57 | }; |
| 58 | |
| 59 | struct anysee_state { |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 60 | u8 hw; /* PCB ID */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 61 | u8 seq; |
| 62 | }; |
| 63 | |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame^] | 64 | #define ANYSEE_HW_02 2 /* E30 */ |
| 65 | #define ANYSEE_HW_507CD 6 /* E30 Plus */ |
| 66 | #define ANYSEE_HW_507DC 10 /* E30 C Plus */ |
| 67 | #define ANYSEE_HW_507SI 11 /* E30 S2 Plus */ |
| 68 | #define ANYSEE_HW_507FA 15 /* E30 Combo Plus / E30 C Plus */ |
| 69 | #define ANYSEE_HW_508TC 18 /* E7 TC */ |
| 70 | #define ANYSEE_HW_508S2 19 /* E7 S2 */ |
| 71 | #define ANYSEE_HW_508PTC 21 /* E7 PTC Plus */ |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 72 | |
| 73 | #define REG_IOA 0x80 /* Port A (bit addressable) */ |
| 74 | #define REG_IOB 0x90 /* Port B (bit addressable) */ |
| 75 | #define REG_IOC 0xa0 /* Port C (bit addressable) */ |
| 76 | #define REG_IOD 0xb0 /* Port D (bit addressable) */ |
| 77 | #define REG_IOE 0xb1 /* Port E (NOT bit addressable) */ |
| 78 | #define REG_OEA 0xb2 /* Port A Output Enable */ |
| 79 | #define REG_OEB 0xb3 /* Port B Output Enable */ |
| 80 | #define REG_OEC 0xb4 /* Port C Output Enable */ |
| 81 | #define REG_OED 0xb5 /* Port D Output Enable */ |
| 82 | #define REG_OEE 0xb6 /* Port E Output Enable */ |
| 83 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | /*************************************************************************** |
| 87 | * USB API description (reverse engineered) |
| 88 | *************************************************************************** |
| 89 | |
| 90 | Transaction flow: |
| 91 | ================= |
| 92 | BULK[00001] >>> REQUEST PACKET 64 bytes |
| 93 | BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY) |
| 94 | BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY) |
| 95 | |
| 96 | General reply packet(s) are always used if not own reply defined. |
| 97 | |
| 98 | ============================================================================ |
| 99 | | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY) |
| 100 | ============================================================================ |
| 101 | | 00 | reply data (if any) from previous transaction |
| 102 | | | Just same reply packet as returned during previous transaction. |
| 103 | | | Needed only if reply is missed in previous transaction. |
| 104 | | | Just skip normally. |
| 105 | ---------------------------------------------------------------------------- |
| 106 | | 01-59 | don't care |
| 107 | ---------------------------------------------------------------------------- |
| 108 | | 60 | packet sequence number |
| 109 | ---------------------------------------------------------------------------- |
| 110 | | 61-63 | don't care |
| 111 | ---------------------------------------------------------------------------- |
| 112 | |
| 113 | ============================================================================ |
| 114 | | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY) |
| 115 | ============================================================================ |
| 116 | | 00 | reply data (if any) |
| 117 | ---------------------------------------------------------------------------- |
| 118 | | 01-59 | don't care |
| 119 | ---------------------------------------------------------------------------- |
| 120 | | 60 | packet sequence number |
| 121 | ---------------------------------------------------------------------------- |
| 122 | | 61-63 | don't care |
| 123 | ---------------------------------------------------------------------------- |
| 124 | |
| 125 | ============================================================================ |
| 126 | | 00-63 | I2C WRITE REQUEST PACKET |
| 127 | ============================================================================ |
| 128 | | 00 | 0x31 I2C write command |
| 129 | ---------------------------------------------------------------------------- |
| 130 | | 01 | i2c address |
| 131 | ---------------------------------------------------------------------------- |
| 132 | | 02 | data length |
| 133 | | | 0x02 (for typical I2C reg / val pair) |
| 134 | ---------------------------------------------------------------------------- |
| 135 | | 03 | 0x01 |
| 136 | ---------------------------------------------------------------------------- |
| 137 | | 04- | data |
| 138 | ---------------------------------------------------------------------------- |
| 139 | | -59 | don't care |
| 140 | ---------------------------------------------------------------------------- |
| 141 | | 60 | packet sequence number |
| 142 | ---------------------------------------------------------------------------- |
| 143 | | 61-63 | don't care |
| 144 | ---------------------------------------------------------------------------- |
| 145 | |
| 146 | ============================================================================ |
| 147 | | 00-63 | I2C READ REQUEST PACKET |
| 148 | ============================================================================ |
| 149 | | 00 | 0x33 I2C read command |
| 150 | ---------------------------------------------------------------------------- |
| 151 | | 01 | i2c address + 1 |
| 152 | ---------------------------------------------------------------------------- |
| 153 | | 02 | register |
| 154 | ---------------------------------------------------------------------------- |
| 155 | | 03 | 0x00 |
| 156 | ---------------------------------------------------------------------------- |
| 157 | | 04 | 0x00 |
| 158 | ---------------------------------------------------------------------------- |
Antti Palosaari | b3e6a5a | 2011-04-09 21:00:51 -0300 | [diff] [blame] | 159 | | 05 | data length |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 160 | ---------------------------------------------------------------------------- |
| 161 | | 06-59 | don't care |
| 162 | ---------------------------------------------------------------------------- |
| 163 | | 60 | packet sequence number |
| 164 | ---------------------------------------------------------------------------- |
| 165 | | 61-63 | don't care |
| 166 | ---------------------------------------------------------------------------- |
| 167 | |
| 168 | ============================================================================ |
| 169 | | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET |
| 170 | ============================================================================ |
| 171 | | 00 | 0xb1 register write command |
| 172 | ---------------------------------------------------------------------------- |
| 173 | | 01-02 | register |
| 174 | ---------------------------------------------------------------------------- |
| 175 | | 03 | 0x01 |
| 176 | ---------------------------------------------------------------------------- |
| 177 | | 04 | value |
| 178 | ---------------------------------------------------------------------------- |
| 179 | | 05-59 | don't care |
| 180 | ---------------------------------------------------------------------------- |
| 181 | | 60 | packet sequence number |
| 182 | ---------------------------------------------------------------------------- |
| 183 | | 61-63 | don't care |
| 184 | ---------------------------------------------------------------------------- |
| 185 | |
| 186 | ============================================================================ |
| 187 | | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET |
| 188 | ============================================================================ |
| 189 | | 00 | 0xb0 register read command |
| 190 | ---------------------------------------------------------------------------- |
| 191 | | 01-02 | register |
| 192 | ---------------------------------------------------------------------------- |
| 193 | | 03 | 0x01 |
| 194 | ---------------------------------------------------------------------------- |
| 195 | | 04-59 | don't care |
| 196 | ---------------------------------------------------------------------------- |
| 197 | | 60 | packet sequence number |
| 198 | ---------------------------------------------------------------------------- |
| 199 | | 61-63 | don't care |
| 200 | ---------------------------------------------------------------------------- |
| 201 | |
| 202 | ============================================================================ |
| 203 | | 00-63 | LED CONTROL REQUEST PACKET |
| 204 | ============================================================================ |
| 205 | | 00 | 0x16 LED and IR control command |
| 206 | ---------------------------------------------------------------------------- |
| 207 | | 01 | 0x01 (LED) |
| 208 | ---------------------------------------------------------------------------- |
| 209 | | 03 | 0x00 blink |
| 210 | | | 0x01 lights continuously |
| 211 | ---------------------------------------------------------------------------- |
| 212 | | 04 | blink interval |
| 213 | | | 0x00 fastest (looks like LED lights continuously) |
| 214 | | | 0xff slowest |
| 215 | ---------------------------------------------------------------------------- |
| 216 | | 05-59 | don't care |
| 217 | ---------------------------------------------------------------------------- |
| 218 | | 60 | packet sequence number |
| 219 | ---------------------------------------------------------------------------- |
| 220 | | 61-63 | don't care |
| 221 | ---------------------------------------------------------------------------- |
| 222 | |
| 223 | ============================================================================ |
| 224 | | 00-63 | IR CONTROL REQUEST PACKET |
| 225 | ============================================================================ |
| 226 | | 00 | 0x16 LED and IR control command |
| 227 | ---------------------------------------------------------------------------- |
| 228 | | 01 | 0x02 (IR) |
| 229 | ---------------------------------------------------------------------------- |
| 230 | | 03 | 0x00 IR disabled |
| 231 | | | 0x01 IR enabled |
| 232 | ---------------------------------------------------------------------------- |
| 233 | | 04-59 | don't care |
| 234 | ---------------------------------------------------------------------------- |
| 235 | | 60 | packet sequence number |
| 236 | ---------------------------------------------------------------------------- |
| 237 | | 61-63 | don't care |
| 238 | ---------------------------------------------------------------------------- |
| 239 | |
| 240 | ============================================================================ |
| 241 | | 00-63 | STREAMING CONTROL REQUEST PACKET |
| 242 | ============================================================================ |
| 243 | | 00 | 0x12 streaming control command |
| 244 | ---------------------------------------------------------------------------- |
| 245 | | 01 | 0x00 streaming disabled |
| 246 | | | 0x01 streaming enabled |
| 247 | ---------------------------------------------------------------------------- |
| 248 | | 02 | 0x00 |
| 249 | ---------------------------------------------------------------------------- |
| 250 | | 03-59 | don't care |
| 251 | ---------------------------------------------------------------------------- |
| 252 | | 60 | packet sequence number |
| 253 | ---------------------------------------------------------------------------- |
| 254 | | 61-63 | don't care |
| 255 | ---------------------------------------------------------------------------- |
| 256 | |
| 257 | ============================================================================ |
| 258 | | 00-63 | REMOTE CONTROL REQUEST PACKET |
| 259 | ============================================================================ |
| 260 | | 00 | 0x41 remote control command |
| 261 | ---------------------------------------------------------------------------- |
| 262 | | 01-59 | don't care |
| 263 | ---------------------------------------------------------------------------- |
| 264 | | 60 | packet sequence number |
| 265 | ---------------------------------------------------------------------------- |
| 266 | | 61-63 | don't care |
| 267 | ---------------------------------------------------------------------------- |
| 268 | |
| 269 | ============================================================================ |
| 270 | | 00-63 | REMOTE CONTROL REPLY PACKET |
| 271 | ============================================================================ |
| 272 | | 00 | 0x00 code not received |
| 273 | | | 0x01 code received |
| 274 | ---------------------------------------------------------------------------- |
| 275 | | 01 | remote control code |
| 276 | ---------------------------------------------------------------------------- |
| 277 | | 02-59 | don't care |
| 278 | ---------------------------------------------------------------------------- |
| 279 | | 60 | packet sequence number |
| 280 | ---------------------------------------------------------------------------- |
| 281 | | 61-63 | don't care |
| 282 | ---------------------------------------------------------------------------- |
| 283 | |
| 284 | ============================================================================ |
| 285 | | 00-63 | GET HARDWARE INFO REQUEST PACKET |
| 286 | ============================================================================ |
| 287 | | 00 | 0x19 get hardware info command |
| 288 | ---------------------------------------------------------------------------- |
| 289 | | 01-59 | don't care |
| 290 | ---------------------------------------------------------------------------- |
| 291 | | 60 | packet sequence number |
| 292 | ---------------------------------------------------------------------------- |
| 293 | | 61-63 | don't care |
| 294 | ---------------------------------------------------------------------------- |
| 295 | |
| 296 | ============================================================================ |
| 297 | | 00-63 | GET HARDWARE INFO REPLY PACKET |
| 298 | ============================================================================ |
| 299 | | 00 | hardware id |
| 300 | ---------------------------------------------------------------------------- |
| 301 | | 01-02 | firmware version |
| 302 | ---------------------------------------------------------------------------- |
| 303 | | 03-59 | don't care |
| 304 | ---------------------------------------------------------------------------- |
| 305 | | 60 | packet sequence number |
| 306 | ---------------------------------------------------------------------------- |
| 307 | | 61-63 | don't care |
| 308 | ---------------------------------------------------------------------------- |
| 309 | |
| 310 | ============================================================================ |
| 311 | | 00-63 | SMART CARD READER PACKET |
| 312 | ============================================================================ |
| 313 | | 00 | 0x34 smart card reader command |
| 314 | ---------------------------------------------------------------------------- |
| 315 | | xx | |
| 316 | ---------------------------------------------------------------------------- |
| 317 | | xx-59 | don't care |
| 318 | ---------------------------------------------------------------------------- |
| 319 | | 60 | packet sequence number |
| 320 | ---------------------------------------------------------------------------- |
| 321 | | 61-63 | don't care |
| 322 | ---------------------------------------------------------------------------- |
| 323 | |
| 324 | */ |