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