Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. |
| 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 | |
| 13 | #ifndef _CAM_REQ_MGR_INTERFACE_H |
| 14 | #define _CAM_REQ_MGR_INTERFACE_H |
| 15 | |
| 16 | #include <linux/types.h> |
| 17 | #include <media/cam_req_mgr.h> |
| 18 | #include "cam_req_mgr_core_defs.h" |
| 19 | #include "cam_req_mgr_util.h" |
| 20 | |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 21 | struct cam_req_mgr_sof_notify; |
| 22 | struct cam_req_mgr_error_notify; |
| 23 | struct cam_req_mgr_add_request; |
| 24 | struct cam_req_mgr_device_info; |
| 25 | struct cam_req_mgr_core_dev_link_setup; |
| 26 | struct cam_req_mgr_apply_request; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 27 | struct cam_req_mgr_flush_request; |
| 28 | struct cam_req_mgr_link_evt_data; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 29 | |
| 30 | /* Request Manager -- camera device driver interface */ |
| 31 | /** |
| 32 | * @brief: camera kernel drivers to cam req mgr communication |
| 33 | * |
| 34 | * @cam_req_mgr_notify_sof: for device which generates sof to inform CRM |
| 35 | * @cam_req_mgr_notify_err: device use this to inform about different errors. |
| 36 | * @cam_req_mgr_add_req: to info CRm about new rqeuest received from userspace |
| 37 | */ |
| 38 | typedef int (*cam_req_mgr_notify_sof)(struct cam_req_mgr_sof_notify *); |
| 39 | typedef int (*cam_req_mgr_notify_err)(struct cam_req_mgr_error_notify *); |
| 40 | typedef int (*cam_req_mgr_add_req)(struct cam_req_mgr_add_request *); |
| 41 | |
| 42 | /** |
| 43 | * @brief: cam req mgr to camera device drivers |
| 44 | * |
| 45 | * @cam_req_mgr_get_dev_info: to fetch details about device linked |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 46 | * @cam_req_mgr_link_setup : to establish link with device for a session |
| 47 | * @cam_req_mgr_notify_err : to broadcast error happened on link for request id |
| 48 | * @cam_req_mgr_apply_req : CRM asks device to apply certain request id. |
| 49 | * @cam_req_mgr_flush_req : Flush or cancle request |
| 50 | * cam_req_mgr_process_evt : generic events |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 51 | */ |
| 52 | typedef int (*cam_req_mgr_get_dev_info) (struct cam_req_mgr_device_info *); |
| 53 | typedef int (*cam_req_mgr_link_setup)( |
| 54 | struct cam_req_mgr_core_dev_link_setup *); |
| 55 | typedef int (*cam_req_mgr_apply_req)(struct cam_req_mgr_apply_request *); |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 56 | typedef int (*cam_req_mgr_flush_req)(struct cam_req_mgr_flush_request *); |
| 57 | typedef int (*cam_req_mgr_process_evt)(struct cam_req_mgr_link_evt_data *); |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 58 | |
| 59 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 60 | * @brief : cam_req_mgr_crm_cb - func table |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 61 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 62 | * @notify_sof : payload for sof indication event |
| 63 | * @notify_err : payload for different error occurred at device |
| 64 | * @add_req : payload to inform which device and what request is received |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 65 | */ |
| 66 | struct cam_req_mgr_crm_cb { |
| 67 | cam_req_mgr_notify_sof notify_sof; |
| 68 | cam_req_mgr_notify_err notify_err; |
| 69 | cam_req_mgr_add_req add_req; |
| 70 | }; |
| 71 | |
| 72 | /** |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 73 | * @brief : cam_req_mgr_kmd_ops - func table |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 74 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 75 | * @get_dev_info : payload to fetch device details |
| 76 | * @link_setup : payload to establish link with device |
| 77 | * @apply_req : payload to apply request id on a device linked |
| 78 | * @flush_req : payload to flush request |
| 79 | * @process_evt : payload to generic event |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 80 | */ |
| 81 | struct cam_req_mgr_kmd_ops { |
| 82 | cam_req_mgr_get_dev_info get_dev_info; |
| 83 | cam_req_mgr_link_setup link_setup; |
| 84 | cam_req_mgr_apply_req apply_req; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 85 | cam_req_mgr_flush_req flush_req; |
| 86 | cam_req_mgr_process_evt process_evt; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | /** |
| 90 | * enum cam_pipeline_delay |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 91 | * @brief : enumerator for different pipeline delays in camera |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 92 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 93 | * @DELAY_0 : device processed settings on same frame |
| 94 | * @DELAY_1 : device processed settings after 1 frame |
| 95 | * @DELAY_2 : device processed settings after 2 frames |
| 96 | * @DELAY_MAX : maximum supported pipeline delay |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 97 | */ |
| 98 | enum cam_pipeline_delay { |
| 99 | CAM_PIPELINE_DELAY_0, |
| 100 | CAM_PIPELINE_DELAY_1, |
| 101 | CAM_PIPELINE_DELAY_2, |
| 102 | CAM_PIPELINE_DELAY_MAX, |
| 103 | }; |
| 104 | |
| 105 | /** |
| 106 | * enum cam_req_status |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 107 | * @brief : enumerator for request status |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 108 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 109 | * @SUCCESS : device processed settings successfully |
| 110 | * @FAILED : device processed settings failed |
| 111 | * @MAX : invalid status value |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 112 | */ |
| 113 | enum cam_req_status { |
| 114 | CAM_REQ_STATUS_SUCCESS, |
| 115 | CAM_REQ_STATUS_FAILED, |
| 116 | CAM_REQ_STATUS_MAX, |
| 117 | }; |
| 118 | |
| 119 | /** |
| 120 | * enum cam_req_mgr_device_error |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 121 | * @brief : enumerator for different errors occurred at device |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 122 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 123 | * @NOT_FOUND : settings asked by request manager is not found |
| 124 | * @BUBBLE : device hit timing issue and is able to recover |
| 125 | * @FATAL : device is in bad shape and can not recover from error |
| 126 | * @PAGE_FAULT : Page fault while accessing memory |
| 127 | * @OVERFLOW : Bus Overflow for IFE/VFE |
| 128 | * @TIMEOUT : Timeout from cci or bus. |
| 129 | * @MAX : Invalid error value |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 130 | */ |
| 131 | enum cam_req_mgr_device_error { |
| 132 | CRM_KMD_ERR_NOT_FOUND, |
| 133 | CRM_KMD_ERR_BUBBLE, |
| 134 | CRM_KMD_ERR_FATAL, |
| 135 | CRM_KMD_ERR_PAGE_FAULT, |
| 136 | CRM_KMD_ERR_OVERFLOW, |
| 137 | CRM_KMD_ERR_TIMEOUT, |
| 138 | CRM_KMD_ERR_MAX, |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * enum cam_req_mgr_device_id |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 143 | * @brief : enumerator for different devices in subsystem |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 144 | * |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 145 | * @CAM_REQ_MGR : request manager itself |
| 146 | * @SENSOR : sensor device |
| 147 | * @FLASH : LED flash or dual LED device |
| 148 | * @ACTUATOR : lens mover |
| 149 | * @IFE : Image processing device |
| 150 | * @EXTERNAL_1 : third party device |
| 151 | * @EXTERNAL_2 : third party device |
| 152 | * @EXTERNAL_3 : third party device |
| 153 | * @MAX : invalid device id |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 154 | */ |
| 155 | enum cam_req_mgr_device_id { |
| 156 | CAM_REQ_MGR_DEVICE, |
| 157 | CAM_REQ_MGR_DEVICE_SENSOR, |
| 158 | CAM_REQ_MGR_DEVICE_FLASH, |
| 159 | CAM_REQ_MGR_DEVICE_ACTUATOR, |
| 160 | CAM_REQ_MGR_DEVICE_IFE, |
| 161 | CAM_REQ_MGR_DEVICE_EXTERNAL_1, |
| 162 | CAM_REQ_MGR_DEVICE_EXTERNAL_2, |
| 163 | CAM_REQ_MGR_DEVICE_EXTERNAL_3, |
| 164 | CAM_REQ_MGR_DEVICE_ID_MAX, |
| 165 | }; |
| 166 | |
| 167 | /* Camera device driver to Req Mgr device interface */ |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 168 | |
| 169 | /** |
| 170 | * enum cam_req_mgr_link_evt_type |
| 171 | * @CAM_REQ_MGR_LINK_EVT_ERR: |
| 172 | * @CAM_REQ_MGR_LINK_EVT_MAX: |
| 173 | */ |
| 174 | enum cam_req_mgr_link_evt_type { |
| 175 | CAM_REQ_MGR_LINK_EVT_ERR, |
| 176 | CAM_REQ_MGR_LINK_EVT_MAX, |
| 177 | }; |
| 178 | |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 179 | /** |
| 180 | * struct cam_req_mgr_sof_notify |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 181 | * @link_hdl : link identifier |
| 182 | * @dev_hdl : device handle which has sent this req id |
| 183 | * @frame_id : frame id for internal tracking |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 184 | */ |
| 185 | struct cam_req_mgr_sof_notify { |
| 186 | int32_t link_hdl; |
| 187 | int32_t dev_hdl; |
| 188 | int64_t frame_id; |
| 189 | }; |
| 190 | |
| 191 | /** |
| 192 | * struct cam_req_mgr_error_notify |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 193 | * @link_hdl : link identifier |
| 194 | * @dev_hdl : device handle which has sent this req id |
| 195 | * @req_id : req id which hit error |
| 196 | * @error : what error device hit while processing this req |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 197 | */ |
| 198 | struct cam_req_mgr_error_notify { |
| 199 | int32_t link_hdl; |
| 200 | int32_t dev_hdl; |
| 201 | int64_t req_id; |
| 202 | enum cam_req_mgr_device_error error; |
| 203 | }; |
| 204 | |
| 205 | /** |
| 206 | * struct cam_req_mgr_add_request |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 207 | * @link_hdl : link identifier |
| 208 | * @dev_hdl : device handle which has sent this req id |
| 209 | * @req_id : req id which device is ready to process |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 210 | * |
| 211 | */ |
| 212 | struct cam_req_mgr_add_request { |
| 213 | int32_t link_hdl; |
| 214 | int32_t dev_hdl; |
| 215 | int64_t req_id; |
| 216 | }; |
| 217 | |
| 218 | |
| 219 | /* CRM to KMD devices */ |
| 220 | /** |
| 221 | * struct cam_req_mgr_device_info |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 222 | * @dev_hdl : Input_param : device handle for reference |
| 223 | * @name : link link or unlink |
| 224 | * @dev_id : device id info |
| 225 | * @p_delay : delay between time settings applied and take effect |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 226 | * |
| 227 | */ |
| 228 | struct cam_req_mgr_device_info { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 229 | int32_t dev_hdl; |
| 230 | char name[256]; |
| 231 | enum cam_req_mgr_device_id dev_id; |
| 232 | enum cam_pipeline_delay p_delay; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 233 | }; |
| 234 | |
| 235 | /** |
| 236 | * struct cam_req_mgr_core_dev_link_setup |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 237 | * @link_enable : link link or unlink |
| 238 | * @link_hdl : link identifier |
| 239 | * @dev_hdl : device handle for reference |
| 240 | * @max_delay : max pipeline delay on this link |
| 241 | * @crm_cb : callback funcs to communicate with req mgr |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 242 | * |
| 243 | */ |
| 244 | struct cam_req_mgr_core_dev_link_setup { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 245 | int32_t link_enable; |
| 246 | int32_t link_hdl; |
| 247 | int32_t dev_hdl; |
| 248 | enum cam_pipeline_delay max_delay; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 249 | struct cam_req_mgr_crm_cb *crm_cb; |
| 250 | }; |
| 251 | |
| 252 | /** |
| 253 | * struct cam_req_mgr_apply_request |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 254 | * @link_hdl : link identifier |
| 255 | * @dev_hdl : device handle for cross check |
| 256 | * @request_id : request id settings to apply |
| 257 | * @report_if_bubble : report to crm if failure in applying |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 258 | * |
| 259 | */ |
| 260 | struct cam_req_mgr_apply_request { |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 261 | int32_t link_hdl; |
| 262 | int32_t dev_hdl; |
| 263 | int64_t request_id; |
| 264 | int32_t report_if_bubble; |
| 265 | }; |
| 266 | |
| 267 | /** |
| 268 | * struct cam_req_mgr_flush_request |
| 269 | * @link_hdl : link identifier |
| 270 | * @dev_hdl : device handle for cross check |
| 271 | * @type : cancel request type flush all or a request |
| 272 | * @request_id : request id to cancel |
| 273 | * |
| 274 | */ |
| 275 | struct cam_req_mgr_flush_request { |
| 276 | int32_t link_hdl; |
| 277 | int32_t dev_hdl; |
| 278 | uint32_t type; |
| 279 | int64_t req_id; |
| 280 | }; |
| 281 | |
| 282 | /** |
| 283 | * struct cam_req_mgr_event_data |
| 284 | * @link_hdl : link handle |
| 285 | * @req_id : request id |
| 286 | * |
| 287 | */ |
| 288 | struct cam_req_mgr_link_evt_data { |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 289 | int32_t link_hdl; |
| 290 | int32_t dev_hdl; |
Sagar Gore | d79f95e | 2017-03-14 18:32:17 -0700 | [diff] [blame^] | 291 | int64_t req_id; |
| 292 | |
| 293 | enum cam_req_mgr_link_evt_type evt_type; |
| 294 | union { |
| 295 | enum cam_req_mgr_device_error error; |
| 296 | } u; |
| 297 | }; |
| 298 | |
| 299 | /** |
| 300 | * struct cam_req_mgr_send_request |
| 301 | * @link_hdl : link identifier |
| 302 | * @idx : slot idx |
| 303 | * |
| 304 | */ |
| 305 | struct cam_req_mgr_send_request { |
| 306 | int32_t link_hdl; |
| 307 | struct cam_req_mgr_req_queue *in_q; |
Sagar Gore | 8d91a62 | 2017-02-23 14:57:18 -0800 | [diff] [blame] | 308 | }; |
| 309 | #endif |