cam_isp_context.h 27 KB

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