summaryrefslogtreecommitdiffstats
path: root/Documentation/dvb/README.flexcop
blob: 8036faa1ead9d02bf2ede1a2cd7a6c2f4b89ff85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
This README escorted the skystar2-driver rewriting procedure. It describes the
state of the new flexcop-driver set and some internals are written down here
too.

How to do something in here?
============================

make -f Makefile.t
make -C ../build-2.6
./in.sh  # load the drivers
./rm.sh  # unload the drivers

Please read this file, if you want to contribute.

This document hopefully describes things about the flexcop and its
device-offsprings. Goal is to write a easy-to-write and easy-to-read set of
drivers based on the skystar2.c and other information.

This directory is temporary. It is used for rewriting the skystar2.c and to
create shared code, which then can be used by the usb box as well.

Remark: flexcop-pci.c was a copy of skystar2.c, but every line has been
touched and rewritten.

General coding processing
=========================

We should proceed as follows (as long as no one complains):

0) Think before start writing code!

1) rewriting the skystar2.c with the help of the flexcop register descriptions
and splitting up the files to a pci-bus-part and a flexcop-part.
The new driver will be called b2c2-flexcop-pci.ko/b2c2-flexcop-usb.ko for the
device-specific part and b2c2-flexcop.ko for the common flexcop-functions.

2) Search for errors in the leftover of flexcop-pci.c (compare with pluto2.c
and other pci drivers)

3) make some beautification (see 'Improvements when rewriting (refactoring) is
done')

4) Testing the new driver and maybe substitute the skystar2.c with it, to reach
a wider tester audience.

5) creating an usb-bus-part using the already written flexcop code for the pci
card.

Idea: create a kernel-object for the flexcop and export all important
functions. This option saves kernel-memory, but maybe a lot of functions have
to be exported to kernel namespace.


Current situation
=================

0) Done :)
1) Done (some minor issues left)
2) Done
3) Not ready yet, more information is necessary
4) next to be done (see the table below)
5) USB driver is working (yes, there are some minor issues)

What seems to be ready?
-----------------------

1) Rewriting
1a) i2c is cut off from the flexcop-pci.c and seems to work
1b) moved tuner and demod stuff from flexcop-pci.c to flexcop-tuner-fe.c
1c) moved lnb and diseqc stuff from flexcop-pci.c to flexcop-tuner-fe.c
1e) eeprom (reading MAC address)
1d) sram (no dynamic sll size detection (commented out) (using default as JJ told me))
1f) misc. register accesses for reading parameters (e.g. resetting, revision)
1g) pid/mac filter (flexcop-hw-filter.c)
1i) dvb-stuff initialization in flexcop.c (done)
1h) dma stuff (now just using the size-irq, instead of all-together, to be done)
1j) remove flexcop initialization from flexcop-pci.c completely (done)
1l) use a well working dma IRQ method (done, see 'Known bugs and problems and TODO')
1k) cleanup flexcop-files (remove unused EXPORT_SYMBOLs, make static from
non-static where possible, moved code to proper places)

2) Search for errors in the leftover of flexcop-pci.c (partially done)
5a) add MAC address reading

What to do in the near future?
--------------------------------------
(no special order here)


5) USB driver
5b) optimize isoc-transfer (submitting/killing isoc URBs when transfer is starting)
5c) feeding of ISOC data to the software demux (format of the isochronous data
and speed optimization, no real error)

Testing changes
---------------

O             = item is working
P             = item is partially working
X             = item is not working
N             = item does not apply here
<empty field> = item need to be examined

       | PCI                               | USB
item   | mt352 | nxt2002 | stv0299 | mt312 | mt352 | nxt2002 | stv0299 | mt312
-------+-------+---------+---------+-------+-------+---------+---------+-------
1a)    | O     |         |         |       | N     | N       | N       | N
1b)    | O     |         |         |       |       |         | O       |
1c)    | N     | N       |         |       | N     | N       | O       |
1d)    |                 O                 |                 O
1e)    |                 O                 |                 O
1f)    |                                   P
1g)    |                                   O
1h)    |                 P                 |
1i)    |                 O                 |                 N
1j)    |                 O                 |                 N
1l)    |                 O                 |                 N
2)     |                 O                 |                 N
5a)    |                 N                 |                 O
5b)*   |                 N                 |
5c)*   |                 N                 |

* - not done yet

Known bugs and problems and TODO
--------------------------------

1g/h/l) when pid filtering is enabled on the pci card

DMA usage currently:
  The DMA is splitted in 2 equal-sized subbuffers. The Flexcop writes to first
  address and triggers an IRQ when it's full and starts writing to the second
  address. When the second address is full, the IRQ is triggered again, and
  the flexcop writes to first address again, and so on.
  The buffersize of each address is currently 640*188 bytes.

  Problem is, when using hw-pid-filtering and doing some low-bandwidth
  operation (like scanning) the buffers won't be filled enough to trigger
  the IRQ. That's why:

  When PID filtering is activated, the timer IRQ is used. Every 1.97 ms the IRQ
  is triggered.  Is the current write address of DMA1 different to the one
  during the last IRQ, then the data is passed to the demuxer.

  There is an additional DMA-IRQ-method: packet count IRQ. This isn't
  implemented correctly yet.

  The solution is to disable HW PID filtering, but I don't know how the DVB
  API software demux behaves on slow systems with 45MBit/s TS.

Solved bugs :)
--------------
1g) pid-filtering (somehow pid index 4 and 5 (EMM_PID and ECM_PID) aren't
working)
SOLUTION: also index 0 was affected, because net_translation is done for
these indexes by default

5b) isochronous transfer does only work in the first attempt (for the Sky2PC USB,
Air2PC is working)
SOLUTION: the flexcop was going asleep and never really woke up again (don't
know if this need fixes, see flexcop-fe-tuner.c:flexcop_sleep)

Improvements when rewriting (refactoring) is done
=================================================

- split sleeping of the flexcop (misc_204.ACPI3_sig = 1;) from lnb_control
  (enable sleeping for other demods than dvb-s)
- add support for CableStar (stv0297 Microtune 203x/ALPS)

Debugging
---------
- add verbose debugging to skystar2.c (dump the reg_dw_data) and compare it
  with this flexcop, this is important, because i2c is now using the
  flexcop_ibi_value union from flexcop-reg.h (do you have a better idea for
  that, please tell us so).

Everything which is identical in the following table, can be put into a common
flexcop-module.

                  PCI                  USB
-------------------------------------------------------------------------------
Different:
Register access:  accessing IO memory  USB control message
I2C bus:          I2C bus of the FC    USB control message
Data transfer:    DMA                  isochronous transfer
EEPROM transfer:  through i2c bus      not clear yet

Identical:
Streaming:                 accessing registers
PID Filtering:             accessing registers
Sram destinations:         accessing registers
Tuner/Demod:                     I2C bus
DVB-stuff:            can be written for common use

Restrictions:
============

We need to create a bus-specific-struct and a flexcop-struct.

bus-specific-struct:

struct flexcop_pci
...

struct flexcop_usb
...


struct flexcop_device {
	void *bus_specific; /* container for bus-specific struct */
...
}

PCI i2c can read/write max 4 bytes at a time, USB can more

Functions
=========

Syntax
------

- Flexcop functions will be called "flexcop(_[a-z0-9]+)+" and exported as such
  if needed.
- Flexcop-device functions will be called "flexcop_device(_[a-z0-9]+)+" and
  exported as such if needed.
- Both will be compiled to b2c2-flexcop.ko and their source can be found in the
  flexcop*.[hc]

Callbacks and exports
---------------------

Bus-specific functions will be given as callbacks (function pointers) to the
flexcop-module. (within the flexcop_device-struct)

Initialization process
======================

b2c2-flexcop.ko is loaded
b2c2-flexcop-<bus>.ko is loaded

suppose a device is found:
malloc flexcop and the bus-specific variables (via flexcop_device_malloc)
fill the bus-specific variable
fill the flexcop variable (especially the bus-specific callbacks)
bus-specific initialization
	- ...
do the common initialization (via flexcop_device_initialize)
	- reset the card
	- determine flexcop type (II, IIB, III)
	- hw_filters (bus dependent)
	- 0x204
	- set sram size
	- create the dvb-stuff
	- create i2c stuff
	- frontend-initialization
done
bus specific:
	- media_destination (this and the following 3 are bus specific)
	- cai_dest
	- cao_dest
	- net_destination

Bugs fixed while rewriting the driver
=====================================

- EEPROM access (to read the MAC address) was fixed to death some time last
  year. (fixed here and in skystar2.c) (Bjarne, this was the piece of code
  (fix-chipaddr) we were wondering about)


Acknowledgements (just for the rewriting part)
================

Bjarne Steinsbo thought a lot in the first place of the pci part for this code
sharing idea.

Andreas Oberritter for providing a recent PCI initialization template
(pluto2.c).

Boleslaw Ciesielski for pointing out a problem with firmware loader.

Vadim Catana for correcting the USB transfer.

comments, critics and ideas to linux-dvb@linuxtv.org or patrick.boettcher@desy.de
OpenPOWER on IntegriCloud