cam_isp_context.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_ISP_CONTEXT_H_
  7. #define _CAM_ISP_CONTEXT_H_
  8. #include <linux/spinlock_types.h>
  9. #include <media/cam_isp.h>
  10. #include <media/cam_defs.h>
  11. #include <media/cam_tfe.h>
  12. #include "cam_context.h"
  13. #include "cam_isp_hw_mgr_intf.h"
  14. #include "cam_req_mgr_workq.h"
  15. #define CAM_IFE_QTIMER_MUL_FACTOR 10000
  16. #define CAM_IFE_QTIMER_DIV_FACTOR 192
  17. /*
  18. * Maximum hw resource - This number is based on the maximum
  19. * output port resource. The current maximum resource number
  20. * is 24.
  21. */
  22. #define CAM_ISP_CTX_RES_MAX 24
  23. /* max requests per ctx for isp */
  24. #define CAM_ISP_CTX_REQ_MAX 8
  25. /*
  26. * Maximum entries in state monitoring array for error logging
  27. */
  28. #define CAM_ISP_CTX_STATE_MONITOR_MAX_ENTRIES 84
  29. /*
  30. * Threshold response time in us beyond which a request is not expected
  31. * to be with IFE hw
  32. */
  33. #define CAM_ISP_CTX_RESPONSE_TIME_THRESHOLD 100000
  34. /* Number of words for dumping isp context */
  35. #define CAM_ISP_CTX_DUMP_NUM_WORDS 5
  36. /* Number of words for dumping isp context events*/
  37. #define CAM_ISP_CTX_DUMP_EVENT_NUM_WORDS 3
  38. /* Number of words for dumping request info*/
  39. #define CAM_ISP_CTX_DUMP_REQUEST_NUM_WORDS 2
  40. /* Maximum entries in event record */
  41. #define CAM_ISP_CTX_EVENT_RECORD_MAX_ENTRIES 8
  42. /* Maximum length of tag while dumping */
  43. #define CAM_ISP_CONTEXT_DUMP_TAG_MAX_LEN 128
  44. /* AEB error count threshold */
  45. #define CAM_ISP_CONTEXT_AEB_ERROR_CNT_MAX 6
  46. /* Debug Buffer length*/
  47. #define CAM_ISP_CONTEXT_DBG_BUF_LEN 300
  48. /* AFD pipeline delay for FCG configuration */
  49. #define CAM_ISP_AFD_PIPELINE_DELAY 3
  50. /* Maximum entries in frame record */
  51. #define CAM_ISP_CTX_MAX_FRAME_RECORDS 5
  52. /* Congestion count threshold */
  53. #define CAM_ISP_CONTEXT_CONGESTION_CNT_MAX 3
  54. /* forward declaration */
  55. struct cam_isp_context;
  56. /* cam isp context irq handling function type */
  57. typedef int (*cam_isp_hw_event_cb_func)(struct cam_isp_context *ctx_isp,
  58. void *evt_data);
  59. /**
  60. * enum cam_isp_ctx_activated_substate - sub states for activated
  61. *
  62. */
  63. enum cam_isp_ctx_activated_substate {
  64. CAM_ISP_CTX_ACTIVATED_SOF,
  65. CAM_ISP_CTX_ACTIVATED_APPLIED,
  66. CAM_ISP_CTX_ACTIVATED_EPOCH,
  67. CAM_ISP_CTX_ACTIVATED_BUBBLE,
  68. CAM_ISP_CTX_ACTIVATED_BUBBLE_APPLIED,
  69. CAM_ISP_CTX_ACTIVATED_HW_ERROR,
  70. CAM_ISP_CTX_ACTIVATED_HALT,
  71. CAM_ISP_CTX_ACTIVATED_MAX,
  72. };
  73. /**
  74. * enum cam_isp_ctx_event_type - events for a request
  75. *
  76. */
  77. enum cam_isp_ctx_event {
  78. CAM_ISP_CTX_EVENT_SUBMIT,
  79. CAM_ISP_CTX_EVENT_APPLY,
  80. CAM_ISP_CTX_EVENT_EPOCH,
  81. CAM_ISP_CTX_EVENT_RUP,
  82. CAM_ISP_CTX_EVENT_BUFDONE,
  83. CAM_ISP_CTX_EVENT_MAX
  84. };
  85. /**
  86. * enum cam_isp_state_change_trigger - Different types of ISP events
  87. *
  88. */
  89. enum cam_isp_state_change_trigger {
  90. CAM_ISP_STATE_CHANGE_TRIGGER_ERROR,
  91. CAM_ISP_STATE_CHANGE_TRIGGER_APPLIED,
  92. CAM_ISP_STATE_CHANGE_TRIGGER_REG_UPDATE,
  93. CAM_ISP_STATE_CHANGE_TRIGGER_SOF,
  94. CAM_ISP_STATE_CHANGE_TRIGGER_EPOCH,
  95. CAM_ISP_STATE_CHANGE_TRIGGER_DONE,
  96. CAM_ISP_STATE_CHANGE_TRIGGER_EOF,
  97. CAM_ISP_STATE_CHANGE_TRIGGER_FLUSH,
  98. CAM_ISP_STATE_CHANGE_TRIGGER_SEC_EVT_SOF,
  99. CAM_ISP_STATE_CHANGE_TRIGGER_SEC_EVT_EPOCH,
  100. CAM_ISP_STATE_CHANGE_TRIGGER_FRAME_DROP,
  101. CAM_ISP_STATE_CHANGE_TRIGGER_CDM_DONE,
  102. CAM_ISP_STATE_CHANGE_TRIGGER_MAX
  103. };
  104. #define CAM_ISP_CTX_DISABLE_RECOVERY_AEB BIT(0)
  105. #define CAM_ISP_CTX_DISABLE_RECOVERY_BUS_OVERFLOW BIT(1)
  106. #define CAM_ISP_CTX_DISABLE_RECOVERY_BUBBLE BIT(2)
  107. /**
  108. * struct cam_isp_ctx_debug - Contains debug parameters
  109. *
  110. * @dentry: Debugfs entry
  111. * @enable_state_monitor_dump: Enable isp state monitor dump
  112. * @enable_cdm_cmd_buff_dump: Enable CDM Command buffer dump
  113. * @disable_internal_recovery: Disable internal kernel recovery mask
  114. *
  115. */
  116. struct cam_isp_ctx_debug {
  117. struct dentry *dentry;
  118. uint32_t enable_state_monitor_dump;
  119. uint8_t enable_cdm_cmd_buff_dump;
  120. uint32_t disable_internal_recovery_mask;
  121. };
  122. /**
  123. * struct cam_isp_ctx_irq_ops - Function table for handling IRQ callbacks
  124. *
  125. * @irq_ops: Array of handle function pointers.
  126. *
  127. */
  128. struct cam_isp_ctx_irq_ops {
  129. cam_isp_hw_event_cb_func irq_ops[CAM_ISP_HW_EVENT_MAX];
  130. };
  131. /**
  132. * struct cam_isp_ctx_req - ISP context request object
  133. *
  134. * @base: Common request object ponter
  135. * @cfg: ISP hardware configuration array
  136. * @num_cfg: Number of ISP hardware configuration entries
  137. * @fence_map_out: Output fence mapping array
  138. * @num_fence_map_out: Number of the output fence map
  139. * @fence_map_in: Input fence mapping array
  140. * @num_fence_map_in: Number of input fence map
  141. * @num_acked: Count to track acked entried for output.
  142. * If count equals the number of fence out, it means
  143. * the request has been completed.
  144. * @num_deferred_acks: Number of buf_dones/acks that are deferred to
  145. * handle or signalled in special scenarios.
  146. * Increment this count instead of num_acked and
  147. * handle the events later where eventually
  148. * increment num_acked.
  149. * @deferred_fence_map_index Saves the indices of fence_map_out for which
  150. * handling of buf_done is deferred.
  151. * @bubble_report: Flag to track if bubble report is active on
  152. * current request
  153. * @hw_update_data: HW update data for this request
  154. * @reapply_type: Determines type of settings to be re-applied
  155. * @event_timestamp: Timestamp for different stage of request
  156. * @cdm_reset_before_apply: For bubble re-apply when buf done not coming set
  157. * to True
  158. *
  159. */
  160. struct cam_isp_ctx_req {
  161. struct cam_ctx_request *base;
  162. struct cam_hw_update_entry *cfg;
  163. uint32_t num_cfg;
  164. struct cam_hw_fence_map_entry *fence_map_out;
  165. uint32_t num_fence_map_out;
  166. struct cam_hw_fence_map_entry *fence_map_in;
  167. uint32_t num_fence_map_in;
  168. uint32_t num_acked;
  169. uint32_t num_deferred_acks;
  170. uint32_t deferred_fence_map_index[CAM_ISP_CTX_RES_MAX];
  171. int32_t bubble_report;
  172. struct cam_isp_prepare_hw_update_data hw_update_data;
  173. enum cam_hw_config_reapply_type reapply_type;
  174. ktime_t event_timestamp
  175. [CAM_ISP_CTX_EVENT_MAX];
  176. bool bubble_detected;
  177. bool cdm_reset_before_apply;
  178. };
  179. /**
  180. * struct cam_isp_context_state_monitor - ISP context state
  181. * monitoring for
  182. * debug purposes
  183. *
  184. * @curr_state: Current sub state that received req
  185. * @trigger: Event type of incoming req
  186. * @req_id: Request id
  187. * @frame_id: Frame id based on SOFs
  188. * @evt_time_stamp Current time stamp
  189. *
  190. */
  191. struct cam_isp_context_state_monitor {
  192. enum cam_isp_ctx_activated_substate curr_state;
  193. enum cam_isp_state_change_trigger trigger;
  194. uint64_t req_id;
  195. int64_t frame_id;
  196. struct timespec64 evt_time_stamp;
  197. };
  198. /**
  199. * struct cam_isp_context_req_id_info - ISP context request id
  200. * information for bufdone.
  201. *
  202. *@last_bufdone_req_id: Last bufdone request id
  203. *
  204. */
  205. struct cam_isp_context_req_id_info {
  206. int64_t last_bufdone_req_id;
  207. };
  208. /**
  209. *
  210. *
  211. * struct cam_isp_context_event_record - Information for last 20 Events
  212. * for a request; Submit, Apply, EPOCH, RUP, Buf done.
  213. *
  214. * @req_id: Last applied request id
  215. * @timestamp: Timestamp for the event
  216. *
  217. */
  218. struct cam_isp_context_event_record {
  219. uint64_t req_id;
  220. ktime_t timestamp;
  221. };
  222. /**
  223. *
  224. *
  225. * struct cam_isp_context_frame_timing_record - Frame timing events
  226. *
  227. * @sof_ts: SOF timestamp
  228. * @eof_ts: EOF ts
  229. * @epoch_ts: EPOCH ts
  230. * @secondary_sof_ts: Secondary SOF ts
  231. *
  232. */
  233. struct cam_isp_context_frame_timing_record {
  234. struct timespec64 sof_ts;
  235. struct timespec64 eof_ts;
  236. struct timespec64 epoch_ts;
  237. struct timespec64 secondary_sof_ts;
  238. };
  239. /**
  240. *
  241. *
  242. * struct cam_isp_context_debug_monitors - ISP context debug monitors
  243. *
  244. * @state_monitor_head: State machine monitor head
  245. * @state_monitor: State machine monitor info
  246. * @event_record_head: Request Event monitor head
  247. * @event_record: Request event monitor info
  248. * @frame_monitor_head: Frame timing monitor head
  249. * @frame_monitor: Frame timing event monitor
  250. *
  251. */
  252. struct cam_isp_context_debug_monitors {
  253. /* State machine monitoring */
  254. atomic64_t state_monitor_head;
  255. struct cam_isp_context_state_monitor state_monitor[
  256. CAM_ISP_CTX_STATE_MONITOR_MAX_ENTRIES];
  257. /* Req event monitor */
  258. atomic64_t event_record_head[
  259. CAM_ISP_CTX_EVENT_MAX];
  260. struct cam_isp_context_event_record event_record[
  261. CAM_ISP_CTX_EVENT_MAX][CAM_ISP_CTX_EVENT_RECORD_MAX_ENTRIES];
  262. /* Frame timing monitor */
  263. atomic64_t frame_monitor_head;
  264. struct cam_isp_context_frame_timing_record frame_monitor[
  265. CAM_ISP_CTX_MAX_FRAME_RECORDS];
  266. };
  267. /**
  268. * struct cam_isp_skip_frame_info - FIFO Queue for number of skipped frames for
  269. * the decision of FCG prediction
  270. * @num_frame_skipped: Keep track of the number of skipped frames in between
  271. * of the normal frames
  272. * @list: List member used to append this node to a linked list
  273. */
  274. struct cam_isp_skip_frame_info {
  275. uint32_t num_frame_skipped;
  276. struct list_head list;
  277. };
  278. /**
  279. * struct cam_isp_fcg_prediction_tracker - Track the number of skipped frames before and
  280. * indicate which FCG prediction should be applied
  281. *
  282. * @num_skipped: Number of skipped frames from previous normally applied frame
  283. * to this normally applied frame
  284. * @sum_skipped: Sum of the number of frames from req generation to req apply
  285. * @skipped_list: Keep track of the number of skipped frames in between from two
  286. * normal frames
  287. */
  288. struct cam_isp_fcg_prediction_tracker {
  289. uint32_t num_skipped;
  290. uint32_t sum_skipped;
  291. struct list_head skipped_list;
  292. };
  293. /**
  294. * struct cam_isp_context - ISP context object
  295. *
  296. * @base: Common context object pointer
  297. * @frame_id: Frame id tracking for the isp context
  298. * @frame_id_meta: Frame id read every epoch for the ctx
  299. * meta from the sensor
  300. * @substate_actiavted: Current substate for the activated state.
  301. * @process_bubble: Atomic variable to check if ctx is still
  302. * processing bubble.
  303. * @substate_machine: ISP substate machine for external interface
  304. * @substate_machine_irq: ISP substate machine for irq handling
  305. * @req_base: Common request object storage
  306. * @req_isp: ISP private request object storage
  307. * @hw_ctx: HW object returned by the acquire device command
  308. * @sof_timestamp_val: Captured time stamp value at sof hw event
  309. * @boot_timestamp: Boot time stamp for a given req_id
  310. * @active_req_cnt: Counter for the active request
  311. * @reported_req_id: Last reported request id
  312. * @subscribe_event: The irq event mask that CRM subscribes to, IFE
  313. * will invoke CRM cb at those event.
  314. * @last_applied_req_id: Last applied request id
  315. * @recovery_req_id: Req ID flagged for internal recovery
  316. * @last_sof_timestamp: SOF timestamp of the last frame
  317. * @bubble_frame_cnt: Count of the frame after bubble
  318. * @aeb_error_cnt: Count number of times a specific AEB error scenario is
  319. * enountered
  320. * @out_of_sync_cnt: Out of sync error count for AEB
  321. * @congestion_cnt: Count number of times congestion was encountered
  322. * consecutively
  323. * @state_monitor_head: Write index to the state monitoring array
  324. * @req_info Request id information about last buf done
  325. * @dbg_monitors: Debug monitors for ISP context
  326. * @rdi_only_context: Get context type information.
  327. * true, if context is rdi only context
  328. * @offline_context: Indicate whether context is for offline IFE
  329. * @vfps_aux_context: Indicate whether context is for VFPS aux link
  330. * @resume_hw_in_flushed: Indicate whether resume hw in flushed state in vfps case
  331. * @hw_acquired: Indicate whether HW resources are acquired
  332. * @init_received: Indicate whether init config packet is received
  333. * @split_acquire: Indicate whether a separate acquire is expected
  334. * @custom_enabled: Custom HW enabled for this ctx
  335. * @use_frame_header_ts: Use frame header for qtimer ts
  336. * @support_consumed_addr: Indicate whether HW has last consumed addr reg
  337. * @sof_dbg_irq_en: Indicates whether ISP context has enabled debug irqs
  338. * @apply_in_progress Whether request apply is in progress
  339. * @use_default_apply: Use default settings in case of frame skip
  340. * @init_timestamp: Timestamp at which this context is initialized
  341. * @isp_device_type: ISP device type
  342. * @rxd_epoch: Indicate whether epoch has been received. Used to
  343. * decide whether to apply request in offline ctx
  344. * @workq: Worker thread for offline ife
  345. * @trigger_id: ID provided by CRM for each ctx on the link
  346. * @last_bufdone_err_apply_req_id: last bufdone error apply request id
  347. * @v4l2_event_sub_ids contains individual bits representing subscribed v4l2 ids
  348. * @evt_inject_params: event injection parameters
  349. * @aeb_enabled: Indicate if stream is for AEB
  350. * @last_sof_jiffies: Record the jiffies of last sof
  351. * @last_applied_jiffies: Record the jiffiest of last applied req
  352. * @vfe_bus_comp_grp: Vfe bus comp group record
  353. * @sfe_bus_comp_grp: Sfe bus comp group record
  354. * @mswitch_default_apply_delay_max_cnt: Max mode switch delay among all devices connected
  355. * on the same link as this ISP context
  356. * @mswitch_default_apply_delay_ref_cnt: Ref cnt for this context to decide when to apply
  357. * mode switch settings
  358. * @handle_mswitch: Indicates if IFE needs to explicitly handle mode switch
  359. * on frame skip callback from request manager.
  360. * This is decided based on the max mode switch delay published
  361. * by other devices on the link as part of link setup
  362. * @mode_switch_en: Indicates if mode switch is enabled
  363. * @hw_idx: Hardware ID
  364. * @fcg_tracker: FCG prediction tracker containing number of previously skipped
  365. * frames and indicates which prediction should be used
  366. *
  367. */
  368. struct cam_isp_context {
  369. struct cam_context *base;
  370. uint64_t frame_id;
  371. uint32_t frame_id_meta;
  372. uint32_t substate_activated;
  373. atomic_t process_bubble;
  374. struct cam_ctx_ops *substate_machine;
  375. struct cam_isp_ctx_irq_ops *substate_machine_irq;
  376. struct cam_ctx_request req_base[CAM_ISP_CTX_REQ_MAX];
  377. struct cam_isp_ctx_req req_isp[CAM_ISP_CTX_REQ_MAX];
  378. void *hw_ctx;
  379. uint64_t sof_timestamp_val;
  380. uint64_t boot_timestamp;
  381. int32_t active_req_cnt;
  382. int64_t reported_req_id;
  383. uint64_t reported_frame_id;
  384. uint32_t subscribe_event;
  385. int64_t last_applied_req_id;
  386. uint64_t recovery_req_id;
  387. uint64_t last_sof_timestamp;
  388. uint32_t bubble_frame_cnt;
  389. uint32_t aeb_error_cnt;
  390. uint32_t out_of_sync_cnt;
  391. uint32_t congestion_cnt;
  392. struct cam_isp_context_req_id_info req_info;
  393. struct cam_isp_context_debug_monitors dbg_monitors;
  394. bool rdi_only_context;
  395. bool offline_context;
  396. bool vfps_aux_context;
  397. bool resume_hw_in_flushed;
  398. bool hw_acquired;
  399. bool init_received;
  400. bool split_acquire;
  401. bool custom_enabled;
  402. bool use_frame_header_ts;
  403. bool support_consumed_addr;
  404. bool sof_dbg_irq_en;
  405. atomic_t apply_in_progress;
  406. atomic_t internal_recovery_set;
  407. bool use_default_apply;
  408. unsigned int init_timestamp;
  409. uint32_t isp_device_type;
  410. atomic_t rxd_epoch;
  411. struct cam_req_mgr_core_workq *workq;
  412. int32_t trigger_id;
  413. int64_t last_bufdone_err_apply_req_id;
  414. uint32_t v4l2_event_sub_ids;
  415. struct cam_hw_inject_evt_param evt_inject_params;
  416. bool aeb_enabled;
  417. uint64_t last_sof_jiffies;
  418. uint64_t last_applied_jiffies;
  419. struct cam_isp_context_comp_record *vfe_bus_comp_grp;
  420. struct cam_isp_context_comp_record *sfe_bus_comp_grp;
  421. int32_t mswitch_default_apply_delay_max_cnt;
  422. atomic_t mswitch_default_apply_delay_ref_cnt;
  423. bool handle_mswitch;
  424. bool mode_switch_en;
  425. uint32_t hw_idx;
  426. struct cam_isp_fcg_prediction_tracker fcg_tracker;
  427. };
  428. /**
  429. * struct cam_isp_context_dump_header - ISP context dump header
  430. * @tag: Tag name for the header
  431. * @word_size: Size of word
  432. * @size: Size of data
  433. *
  434. */
  435. struct cam_isp_context_dump_header {
  436. uint8_t tag[CAM_ISP_CONTEXT_DUMP_TAG_MAX_LEN];
  437. uint64_t size;
  438. uint32_t word_size;
  439. };
  440. /** * struct cam_isp_ctx_req_mini_dump - ISP mini dumprequest
  441. *
  442. * @map_out: Output fence mapping
  443. * @map_in: Input fence mapping
  444. * @io_cfg: IO buffer configuration
  445. * @reapply_type: Determines type of settings to be re-applied
  446. * @request_id: Request ID
  447. * @num_fence_map_out: Number of the output fence map
  448. * @num_fence_map_in: Number of input fence map
  449. * @num_io_cfg: Number of ISP hardware configuration entries
  450. * @num_acked: Count to track acked entried for output.
  451. * @num_deferred_acks: Number of buf_dones/acks that are deferred to
  452. * handle or signalled in special scenarios.
  453. * Increment this count instead of num_acked and
  454. * handle the events later where eventually
  455. * increment num_acked.
  456. * @bubble_report: Flag to track if bubble report is active on
  457. * current request
  458. * @bubble_detected: Flag to track if bubble is detected
  459. * @cdm_reset_before_apply: For bubble re-apply when buf done not coming set
  460. * to True
  461. *
  462. */
  463. struct cam_isp_ctx_req_mini_dump {
  464. struct cam_hw_fence_map_entry *map_out;
  465. struct cam_hw_fence_map_entry *map_in;
  466. struct cam_buf_io_cfg *io_cfg;
  467. enum cam_hw_config_reapply_type reapply_type;
  468. uint64_t request_id;
  469. uint8_t num_fence_map_in;
  470. uint8_t num_fence_map_out;
  471. uint8_t num_io_cfg;
  472. uint8_t num_acked;
  473. uint8_t num_deferred_acks;
  474. bool bubble_report;
  475. bool bubble_detected;
  476. bool cdm_reset_before_apply;
  477. };
  478. /**
  479. * struct cam_isp_ctx_mini_dump_info - Isp context mini dump data
  480. *
  481. * @active_list: Active Req list
  482. * @pending_list: Pending req list
  483. * @wait_list: Wait Req List
  484. * @event_record: Event record
  485. * @sof_timestamp_val: Captured time stamp value at sof hw event
  486. * @boot_timestamp: Boot time stamp for a given req_id
  487. * @last_sof_timestamp: SOF timestamp of the last frame
  488. * @init_timestamp: Timestamp at which this context is initialized
  489. * @frame_id: Frame id read every epoch for the ctx
  490. * @reported_req_id: Last reported request id
  491. * @last_applied_req_id: Last applied request id
  492. * @frame_id_meta: Frame id for meta
  493. * @ctx_id: Context id
  494. * @subscribe_event: The irq event mask that CRM subscribes to, IFE
  495. * will invoke CRM cb at those event.
  496. * @bubble_frame_cnt: Count of the frame after bubble
  497. * @isp_device_type: ISP device type
  498. * @active_req_cnt: Counter for the active request
  499. * @trigger_id: ID provided by CRM for each ctx on the link
  500. * @substate_actiavted: Current substate for the activated state.
  501. * @rxd_epoch: Indicate whether epoch has been received. Used to
  502. * decide whether to apply request in offline ctx
  503. * @process_bubble: Atomic variable to check if ctx is still
  504. * processing bubble.
  505. * @apply_in_progress Whether request apply is in progress
  506. * @rdi_only_context: Get context type information.
  507. * true, if context is rdi only context
  508. * @offline_context: Indicate whether context is for offline IFE
  509. * @hw_acquired: Indicate whether HW resources are acquired
  510. * @init_received: Indicate whether init config packet is received
  511. * meta from the sensor
  512. * @split_acquire: Indicate whether a separate acquire is expected
  513. * @custom_enabled: Custom HW enabled for this ctx
  514. * @use_frame_header_ts: Use frame header for qtimer ts
  515. * @support_consumed_addr: Indicate whether HW has last consumed addr reg
  516. * @use_default_apply: Use default settings in case of frame skip
  517. *
  518. */
  519. struct cam_isp_ctx_mini_dump_info {
  520. struct cam_isp_ctx_req_mini_dump *active_list;
  521. struct cam_isp_ctx_req_mini_dump *pending_list;
  522. struct cam_isp_ctx_req_mini_dump *wait_list;
  523. struct cam_isp_context_event_record event_record[
  524. CAM_ISP_CTX_EVENT_MAX][CAM_ISP_CTX_EVENT_RECORD_MAX_ENTRIES];
  525. uint64_t sof_timestamp_val;
  526. uint64_t boot_timestamp;
  527. uint64_t last_sof_timestamp;
  528. uint64_t init_timestamp;
  529. int64_t frame_id;
  530. int64_t reported_req_id;
  531. int64_t last_applied_req_id;
  532. int64_t last_bufdone_err_apply_req_id;
  533. uint32_t frame_id_meta;
  534. uint8_t ctx_id;
  535. uint8_t subscribe_event;
  536. uint8_t bubble_frame_cnt;
  537. uint8_t isp_device_type;
  538. uint8_t active_req_cnt;
  539. uint8_t trigger_id;
  540. uint8_t substate_activated;
  541. uint8_t rxd_epoch;
  542. uint8_t process_bubble;
  543. uint8_t active_cnt;
  544. uint8_t pending_cnt;
  545. uint8_t wait_cnt;
  546. bool apply_in_progress;
  547. bool rdi_only_context;
  548. bool offline_context;
  549. bool hw_acquired;
  550. bool init_received;
  551. bool split_acquire;
  552. bool custom_enabled;
  553. bool use_frame_header_ts;
  554. bool support_consumed_addr;
  555. bool use_default_apply;
  556. };
  557. /**
  558. * cam_isp_context_init()
  559. *
  560. * @brief: Initialization function for the ISP context
  561. *
  562. * @ctx: ISP context obj to be initialized
  563. * @bridge_ops: Bridge call back funciton
  564. * @hw_intf: ISP hw manager interface
  565. * @ctx_id: ID for this context
  566. * @isp_device_type Isp device type
  567. * @img_iommu_hdl IOMMU HDL for image buffers
  568. *
  569. */
  570. int cam_isp_context_init(struct cam_isp_context *ctx,
  571. struct cam_context *ctx_base,
  572. struct cam_req_mgr_kmd_ops *bridge_ops,
  573. struct cam_hw_mgr_intf *hw_intf,
  574. uint32_t ctx_id,
  575. uint32_t isp_device_type,
  576. int img_iommu_hdl);
  577. /**
  578. * cam_isp_context_deinit()
  579. *
  580. * @brief: Deinitialize function for the ISP context
  581. *
  582. * @ctx: ISP context obj to be deinitialized
  583. *
  584. */
  585. int cam_isp_context_deinit(struct cam_isp_context *ctx);
  586. #endif /* __CAM_ISP_CONTEXT_H__ */