README.flexcop 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. This README escorted the skystar2-driver rewriting procedure. It describes the
  2. state of the new flexcop-driver set and some internals are written down here
  3. too.
  4. How to do something in here?
  5. ============================
  6. make -f Makefile.t
  7. make -C ../build-2.6
  8. ./in.sh # load the drivers
  9. ./rm.sh # unload the drivers
  10. Please read this file, if you want to contribute.
  11. This document hopefully describes things about the flexcop and its
  12. device-offsprings. Goal is to write a easy-to-write and easy-to-read set of
  13. drivers based on the skystar2.c and other information.
  14. This directory is temporary. It is used for rewriting the skystar2.c and to
  15. create shared code, which then can be used by the usb box as well.
  16. Remark: flexcop-pci.c was a copy of skystar2.c, but every line has been
  17. touched and rewritten.
  18. General coding processing
  19. =========================
  20. We should proceed as follows (as long as no one complains):
  21. 0) Think before start writing code!
  22. 1) rewriting the skystar2.c with the help of the flexcop register descriptions
  23. and splitting up the files to a pci-bus-part and a flexcop-part.
  24. The new driver will be called b2c2-flexcop-pci.ko/b2c2-flexcop-usb.ko for the
  25. device-specific part and b2c2-flexcop.ko for the common flexcop-functions.
  26. 2) Search for errors in the leftover of flexcop-pci.c (compare with pluto2.c
  27. and other pci drivers)
  28. 3) make some beautification (see 'Improvements when rewriting (refactoring) is
  29. done')
  30. 4) Testing the new driver and maybe substitute the skystar2.c with it, to reach
  31. a wider tester audience.
  32. 5) creating an usb-bus-part using the already written flexcop code for the pci
  33. card.
  34. Idea: create a kernel-object for the flexcop and export all important
  35. functions. This option saves kernel-memory, but maybe a lot of functions have
  36. to be exported to kernel namespace.
  37. Current situation
  38. =================
  39. 0) Done :)
  40. 1) Done (some minor issues left)
  41. 2) Done
  42. 3) Not ready yet, more information is necessary
  43. 4) next to be done (see the table below)
  44. 5) USB driver is working (yes, there are some minor issues)
  45. What seems to be ready?
  46. -----------------------
  47. 1) Rewriting
  48. 1a) i2c is cut off from the flexcop-pci.c and seems to work
  49. 1b) moved tuner and demod stuff from flexcop-pci.c to flexcop-tuner-fe.c
  50. 1c) moved lnb and diseqc stuff from flexcop-pci.c to flexcop-tuner-fe.c
  51. 1e) eeprom (reading MAC address)
  52. 1d) sram (no dynamic sll size detection (commented out) (using default as JJ told me))
  53. 1f) misc. register accesses for reading parameters (e.g. resetting, revision)
  54. 1g) pid/mac filter (flexcop-hw-filter.c)
  55. 1i) dvb-stuff initialization in flexcop.c (done)
  56. 1h) dma stuff (now just using the size-irq, instead of all-together, to be done)
  57. 1j) remove flexcop initialization from flexcop-pci.c completely (done)
  58. 1l) use a well working dma IRQ method (done, see 'Known bugs and problems and TODO')
  59. 1k) cleanup flexcop-files (remove unused EXPORT_SYMBOLs, make static from
  60. non-static where possible, moved code to proper places)
  61. 2) Search for errors in the leftover of flexcop-pci.c (partially done)
  62. 5a) add MAC address reading
  63. What to do in the near future?
  64. --------------------------------------
  65. (no special order here)
  66. 5) USB driver
  67. 5b) optimize isoc-transfer (submitting/killing isoc URBs when transfer is starting)
  68. 5c) feeding of ISOC data to the software demux (format of the isochronous data
  69. and speed optimization, no real error)
  70. Testing changes
  71. ---------------
  72. O = item is working
  73. P = item is partially working
  74. X = item is not working
  75. N = item does not apply here
  76. <empty field> = item need to be examined
  77. | PCI | USB
  78. item | mt352 | nxt2002 | stv0299 | mt312 | mt352 | nxt2002 | stv0299 | mt312
  79. -------+-------+---------+---------+-------+-------+---------+---------+-------
  80. 1a) | O | | | | N | N | N | N
  81. 1b) | O | | | | | | O |
  82. 1c) | N | N | | | N | N | O |
  83. 1d) | O | O
  84. 1e) | O | O
  85. 1f) | P
  86. 1g) | O
  87. 1h) | P |
  88. 1i) | O | N
  89. 1j) | O | N
  90. 1l) | O | N
  91. 2) | O | N
  92. 5a) | N | O
  93. 5b)* | N |
  94. 5c)* | N |
  95. * - not done yet
  96. Known bugs and problems and TODO
  97. --------------------------------
  98. 1g/h/l) when pid filtering is enabled on the pci card
  99. DMA usage currently:
  100. The DMA is splitted in 2 equal-sized subbuffers. The Flexcop writes to first
  101. address and triggers an IRQ when it's full and starts writing to the second
  102. address. When the second address is full, the IRQ is triggered again, and
  103. the flexcop writes to first address again, and so on.
  104. The buffersize of each address is currently 640*188 bytes.
  105. Problem is, when using hw-pid-filtering and doing some low-bandwidth
  106. operation (like scanning) the buffers won't be filled enough to trigger
  107. the IRQ. That's why:
  108. When PID filtering is activated, the timer IRQ is used. Every 1.97 ms the IRQ
  109. is triggered. Is the current write address of DMA1 different to the one
  110. during the last IRQ, then the data is passed to the demuxer.
  111. There is an additional DMA-IRQ-method: packet count IRQ. This isn't
  112. implemented correctly yet.
  113. The solution is to disable HW PID filtering, but I don't know how the DVB
  114. API software demux behaves on slow systems with 45MBit/s TS.
  115. Solved bugs :)
  116. --------------
  117. 1g) pid-filtering (somehow pid index 4 and 5 (EMM_PID and ECM_PID) aren't
  118. working)
  119. SOLUTION: also index 0 was affected, because net_translation is done for
  120. these indexes by default
  121. 5b) isochronous transfer does only work in the first attempt (for the Sky2PC USB,
  122. Air2PC is working)
  123. SOLUTION: the flexcop was going asleep and never really woke up again (don't
  124. know if this need fixes, see flexcop-fe-tuner.c:flexcop_sleep)
  125. Improvements when rewriting (refactoring) is done
  126. =================================================
  127. - split sleeping of the flexcop (misc_204.ACPI3_sig = 1;) from lnb_control
  128. (enable sleeping for other demods than dvb-s)
  129. - add support for CableStar (stv0297 Microtune 203x/ALPS)
  130. Debugging
  131. ---------
  132. - add verbose debugging to skystar2.c (dump the reg_dw_data) and compare it
  133. with this flexcop, this is important, because i2c is now using the
  134. flexcop_ibi_value union from flexcop-reg.h (do you have a better idea for
  135. that, please tell us so).
  136. Everything which is identical in the following table, can be put into a common
  137. flexcop-module.
  138. PCI USB
  139. -------------------------------------------------------------------------------
  140. Different:
  141. Register access: accessing IO memory USB control message
  142. I2C bus: I2C bus of the FC USB control message
  143. Data transfer: DMA isochronous transfer
  144. EEPROM transfer: through i2c bus not clear yet
  145. Identical:
  146. Streaming: accessing registers
  147. PID Filtering: accessing registers
  148. Sram destinations: accessing registers
  149. Tuner/Demod: I2C bus
  150. DVB-stuff: can be written for common use
  151. Restrictions:
  152. ============
  153. We need to create a bus-specific-struct and a flexcop-struct.
  154. bus-specific-struct:
  155. struct flexcop_pci
  156. ...
  157. struct flexcop_usb
  158. ...
  159. struct flexcop_device {
  160. void *bus_specific; /* container for bus-specific struct */
  161. ...
  162. }
  163. PCI i2c can read/write max 4 bytes at a time, USB can more
  164. Functions
  165. =========
  166. Syntax
  167. ------
  168. - Flexcop functions will be called "flexcop(_[a-z0-9]+)+" and exported as such
  169. if needed.
  170. - Flexcop-device functions will be called "flexcop_device(_[a-z0-9]+)+" and
  171. exported as such if needed.
  172. - Both will be compiled to b2c2-flexcop.ko and their source can be found in the
  173. flexcop*.[hc]
  174. Callbacks and exports
  175. ---------------------
  176. Bus-specific functions will be given as callbacks (function pointers) to the
  177. flexcop-module. (within the flexcop_device-struct)
  178. Initialization process
  179. ======================
  180. b2c2-flexcop.ko is loaded
  181. b2c2-flexcop-<bus>.ko is loaded
  182. suppose a device is found:
  183. malloc flexcop and the bus-specific variables (via flexcop_device_malloc)
  184. fill the bus-specific variable
  185. fill the flexcop variable (especially the bus-specific callbacks)
  186. bus-specific initialization
  187. - ...
  188. do the common initialization (via flexcop_device_initialize)
  189. - reset the card
  190. - determine flexcop type (II, IIB, III)
  191. - hw_filters (bus dependent)
  192. - 0x204
  193. - set sram size
  194. - create the dvb-stuff
  195. - create i2c stuff
  196. - frontend-initialization
  197. done
  198. bus specific:
  199. - media_destination (this and the following 3 are bus specific)
  200. - cai_dest
  201. - cao_dest
  202. - net_destination
  203. Bugs fixed while rewriting the driver
  204. =====================================
  205. - EEPROM access (to read the MAC address) was fixed to death some time last
  206. year. (fixed here and in skystar2.c) (Bjarne, this was the piece of code
  207. (fix-chipaddr) we were wondering about)
  208. Acknowledgements (just for the rewriting part)
  209. ================
  210. Bjarne Steinsbo thought a lot in the first place of the pci part for this code
  211. sharing idea.
  212. Andreas Oberritter for providing a recent PCI initialization template
  213. (pluto2.c).
  214. Boleslaw Ciesielski for pointing out a problem with firmware loader.
  215. Vadim Catana for correcting the USB transfer.
  216. comments, critics and ideas to linux-dvb@linuxtv.org or patrick.boettcher@desy.de