xref: /OK3568_Linux_fs/external/mpp/doc/design/2.kernel_driver.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunHardware kernel driver design (2016.10.17)
2*4882a593Smuzhiyun================================================================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunRockchip has two sets of hardware kernel driver.
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunThe first one is vcodec_service/vpu_service/mpp_service which is a high
7*4882a593Smuzhiyunperformance stateless frame base hardware kernel driver. This driver supports
8*4882a593Smuzhiyunall available codecs that hardware can provide. This driver is used on Android/
9*4882a593SmuzhiyunLinux.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunHere is the vcodec_service kernel driver framework diagram.
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun    +-------------+             +-------------+             +-------------+
14*4882a593Smuzhiyun    |  client  A  |             |  client  B  |             |  client  C  |
15*4882a593Smuzhiyun    +-------------+             +-------------+             +-------------+
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunuserspace
18*4882a593Smuzhiyun+------------------------------------------------------------------------------+
19*4882a593Smuzhiyun kernel
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun    +-------------+             +-------------+             +-------------+
22*4882a593Smuzhiyun    |  session A  |             |  session B  |             |  session C  |
23*4882a593Smuzhiyun    +-------------+             +-------------+             +-------------+
24*4882a593Smuzhiyun    |             |             |             |             |             |
25*4882a593Smuzhiyun waiting         done        waiting         done        waiting         done
26*4882a593Smuzhiyun    |             |             |             |             |             |
27*4882a593Smuzhiyun+---+---+     +---+---+     +---+---+     +---+---+                   +---+---+
28*4882a593Smuzhiyun| task3 |     | task0 |     | task1 |     | task0 |                   | task0 |
29*4882a593Smuzhiyun+---+---+     +-------+     +-------+     +-------+                   +---+---+
30*4882a593Smuzhiyun    |                                                                     |
31*4882a593Smuzhiyun+---+---+                                                             +---+---+
32*4882a593Smuzhiyun| task2 |                                                             | task1 |
33*4882a593Smuzhiyun+-------+                                                             +-------+
34*4882a593Smuzhiyun                                 +-----------+
35*4882a593Smuzhiyun                                 |  service  |
36*4882a593Smuzhiyun                       +---------+-----------+---------+
37*4882a593Smuzhiyun                       |               |               |
38*4882a593Smuzhiyun                    waiting         running          done
39*4882a593Smuzhiyun                       |               |               |
40*4882a593Smuzhiyun                 +-----+-----+   +-----+-----+   +-----+-----+
41*4882a593Smuzhiyun                 |  task A2  |   |  task A1  |   |  task C0  |
42*4882a593Smuzhiyun                 +-----+-----+   +-----------+   +-----+-----+
43*4882a593Smuzhiyun                       |                               |
44*4882a593Smuzhiyun                 +-----+-----+                   +-----+-----+
45*4882a593Smuzhiyun                 |  task B1  |                   |  task C1  |
46*4882a593Smuzhiyun                 +-----+-----+                   +-----+-----+
47*4882a593Smuzhiyun                       |                               |
48*4882a593Smuzhiyun                 +-----+-----+                   +-----+-----+
49*4882a593Smuzhiyun                 |  task A3  |                   |  task A0  |
50*4882a593Smuzhiyun                 +-----------+                   +-----+-----+
51*4882a593Smuzhiyun                       |
52*4882a593Smuzhiyun                 +-----+-----+
53*4882a593Smuzhiyun                 |  task B0  |
54*4882a593Smuzhiyun                 +-----------+
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunThe principle of this design is to separate user task handling and hardware
57*4882a593Smuzhiyunresource management and minimize the kernel serial process time between two
58*4882a593Smuzhiyunhardware process operation.
59*4882a593Smuzhiyun
60*4882a593SmuzhiyunThe driver uses session as communication channel. Each userspace client (client)
61*4882a593Smuzhiyunwill have a kernel session. Client will commit tasks to session. Then hardware
62*4882a593Smuzhiyunis managed by service (vpu_service/vcodec_service). Service will provide the
63*4882a593Smuzhiyunability to process tasks in sessions.
64*4882a593Smuzhiyun
65*4882a593SmuzhiyunWhen client commits a task to kernel the task will be set to waiting status and
66*4882a593Smuzhiyunlink to both session waiting list and service waiting list. Then service will
67*4882a593Smuzhiyunget task from waiting list to running list and run. When hardware finishs a task
68*4882a593Smuzhiyunthe task will be moved to done list and put to both service done list and
69*4882a593Smuzhiyunsession done list. Finally client will get the finished task from session.
70*4882a593Smuzhiyun
71