Venkat Chinta | ddbe513 | 2018-01-30 12:00:29 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | #ifndef _CAM_REQ_MGR_CORE_H_ |
| 13 | #define _CAM_REQ_MGR_CORE_H_ |
| 14 | |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 16 | #include "cam_req_mgr_interface.h" |
| 17 | #include "cam_req_mgr_core_defs.h" |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 18 | #include "cam_req_mgr_timer.h" |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 19 | |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 20 | #define CAM_REQ_MGR_MAX_LINKED_DEV 16 |
| 21 | #define MAX_REQ_SLOTS 48 |
| 22 | |
| 23 | #define CAM_REQ_MGR_WATCHDOG_TIMEOUT 5000 |
| 24 | #define CAM_REQ_MGR_SCHED_REQ_TIMEOUT 1000 |
| 25 | #define CAM_REQ_MGR_SIMULATE_SCHED_REQ 30 |
| 26 | |
| 27 | #define FORCE_DISABLE_RECOVERY 2 |
| 28 | #define FORCE_ENABLE_RECOVERY 1 |
| 29 | #define AUTO_RECOVERY 0 |
| 30 | |
Sagar Gore | b56c81e | 2017-05-08 17:15:47 -0700 | [diff] [blame] | 31 | #define CRM_WORKQ_NUM_TASKS 60 |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 32 | |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 33 | #define MAX_SYNC_COUNT 65535 |
| 34 | |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 35 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 36 | * enum crm_workq_task_type |
| 37 | * @codes: to identify which type of task is present |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 38 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 39 | enum crm_workq_task_type { |
| 40 | CRM_WORKQ_TASK_GET_DEV_INFO, |
| 41 | CRM_WORKQ_TASK_SETUP_LINK, |
| 42 | CRM_WORKQ_TASK_DEV_ADD_REQ, |
| 43 | CRM_WORKQ_TASK_APPLY_REQ, |
| 44 | CRM_WORKQ_TASK_NOTIFY_SOF, |
| 45 | CRM_WORKQ_TASK_NOTIFY_ERR, |
| 46 | CRM_WORKQ_TASK_SCHED_REQ, |
| 47 | CRM_WORKQ_TASK_FLUSH_REQ, |
| 48 | CRM_WORKQ_TASK_INVALID, |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * struct crm_task_payload |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 53 | * @type : to identify which type of task is present |
| 54 | * @u : union of payload of all types of tasks supported |
| 55 | * @sched_req : contains info of incoming reqest from CSL to CRM |
| 56 | * @flush_info : contains info of cancelled reqest |
| 57 | * @dev_req : contains tracking info of available req id at device |
| 58 | * @send_req : contains info of apply settings to be sent to devs in link |
| 59 | * @apply_req : contains info of which request is applied at device |
| 60 | * @notify_trigger : contains notification from IFE to CRM about trigger |
| 61 | * @notify_err : contains error info happened while processing request |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 62 | * - |
| 63 | */ |
| 64 | struct crm_task_payload { |
| 65 | enum crm_workq_task_type type; |
| 66 | union { |
| 67 | struct cam_req_mgr_sched_request sched_req; |
| 68 | struct cam_req_mgr_flush_info flush_info; |
| 69 | struct cam_req_mgr_add_request dev_req; |
| 70 | struct cam_req_mgr_send_request send_req; |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 71 | struct cam_req_mgr_trigger_notify notify_trigger; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 72 | struct cam_req_mgr_error_notify notify_err; |
| 73 | } u; |
| 74 | }; |
| 75 | |
| 76 | /** |
| 77 | * enum crm_req_state |
| 78 | * State machine for life cycle of request in pd table |
| 79 | * EMPTY : indicates req slot is empty |
| 80 | * PENDING : indicates req slot is waiting for reqs from all devs |
| 81 | * READY : indicates req slot is ready to be sent to devs |
| 82 | * INVALID : indicates req slot is not in valid state |
| 83 | */ |
| 84 | enum crm_req_state { |
| 85 | CRM_REQ_STATE_EMPTY, |
| 86 | CRM_REQ_STATE_PENDING, |
| 87 | CRM_REQ_STATE_READY, |
| 88 | CRM_REQ_STATE_INVALID, |
| 89 | }; |
| 90 | |
| 91 | /** |
| 92 | * enum crm_slot_status |
| 93 | * State machine for life cycle of request in input queue |
| 94 | * NO_REQ : empty slot |
| 95 | * REQ_ADDED : new entry in slot |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 96 | * PENDING : waiting for next trigger to apply |
| 97 | * APPLIED : req is sent to all devices |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 98 | * INVALID : invalid state |
| 99 | */ |
| 100 | enum crm_slot_status { |
| 101 | CRM_SLOT_STATUS_NO_REQ, |
| 102 | CRM_SLOT_STATUS_REQ_ADDED, |
| 103 | CRM_SLOT_STATUS_REQ_PENDING, |
| 104 | CRM_SLOT_STATUS_REQ_APPLIED, |
| 105 | CRM_SLOT_STATUS_INVALID, |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | /** |
| 109 | * enum cam_req_mgr_link_state |
| 110 | * State machine for life cycle of link in crm |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 111 | * AVAILABLE : link available |
| 112 | * IDLE : link initialized but not ready yet |
| 113 | * READY : link is ready for use |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 114 | * ERR : link has encountered error |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 115 | * MAX : invalid state |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 116 | */ |
| 117 | enum cam_req_mgr_link_state { |
| 118 | CAM_CRM_LINK_STATE_AVAILABLE, |
| 119 | CAM_CRM_LINK_STATE_IDLE, |
| 120 | CAM_CRM_LINK_STATE_READY, |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 121 | CAM_CRM_LINK_STATE_ERR, |
| 122 | CAM_CRM_LINK_STATE_MAX, |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 126 | * struct cam_req_mgr_traverse |
Karthik Anantha Ram | fa64333 | 2017-11-06 13:49:31 -0800 | [diff] [blame] | 127 | * @idx : slot index |
| 128 | * @result : contains which all tables were able to apply successfully |
| 129 | * @tbl : pointer of pipeline delay based request table |
| 130 | * @apply_data : pointer which various tables will update during traverse |
| 131 | * @in_q : input request queue pointer |
| 132 | * @validate_only : Whether to validate only and/or update settings |
Vishalsingh Hajeri | 87c3131b | 2018-02-09 17:36:35 -0800 | [diff] [blame] | 133 | * @self_link : To indicate whether the check is for the given link or the |
| 134 | * other sync link |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 135 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 136 | struct cam_req_mgr_traverse { |
| 137 | int32_t idx; |
| 138 | uint32_t result; |
| 139 | struct cam_req_mgr_req_tbl *tbl; |
| 140 | struct cam_req_mgr_apply *apply_data; |
| 141 | struct cam_req_mgr_req_queue *in_q; |
Karthik Anantha Ram | fa64333 | 2017-11-06 13:49:31 -0800 | [diff] [blame] | 142 | bool validate_only; |
Vishalsingh Hajeri | 87c3131b | 2018-02-09 17:36:35 -0800 | [diff] [blame] | 143 | bool self_link; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | /** |
| 147 | * struct cam_req_mgr_apply |
| 148 | * @idx : corresponding input queue slot index |
| 149 | * @pd : pipeline delay of device |
| 150 | * @req_id : req id for dev with above pd to process |
| 151 | * @skip_idx: skip applying settings when this is set. |
| 152 | */ |
| 153 | struct cam_req_mgr_apply { |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 154 | int32_t idx; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 155 | int32_t pd; |
| 156 | int64_t req_id; |
| 157 | int32_t skip_idx; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 161 | * struct cam_req_mgr_tbl_slot |
| 162 | * @idx : slot index |
| 163 | * @req_ready_map : mask tracking which all devices have request ready |
| 164 | * @state : state machine for life cycle of a slot |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 165 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 166 | struct cam_req_mgr_tbl_slot { |
| 167 | int32_t idx; |
| 168 | uint32_t req_ready_map; |
| 169 | enum crm_req_state state; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 173 | * struct cam_req_mgr_req_tbl |
| 174 | * @id : table indetifier |
| 175 | * @pd : pipeline delay of table |
| 176 | * @dev_count : num of devices having same pipeline delay |
| 177 | * @dev_mask : mask to track which devices are linked |
| 178 | * @skip_traverse : to indicate how many traverses need to be dropped |
| 179 | * by this table especially in the beginning or bubble recovery |
| 180 | * @next : pointer to next pipeline delay request table |
| 181 | * @pd_delta : differnce between this table's pipeline delay and next |
| 182 | * @num_slots : number of request slots present in the table |
| 183 | * @slot : array of slots tracking requests availability at devices |
Sagar Gore | a4d7dfd | 2017-09-13 19:56:24 -0700 | [diff] [blame] | 184 | * @inject_delay : insert extra bubbling for flash type of use cases |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 185 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 186 | struct cam_req_mgr_req_tbl { |
| 187 | int32_t id; |
| 188 | int32_t pd; |
| 189 | int32_t dev_count; |
| 190 | int32_t dev_mask; |
| 191 | int32_t skip_traverse; |
| 192 | struct cam_req_mgr_req_tbl *next; |
| 193 | int32_t pd_delta; |
| 194 | int32_t num_slots; |
| 195 | struct cam_req_mgr_tbl_slot slot[MAX_REQ_SLOTS]; |
Sagar Gore | a4d7dfd | 2017-09-13 19:56:24 -0700 | [diff] [blame] | 196 | uint32_t inject_delay; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 200 | * struct cam_req_mgr_slot |
| 201 | * - Internal Book keeping |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 202 | * @idx : slot index |
| 203 | * @skip_idx : if req id in this slot needs to be skipped/not applied |
| 204 | * @status : state machine for life cycle of a slot |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 205 | * - members updated due to external events |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 206 | * @recover : if user enabled recovery for this request. |
| 207 | * @req_id : mask tracking which all devices have request ready |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 208 | * @sync_mode : Sync mode in which req id in this slot has to applied |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 209 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 210 | struct cam_req_mgr_slot { |
| 211 | int32_t idx; |
| 212 | int32_t skip_idx; |
| 213 | enum crm_slot_status status; |
| 214 | int32_t recover; |
| 215 | int64_t req_id; |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 216 | int32_t sync_mode; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | /** |
| 220 | * struct cam_req_mgr_req_queue |
| 221 | * @num_slots : max num of input queue slots |
| 222 | * @slot : request slot holding incoming request id and bubble info. |
| 223 | * @rd_idx : indicates slot index currently in process. |
| 224 | * @wr_idx : indicates slot index to hold new upcoming req. |
| 225 | */ |
| 226 | struct cam_req_mgr_req_queue { |
| 227 | int32_t num_slots; |
| 228 | struct cam_req_mgr_slot slot[MAX_REQ_SLOTS]; |
| 229 | int32_t rd_idx; |
| 230 | int32_t wr_idx; |
| 231 | }; |
| 232 | |
| 233 | /** |
| 234 | * struct cam_req_mgr_req_data |
| 235 | * @in_q : Poiner to Input request queue |
| 236 | * @l_tbl : unique pd request tables. |
| 237 | * @num_tbl : how many unique pd value devices are present |
| 238 | * @apply_data : Holds information about request id for a request |
| 239 | * @lock : mutex lock protecting request data ops. |
| 240 | */ |
| 241 | struct cam_req_mgr_req_data { |
| 242 | struct cam_req_mgr_req_queue *in_q; |
| 243 | struct cam_req_mgr_req_tbl *l_tbl; |
| 244 | int32_t num_tbl; |
| 245 | struct cam_req_mgr_apply apply_data[CAM_PIPELINE_DELAY_MAX]; |
| 246 | struct mutex lock; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 247 | }; |
| 248 | |
| 249 | /** |
| 250 | * struct cam_req_mgr_connected_device |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 251 | * - Device Properties |
| 252 | * @dev_hdl : device handle |
| 253 | * @dev_bit : unique bit assigned to device in link |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 254 | * - Device characteristics |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 255 | * @pd_tbl : tracks latest available req id at this device |
| 256 | * @dev_info : holds dev characteristics such as pipeline delay, dev name |
| 257 | * @ops : holds func pointer to call methods on this device |
| 258 | * @parent : pvt data - like link which this dev hdl belongs to |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 259 | */ |
| 260 | struct cam_req_mgr_connected_device { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 261 | int32_t dev_hdl; |
| 262 | int64_t dev_bit; |
| 263 | struct cam_req_mgr_req_tbl *pd_tbl; |
| 264 | struct cam_req_mgr_device_info dev_info; |
| 265 | struct cam_req_mgr_kmd_ops *ops; |
| 266 | void *parent; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | /** |
| 270 | * struct cam_req_mgr_core_link |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 271 | * - Link Properties |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 272 | * @link_hdl : Link identifier |
| 273 | * @num_devs : num of connected devices to this link |
| 274 | * @max_delay : Max of pipeline delay of all connected devs |
| 275 | * @workq : Pointer to handle workq related jobs |
| 276 | * @pd_mask : each set bit indicates the device with pd equal to |
| 277 | * bit position is available. |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 278 | * - List of connected devices |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 279 | * @l_dev : List of connected devices to this link |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 280 | * - Request handling data struct |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 281 | * @req : req data holder. |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 282 | * - Timer |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 283 | * @watchdog : watchdog timer to recover from sof freeze |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 284 | * - Link private data |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 285 | * @workq_comp : conditional variable to block user thread for workq |
| 286 | * to finish schedule request processing |
| 287 | * @state : link state machine |
| 288 | * @parent : pvt data - link's parent is session |
| 289 | * @lock : mutex lock to guard link data operations |
| 290 | * @link_state_spin_lock : spin lock to protect link state variable |
| 291 | * @subscribe_event : irqs that link subscribes, IFE should send |
| 292 | * notification to CRM at those hw events. |
| 293 | * @trigger_mask : mask on which irq the req is already applied |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 294 | * @sync_link : pointer to the sync link for synchronization |
| 295 | * @sof_counter : sof counter during sync_mode |
| 296 | * @sync_self_ref : reference sync count against which the difference |
| 297 | * between sync_counts for a given link is checked |
| 298 | * @frame_skip_flag : flag that determines if a frame needs to be skipped |
| 299 | * |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 300 | */ |
| 301 | struct cam_req_mgr_core_link { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 302 | int32_t link_hdl; |
| 303 | int32_t num_devs; |
| 304 | enum cam_pipeline_delay max_delay; |
| 305 | struct cam_req_mgr_core_workq *workq; |
| 306 | int32_t pd_mask; |
| 307 | struct cam_req_mgr_connected_device *l_dev; |
| 308 | struct cam_req_mgr_req_data req; |
| 309 | struct cam_req_mgr_timer *watchdog; |
| 310 | struct completion workq_comp; |
| 311 | enum cam_req_mgr_link_state state; |
| 312 | void *parent; |
| 313 | struct mutex lock; |
Ravikishore Pampana | 6c2e1c1 | 2017-10-16 18:46:15 +0530 | [diff] [blame] | 314 | spinlock_t link_state_spin_lock; |
Junzhe Zou | 2df8450 | 2017-05-26 13:20:23 -0700 | [diff] [blame] | 315 | uint32_t subscribe_event; |
| 316 | uint32_t trigger_mask; |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 317 | struct cam_req_mgr_core_link *sync_link; |
| 318 | int64_t sof_counter; |
| 319 | int64_t sync_self_ref; |
| 320 | bool frame_skip_flag; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | /** |
| 324 | * struct cam_req_mgr_core_session |
| 325 | * - Session Properties |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 326 | * @session_hdl : session identifier |
| 327 | * @num_links : num of active links for current session |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 328 | * - Links of this session |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 329 | * @links : pointer to array of links within session |
| 330 | * @in_q : Input request queue one per session |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 331 | * - Session private data |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 332 | * @entry : pvt data - entry in the list of sessions |
| 333 | * @lock : pvt data - spin lock to guard session data |
| 334 | * - Debug data |
| 335 | * @force_err_recovery : For debugging, we can force bubble recovery |
| 336 | * to be always ON or always OFF using debugfs. |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 337 | * @sync_mode : Sync mode for this session links |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 338 | */ |
| 339 | struct cam_req_mgr_core_session { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 340 | int32_t session_hdl; |
| 341 | uint32_t num_links; |
| 342 | struct cam_req_mgr_core_link *links[MAX_LINKS_PER_SESSION]; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 343 | struct list_head entry; |
| 344 | struct mutex lock; |
| 345 | int32_t force_err_recovery; |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 346 | int32_t sync_mode; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 347 | }; |
| 348 | |
| 349 | /** |
| 350 | * struct cam_req_mgr_core_device |
| 351 | * - Core camera request manager data struct |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 352 | * @session_head : list head holding sessions |
| 353 | * @crm_lock : mutex lock to protect session creation & destruction |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 354 | */ |
| 355 | struct cam_req_mgr_core_device { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 356 | struct list_head session_head; |
| 357 | struct mutex crm_lock; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 358 | }; |
| 359 | |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 360 | /** |
| 361 | * cam_req_mgr_create_session() |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 362 | * @brief : creates session |
| 363 | * @ses_info : output param for session handle |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 364 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 365 | * called as part of session creation. |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 366 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 367 | int cam_req_mgr_create_session(struct cam_req_mgr_session_info *ses_info); |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * cam_req_mgr_destroy_session() |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 371 | * @brief : destroy session |
| 372 | * @ses_info : session handle info, input param |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 373 | * |
| 374 | * Called as part of session destroy |
| 375 | * return success/failure |
| 376 | */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 377 | int cam_req_mgr_destroy_session(struct cam_req_mgr_session_info *ses_info); |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 378 | |
| 379 | /** |
| 380 | * cam_req_mgr_link() |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 381 | * @brief : creates a link for a session |
| 382 | * @link_info : handle and session info to create a link |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 383 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 384 | * link is formed in a session for multiple devices. it creates |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 385 | * a unique link handle for the link and is specific to a |
| 386 | * session. Returns link handle |
| 387 | */ |
| 388 | int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info); |
| 389 | |
| 390 | /** |
| 391 | * cam_req_mgr_unlink() |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 392 | * @brief : destroy a link in a session |
| 393 | * @unlink_info : session and link handle info |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 394 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame] | 395 | * link is destroyed in a session |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 396 | */ |
| 397 | int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info); |
| 398 | |
| 399 | /** |
| 400 | * cam_req_mgr_schedule_request() |
| 401 | * @brief: Request is scheduled |
| 402 | * @sched_req: request id, session and link id info, bubble recovery info |
| 403 | */ |
| 404 | int cam_req_mgr_schedule_request( |
| 405 | struct cam_req_mgr_sched_request *sched_req); |
| 406 | |
| 407 | /** |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 408 | * cam_req_mgr_sync_mode_setup() |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 409 | * @brief: sync for links in a session |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 410 | * @sync_info: session, links info and master link info |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 411 | */ |
Pavan Kumar Chilamkurthi | 1fd0344 | 2017-11-07 17:07:21 -0800 | [diff] [blame] | 412 | int cam_req_mgr_sync_config(struct cam_req_mgr_sync_mode *sync_info); |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 413 | |
| 414 | /** |
| 415 | * cam_req_mgr_flush_requests() |
| 416 | * @brief: flush all requests |
| 417 | * @flush_info: requests related to link and session |
| 418 | */ |
| 419 | int cam_req_mgr_flush_requests( |
| 420 | struct cam_req_mgr_flush_info *flush_info); |
| 421 | |
| 422 | /** |
| 423 | * cam_req_mgr_core_device_init() |
| 424 | * @brief: initialize crm core |
| 425 | */ |
| 426 | int cam_req_mgr_core_device_init(void); |
| 427 | |
| 428 | /** |
| 429 | * cam_req_mgr_core_device_deinit() |
| 430 | * @brief: cleanp crm core |
| 431 | */ |
| 432 | int cam_req_mgr_core_device_deinit(void); |
Soundrapandian Jeyaprakash | 8d16e27 | 2017-10-12 11:05:37 -0700 | [diff] [blame] | 433 | |
| 434 | /** |
| 435 | * cam_req_mgr_handle_core_shutdown() |
| 436 | * @brief: Handles camera close |
| 437 | */ |
| 438 | void cam_req_mgr_handle_core_shutdown(void); |
Jing Zhou | 0f64533 | 2017-11-17 12:16:40 -0800 | [diff] [blame] | 439 | |
| 440 | /** |
| 441 | * cam_req_mgr_link_control() |
| 442 | * @brief: Handles link control operations |
| 443 | * @control: Link control command |
| 444 | */ |
| 445 | int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control); |
| 446 | |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 447 | #endif |
| 448 | |