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