anysee.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver
  4. *
  5. * Copyright (C) 2007 Antti Palosaari <[email protected]>
  6. *
  7. * TODO:
  8. * - add smart card reader support for Conditional Access (CA)
  9. *
  10. * Card reader in Anysee is nothing more than ISO 7816 card reader.
  11. * There is no hardware CAM in any Anysee device sold.
  12. * In my understanding it should be implemented by making own module
  13. * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
  14. * module registers serial interface that can be used to communicate
  15. * with any ISO 7816 smart card.
  16. *
  17. * Any help according to implement serial smart card reader support
  18. * is highly welcome!
  19. */
  20. #ifndef _DVB_USB_ANYSEE_H_
  21. #define _DVB_USB_ANYSEE_H_
  22. #define DVB_USB_LOG_PREFIX "anysee"
  23. #include "dvb_usb.h"
  24. #include <media/dvb_ca_en50221.h>
  25. enum cmd {
  26. CMD_I2C_READ = 0x33,
  27. CMD_I2C_WRITE = 0x31,
  28. CMD_REG_READ = 0xb0,
  29. CMD_REG_WRITE = 0xb1,
  30. CMD_STREAMING_CTRL = 0x12,
  31. CMD_LED_AND_IR_CTRL = 0x16,
  32. CMD_GET_IR_CODE = 0x41,
  33. CMD_GET_HW_INFO = 0x19,
  34. CMD_SMARTCARD = 0x34,
  35. CMD_CI = 0x37,
  36. };
  37. struct anysee_state {
  38. u8 buf[64];
  39. u8 seq;
  40. u8 hw; /* PCB ID */
  41. #define ANYSEE_I2C_CLIENT_MAX 1
  42. struct i2c_client *i2c_client[ANYSEE_I2C_CLIENT_MAX];
  43. u8 fe_id:1; /* frondend ID */
  44. u8 has_ci:1;
  45. u8 has_tda18212:1;
  46. u8 ci_attached:1;
  47. struct dvb_ca_en50221 ci;
  48. unsigned long ci_cam_ready; /* jiffies */
  49. };
  50. #define ANYSEE_HW_507T 2 /* E30 */
  51. #define ANYSEE_HW_507CD 6 /* E30 Plus */
  52. #define ANYSEE_HW_507DC 10 /* E30 C Plus */
  53. #define ANYSEE_HW_507SI 11 /* E30 S2 Plus */
  54. #define ANYSEE_HW_507FA 15 /* E30 Combo Plus / E30 C Plus */
  55. #define ANYSEE_HW_508TC 18 /* E7 TC */
  56. #define ANYSEE_HW_508S2 19 /* E7 S2 */
  57. #define ANYSEE_HW_508T2C 20 /* E7 T2C */
  58. #define ANYSEE_HW_508PTC 21 /* E7 PTC Plus */
  59. #define ANYSEE_HW_508PS2 22 /* E7 PS2 Plus */
  60. #define REG_IOA 0x80 /* Port A (bit addressable) */
  61. #define REG_IOB 0x90 /* Port B (bit addressable) */
  62. #define REG_IOC 0xa0 /* Port C (bit addressable) */
  63. #define REG_IOD 0xb0 /* Port D (bit addressable) */
  64. #define REG_IOE 0xb1 /* Port E (NOT bit addressable) */
  65. #define REG_OEA 0xb2 /* Port A Output Enable */
  66. #define REG_OEB 0xb3 /* Port B Output Enable */
  67. #define REG_OEC 0xb4 /* Port C Output Enable */
  68. #define REG_OED 0xb5 /* Port D Output Enable */
  69. #define REG_OEE 0xb6 /* Port E Output Enable */
  70. #endif
  71. /***************************************************************************
  72. * USB API description (reverse engineered)
  73. ***************************************************************************
  74. Transaction flow:
  75. =================
  76. BULK[00001] >>> REQUEST PACKET 64 bytes
  77. BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY)
  78. BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY)
  79. General reply packet(s) are always used if not own reply defined.
  80. ============================================================================
  81. | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY)
  82. ============================================================================
  83. | 00 | reply data (if any) from previous transaction
  84. | | Just same reply packet as returned during previous transaction.
  85. | | Needed only if reply is missed in previous transaction.
  86. | | Just skip normally.
  87. ----------------------------------------------------------------------------
  88. | 01-59 | don't care
  89. ----------------------------------------------------------------------------
  90. | 60 | packet sequence number
  91. ----------------------------------------------------------------------------
  92. | 61-63 | don't care
  93. ----------------------------------------------------------------------------
  94. ============================================================================
  95. | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY)
  96. ============================================================================
  97. | 00 | reply data (if any)
  98. ----------------------------------------------------------------------------
  99. | 01-59 | don't care
  100. ----------------------------------------------------------------------------
  101. | 60 | packet sequence number
  102. ----------------------------------------------------------------------------
  103. | 61-63 | don't care
  104. ----------------------------------------------------------------------------
  105. ============================================================================
  106. | 00-63 | I2C WRITE REQUEST PACKET
  107. ============================================================================
  108. | 00 | 0x31 I2C write command
  109. ----------------------------------------------------------------------------
  110. | 01 | i2c address
  111. ----------------------------------------------------------------------------
  112. | 02 | data length
  113. | | 0x02 (for typical I2C reg / val pair)
  114. ----------------------------------------------------------------------------
  115. | 03 | 0x01
  116. ----------------------------------------------------------------------------
  117. | 04- | data
  118. ----------------------------------------------------------------------------
  119. | -59 | don't care
  120. ----------------------------------------------------------------------------
  121. | 60 | packet sequence number
  122. ----------------------------------------------------------------------------
  123. | 61-63 | don't care
  124. ----------------------------------------------------------------------------
  125. ============================================================================
  126. | 00-63 | I2C READ REQUEST PACKET
  127. ============================================================================
  128. | 00 | 0x33 I2C read command
  129. ----------------------------------------------------------------------------
  130. | 01 | i2c address + 1
  131. ----------------------------------------------------------------------------
  132. | 02 | register
  133. ----------------------------------------------------------------------------
  134. | 03 | 0x00
  135. ----------------------------------------------------------------------------
  136. | 04 | 0x00
  137. ----------------------------------------------------------------------------
  138. | 05 | data length
  139. ----------------------------------------------------------------------------
  140. | 06-59 | don't care
  141. ----------------------------------------------------------------------------
  142. | 60 | packet sequence number
  143. ----------------------------------------------------------------------------
  144. | 61-63 | don't care
  145. ----------------------------------------------------------------------------
  146. ============================================================================
  147. | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET
  148. ============================================================================
  149. | 00 | 0xb1 register write command
  150. ----------------------------------------------------------------------------
  151. | 01-02 | register
  152. ----------------------------------------------------------------------------
  153. | 03 | 0x01
  154. ----------------------------------------------------------------------------
  155. | 04 | value
  156. ----------------------------------------------------------------------------
  157. | 05-59 | don't care
  158. ----------------------------------------------------------------------------
  159. | 60 | packet sequence number
  160. ----------------------------------------------------------------------------
  161. | 61-63 | don't care
  162. ----------------------------------------------------------------------------
  163. ============================================================================
  164. | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET
  165. ============================================================================
  166. | 00 | 0xb0 register read command
  167. ----------------------------------------------------------------------------
  168. | 01-02 | register
  169. ----------------------------------------------------------------------------
  170. | 03 | 0x01
  171. ----------------------------------------------------------------------------
  172. | 04-59 | don't care
  173. ----------------------------------------------------------------------------
  174. | 60 | packet sequence number
  175. ----------------------------------------------------------------------------
  176. | 61-63 | don't care
  177. ----------------------------------------------------------------------------
  178. ============================================================================
  179. | 00-63 | LED CONTROL REQUEST PACKET
  180. ============================================================================
  181. | 00 | 0x16 LED and IR control command
  182. ----------------------------------------------------------------------------
  183. | 01 | 0x01 (LED)
  184. ----------------------------------------------------------------------------
  185. | 03 | 0x00 blink
  186. | | 0x01 lights continuously
  187. ----------------------------------------------------------------------------
  188. | 04 | blink interval
  189. | | 0x00 fastest (looks like LED lights continuously)
  190. | | 0xff slowest
  191. ----------------------------------------------------------------------------
  192. | 05-59 | don't care
  193. ----------------------------------------------------------------------------
  194. | 60 | packet sequence number
  195. ----------------------------------------------------------------------------
  196. | 61-63 | don't care
  197. ----------------------------------------------------------------------------
  198. ============================================================================
  199. | 00-63 | IR CONTROL REQUEST PACKET
  200. ============================================================================
  201. | 00 | 0x16 LED and IR control command
  202. ----------------------------------------------------------------------------
  203. | 01 | 0x02 (IR)
  204. ----------------------------------------------------------------------------
  205. | 03 | 0x00 IR disabled
  206. | | 0x01 IR enabled
  207. ----------------------------------------------------------------------------
  208. | 04-59 | don't care
  209. ----------------------------------------------------------------------------
  210. | 60 | packet sequence number
  211. ----------------------------------------------------------------------------
  212. | 61-63 | don't care
  213. ----------------------------------------------------------------------------
  214. ============================================================================
  215. | 00-63 | STREAMING CONTROL REQUEST PACKET
  216. ============================================================================
  217. | 00 | 0x12 streaming control command
  218. ----------------------------------------------------------------------------
  219. | 01 | 0x00 streaming disabled
  220. | | 0x01 streaming enabled
  221. ----------------------------------------------------------------------------
  222. | 02 | 0x00
  223. ----------------------------------------------------------------------------
  224. | 03-59 | don't care
  225. ----------------------------------------------------------------------------
  226. | 60 | packet sequence number
  227. ----------------------------------------------------------------------------
  228. | 61-63 | don't care
  229. ----------------------------------------------------------------------------
  230. ============================================================================
  231. | 00-63 | REMOTE CONTROL REQUEST PACKET
  232. ============================================================================
  233. | 00 | 0x41 remote control command
  234. ----------------------------------------------------------------------------
  235. | 01-59 | don't care
  236. ----------------------------------------------------------------------------
  237. | 60 | packet sequence number
  238. ----------------------------------------------------------------------------
  239. | 61-63 | don't care
  240. ----------------------------------------------------------------------------
  241. ============================================================================
  242. | 00-63 | REMOTE CONTROL REPLY PACKET
  243. ============================================================================
  244. | 00 | 0x00 code not received
  245. | | 0x01 code received
  246. ----------------------------------------------------------------------------
  247. | 01 | remote control code
  248. ----------------------------------------------------------------------------
  249. | 02-59 | don't care
  250. ----------------------------------------------------------------------------
  251. | 60 | packet sequence number
  252. ----------------------------------------------------------------------------
  253. | 61-63 | don't care
  254. ----------------------------------------------------------------------------
  255. ============================================================================
  256. | 00-63 | GET HARDWARE INFO REQUEST PACKET
  257. ============================================================================
  258. | 00 | 0x19 get hardware info command
  259. ----------------------------------------------------------------------------
  260. | 01-59 | don't care
  261. ----------------------------------------------------------------------------
  262. | 60 | packet sequence number
  263. ----------------------------------------------------------------------------
  264. | 61-63 | don't care
  265. ----------------------------------------------------------------------------
  266. ============================================================================
  267. | 00-63 | GET HARDWARE INFO REPLY PACKET
  268. ============================================================================
  269. | 00 | hardware id
  270. ----------------------------------------------------------------------------
  271. | 01-02 | firmware version
  272. ----------------------------------------------------------------------------
  273. | 03-59 | don't care
  274. ----------------------------------------------------------------------------
  275. | 60 | packet sequence number
  276. ----------------------------------------------------------------------------
  277. | 61-63 | don't care
  278. ----------------------------------------------------------------------------
  279. ============================================================================
  280. | 00-63 | SMART CARD READER PACKET
  281. ============================================================================
  282. | 00 | 0x34 smart card reader command
  283. ----------------------------------------------------------------------------
  284. | xx |
  285. ----------------------------------------------------------------------------
  286. | xx-59 | don't care
  287. ----------------------------------------------------------------------------
  288. | 60 | packet sequence number
  289. ----------------------------------------------------------------------------
  290. | 61-63 | don't care
  291. ----------------------------------------------------------------------------
  292. */