ci.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. * For the user
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. NOTE: This document describes the usage of the high level CI API as
  4. in accordance to the Linux DVB API. This is a not a documentation for the,
  5. existing low level CI API.
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. To utilize the High Level CI capabilities,
  8. (1*) This point is valid only for the Twinhan/clones
  9. For the Twinhan/Twinhan clones, the dst_ca module handles the CI
  10. hardware handling.This module is loaded automatically if a CI
  11. (Common Interface, that holds the CAM (Conditional Access Module)
  12. is detected.
  13. (2) one requires a userspace application, ca_zap. This small userland
  14. application is in charge of sending the descrambling related information
  15. to the CAM.
  16. This application requires the following to function properly as of now.
  17. (a) Tune to a valid channel, with szap.
  18. eg: $ szap -c channels.conf -r "TMC" -x
  19. (b) a channels.conf containing a valid PMT PID
  20. eg: TMC:11996:h:0:27500:278:512:650:321
  21. here 278 is a valid PMT PID. the rest of the values are the
  22. same ones that szap uses.
  23. (c) after running a szap, you have to run ca_zap, for the
  24. descrambler to function,
  25. eg: $ ca_zap patched_channels.conf "TMC"
  26. The patched means a patch to apply to scan, such that scan can
  27. generate a channels.conf_with pmt, which has this PMT PID info
  28. (NOTE: szap cannot use this channels.conf with the PMT_PID)
  29. (d) Hopeflly Enjoy your favourite subscribed channel as you do with
  30. a FTA card.
  31. (3) Currently ca_zap, and dst_test, both are meant for demonstration
  32. purposes only, they can become full fledged applications if necessary.
  33. * Cards that fall in this category
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. At present the cards that fall in this category are the Twinhan and it's
  36. clones, these cards are available as VVMER, Tomato, Hercules, Orange and
  37. so on.
  38. * CI modules that are supported
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. The CI module support is largely dependant upon the firmware on the cards
  41. Some cards do support almost all of the available CI modules. There is
  42. nothing much that can be done in order to make additional CI modules
  43. working with these cards.
  44. Modules that have been tested by this driver at present are
  45. (1) Irdeto 1 and 2 from SCM
  46. (2) Viaccess from SCM
  47. (3) Dragoncam
  48. * The High level CI API
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. * For the programmer
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. With the High Level CI approach any new card with almost any random
  53. architecture can be implemented with this style, the definitions
  54. insidethe switch statement can be easily adapted for any card, thereby
  55. eliminating the need for any additional ioctls.
  56. The disadvantage is that the driver/hardware has to manage the rest. For
  57. the application programmer it would be as simple as sending/receiving an
  58. array to/from the CI ioctls as defined in the Linux DVB API. No changes
  59. have been made in the API to accomodate this feature.
  60. * Why the need for another CI interface ?
  61. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. This is one of the most commonly asked question. Well a nice question.
  63. Strictly speaking this is not a new interface.
  64. The CI interface is defined in the DVB API in ca.h as
  65. typedef struct ca_slot_info {
  66. int num; /* slot number */
  67. int type; /* CA interface this slot supports */
  68. #define CA_CI 1 /* CI high level interface */
  69. #define CA_CI_LINK 2 /* CI link layer level interface */
  70. #define CA_CI_PHYS 4 /* CI physical layer level interface */
  71. #define CA_DESCR 8 /* built-in descrambler */
  72. #define CA_SC 128 /* simple smart card interface */
  73. unsigned int flags;
  74. #define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
  75. #define CA_CI_MODULE_READY 2
  76. } ca_slot_info_t;
  77. This CI interface follows the CI high level interface, which is not
  78. implemented by most applications. Hence this area is revisited.
  79. This CI interface is quite different in the case that it tries to
  80. accomodate all other CI based devices, that fall into the other categories
  81. This means that this CI interface handles the EN50221 style tags in the
  82. Application layer only and no session management is taken care of by the
  83. application. The driver/hardware will take care of all that.
  84. This interface is purely an EN50221 interface exchanging APDU's. This
  85. means that no session management, link layer or a transport layer do
  86. exist in this case in the application to driver communication. It is
  87. as simple as that. The driver/hardware has to take care of that.
  88. With this High Level CI interface, the interface can be defined with the
  89. regular ioctls.
  90. All these ioctls are also valid for the High level CI interface
  91. #define CA_RESET _IO('o', 128)
  92. #define CA_GET_CAP _IOR('o', 129, ca_caps_t)
  93. #define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t)
  94. #define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
  95. #define CA_GET_MSG _IOR('o', 132, ca_msg_t)
  96. #define CA_SEND_MSG _IOW('o', 133, ca_msg_t)
  97. #define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
  98. #define CA_SET_PID _IOW('o', 135, ca_pid_t)
  99. On querying the device, the device yields information thus
  100. CA_GET_SLOT_INFO
  101. ----------------------------
  102. Command = [info]
  103. APP: Number=[1]
  104. APP: Type=[1]
  105. APP: flags=[1]
  106. APP: CI High level interface
  107. APP: CA/CI Module Present
  108. CA_GET_CAP
  109. ----------------------------
  110. Command = [caps]
  111. APP: Slots=[1]
  112. APP: Type=[1]
  113. APP: Descrambler keys=[16]
  114. APP: Type=[1]
  115. CA_SEND_MSG
  116. ----------------------------
  117. Descriptors(Program Level)=[ 09 06 06 04 05 50 ff f1]
  118. Found CA descriptor @ program level
  119. (20) ES type=[2] ES pid=[201] ES length =[0 (0x0)]
  120. (25) ES type=[4] ES pid=[301] ES length =[0 (0x0)]
  121. ca_message length is 25 (0x19) bytes
  122. EN50221 CA MSG=[ 9f 80 32 19 03 01 2d d1 f0 08 01 09 06 06 04 05 50 ff f1 02 e0 c9 00 00 04 e1 2d 00 00]
  123. Not all ioctl's are implemented in the driver from the API, the other
  124. features of the hardware that cannot be implemented by the API are achieved
  125. using the CA_GET_MSG and CA_SEND_MSG ioctls. An EN50221 style wrapper is
  126. used to exchange the data to maintain compatibility with other hardware.
  127. /* a message to/from a CI-CAM */
  128. typedef struct ca_msg {
  129. unsigned int index;
  130. unsigned int type;
  131. unsigned int length;
  132. unsigned char msg[256];
  133. } ca_msg_t;
  134. The flow of data can be described thus,
  135. App (User)
  136. -----
  137. parse
  138. |
  139. |
  140. v
  141. en50221 APDU (package)
  142. --------------------------------------
  143. | | | High Level CI driver
  144. | | |
  145. | v |
  146. | en50221 APDU (unpackage) |
  147. | | |
  148. | | |
  149. | v |
  150. | sanity checks |
  151. | | |
  152. | | |
  153. | v |
  154. | do (H/W dep) |
  155. --------------------------------------
  156. | Hardware
  157. |
  158. v
  159. The High Level CI interface uses the EN50221 DVB standard, following a
  160. standard ensures futureproofness.