Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver
0004  *
0005  * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
0006  *
0007  * TODO:
0008  * - add smart card reader support for Conditional Access (CA)
0009  *
0010  * Card reader in Anysee is nothing more than ISO 7816 card reader.
0011  * There is no hardware CAM in any Anysee device sold.
0012  * In my understanding it should be implemented by making own module
0013  * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
0014  * module registers serial interface that can be used to communicate
0015  * with any ISO 7816 smart card.
0016  *
0017  * Any help according to implement serial smart card reader support
0018  * is highly welcome!
0019  */
0020 
0021 #ifndef _DVB_USB_ANYSEE_H_
0022 #define _DVB_USB_ANYSEE_H_
0023 
0024 #define DVB_USB_LOG_PREFIX "anysee"
0025 #include "dvb_usb.h"
0026 #include <media/dvb_ca_en50221.h>
0027 
0028 enum cmd {
0029     CMD_I2C_READ            = 0x33,
0030     CMD_I2C_WRITE           = 0x31,
0031     CMD_REG_READ            = 0xb0,
0032     CMD_REG_WRITE           = 0xb1,
0033     CMD_STREAMING_CTRL      = 0x12,
0034     CMD_LED_AND_IR_CTRL     = 0x16,
0035     CMD_GET_IR_CODE         = 0x41,
0036     CMD_GET_HW_INFO         = 0x19,
0037     CMD_SMARTCARD           = 0x34,
0038     CMD_CI                  = 0x37,
0039 };
0040 
0041 struct anysee_state {
0042     u8 buf[64];
0043     u8 seq;
0044     u8 hw; /* PCB ID */
0045     #define ANYSEE_I2C_CLIENT_MAX 1
0046     struct i2c_client *i2c_client[ANYSEE_I2C_CLIENT_MAX];
0047     u8 fe_id:1; /* frondend ID */
0048     u8 has_ci:1;
0049     u8 has_tda18212:1;
0050     u8 ci_attached:1;
0051     struct dvb_ca_en50221 ci;
0052     unsigned long ci_cam_ready; /* jiffies */
0053 };
0054 
0055 #define ANYSEE_HW_507T    2 /* E30 */
0056 #define ANYSEE_HW_507CD   6 /* E30 Plus */
0057 #define ANYSEE_HW_507DC  10 /* E30 C Plus */
0058 #define ANYSEE_HW_507SI  11 /* E30 S2 Plus */
0059 #define ANYSEE_HW_507FA  15 /* E30 Combo Plus / E30 C Plus */
0060 #define ANYSEE_HW_508TC  18 /* E7 TC */
0061 #define ANYSEE_HW_508S2  19 /* E7 S2 */
0062 #define ANYSEE_HW_508T2C 20 /* E7 T2C */
0063 #define ANYSEE_HW_508PTC 21 /* E7 PTC Plus */
0064 #define ANYSEE_HW_508PS2 22 /* E7 PS2 Plus */
0065 
0066 #define REG_IOA       0x80 /* Port A (bit addressable) */
0067 #define REG_IOB       0x90 /* Port B (bit addressable) */
0068 #define REG_IOC       0xa0 /* Port C (bit addressable) */
0069 #define REG_IOD       0xb0 /* Port D (bit addressable) */
0070 #define REG_IOE       0xb1 /* Port E (NOT bit addressable) */
0071 #define REG_OEA       0xb2 /* Port A Output Enable */
0072 #define REG_OEB       0xb3 /* Port B Output Enable */
0073 #define REG_OEC       0xb4 /* Port C Output Enable */
0074 #define REG_OED       0xb5 /* Port D Output Enable */
0075 #define REG_OEE       0xb6 /* Port E Output Enable */
0076 
0077 #endif
0078 
0079 /***************************************************************************
0080  * USB API description (reverse engineered)
0081  ***************************************************************************
0082 
0083 Transaction flow:
0084 =================
0085 BULK[00001] >>> REQUEST PACKET 64 bytes
0086 BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY)
0087 BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY)
0088 
0089 General reply packet(s) are always used if not own reply defined.
0090 
0091 ============================================================================
0092 | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY)
0093 ============================================================================
0094 |    00 | reply data (if any) from previous transaction
0095 |       | Just same reply packet as returned during previous transaction.
0096 |       | Needed only if reply is missed in previous transaction.
0097 |       | Just skip normally.
0098 ----------------------------------------------------------------------------
0099 | 01-59 | don't care
0100 ----------------------------------------------------------------------------
0101 |    60 | packet sequence number
0102 ----------------------------------------------------------------------------
0103 | 61-63 | don't care
0104 ----------------------------------------------------------------------------
0105 
0106 ============================================================================
0107 | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY)
0108 ============================================================================
0109 |    00 | reply data (if any)
0110 ----------------------------------------------------------------------------
0111 | 01-59 | don't care
0112 ----------------------------------------------------------------------------
0113 |    60 | packet sequence number
0114 ----------------------------------------------------------------------------
0115 | 61-63 | don't care
0116 ----------------------------------------------------------------------------
0117 
0118 ============================================================================
0119 | 00-63 | I2C WRITE REQUEST PACKET
0120 ============================================================================
0121 |    00 | 0x31 I2C write command
0122 ----------------------------------------------------------------------------
0123 |    01 | i2c address
0124 ----------------------------------------------------------------------------
0125 |    02 | data length
0126 |       | 0x02 (for typical I2C reg / val pair)
0127 ----------------------------------------------------------------------------
0128 |    03 | 0x01
0129 ----------------------------------------------------------------------------
0130 | 04-   | data
0131 ----------------------------------------------------------------------------
0132 |   -59 | don't care
0133 ----------------------------------------------------------------------------
0134 |    60 | packet sequence number
0135 ----------------------------------------------------------------------------
0136 | 61-63 | don't care
0137 ----------------------------------------------------------------------------
0138 
0139 ============================================================================
0140 | 00-63 | I2C READ REQUEST PACKET
0141 ============================================================================
0142 |    00 | 0x33 I2C read command
0143 ----------------------------------------------------------------------------
0144 |    01 | i2c address + 1
0145 ----------------------------------------------------------------------------
0146 |    02 | register
0147 ----------------------------------------------------------------------------
0148 |    03 | 0x00
0149 ----------------------------------------------------------------------------
0150 |    04 | 0x00
0151 ----------------------------------------------------------------------------
0152 |    05 | data length
0153 ----------------------------------------------------------------------------
0154 | 06-59 | don't care
0155 ----------------------------------------------------------------------------
0156 |    60 | packet sequence number
0157 ----------------------------------------------------------------------------
0158 | 61-63 | don't care
0159 ----------------------------------------------------------------------------
0160 
0161 ============================================================================
0162 | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET
0163 ============================================================================
0164 |    00 | 0xb1 register write command
0165 ----------------------------------------------------------------------------
0166 | 01-02 | register
0167 ----------------------------------------------------------------------------
0168 |    03 | 0x01
0169 ----------------------------------------------------------------------------
0170 |    04 | value
0171 ----------------------------------------------------------------------------
0172 | 05-59 | don't care
0173 ----------------------------------------------------------------------------
0174 |    60 | packet sequence number
0175 ----------------------------------------------------------------------------
0176 | 61-63 | don't care
0177 ----------------------------------------------------------------------------
0178 
0179 ============================================================================
0180 | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET
0181 ============================================================================
0182 |    00 | 0xb0 register read command
0183 ----------------------------------------------------------------------------
0184 | 01-02 | register
0185 ----------------------------------------------------------------------------
0186 |    03 | 0x01
0187 ----------------------------------------------------------------------------
0188 | 04-59 | don't care
0189 ----------------------------------------------------------------------------
0190 |    60 | packet sequence number
0191 ----------------------------------------------------------------------------
0192 | 61-63 | don't care
0193 ----------------------------------------------------------------------------
0194 
0195 ============================================================================
0196 | 00-63 | LED CONTROL REQUEST PACKET
0197 ============================================================================
0198 |    00 | 0x16 LED and IR control command
0199 ----------------------------------------------------------------------------
0200 |    01 | 0x01 (LED)
0201 ----------------------------------------------------------------------------
0202 |    03 | 0x00 blink
0203 |       | 0x01 lights continuously
0204 ----------------------------------------------------------------------------
0205 |    04 | blink interval
0206 |       | 0x00 fastest (looks like LED lights continuously)
0207 |       | 0xff slowest
0208 ----------------------------------------------------------------------------
0209 | 05-59 | don't care
0210 ----------------------------------------------------------------------------
0211 |    60 | packet sequence number
0212 ----------------------------------------------------------------------------
0213 | 61-63 | don't care
0214 ----------------------------------------------------------------------------
0215 
0216 ============================================================================
0217 | 00-63 | IR CONTROL REQUEST PACKET
0218 ============================================================================
0219 |    00 | 0x16 LED and IR control command
0220 ----------------------------------------------------------------------------
0221 |    01 | 0x02 (IR)
0222 ----------------------------------------------------------------------------
0223 |    03 | 0x00 IR disabled
0224 |       | 0x01 IR enabled
0225 ----------------------------------------------------------------------------
0226 | 04-59 | don't care
0227 ----------------------------------------------------------------------------
0228 |    60 | packet sequence number
0229 ----------------------------------------------------------------------------
0230 | 61-63 | don't care
0231 ----------------------------------------------------------------------------
0232 
0233 ============================================================================
0234 | 00-63 | STREAMING CONTROL REQUEST PACKET
0235 ============================================================================
0236 |    00 | 0x12 streaming control command
0237 ----------------------------------------------------------------------------
0238 |    01 | 0x00 streaming disabled
0239 |       | 0x01 streaming enabled
0240 ----------------------------------------------------------------------------
0241 |    02 | 0x00
0242 ----------------------------------------------------------------------------
0243 | 03-59 | don't care
0244 ----------------------------------------------------------------------------
0245 |    60 | packet sequence number
0246 ----------------------------------------------------------------------------
0247 | 61-63 | don't care
0248 ----------------------------------------------------------------------------
0249 
0250 ============================================================================
0251 | 00-63 | REMOTE CONTROL REQUEST PACKET
0252 ============================================================================
0253 |    00 | 0x41 remote control command
0254 ----------------------------------------------------------------------------
0255 | 01-59 | don't care
0256 ----------------------------------------------------------------------------
0257 |    60 | packet sequence number
0258 ----------------------------------------------------------------------------
0259 | 61-63 | don't care
0260 ----------------------------------------------------------------------------
0261 
0262 ============================================================================
0263 | 00-63 | REMOTE CONTROL REPLY PACKET
0264 ============================================================================
0265 |    00 | 0x00 code not received
0266 |       | 0x01 code received
0267 ----------------------------------------------------------------------------
0268 |    01 | remote control code
0269 ----------------------------------------------------------------------------
0270 | 02-59 | don't care
0271 ----------------------------------------------------------------------------
0272 |    60 | packet sequence number
0273 ----------------------------------------------------------------------------
0274 | 61-63 | don't care
0275 ----------------------------------------------------------------------------
0276 
0277 ============================================================================
0278 | 00-63 | GET HARDWARE INFO REQUEST PACKET
0279 ============================================================================
0280 |    00 | 0x19 get hardware info command
0281 ----------------------------------------------------------------------------
0282 | 01-59 | don't care
0283 ----------------------------------------------------------------------------
0284 |    60 | packet sequence number
0285 ----------------------------------------------------------------------------
0286 | 61-63 | don't care
0287 ----------------------------------------------------------------------------
0288 
0289 ============================================================================
0290 | 00-63 | GET HARDWARE INFO REPLY PACKET
0291 ============================================================================
0292 |    00 | hardware id
0293 ----------------------------------------------------------------------------
0294 | 01-02 | firmware version
0295 ----------------------------------------------------------------------------
0296 | 03-59 | don't care
0297 ----------------------------------------------------------------------------
0298 |    60 | packet sequence number
0299 ----------------------------------------------------------------------------
0300 | 61-63 | don't care
0301 ----------------------------------------------------------------------------
0302 
0303 ============================================================================
0304 | 00-63 | SMART CARD READER PACKET
0305 ============================================================================
0306 |    00 | 0x34 smart card reader command
0307 ----------------------------------------------------------------------------
0308 |    xx |
0309 ----------------------------------------------------------------------------
0310 | xx-59 | don't care
0311 ----------------------------------------------------------------------------
0312 |    60 | packet sequence number
0313 ----------------------------------------------------------------------------
0314 | 61-63 | don't care
0315 ----------------------------------------------------------------------------
0316 
0317 */