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" |
Antti Palosaari | a4e7c51 | 2012-06-14 04:56:09 -0300 | [diff] [blame^] | 38 | #include "dvb_usb.h" |
Antti Palosaari | 05cd37d | 2011-09-05 23:33:04 -0300 | [diff] [blame] | 39 | #include "dvb_ca_en50221.h" |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 40 | |
Antti Palosaari | a4e7c51 | 2012-06-14 04:56:09 -0300 | [diff] [blame^] | 41 | #ifdef CONFIG_DVB_USB_DEBUG |
| 42 | #define dprintk(var, level, args...) \ |
| 43 | do { if ((var & level)) printk(args); } while (0) |
| 44 | #define DVB_USB_DEBUG_STATUS |
| 45 | #else |
| 46 | #define dprintk(args...) |
| 47 | #define debug_dump(b, l, func) |
| 48 | #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" |
| 49 | #endif |
| 50 | |
| 51 | #define debug_dump(b, l, func) {\ |
| 52 | int loop_; \ |
| 53 | for (loop_ = 0; loop_ < l; loop_++) \ |
| 54 | func("%02x ", b[loop_]); \ |
| 55 | func("\n");\ |
| 56 | } |
| 57 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 58 | #define deb_info(args...) dprintk(dvb_usb_anysee_debug, 0x01, args) |
| 59 | #define deb_xfer(args...) dprintk(dvb_usb_anysee_debug, 0x02, args) |
| 60 | #define deb_rc(args...) dprintk(dvb_usb_anysee_debug, 0x04, args) |
| 61 | #define deb_reg(args...) dprintk(dvb_usb_anysee_debug, 0x08, args) |
| 62 | #define deb_i2c(args...) dprintk(dvb_usb_anysee_debug, 0x10, args) |
| 63 | #define deb_fw(args...) dprintk(dvb_usb_anysee_debug, 0x20, args) |
| 64 | |
Antti Palosaari | a4e7c51 | 2012-06-14 04:56:09 -0300 | [diff] [blame^] | 65 | #undef err |
| 66 | #define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 67 | #undef info |
| 68 | #define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 69 | #undef warn |
| 70 | #define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) |
| 71 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 72 | enum cmd { |
| 73 | CMD_I2C_READ = 0x33, |
| 74 | CMD_I2C_WRITE = 0x31, |
| 75 | CMD_REG_READ = 0xb0, |
| 76 | CMD_REG_WRITE = 0xb1, |
| 77 | CMD_STREAMING_CTRL = 0x12, |
| 78 | CMD_LED_AND_IR_CTRL = 0x16, |
| 79 | CMD_GET_IR_CODE = 0x41, |
| 80 | CMD_GET_HW_INFO = 0x19, |
| 81 | CMD_SMARTCARD = 0x34, |
Antti Palosaari | 05cd37d | 2011-09-05 23:33:04 -0300 | [diff] [blame] | 82 | CMD_CI = 0x37, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | struct anysee_state { |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 86 | u8 hw; /* PCB ID */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 87 | u8 seq; |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 88 | u8 fe_id:1; /* frondend ID */ |
Antti Palosaari | 05cd37d | 2011-09-05 23:33:04 -0300 | [diff] [blame] | 89 | u8 has_ci:1; |
| 90 | struct dvb_ca_en50221 ci; |
| 91 | unsigned long ci_cam_ready; /* jiffies */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 92 | }; |
| 93 | |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 94 | #define ANYSEE_HW_507T 2 /* E30 */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 95 | #define ANYSEE_HW_507CD 6 /* E30 Plus */ |
| 96 | #define ANYSEE_HW_507DC 10 /* E30 C Plus */ |
| 97 | #define ANYSEE_HW_507SI 11 /* E30 S2 Plus */ |
| 98 | #define ANYSEE_HW_507FA 15 /* E30 Combo Plus / E30 C Plus */ |
| 99 | #define ANYSEE_HW_508TC 18 /* E7 TC */ |
| 100 | #define ANYSEE_HW_508S2 19 /* E7 S2 */ |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame] | 101 | #define ANYSEE_HW_508T2C 20 /* E7 T2C */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 102 | #define ANYSEE_HW_508PTC 21 /* E7 PTC Plus */ |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 103 | #define ANYSEE_HW_508PS2 22 /* E7 PS2 Plus */ |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 104 | |
| 105 | #define REG_IOA 0x80 /* Port A (bit addressable) */ |
| 106 | #define REG_IOB 0x90 /* Port B (bit addressable) */ |
| 107 | #define REG_IOC 0xa0 /* Port C (bit addressable) */ |
| 108 | #define REG_IOD 0xb0 /* Port D (bit addressable) */ |
| 109 | #define REG_IOE 0xb1 /* Port E (NOT bit addressable) */ |
| 110 | #define REG_OEA 0xb2 /* Port A Output Enable */ |
| 111 | #define REG_OEB 0xb3 /* Port B Output Enable */ |
| 112 | #define REG_OEC 0xb4 /* Port C Output Enable */ |
| 113 | #define REG_OED 0xb5 /* Port D Output Enable */ |
| 114 | #define REG_OEE 0xb6 /* Port E Output Enable */ |
| 115 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 116 | #endif |
| 117 | |
| 118 | /*************************************************************************** |
| 119 | * USB API description (reverse engineered) |
| 120 | *************************************************************************** |
| 121 | |
| 122 | Transaction flow: |
| 123 | ================= |
| 124 | BULK[00001] >>> REQUEST PACKET 64 bytes |
| 125 | BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY) |
| 126 | BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY) |
| 127 | |
| 128 | General reply packet(s) are always used if not own reply defined. |
| 129 | |
| 130 | ============================================================================ |
| 131 | | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY) |
| 132 | ============================================================================ |
| 133 | | 00 | reply data (if any) from previous transaction |
| 134 | | | Just same reply packet as returned during previous transaction. |
| 135 | | | Needed only if reply is missed in previous transaction. |
| 136 | | | Just skip normally. |
| 137 | ---------------------------------------------------------------------------- |
| 138 | | 01-59 | don't care |
| 139 | ---------------------------------------------------------------------------- |
| 140 | | 60 | packet sequence number |
| 141 | ---------------------------------------------------------------------------- |
| 142 | | 61-63 | don't care |
| 143 | ---------------------------------------------------------------------------- |
| 144 | |
| 145 | ============================================================================ |
| 146 | | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY) |
| 147 | ============================================================================ |
| 148 | | 00 | reply data (if any) |
| 149 | ---------------------------------------------------------------------------- |
| 150 | | 01-59 | don't care |
| 151 | ---------------------------------------------------------------------------- |
| 152 | | 60 | packet sequence number |
| 153 | ---------------------------------------------------------------------------- |
| 154 | | 61-63 | don't care |
| 155 | ---------------------------------------------------------------------------- |
| 156 | |
| 157 | ============================================================================ |
| 158 | | 00-63 | I2C WRITE REQUEST PACKET |
| 159 | ============================================================================ |
| 160 | | 00 | 0x31 I2C write command |
| 161 | ---------------------------------------------------------------------------- |
| 162 | | 01 | i2c address |
| 163 | ---------------------------------------------------------------------------- |
| 164 | | 02 | data length |
| 165 | | | 0x02 (for typical I2C reg / val pair) |
| 166 | ---------------------------------------------------------------------------- |
| 167 | | 03 | 0x01 |
| 168 | ---------------------------------------------------------------------------- |
| 169 | | 04- | data |
| 170 | ---------------------------------------------------------------------------- |
| 171 | | -59 | don't care |
| 172 | ---------------------------------------------------------------------------- |
| 173 | | 60 | packet sequence number |
| 174 | ---------------------------------------------------------------------------- |
| 175 | | 61-63 | don't care |
| 176 | ---------------------------------------------------------------------------- |
| 177 | |
| 178 | ============================================================================ |
| 179 | | 00-63 | I2C READ REQUEST PACKET |
| 180 | ============================================================================ |
| 181 | | 00 | 0x33 I2C read command |
| 182 | ---------------------------------------------------------------------------- |
| 183 | | 01 | i2c address + 1 |
| 184 | ---------------------------------------------------------------------------- |
| 185 | | 02 | register |
| 186 | ---------------------------------------------------------------------------- |
| 187 | | 03 | 0x00 |
| 188 | ---------------------------------------------------------------------------- |
| 189 | | 04 | 0x00 |
| 190 | ---------------------------------------------------------------------------- |
Antti Palosaari | b3e6a5a | 2011-04-09 21:00:51 -0300 | [diff] [blame] | 191 | | 05 | data length |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 192 | ---------------------------------------------------------------------------- |
| 193 | | 06-59 | don't care |
| 194 | ---------------------------------------------------------------------------- |
| 195 | | 60 | packet sequence number |
| 196 | ---------------------------------------------------------------------------- |
| 197 | | 61-63 | don't care |
| 198 | ---------------------------------------------------------------------------- |
| 199 | |
| 200 | ============================================================================ |
| 201 | | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET |
| 202 | ============================================================================ |
| 203 | | 00 | 0xb1 register write command |
| 204 | ---------------------------------------------------------------------------- |
| 205 | | 01-02 | register |
| 206 | ---------------------------------------------------------------------------- |
| 207 | | 03 | 0x01 |
| 208 | ---------------------------------------------------------------------------- |
| 209 | | 04 | value |
| 210 | ---------------------------------------------------------------------------- |
| 211 | | 05-59 | don't care |
| 212 | ---------------------------------------------------------------------------- |
| 213 | | 60 | packet sequence number |
| 214 | ---------------------------------------------------------------------------- |
| 215 | | 61-63 | don't care |
| 216 | ---------------------------------------------------------------------------- |
| 217 | |
| 218 | ============================================================================ |
| 219 | | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET |
| 220 | ============================================================================ |
| 221 | | 00 | 0xb0 register read command |
| 222 | ---------------------------------------------------------------------------- |
| 223 | | 01-02 | register |
| 224 | ---------------------------------------------------------------------------- |
| 225 | | 03 | 0x01 |
| 226 | ---------------------------------------------------------------------------- |
| 227 | | 04-59 | don't care |
| 228 | ---------------------------------------------------------------------------- |
| 229 | | 60 | packet sequence number |
| 230 | ---------------------------------------------------------------------------- |
| 231 | | 61-63 | don't care |
| 232 | ---------------------------------------------------------------------------- |
| 233 | |
| 234 | ============================================================================ |
| 235 | | 00-63 | LED CONTROL REQUEST PACKET |
| 236 | ============================================================================ |
| 237 | | 00 | 0x16 LED and IR control command |
| 238 | ---------------------------------------------------------------------------- |
| 239 | | 01 | 0x01 (LED) |
| 240 | ---------------------------------------------------------------------------- |
| 241 | | 03 | 0x00 blink |
| 242 | | | 0x01 lights continuously |
| 243 | ---------------------------------------------------------------------------- |
| 244 | | 04 | blink interval |
| 245 | | | 0x00 fastest (looks like LED lights continuously) |
| 246 | | | 0xff slowest |
| 247 | ---------------------------------------------------------------------------- |
| 248 | | 05-59 | don't care |
| 249 | ---------------------------------------------------------------------------- |
| 250 | | 60 | packet sequence number |
| 251 | ---------------------------------------------------------------------------- |
| 252 | | 61-63 | don't care |
| 253 | ---------------------------------------------------------------------------- |
| 254 | |
| 255 | ============================================================================ |
| 256 | | 00-63 | IR CONTROL REQUEST PACKET |
| 257 | ============================================================================ |
| 258 | | 00 | 0x16 LED and IR control command |
| 259 | ---------------------------------------------------------------------------- |
| 260 | | 01 | 0x02 (IR) |
| 261 | ---------------------------------------------------------------------------- |
| 262 | | 03 | 0x00 IR disabled |
| 263 | | | 0x01 IR enabled |
| 264 | ---------------------------------------------------------------------------- |
| 265 | | 04-59 | don't care |
| 266 | ---------------------------------------------------------------------------- |
| 267 | | 60 | packet sequence number |
| 268 | ---------------------------------------------------------------------------- |
| 269 | | 61-63 | don't care |
| 270 | ---------------------------------------------------------------------------- |
| 271 | |
| 272 | ============================================================================ |
| 273 | | 00-63 | STREAMING CONTROL REQUEST PACKET |
| 274 | ============================================================================ |
| 275 | | 00 | 0x12 streaming control command |
| 276 | ---------------------------------------------------------------------------- |
| 277 | | 01 | 0x00 streaming disabled |
| 278 | | | 0x01 streaming enabled |
| 279 | ---------------------------------------------------------------------------- |
| 280 | | 02 | 0x00 |
| 281 | ---------------------------------------------------------------------------- |
| 282 | | 03-59 | don't care |
| 283 | ---------------------------------------------------------------------------- |
| 284 | | 60 | packet sequence number |
| 285 | ---------------------------------------------------------------------------- |
| 286 | | 61-63 | don't care |
| 287 | ---------------------------------------------------------------------------- |
| 288 | |
| 289 | ============================================================================ |
| 290 | | 00-63 | REMOTE CONTROL REQUEST PACKET |
| 291 | ============================================================================ |
| 292 | | 00 | 0x41 remote control command |
| 293 | ---------------------------------------------------------------------------- |
| 294 | | 01-59 | don't care |
| 295 | ---------------------------------------------------------------------------- |
| 296 | | 60 | packet sequence number |
| 297 | ---------------------------------------------------------------------------- |
| 298 | | 61-63 | don't care |
| 299 | ---------------------------------------------------------------------------- |
| 300 | |
| 301 | ============================================================================ |
| 302 | | 00-63 | REMOTE CONTROL REPLY PACKET |
| 303 | ============================================================================ |
| 304 | | 00 | 0x00 code not received |
| 305 | | | 0x01 code received |
| 306 | ---------------------------------------------------------------------------- |
| 307 | | 01 | remote control code |
| 308 | ---------------------------------------------------------------------------- |
| 309 | | 02-59 | don't care |
| 310 | ---------------------------------------------------------------------------- |
| 311 | | 60 | packet sequence number |
| 312 | ---------------------------------------------------------------------------- |
| 313 | | 61-63 | don't care |
| 314 | ---------------------------------------------------------------------------- |
| 315 | |
| 316 | ============================================================================ |
| 317 | | 00-63 | GET HARDWARE INFO REQUEST PACKET |
| 318 | ============================================================================ |
| 319 | | 00 | 0x19 get hardware info command |
| 320 | ---------------------------------------------------------------------------- |
| 321 | | 01-59 | don't care |
| 322 | ---------------------------------------------------------------------------- |
| 323 | | 60 | packet sequence number |
| 324 | ---------------------------------------------------------------------------- |
| 325 | | 61-63 | don't care |
| 326 | ---------------------------------------------------------------------------- |
| 327 | |
| 328 | ============================================================================ |
| 329 | | 00-63 | GET HARDWARE INFO REPLY PACKET |
| 330 | ============================================================================ |
| 331 | | 00 | hardware id |
| 332 | ---------------------------------------------------------------------------- |
| 333 | | 01-02 | firmware version |
| 334 | ---------------------------------------------------------------------------- |
| 335 | | 03-59 | don't care |
| 336 | ---------------------------------------------------------------------------- |
| 337 | | 60 | packet sequence number |
| 338 | ---------------------------------------------------------------------------- |
| 339 | | 61-63 | don't care |
| 340 | ---------------------------------------------------------------------------- |
| 341 | |
| 342 | ============================================================================ |
| 343 | | 00-63 | SMART CARD READER PACKET |
| 344 | ============================================================================ |
| 345 | | 00 | 0x34 smart card reader command |
| 346 | ---------------------------------------------------------------------------- |
| 347 | | xx | |
| 348 | ---------------------------------------------------------------------------- |
| 349 | | xx-59 | don't care |
| 350 | ---------------------------------------------------------------------------- |
| 351 | | 60 | packet sequence number |
| 352 | ---------------------------------------------------------------------------- |
| 353 | | 61-63 | don't care |
| 354 | ---------------------------------------------------------------------------- |
| 355 | |
| 356 | */ |