• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __TDE_OSILIST_H__
20 #define __TDE_OSILIST_H__
21 
22 #include "drv_tde_ioctl.h"
23 #include "tde_define.h"
24 #include "drv_tde_type.h"
25 #include "osal_list.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 #endif /* __cplusplus */
32 
33 /* Data struct of software list node */
34 typedef struct {
35     struct osal_list_head list;
36     hi_s32 handle;                   /* Job handle of the instruct */
37     hi_s32 index;                    /*
38                                       * Instruct serial number in job,
39                                       * form one on start, the same number is the same instruct
40                                       */
41     tde_node_subm_type subm_type;   /* current node type */
42     tde_node_buf node_buf;          /* Node of operate config */
43     hi_u32 phy_buff_num;            /* Number of physical buffer distributed */
44 } tde_swnode;
45 
46 /* Job definition */
47 typedef struct {
48     struct osal_list_head list;
49     hi_s32 handle;                /* Job handle */
50     tde_func_cb func_compl_cb;     /* Pointer of callback function */
51     hi_void *func_para;           /* Arguments of callback function */
52     tde_notify_mode noti_type; /* Notice type after node completed */
53     hi_u32 cmd_num;             /* Instruct number of job */
54     hi_u32 node_num;            /* Node number of job */
55     tde_swnode *first_cmd;    /* Software node of first instruct in job */
56     tde_swnode *last_cmd;     /* Software node of last instruct in job  */
57     tde_swnode *tail_node;    /* Last software node of job */
58 #ifndef HI_BUILD_IN_BOOT
59     osal_wait_t query; /* Wait queue used in query */
60 #endif
61     hi_bool submitted;       /* If have submitted */
62     hi_bool aq_use_buff;       /* If using temporary buffer */
63     hi_u8 wait_for_done_count; /* wait job count */
64     hi_void *private_data;
65 } tde_swjob;
66 
67 /*
68  * Function:      tde_osi_list_init
69  * Description:   Initialize all lists inside software to use as TDE operation cache
70  * Return:        Success/fail
71  */
72 hi_s32 tde_osi_list_init(hi_void);
73 
74 /*
75  * Function:      tde_osi_list_term
76  * Description:   Release all lists inside software to use as TDE operation cache
77  */
78 hi_void tde_osi_list_term(hi_void);
79 
80 hi_s32 tde_osi_list_begin_job(hi_s32 *handle, hi_void *private_data);
81 
82 /*
83  * Function:      tde_osi_list_cancel_job
84  * Description:   Delete list of handle point
85  * Input:         handle: the list wait for delete
86  * Return:        success/fail
87  */
88 hi_s32 tde_osi_list_cancel_job(hi_s32 handle);
89 
90 /*
91  * Function:      tde_osi_list_submit_job
92  * Description:   Create list, return head pointer of list
93  * Input:         handle: Head pointer of job needing submit
94  *                is_block: if block
95  *                time_out: time out
96  *                func_compl_cb: callback function of complete operate
97  * Return:        success/fail/time out
98  */
99 #if (TDE_CAPABILITY & SYNC)
100 hi_s32 tde_osi_list_submit_job(drv_tde_end_job_cmd *end_job, tde_func_cb func_compl_cb, hi_void *func_para,
101                                tde_notify_mode noti_type, hi_bool is_sync);
102 #else
103 hi_s32 tde_osi_list_submit_job(drv_tde_end_job_cmd *end_job, tde_func_cb func_compl_cb, hi_void *func_para,
104                                tde_notify_mode noti_type);
105 #endif
106 
107 /*
108  * Prototype    : func_compl_cb
109  * Description  : wait for all TDE operate completed
110  * Return Value : HI_SUCCESS,TDE operate completed
111  */
112 #ifndef HI_BUILD_IN_BOOT
113 hi_s32 tde_osi_list_wait_all_done(hi_void);
114 
115 /*
116  * Function:      tde_osi_list_wait_for_done
117  * Description:   Query if submitted TDE operate is completed
118  * Input:         handle: task handle
119  *                time_out: if Time out
120  * Return:        Success/fail
121  */
122 hi_s32 tde_osi_list_wait_for_done(hi_s32 handle, hi_u32 time_out);
123 
124 /*
125  * Function:      tde_osi_list_comp_proc
126  * Description:   Interrupt to handling all list operate is completed
127  * Return:        task handle is created
128  */
129 hi_void tde_osi_list_comp_proc(hi_void);
130 #ifdef TDE_HWC_COOPERATE
131 hi_void tde_osi_list_comp(hi_void);
132 #endif
133 hi_void tde_osi_list_node_comp(hi_void);
134 #endif
135 
136 /*
137  * Function:      tde_osi_list_get_phy_buff
138  * Description:   Get one physical buffer, used in deflicker and zoom
139  * Return:        physical address assigned
140  */
141 hi_u32 tde_osi_list_get_phy_buff(hi_u32 cb_cr_offset);
142 
143 hi_void tde_osi_list_put_phy_buff(hi_u32 buff_num);
144 
145 hi_void tde_osi_list_free_serial_cmd(tde_swnode *fst_cmd, tde_swnode *last_cmd);
146 hi_s32 tde_osi_list_lock_working_flag(unsigned long *lock);
147 
148 hi_s32 tde_osi_list_unlock_working_flag(unsigned long *lock);
149 
150 hi_s32 tde_osi_list_get_working_flag(hi_bool *flag);
151 
152 #ifdef __cplusplus
153 #if __cplusplus
154 }
155 #endif /* __cplusplus */
156 #endif /* __cplusplus */
157 
158 #endif /* _TDE_OSILIST_H_ */
159