blob: 6195b5965647aa7027492e05bd784edabb09e062 [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
Junzhe Zou2df84502017-05-26 13:20:23 -070021struct cam_req_mgr_trigger_notify;
Sagar Gore8d91a622017-02-23 14:57:18 -080022struct 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/**
Junzhe Zou2df84502017-05-26 13:20:23 -070032 * @brief: camera kernel drivers to cam req mgr communication
Sagar Gore8d91a622017-02-23 14:57:18 -080033 *
Junzhe Zou2df84502017-05-26 13:20:23 -070034 * @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 Gore8d91a622017-02-23 14:57:18 -080038 */
Junzhe Zou2df84502017-05-26 13:20:23 -070039typedef int (*cam_req_mgr_notify_trigger)(
40 struct cam_req_mgr_trigger_notify *);
Sagar Gore8d91a622017-02-23 14:57:18 -080041typedef int (*cam_req_mgr_notify_err)(struct cam_req_mgr_error_notify *);
42typedef 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 Gored79f95e2017-03-14 18:32:17 -070048 * @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 Gore8d91a622017-02-23 14:57:18 -080053 */
54typedef int (*cam_req_mgr_get_dev_info) (struct cam_req_mgr_device_info *);
55typedef int (*cam_req_mgr_link_setup)(
56 struct cam_req_mgr_core_dev_link_setup *);
57typedef int (*cam_req_mgr_apply_req)(struct cam_req_mgr_apply_request *);
Sagar Gored79f95e2017-03-14 18:32:17 -070058typedef int (*cam_req_mgr_flush_req)(struct cam_req_mgr_flush_request *);
59typedef int (*cam_req_mgr_process_evt)(struct cam_req_mgr_link_evt_data *);
Sagar Gore8d91a622017-02-23 14:57:18 -080060
61/**
Junzhe Zou2df84502017-05-26 13:20:23 -070062 * @brief : cam_req_mgr_crm_cb - func table
Sagar Gore8d91a622017-02-23 14:57:18 -080063 *
Junzhe Zou2df84502017-05-26 13:20:23 -070064 * @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 Gore8d91a622017-02-23 14:57:18 -080067 */
68struct cam_req_mgr_crm_cb {
Junzhe Zou2df84502017-05-26 13:20:23 -070069 cam_req_mgr_notify_trigger notify_trigger;
70 cam_req_mgr_notify_err notify_err;
71 cam_req_mgr_add_req add_req;
Sagar Gore8d91a622017-02-23 14:57:18 -080072};
73
74/**
Sagar Gored79f95e2017-03-14 18:32:17 -070075 * @brief : cam_req_mgr_kmd_ops - func table
Sagar Gore8d91a622017-02-23 14:57:18 -080076 *
Sagar Gored79f95e2017-03-14 18:32:17 -070077 * @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 Gore8d91a622017-02-23 14:57:18 -080082 */
83struct 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 Gored79f95e2017-03-14 18:32:17 -070087 cam_req_mgr_flush_req flush_req;
88 cam_req_mgr_process_evt process_evt;
Sagar Gore8d91a622017-02-23 14:57:18 -080089};
90
91/**
92 * enum cam_pipeline_delay
Sagar Gored79f95e2017-03-14 18:32:17 -070093 * @brief : enumerator for different pipeline delays in camera
Sagar Gore8d91a622017-02-23 14:57:18 -080094 *
Sagar Gored79f95e2017-03-14 18:32:17 -070095 * @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 Gore8d91a622017-02-23 14:57:18 -080099 */
100enum 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 Zou2df84502017-05-26 13:20:23 -0700108 * @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 Gore8d91a622017-02-23 14:57:18 -0800115 * enum cam_req_status
Sagar Gored79f95e2017-03-14 18:32:17 -0700116 * @brief : enumerator for request status
Sagar Gore8d91a622017-02-23 14:57:18 -0800117 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700118 * @SUCCESS : device processed settings successfully
119 * @FAILED : device processed settings failed
120 * @MAX : invalid status value
Sagar Gore8d91a622017-02-23 14:57:18 -0800121 */
122enum 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 Gored79f95e2017-03-14 18:32:17 -0700130 * @brief : enumerator for different errors occurred at device
Sagar Gore8d91a622017-02-23 14:57:18 -0800131 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700132 * @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 Gore8d91a622017-02-23 14:57:18 -0800139 */
140enum 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 Gored79f95e2017-03-14 18:32:17 -0700152 * @brief : enumerator for different devices in subsystem
Sagar Gore8d91a622017-02-23 14:57:18 -0800153 *
Sagar Gored79f95e2017-03-14 18:32:17 -0700154 * @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 Gore8d91a622017-02-23 14:57:18 -0800163 */
164enum 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 Gored79f95e2017-03-14 18:32:17 -0700177
178/**
179 * enum cam_req_mgr_link_evt_type
180 * @CAM_REQ_MGR_LINK_EVT_ERR:
181 * @CAM_REQ_MGR_LINK_EVT_MAX:
182 */
183enum cam_req_mgr_link_evt_type {
184 CAM_REQ_MGR_LINK_EVT_ERR,
185 CAM_REQ_MGR_LINK_EVT_MAX,
186};
187
Sagar Gore8d91a622017-02-23 14:57:18 -0800188/**
Junzhe Zou2df84502017-05-26 13:20:23 -0700189 * struct cam_req_mgr_trigger_notify
Sagar Gored79f95e2017-03-14 18:32:17 -0700190 * @link_hdl : link identifier
191 * @dev_hdl : device handle which has sent this req id
192 * @frame_id : frame id for internal tracking
Junzhe Zou2df84502017-05-26 13:20:23 -0700193 * @trigger : trigger point of this notification, CRM will send apply
194 * only to the devices which subscribe to this point.
Sagar Gore8d91a622017-02-23 14:57:18 -0800195 */
Junzhe Zou2df84502017-05-26 13:20:23 -0700196struct 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 Gore8d91a622017-02-23 14:57:18 -0800201};
202
203/**
204 * struct cam_req_mgr_error_notify
Sagar Gored79f95e2017-03-14 18:32:17 -0700205 * @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 Gore8d91a622017-02-23 14:57:18 -0800209 */
210struct cam_req_mgr_error_notify {
Jigarkumar Zala35226272017-04-19 16:05:24 -0700211 int32_t link_hdl;
212 int32_t dev_hdl;
213 uint64_t req_id;
Sagar Gore8d91a622017-02-23 14:57:18 -0800214 enum cam_req_mgr_device_error error;
215};
216
217/**
218 * struct cam_req_mgr_add_request
Sagar Gored79f95e2017-03-14 18:32:17 -0700219 * @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 Gore8d91a622017-02-23 14:57:18 -0800222 *
223 */
224struct cam_req_mgr_add_request {
Jigarkumar Zala35226272017-04-19 16:05:24 -0700225 int32_t link_hdl;
226 int32_t dev_hdl;
227 uint64_t req_id;
Sagar Gore8d91a622017-02-23 14:57:18 -0800228};
229
230
231/* CRM to KMD devices */
232/**
233 * struct cam_req_mgr_device_info
Sagar Gored79f95e2017-03-14 18:32:17 -0700234 * @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 Zou2df84502017-05-26 13:20:23 -0700238 * @trigger : Trigger point for the client
Sagar Gore8d91a622017-02-23 14:57:18 -0800239 *
240 */
241struct cam_req_mgr_device_info {
Sagar Gored79f95e2017-03-14 18:32:17 -0700242 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 Zou2df84502017-05-26 13:20:23 -0700246 uint32_t trigger;
Sagar Gore8d91a622017-02-23 14:57:18 -0800247};
248
249/**
250 * struct cam_req_mgr_core_dev_link_setup
Junzhe Zou2df84502017-05-26 13:20:23 -0700251 * @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 Gore8d91a622017-02-23 14:57:18 -0800257 *
258 */
259struct cam_req_mgr_core_dev_link_setup {
Sagar Gored79f95e2017-03-14 18:32:17 -0700260 int32_t link_enable;
261 int32_t link_hdl;
262 int32_t dev_hdl;
263 enum cam_pipeline_delay max_delay;
Sagar Gore8d91a622017-02-23 14:57:18 -0800264 struct cam_req_mgr_crm_cb *crm_cb;
Junzhe Zou2df84502017-05-26 13:20:23 -0700265 uint32_t subscribe_event;
Sagar Gore8d91a622017-02-23 14:57:18 -0800266};
267
268/**
269 * struct cam_req_mgr_apply_request
Sagar Gored79f95e2017-03-14 18:32:17 -0700270 * @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 Zou2df84502017-05-26 13:20:23 -0700274 * @trigger_point : the trigger point of this apply
Sagar Gore8d91a622017-02-23 14:57:18 -0800275 *
276 */
277struct cam_req_mgr_apply_request {
Sagar Gored79f95e2017-03-14 18:32:17 -0700278 int32_t link_hdl;
279 int32_t dev_hdl;
Jigarkumar Zala35226272017-04-19 16:05:24 -0700280 uint64_t request_id;
Sagar Gored79f95e2017-03-14 18:32:17 -0700281 int32_t report_if_bubble;
Junzhe Zou2df84502017-05-26 13:20:23 -0700282 uint32_t trigger_point;
Sagar Gored79f95e2017-03-14 18:32:17 -0700283};
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 */
293struct cam_req_mgr_flush_request {
294 int32_t link_hdl;
295 int32_t dev_hdl;
296 uint32_t type;
Jigarkumar Zala35226272017-04-19 16:05:24 -0700297 uint64_t req_id;
Sagar Gored79f95e2017-03-14 18:32:17 -0700298};
299
300/**
301 * struct cam_req_mgr_event_data
302 * @link_hdl : link handle
303 * @req_id : request id
304 *
305 */
306struct cam_req_mgr_link_evt_data {
Jigarkumar Zala35226272017-04-19 16:05:24 -0700307 int32_t link_hdl;
308 int32_t dev_hdl;
309 uint64_t req_id;
Sagar Gored79f95e2017-03-14 18:32:17 -0700310
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 */
323struct cam_req_mgr_send_request {
324 int32_t link_hdl;
325 struct cam_req_mgr_req_queue *in_q;
Sagar Gore8d91a622017-02-23 14:57:18 -0800326};
327#endif