anysee.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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
  26. * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
  27. * module registers serial interface that can be used to communicate
  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. #ifndef _DVB_USB_ANYSEE_H_
  34. #define _DVB_USB_ANYSEE_H_
  35. #define DVB_USB_LOG_PREFIX "anysee"
  36. #include "dvb-usb.h"
  37. #define deb_info(args...) dprintk(dvb_usb_anysee_debug, 0x01, args)
  38. #define deb_xfer(args...) dprintk(dvb_usb_anysee_debug, 0x02, args)
  39. #define deb_rc(args...) dprintk(dvb_usb_anysee_debug, 0x04, args)
  40. #define deb_reg(args...) dprintk(dvb_usb_anysee_debug, 0x08, args)
  41. #define deb_i2c(args...) dprintk(dvb_usb_anysee_debug, 0x10, args)
  42. #define deb_fw(args...) dprintk(dvb_usb_anysee_debug, 0x20, args)
  43. enum cmd {
  44. CMD_I2C_READ = 0x33,
  45. CMD_I2C_WRITE = 0x31,
  46. CMD_REG_READ = 0xb0,
  47. CMD_REG_WRITE = 0xb1,
  48. CMD_STREAMING_CTRL = 0x12,
  49. CMD_LED_AND_IR_CTRL = 0x16,
  50. CMD_GET_IR_CODE = 0x41,
  51. CMD_GET_HW_INFO = 0x19,
  52. CMD_SMARTCARD = 0x34,
  53. };
  54. struct anysee_state {
  55. u8 tuner;
  56. u8 seq;
  57. };
  58. #endif
  59. /***************************************************************************
  60. * USB API description (reverse engineered)
  61. ***************************************************************************
  62. Transaction flow:
  63. =================
  64. BULK[00001] >>> REQUEST PACKET 64 bytes
  65. BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY)
  66. BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY)
  67. General reply packet(s) are always used if not own reply defined.
  68. ============================================================================
  69. | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY)
  70. ============================================================================
  71. | 00 | reply data (if any) from previous transaction
  72. | | Just same reply packet as returned during previous transaction.
  73. | | Needed only if reply is missed in previous transaction.
  74. | | Just skip normally.
  75. ----------------------------------------------------------------------------
  76. | 01-59 | don't care
  77. ----------------------------------------------------------------------------
  78. | 60 | packet sequence number
  79. ----------------------------------------------------------------------------
  80. | 61-63 | don't care
  81. ----------------------------------------------------------------------------
  82. ============================================================================
  83. | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY)
  84. ============================================================================
  85. | 00 | reply data (if any)
  86. ----------------------------------------------------------------------------
  87. | 01-59 | don't care
  88. ----------------------------------------------------------------------------
  89. | 60 | packet sequence number
  90. ----------------------------------------------------------------------------
  91. | 61-63 | don't care
  92. ----------------------------------------------------------------------------
  93. ============================================================================
  94. | 00-63 | I2C WRITE REQUEST PACKET
  95. ============================================================================
  96. | 00 | 0x31 I2C write command
  97. ----------------------------------------------------------------------------
  98. | 01 | i2c address
  99. ----------------------------------------------------------------------------
  100. | 02 | data length
  101. | | 0x02 (for typical I2C reg / val pair)
  102. ----------------------------------------------------------------------------
  103. | 03 | 0x01
  104. ----------------------------------------------------------------------------
  105. | 04- | data
  106. ----------------------------------------------------------------------------
  107. | -59 | don't care
  108. ----------------------------------------------------------------------------
  109. | 60 | packet sequence number
  110. ----------------------------------------------------------------------------
  111. | 61-63 | don't care
  112. ----------------------------------------------------------------------------
  113. ============================================================================
  114. | 00-63 | I2C READ REQUEST PACKET
  115. ============================================================================
  116. | 00 | 0x33 I2C read command
  117. ----------------------------------------------------------------------------
  118. | 01 | i2c address + 1
  119. ----------------------------------------------------------------------------
  120. | 02 | register
  121. ----------------------------------------------------------------------------
  122. | 03 | 0x00
  123. ----------------------------------------------------------------------------
  124. | 04 | 0x00
  125. ----------------------------------------------------------------------------
  126. | 05 | 0x01
  127. ----------------------------------------------------------------------------
  128. | 06-59 | don't care
  129. ----------------------------------------------------------------------------
  130. | 60 | packet sequence number
  131. ----------------------------------------------------------------------------
  132. | 61-63 | don't care
  133. ----------------------------------------------------------------------------
  134. ============================================================================
  135. | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET
  136. ============================================================================
  137. | 00 | 0xb1 register write command
  138. ----------------------------------------------------------------------------
  139. | 01-02 | register
  140. ----------------------------------------------------------------------------
  141. | 03 | 0x01
  142. ----------------------------------------------------------------------------
  143. | 04 | value
  144. ----------------------------------------------------------------------------
  145. | 05-59 | don't care
  146. ----------------------------------------------------------------------------
  147. | 60 | packet sequence number
  148. ----------------------------------------------------------------------------
  149. | 61-63 | don't care
  150. ----------------------------------------------------------------------------
  151. ============================================================================
  152. | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET
  153. ============================================================================
  154. | 00 | 0xb0 register read command
  155. ----------------------------------------------------------------------------
  156. | 01-02 | register
  157. ----------------------------------------------------------------------------
  158. | 03 | 0x01
  159. ----------------------------------------------------------------------------
  160. | 04-59 | don't care
  161. ----------------------------------------------------------------------------
  162. | 60 | packet sequence number
  163. ----------------------------------------------------------------------------
  164. | 61-63 | don't care
  165. ----------------------------------------------------------------------------
  166. ============================================================================
  167. | 00-63 | LED CONTROL REQUEST PACKET
  168. ============================================================================
  169. | 00 | 0x16 LED and IR control command
  170. ----------------------------------------------------------------------------
  171. | 01 | 0x01 (LED)
  172. ----------------------------------------------------------------------------
  173. | 03 | 0x00 blink
  174. | | 0x01 lights continuously
  175. ----------------------------------------------------------------------------
  176. | 04 | blink interval
  177. | | 0x00 fastest (looks like LED lights continuously)
  178. | | 0xff slowest
  179. ----------------------------------------------------------------------------
  180. | 05-59 | don't care
  181. ----------------------------------------------------------------------------
  182. | 60 | packet sequence number
  183. ----------------------------------------------------------------------------
  184. | 61-63 | don't care
  185. ----------------------------------------------------------------------------
  186. ============================================================================
  187. | 00-63 | IR CONTROL REQUEST PACKET
  188. ============================================================================
  189. | 00 | 0x16 LED and IR control command
  190. ----------------------------------------------------------------------------
  191. | 01 | 0x02 (IR)
  192. ----------------------------------------------------------------------------
  193. | 03 | 0x00 IR disabled
  194. | | 0x01 IR enabled
  195. ----------------------------------------------------------------------------
  196. | 04-59 | don't care
  197. ----------------------------------------------------------------------------
  198. | 60 | packet sequence number
  199. ----------------------------------------------------------------------------
  200. | 61-63 | don't care
  201. ----------------------------------------------------------------------------
  202. ============================================================================
  203. | 00-63 | STREAMING CONTROL REQUEST PACKET
  204. ============================================================================
  205. | 00 | 0x12 streaming control command
  206. ----------------------------------------------------------------------------
  207. | 01 | 0x00 streaming disabled
  208. | | 0x01 streaming enabled
  209. ----------------------------------------------------------------------------
  210. | 02 | 0x00
  211. ----------------------------------------------------------------------------
  212. | 03-59 | don't care
  213. ----------------------------------------------------------------------------
  214. | 60 | packet sequence number
  215. ----------------------------------------------------------------------------
  216. | 61-63 | don't care
  217. ----------------------------------------------------------------------------
  218. ============================================================================
  219. | 00-63 | REMOTE CONTROL REQUEST PACKET
  220. ============================================================================
  221. | 00 | 0x41 remote control command
  222. ----------------------------------------------------------------------------
  223. | 01-59 | don't care
  224. ----------------------------------------------------------------------------
  225. | 60 | packet sequence number
  226. ----------------------------------------------------------------------------
  227. | 61-63 | don't care
  228. ----------------------------------------------------------------------------
  229. ============================================================================
  230. | 00-63 | REMOTE CONTROL REPLY PACKET
  231. ============================================================================
  232. | 00 | 0x00 code not received
  233. | | 0x01 code received
  234. ----------------------------------------------------------------------------
  235. | 01 | remote control code
  236. ----------------------------------------------------------------------------
  237. | 02-59 | don't care
  238. ----------------------------------------------------------------------------
  239. | 60 | packet sequence number
  240. ----------------------------------------------------------------------------
  241. | 61-63 | don't care
  242. ----------------------------------------------------------------------------
  243. ============================================================================
  244. | 00-63 | GET HARDWARE INFO REQUEST PACKET
  245. ============================================================================
  246. | 00 | 0x19 get hardware info command
  247. ----------------------------------------------------------------------------
  248. | 01-59 | don't care
  249. ----------------------------------------------------------------------------
  250. | 60 | packet sequence number
  251. ----------------------------------------------------------------------------
  252. | 61-63 | don't care
  253. ----------------------------------------------------------------------------
  254. ============================================================================
  255. | 00-63 | GET HARDWARE INFO REPLY PACKET
  256. ============================================================================
  257. | 00 | hardware id
  258. ----------------------------------------------------------------------------
  259. | 01-02 | firmware version
  260. ----------------------------------------------------------------------------
  261. | 03-59 | don't care
  262. ----------------------------------------------------------------------------
  263. | 60 | packet sequence number
  264. ----------------------------------------------------------------------------
  265. | 61-63 | don't care
  266. ----------------------------------------------------------------------------
  267. ============================================================================
  268. | 00-63 | SMART CARD READER PACKET
  269. ============================================================================
  270. | 00 | 0x34 smart card reader command
  271. ----------------------------------------------------------------------------
  272. | xx |
  273. ----------------------------------------------------------------------------
  274. | xx-59 | don't care
  275. ----------------------------------------------------------------------------
  276. | 60 | packet sequence number
  277. ----------------------------------------------------------------------------
  278. | 61-63 | don't care
  279. ----------------------------------------------------------------------------
  280. */