blob: 8ac8794315401d06a087dcf4614444ce98c8d12b [file] [log] [blame]
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001/*
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 Palosaari9fdd9ca2008-06-11 11:43:19 -030026 * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
27 * module registers serial interface that can be used to communicate
Antti Palosaaria51e34d2008-05-17 23:05:48 -030028 * 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"
Antti Palosaari05cd37d2011-09-05 23:33:04 -030039#include "dvb_ca_en50221.h"
Antti Palosaaria51e34d2008-05-17 23:05:48 -030040
41#define deb_info(args...) dprintk(dvb_usb_anysee_debug, 0x01, args)
42#define deb_xfer(args...) dprintk(dvb_usb_anysee_debug, 0x02, args)
43#define deb_rc(args...) dprintk(dvb_usb_anysee_debug, 0x04, args)
44#define deb_reg(args...) dprintk(dvb_usb_anysee_debug, 0x08, args)
45#define deb_i2c(args...) dprintk(dvb_usb_anysee_debug, 0x10, args)
46#define deb_fw(args...) dprintk(dvb_usb_anysee_debug, 0x20, args)
47
48enum cmd {
49 CMD_I2C_READ = 0x33,
50 CMD_I2C_WRITE = 0x31,
51 CMD_REG_READ = 0xb0,
52 CMD_REG_WRITE = 0xb1,
53 CMD_STREAMING_CTRL = 0x12,
54 CMD_LED_AND_IR_CTRL = 0x16,
55 CMD_GET_IR_CODE = 0x41,
56 CMD_GET_HW_INFO = 0x19,
57 CMD_SMARTCARD = 0x34,
Antti Palosaari05cd37d2011-09-05 23:33:04 -030058 CMD_CI = 0x37,
Antti Palosaaria51e34d2008-05-17 23:05:48 -030059};
60
61struct anysee_state {
Antti Palosaari41f81f62011-04-10 17:53:52 -030062 u8 hw; /* PCB ID */
Antti Palosaaria51e34d2008-05-17 23:05:48 -030063 u8 seq;
Antti Palosaari449d1a02011-07-25 20:25:21 -030064 u8 fe_id:1; /* frondend ID */
Antti Palosaari05cd37d2011-09-05 23:33:04 -030065 u8 has_ci:1;
66 struct dvb_ca_en50221 ci;
67 unsigned long ci_cam_ready; /* jiffies */
Antti Palosaaria51e34d2008-05-17 23:05:48 -030068};
69
Antti Palosaari05c46c02011-05-25 18:30:09 -030070#define ANYSEE_HW_507T 2 /* E30 */
Antti Palosaari8439e0d2011-05-24 07:57:34 -030071#define ANYSEE_HW_507CD 6 /* E30 Plus */
72#define ANYSEE_HW_507DC 10 /* E30 C Plus */
73#define ANYSEE_HW_507SI 11 /* E30 S2 Plus */
74#define ANYSEE_HW_507FA 15 /* E30 Combo Plus / E30 C Plus */
75#define ANYSEE_HW_508TC 18 /* E7 TC */
76#define ANYSEE_HW_508S2 19 /* E7 S2 */
Antti Palosaari608add82011-08-12 18:29:46 -030077#define ANYSEE_HW_508T2C 20 /* E7 T2C */
Antti Palosaari8439e0d2011-05-24 07:57:34 -030078#define ANYSEE_HW_508PTC 21 /* E7 PTC Plus */
Antti Palosaarifea3c392011-05-25 18:21:43 -030079#define ANYSEE_HW_508PS2 22 /* E7 PS2 Plus */
Antti Palosaari41f81f62011-04-10 17:53:52 -030080
81#define REG_IOA 0x80 /* Port A (bit addressable) */
82#define REG_IOB 0x90 /* Port B (bit addressable) */
83#define REG_IOC 0xa0 /* Port C (bit addressable) */
84#define REG_IOD 0xb0 /* Port D (bit addressable) */
85#define REG_IOE 0xb1 /* Port E (NOT bit addressable) */
86#define REG_OEA 0xb2 /* Port A Output Enable */
87#define REG_OEB 0xb3 /* Port B Output Enable */
88#define REG_OEC 0xb4 /* Port C Output Enable */
89#define REG_OED 0xb5 /* Port D Output Enable */
90#define REG_OEE 0xb6 /* Port E Output Enable */
91
Antti Palosaaria51e34d2008-05-17 23:05:48 -030092#endif
93
94/***************************************************************************
95 * USB API description (reverse engineered)
96 ***************************************************************************
97
98Transaction flow:
99=================
100BULK[00001] >>> REQUEST PACKET 64 bytes
101BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY)
102BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY)
103
104General reply packet(s) are always used if not own reply defined.
105
106============================================================================
107| 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY)
108============================================================================
109| 00 | reply data (if any) from previous transaction
110| | Just same reply packet as returned during previous transaction.
111| | Needed only if reply is missed in previous transaction.
112| | Just skip normally.
113----------------------------------------------------------------------------
114| 01-59 | don't care
115----------------------------------------------------------------------------
116| 60 | packet sequence number
117----------------------------------------------------------------------------
118| 61-63 | don't care
119----------------------------------------------------------------------------
120
121============================================================================
122| 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY)
123============================================================================
124| 00 | reply data (if any)
125----------------------------------------------------------------------------
126| 01-59 | don't care
127----------------------------------------------------------------------------
128| 60 | packet sequence number
129----------------------------------------------------------------------------
130| 61-63 | don't care
131----------------------------------------------------------------------------
132
133============================================================================
134| 00-63 | I2C WRITE REQUEST PACKET
135============================================================================
136| 00 | 0x31 I2C write command
137----------------------------------------------------------------------------
138| 01 | i2c address
139----------------------------------------------------------------------------
140| 02 | data length
141| | 0x02 (for typical I2C reg / val pair)
142----------------------------------------------------------------------------
143| 03 | 0x01
144----------------------------------------------------------------------------
145| 04- | data
146----------------------------------------------------------------------------
147| -59 | don't care
148----------------------------------------------------------------------------
149| 60 | packet sequence number
150----------------------------------------------------------------------------
151| 61-63 | don't care
152----------------------------------------------------------------------------
153
154============================================================================
155| 00-63 | I2C READ REQUEST PACKET
156============================================================================
157| 00 | 0x33 I2C read command
158----------------------------------------------------------------------------
159| 01 | i2c address + 1
160----------------------------------------------------------------------------
161| 02 | register
162----------------------------------------------------------------------------
163| 03 | 0x00
164----------------------------------------------------------------------------
165| 04 | 0x00
166----------------------------------------------------------------------------
Antti Palosaarib3e6a5a2011-04-09 21:00:51 -0300167| 05 | data length
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300168----------------------------------------------------------------------------
169| 06-59 | don't care
170----------------------------------------------------------------------------
171| 60 | packet sequence number
172----------------------------------------------------------------------------
173| 61-63 | don't care
174----------------------------------------------------------------------------
175
176============================================================================
177| 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET
178============================================================================
179| 00 | 0xb1 register write command
180----------------------------------------------------------------------------
181| 01-02 | register
182----------------------------------------------------------------------------
183| 03 | 0x01
184----------------------------------------------------------------------------
185| 04 | value
186----------------------------------------------------------------------------
187| 05-59 | don't care
188----------------------------------------------------------------------------
189| 60 | packet sequence number
190----------------------------------------------------------------------------
191| 61-63 | don't care
192----------------------------------------------------------------------------
193
194============================================================================
195| 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET
196============================================================================
197| 00 | 0xb0 register read command
198----------------------------------------------------------------------------
199| 01-02 | register
200----------------------------------------------------------------------------
201| 03 | 0x01
202----------------------------------------------------------------------------
203| 04-59 | don't care
204----------------------------------------------------------------------------
205| 60 | packet sequence number
206----------------------------------------------------------------------------
207| 61-63 | don't care
208----------------------------------------------------------------------------
209
210============================================================================
211| 00-63 | LED CONTROL REQUEST PACKET
212============================================================================
213| 00 | 0x16 LED and IR control command
214----------------------------------------------------------------------------
215| 01 | 0x01 (LED)
216----------------------------------------------------------------------------
217| 03 | 0x00 blink
218| | 0x01 lights continuously
219----------------------------------------------------------------------------
220| 04 | blink interval
221| | 0x00 fastest (looks like LED lights continuously)
222| | 0xff slowest
223----------------------------------------------------------------------------
224| 05-59 | don't care
225----------------------------------------------------------------------------
226| 60 | packet sequence number
227----------------------------------------------------------------------------
228| 61-63 | don't care
229----------------------------------------------------------------------------
230
231============================================================================
232| 00-63 | IR CONTROL REQUEST PACKET
233============================================================================
234| 00 | 0x16 LED and IR control command
235----------------------------------------------------------------------------
236| 01 | 0x02 (IR)
237----------------------------------------------------------------------------
238| 03 | 0x00 IR disabled
239| | 0x01 IR enabled
240----------------------------------------------------------------------------
241| 04-59 | don't care
242----------------------------------------------------------------------------
243| 60 | packet sequence number
244----------------------------------------------------------------------------
245| 61-63 | don't care
246----------------------------------------------------------------------------
247
248============================================================================
249| 00-63 | STREAMING CONTROL REQUEST PACKET
250============================================================================
251| 00 | 0x12 streaming control command
252----------------------------------------------------------------------------
253| 01 | 0x00 streaming disabled
254| | 0x01 streaming enabled
255----------------------------------------------------------------------------
256| 02 | 0x00
257----------------------------------------------------------------------------
258| 03-59 | don't care
259----------------------------------------------------------------------------
260| 60 | packet sequence number
261----------------------------------------------------------------------------
262| 61-63 | don't care
263----------------------------------------------------------------------------
264
265============================================================================
266| 00-63 | REMOTE CONTROL REQUEST PACKET
267============================================================================
268| 00 | 0x41 remote control command
269----------------------------------------------------------------------------
270| 01-59 | don't care
271----------------------------------------------------------------------------
272| 60 | packet sequence number
273----------------------------------------------------------------------------
274| 61-63 | don't care
275----------------------------------------------------------------------------
276
277============================================================================
278| 00-63 | REMOTE CONTROL REPLY PACKET
279============================================================================
280| 00 | 0x00 code not received
281| | 0x01 code received
282----------------------------------------------------------------------------
283| 01 | remote control code
284----------------------------------------------------------------------------
285| 02-59 | don't care
286----------------------------------------------------------------------------
287| 60 | packet sequence number
288----------------------------------------------------------------------------
289| 61-63 | don't care
290----------------------------------------------------------------------------
291
292============================================================================
293| 00-63 | GET HARDWARE INFO REQUEST PACKET
294============================================================================
295| 00 | 0x19 get hardware info command
296----------------------------------------------------------------------------
297| 01-59 | don't care
298----------------------------------------------------------------------------
299| 60 | packet sequence number
300----------------------------------------------------------------------------
301| 61-63 | don't care
302----------------------------------------------------------------------------
303
304============================================================================
305| 00-63 | GET HARDWARE INFO REPLY PACKET
306============================================================================
307| 00 | hardware id
308----------------------------------------------------------------------------
309| 01-02 | firmware version
310----------------------------------------------------------------------------
311| 03-59 | don't care
312----------------------------------------------------------------------------
313| 60 | packet sequence number
314----------------------------------------------------------------------------
315| 61-63 | don't care
316----------------------------------------------------------------------------
317
318============================================================================
319| 00-63 | SMART CARD READER PACKET
320============================================================================
321| 00 | 0x34 smart card reader command
322----------------------------------------------------------------------------
323| xx |
324----------------------------------------------------------------------------
325| xx-59 | don't care
326----------------------------------------------------------------------------
327| 60 | packet sequence number
328----------------------------------------------------------------------------
329| 61-63 | don't care
330----------------------------------------------------------------------------
331
332*/