blob: 91860f610799a9d40d86b6fce323d93964458f18 [file] [log] [blame]
Sagar Gore8d91a622017-02-23 14:57:18 -08001/* 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 Gore8d91a622017-02-23 14:57:18 -080021struct cam_req_mgr_sof_notify;
22struct cam_req_mgr_error_notify;
23struct cam_req_mgr_add_request;
24struct cam_req_mgr_device_info;
25struct cam_req_mgr_core_dev_link_setup;
26struct cam_req_mgr_apply_request;
Sagar Gored79f95e2017-03-14 18:32:17 -070027struct cam_req_mgr_flush_request;
28struct cam_req_mgr_link_evt_data;
Sagar Gore8d91a622017-02-23 14:57:18 -080029
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 */
38typedef int (*cam_req_mgr_notify_sof)(struct cam_req_mgr_sof_notify *);
39typedef int (*cam_req_mgr_notify_err)(struct cam_req_mgr_error_notify *);
40typedef 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 Gored79f95e2017-03-14 18:32:17 -070046 * @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 Gore8d91a622017-02-23 14:57:18 -080051 */
52typedef int (*cam_req_mgr_get_dev_info) (struct cam_req_mgr_device_info *);
53typedef int (*cam_req_mgr_link_setup)(
54 struct cam_req_mgr_core_dev_link_setup *);
55typedef int (*cam_req_mgr_apply_req)(struct cam_req_mgr_apply_request *);
Sagar Gored79f95e2017-03-14 18:32:17 -070056typedef int (*cam_req_mgr_flush_req)(struct cam_req_mgr_flush_request *);
57typedef int (*cam_req_mgr_process_evt)(struct cam_req_mgr_link_evt_data *);
Sagar Gore8d91a622017-02-23 14:57:18 -080058
59/**
Sagar Gored79f95e2017-03-14 18:32:17 -070060 * @brief : cam_req_mgr_crm_cb - func table
Sagar Gore8d91a622017-02-23 14:57:18 -080061 *
Sagar Gored79f95e2017-03-14 18:32:17 -070062 * @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 Gore8d91a622017-02-23 14:57:18 -080065 */
66struct 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 Gored79f95e2017-03-14 18:32:17 -070073 * @brief : cam_req_mgr_kmd_ops - func table
Sagar Gore8d91a622017-02-23 14:57:18 -080074 *
Sagar Gored79f95e2017-03-14 18:32:17 -070075 * @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 Gore8d91a622017-02-23 14:57:18 -080080 */
81struct 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 Gored79f95e2017-03-14 18:32:17 -070085 cam_req_mgr_flush_req flush_req;
86 cam_req_mgr_process_evt process_evt;
Sagar Gore8d91a622017-02-23 14:57:18 -080087};
88
89/**
90 * enum cam_pipeline_delay
Sagar Gored79f95e2017-03-14 18:32:17 -070091 * @brief : enumerator for different pipeline delays in camera
Sagar Gore8d91a622017-02-23 14:57:18 -080092 *
Sagar Gored79f95e2017-03-14 18:32:17 -070093 * @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 Gore8d91a622017-02-23 14:57:18 -080097 */
98enum 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 Gored79f95e2017-03-14 18:32:17 -0700107 * @brief : enumerator for request status
Sagar Gore8d91a622017-02-23 14:57:18 -0800108 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700109 * @SUCCESS : device processed settings successfully
110 * @FAILED : device processed settings failed
111 * @MAX : invalid status value
Sagar Gore8d91a622017-02-23 14:57:18 -0800112 */
113enum 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 Gored79f95e2017-03-14 18:32:17 -0700121 * @brief : enumerator for different errors occurred at device
Sagar Gore8d91a622017-02-23 14:57:18 -0800122 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700123 * @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 Gore8d91a622017-02-23 14:57:18 -0800130 */
131enum 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 Gored79f95e2017-03-14 18:32:17 -0700143 * @brief : enumerator for different devices in subsystem
Sagar Gore8d91a622017-02-23 14:57:18 -0800144 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700145 * @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 Gore8d91a622017-02-23 14:57:18 -0800154 */
155enum 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 Gored79f95e2017-03-14 18:32:17 -0700168
169/**
170 * enum cam_req_mgr_link_evt_type
171 * @CAM_REQ_MGR_LINK_EVT_ERR:
172 * @CAM_REQ_MGR_LINK_EVT_MAX:
173 */
174enum cam_req_mgr_link_evt_type {
175 CAM_REQ_MGR_LINK_EVT_ERR,
176 CAM_REQ_MGR_LINK_EVT_MAX,
177};
178
Sagar Gore8d91a622017-02-23 14:57:18 -0800179/**
180 * struct cam_req_mgr_sof_notify
Sagar Gored79f95e2017-03-14 18:32:17 -0700181 * @link_hdl : link identifier
182 * @dev_hdl : device handle which has sent this req id
183 * @frame_id : frame id for internal tracking
Sagar Gore8d91a622017-02-23 14:57:18 -0800184 */
185struct 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 Gored79f95e2017-03-14 18:32:17 -0700193 * @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 Gore8d91a622017-02-23 14:57:18 -0800197 */
198struct 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 Gored79f95e2017-03-14 18:32:17 -0700207 * @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 Gore8d91a622017-02-23 14:57:18 -0800210 *
211 */
212struct 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 Gored79f95e2017-03-14 18:32:17 -0700222 * @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 Gore8d91a622017-02-23 14:57:18 -0800226 *
227 */
228struct cam_req_mgr_device_info {
Sagar Gored79f95e2017-03-14 18:32:17 -0700229 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 Gore8d91a622017-02-23 14:57:18 -0800233};
234
235/**
236 * struct cam_req_mgr_core_dev_link_setup
Sagar Gored79f95e2017-03-14 18:32:17 -0700237 * @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 Gore8d91a622017-02-23 14:57:18 -0800242 *
243 */
244struct cam_req_mgr_core_dev_link_setup {
Sagar Gored79f95e2017-03-14 18:32:17 -0700245 int32_t link_enable;
246 int32_t link_hdl;
247 int32_t dev_hdl;
248 enum cam_pipeline_delay max_delay;
Sagar Gore8d91a622017-02-23 14:57:18 -0800249 struct cam_req_mgr_crm_cb *crm_cb;
250};
251
252/**
253 * struct cam_req_mgr_apply_request
Sagar Gored79f95e2017-03-14 18:32:17 -0700254 * @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 Gore8d91a622017-02-23 14:57:18 -0800258 *
259 */
260struct cam_req_mgr_apply_request {
Sagar Gored79f95e2017-03-14 18:32:17 -0700261 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 */
275struct 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 */
288struct cam_req_mgr_link_evt_data {
Sagar Gore8d91a622017-02-23 14:57:18 -0800289 int32_t link_hdl;
290 int32_t dev_hdl;
Sagar Gored79f95e2017-03-14 18:32:17 -0700291 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 */
305struct cam_req_mgr_send_request {
306 int32_t link_hdl;
307 struct cam_req_mgr_req_queue *in_q;
Sagar Gore8d91a622017-02-23 14:57:18 -0800308};
309#endif