xref: /rockchip-linux_mpp/mpp/hal/inc/hal_task.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __HAL_TASK__
18 #define __HAL_TASK__
19 
20 #include "rk_type.h"
21 #include "mpp_err.h"
22 
23 typedef enum HalTaskStatus_e {
24     TASK_IDLE,
25     TASK_PROCESSING,
26     TASK_PROC_DONE,
27     TASK_BUTT,
28 } HalTaskStatus;
29 
30 typedef void* HalTaskHnd;
31 typedef void* HalTaskGroup;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * group init / deinit will be called by hal
39  * HalTaskGroup is a group of task list with status
40  */
41 MPP_RET hal_task_group_init(HalTaskGroup *group, RK_S32 stage_cnt,
42                             RK_S32 task_cnt, RK_S32 task_size);
43 MPP_RET hal_task_group_deinit(HalTaskGroup group);
44 
45 /*
46  * normal working flow:
47  *
48  * dec:
49  *
50  * - codec
51  * hal_task_get_hnd(group, idle, hnd)       - dec try get idle task to work
52  * hal_task_hnd_set_status(hnd, prepare)    - dec prepare the task
53  * codec prepare task
54  * hal_task_hnd_set_status(hnd, wait_proc)  - dec send the task to hardware queue
55  *
56  * - hal
57  * hal_task_get_hnd(group, wait_proc, hnd)  - hal get task on wait_proc status
58  * hal start task
59  * hal_task_set_hnd(hnd, processing)        - hal send task to hardware for process
60  * hal wait task done
61  * hal_task_set_hnd(hnd, proc_done)         - hal mark task is finished
62  *
63  * - codec
64  * hal_task_get_hnd(group, task_done, hnd)  - codec query the previous finished task
65  * codec do error process on task
66  * hal_task_set_hnd(hnd, idle)              - codec mark task is idle
67  *
68  */
69 MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_S32 status, HalTaskHnd *hnd);
70 RK_S32  hal_task_get_count(HalTaskGroup group, RK_S32 status);
71 MPP_RET hal_task_hnd_set_status(HalTaskHnd hnd, RK_S32 status);
72 MPP_RET hal_task_hnd_set_info(HalTaskHnd hnd, void *task);
73 MPP_RET hal_task_hnd_get_info(HalTaskHnd hnd, void *task);
74 void   *hal_task_hnd_get_data(HalTaskHnd hnd);
75 MPP_RET hal_task_check_empty(HalTaskGroup group, RK_S32 status);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /*__HAL_TASK__*/
82