1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20 #include "acamera_fw.h"
21 #if ACAMERA_ISP_PROFILING
22 #include "acamera_profiler.h"
23 #endif
24 #include <linux/fs.h>
25 #include <linux/version.h>
26 #include <asm/uaccess.h>
27
28 #if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 0, 0))
29 #include <linux/fs.h>
30 #endif
31
32 #include "acamera_isp_config.h"
33 #include "acamera_command_api.h"
34 #include "acamera_isp_core_nomem_settings.h"
35 #include "acamera_metering_stats_mem_config.h"
36 #include "system_timer.h"
37 #include "acamera_logger.h"
38 #include "acamera_sbus_api.h"
39 #include "sensor_init.h"
40 #include "isp_config_seq.h"
41 #include "system_am_sc.h"
42 #include "system_autowrite.h"
43
44 #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
45
46 #if ISP_HAS_FPGA_WRAPPER
47 #include "acamera_fpga_config.h"
48 #endif
49
50 #if ISP_HAS_META_CB && defined( ISP_HAS_METADATA_FSM )
51 #include "metadata_api.h"
52 #endif
53
54 #include "acamera_3aalg_preset.h"
55
56 static const acam_reg_t **p_isp_data = SENSOR_ISP_SEQUENCE_DEFAULT;
57
58 uint32_t seamless = 0;
59 module_param(seamless, uint, 0664);
60 MODULE_PARM_DESC(seamless, "\n control seamless\n");
61
62 extern void acamera_notify_evt_data_avail( void );
63
acamera_load_isp_sequence(uintptr_t isp_base,const acam_reg_t ** sequence,uint8_t num)64 void acamera_load_isp_sequence( uintptr_t isp_base, const acam_reg_t **sequence, uint8_t num )
65 {
66 acamera_sbus_t sbus;
67 sbus.mask = SBUS_MASK_SAMPLE_32BITS | SBUS_MASK_SAMPLE_16BITS | SBUS_MASK_SAMPLE_8BITS | SBUS_MASK_ADDR_STEP_32BITS | SBUS_MASK_ADDR_32BITS;
68 acamera_sbus_init( &sbus, sbus_isp );
69 acamera_load_array_sequence( &sbus, isp_base, 0, sequence, num );
70 }
71
72
acamera_load_sw_sequence(uintptr_t isp_base,const acam_reg_t ** sequence,uint8_t num)73 void acamera_load_sw_sequence( uintptr_t isp_base, const acam_reg_t **sequence, uint8_t num )
74 {
75 acamera_sbus_t sbus;
76 sbus.mask = SBUS_MASK_SAMPLE_32BITS | SBUS_MASK_SAMPLE_16BITS | SBUS_MASK_SAMPLE_8BITS | SBUS_MASK_ADDR_STEP_32BITS | SBUS_MASK_ADDR_32BITS;
77 acamera_sbus_init( &sbus, sbus_isp_sw );
78 acamera_load_array_sequence( &sbus, isp_base, 0, sequence, num );
79 }
80
81
82 #define IRQ_ID_UNDEFINED 0xFF
83
84
acamera_fw_init(acamera_context_t * p_ctx)85 void acamera_fw_init( acamera_context_t *p_ctx )
86 {
87 #if ACAMERA_ISP_PROFILING
88 #if ACAMERA_ISP_PROFILING_INIT
89 p_ctx->binit_profiler = 0;
90 p_ctx->breport_profiler = 0;
91 #else
92 p_ctx->binit_profiler = 0;
93 p_ctx->breport_profiler = 0;
94 #endif
95 p_ctx->start_profiling = 500; //start when gframe == 500
96 p_ctx->stop_profiling = 1000; //stop when gframe == 1000
97 #endif
98
99 p_ctx->irq_flag = 1;
100
101 if(seamless)
102 {
103 if(acamera_isp_input_port_mode_status_read( 0 ) != ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_START)
104 p_ctx->fsm_mgr.isp_seamless = 0;
105 else
106 p_ctx->fsm_mgr.isp_seamless = 1;
107 }
108 else
109 p_ctx->fsm_mgr.isp_seamless = 0;
110
111 LOG(LOG_CRIT, "seamless:%d", p_ctx->fsm_mgr.isp_seamless);
112
113 p_ctx->fsm_mgr.p_ctx = p_ctx;
114 p_ctx->fsm_mgr.ctx_id = p_ctx->context_id;
115 p_ctx->fsm_mgr.isp_base = p_ctx->settings.isp_base;
116 acamera_fsm_mgr_init( &p_ctx->fsm_mgr );
117
118 p_ctx->irq_flag = 0;
119 acamera_fw_interrupts_enable( p_ctx );
120 p_ctx->system_state = FW_RUN;
121 }
122
acamera_fw_deinit(acamera_context_t * p_ctx)123 void acamera_fw_deinit( acamera_context_t *p_ctx )
124 {
125 p_ctx->fsm_mgr.p_ctx = p_ctx;
126 acamera_fsm_mgr_deinit( &p_ctx->fsm_mgr );
127 }
128
acamera_fw_error_routine(acamera_context_t * p_ctx,uint32_t irq_mask)129 void acamera_fw_error_routine( acamera_context_t *p_ctx, uint32_t irq_mask )
130 {
131 //masked all interrupts
132 acamera_isp_isp_global_interrupt_mask_vector_write( 0, ISP_IRQ_DISABLE_ALL_IRQ );
133 //safe stop
134 acamera_isp_input_port_mode_request_write( p_ctx->settings.isp_base, ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_STOP );
135
136 // check whether the HW is stopped or not.
137 uint32_t count = 0;
138 while ( acamera_isp_input_port_mode_status_read( p_ctx->settings.isp_base ) != ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_STOP || acamera_isp_isp_global_monitor_fr_pipeline_busy_read( p_ctx->settings.isp_base ) ) {
139 //cannot sleep use this delay
140 do {
141 count++;
142 } while ( count % 32 != 0 );
143
144 if ( ( count >> 5 ) > 50 ) {
145 LOG( LOG_INFO, "stopping isp failed, timeout: %u.", (unsigned int)count * 1000 );
146 break;
147 }
148 }
149
150 acamera_isp_isp_global_global_fsm_reset_write( p_ctx->settings.isp_base, 1 );
151 acamera_isp_isp_global_global_fsm_reset_write( p_ctx->settings.isp_base, 0 );
152
153 //return the interrupts
154 acamera_isp_isp_global_interrupt_mask_vector_write( 0, ISP_IRQ_MASK_VECTOR );
155
156 acamera_isp_input_port_mode_request_write( p_ctx->settings.isp_base, ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_START );
157
158 LOG( LOG_ERR, "starting isp from error" );
159 }
160
161
acamera_fw_process(acamera_context_t * p_ctx)162 void acamera_fw_process( acamera_context_t *p_ctx )
163 {
164 #if ACAMERA_ISP_PROFILING
165 if ( ( p_ctx->frame >= p_ctx->start_profiling ) && ( !p_ctx->binit_profiler ) ) {
166 acamera_profiler_init();
167 p_ctx->binit_profiler = 1;
168 }
169 #endif
170 if (p_ctx->system_state == FW_RUN) //need to capture on firmware freeze
171 {
172 // firmware not frozen
173 // 0 means handle all the events and then return.
174 acamera_fsm_mgr_process_events( &p_ctx->fsm_mgr, 0 );
175 }
176 #if ACAMERA_ISP_PROFILING
177 if ( ( p_ctx->frame >= p_ctx->stop_profiling ) && ( !p_ctx->breport_profiler ) ) {
178 acamera_profiler_report();
179 p_ctx->breport_profiler = 1;
180 }
181 #endif
182 }
183
acamera_fw_raise_event(acamera_context_t * p_ctx,event_id_t event_id)184 void acamera_fw_raise_event( acamera_context_t *p_ctx, event_id_t event_id )
185 { //dma writer events should be passed for the capture on freeze requirement
186 if ( p_ctx->stab.global_freeze_firmware == 0 || event_id == event_id_new_frame || event_id == event_id_drop_frame
187 #if defined( ISP_HAS_DMA_WRITER_FSM )
188 || event_id == event_id_frame_buffer_fr_ready || event_id == event_id_frame_buffer_ds_ready || event_id == event_id_frame_buffer_metadata
189 #endif
190 #if defined( ISP_HAS_METADATA_FSM )
191 || event_id == event_id_metadata_ready || event_id == event_id_metadata_update
192 #endif
193 #if defined( ISP_HAS_BSP_TEST_FSM )
194 || event_id == event_id_bsp_test_interrupt_finished
195 #endif
196 ) {
197 acamera_event_queue_push( &p_ctx->fsm_mgr.event_queue, (int)( event_id ) );
198
199 acamera_notify_evt_data_avail();
200 }
201 }
202
acamera_fsm_mgr_raise_event(acamera_fsm_mgr_t * p_fsm_mgr,event_id_t event_id)203 void acamera_fsm_mgr_raise_event( acamera_fsm_mgr_t *p_fsm_mgr, event_id_t event_id )
204 { //dma writer events should be passed for the capture on freeze requirement
205 if ( p_fsm_mgr->p_ctx->stab.global_freeze_firmware == 0 || event_id == event_id_new_frame || event_id == event_id_drop_frame
206 #if defined( ISP_HAS_DMA_WRITER_FSM )
207 || event_id == event_id_frame_buffer_fr_ready || event_id == event_id_frame_buffer_ds_ready || event_id == event_id_frame_buffer_metadata
208 #endif
209 #if defined( ISP_HAS_BSP_TEST_FSM )
210 || event_id == event_id_bsp_test_interrupt_finished
211 #endif
212 ) {
213 acamera_event_queue_push( &( p_fsm_mgr->event_queue ), (int)( event_id ) );
214
215 acamera_notify_evt_data_avail();
216 }
217 }
218
acamera_extern_param_calculate(void * param)219 int32_t acamera_extern_param_calculate(void *param)
220 {
221 int32_t rtn = 0;
222 uint32_t alpha = 0;
223 uint32_t i, j;
224 uint32_t r_cnt = 0;
225 uint32_t c_cnt = 0;
226 uint32_t l_gain = 0;
227 uint32_t w_cnt = 0;
228 uint32_t *c_param = NULL;
229 uint32_t *c_result = NULL;
230 uint32_t x0, y0, x1, y1;
231 fsm_ext_param_ctrl_t *p_ctrl = param;
232
233 if (p_ctrl == NULL || p_ctrl->ctx == NULL || p_ctrl->result == NULL) {
234 LOG(LOG_CRIT, "Error input param");
235 rtn = -1;
236 goto over_return;
237 }
238
239 c_param = _GET_UINT_PTR(p_ctrl->ctx, p_ctrl->id);
240 l_gain = (p_ctrl->total_gain) >> (LOG2_GAIN_SHIFT - 8);
241 r_cnt = _GET_ROWS(p_ctrl->ctx, p_ctrl->id);
242 c_cnt = _GET_COLS(p_ctrl->ctx, p_ctrl->id);
243 w_cnt = _GET_WIDTH(p_ctrl->ctx, p_ctrl->id);
244 c_result = p_ctrl->result;
245
246 if (l_gain <= c_param[0]) {
247 system_memcpy(c_result, c_param, c_cnt * w_cnt);
248 goto over_return;
249 }
250
251 if (l_gain >= c_param[(r_cnt - 1) * c_cnt]) {
252 system_memcpy(c_result, &c_param[(r_cnt - 1) * c_cnt], c_cnt * w_cnt);
253 goto over_return;
254 }
255
256 for (i = 1; i < r_cnt; i++) {
257 if (l_gain < c_param[i * c_cnt]) {
258 break;
259 }
260 }
261
262 for (j = 1; j < c_cnt; j++) {
263 x0 = c_param[(i - 1) * c_cnt];
264 x1 = c_param[i * c_cnt];
265 y0 = c_param[(i - 1) * c_cnt + j];
266 y1 = c_param[i * c_cnt + j];
267 if (x1 != x0) {
268 alpha = (l_gain - x0) * 256 / (x1 - x0);
269 c_result[j] = (y1 * alpha + y0 * (256 - alpha)) >> 8;
270 } else {
271 c_result[j] = y1;
272 LOG(LOG_CRIT, "AVOIDED DIVISION BY ZERO");
273 }
274 }
275
276 c_result[0] = l_gain;
277
278 over_return:
279 return rtn;
280 }
281
acamera_open_external_bin(void * ctx,struct file ** fp,uint32_t * size)282 static void acamera_open_external_bin(void *ctx, struct file **fp, uint32_t *size)
283 {
284 uint32_t mode = 0;
285 char f_name[40] = {'\0'};
286 acamera_context_ptr_t p_ctx;
287 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
288 struct kstat stat;
289 #endif
290
291 if (ctx == NULL || fp == NULL) {
292 LOG(LOG_ERR, "Error input param");
293 return;
294 }
295
296 p_ctx = ctx;
297
298 acamera_fsm_mgr_get_param(&p_ctx->fsm_mgr, FSM_PARAM_GET_WDR_MODE, NULL, 0, &mode, sizeof(mode));
299
300 switch (mode) {
301 case WDR_MODE_LINEAR:
302 snprintf(f_name, sizeof(f_name), "/data/isp_tuning/tuning_linear.bin");
303 break;
304 case WDR_MODE_NATIVE:
305 snprintf(f_name, sizeof(f_name), "/data/isp_tuning/tuning_native.bin");
306 break;
307 case WDR_MODE_FS_LIN:
308 snprintf(f_name, sizeof(f_name), "/data/isp_tuning/tuning_fs_lin.bin");
309 break;
310 default:
311 LOG(LOG_ERR, "Error input mode %u", mode);
312 return;
313 }
314
315 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
316 if (vfs_stat(f_name, &stat)) {
317 return;
318 }
319
320 *size = stat.size;
321 #endif
322
323 *fp = filp_open(f_name, O_RDONLY, 0);
324
325 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
326 if (IS_ERR(*fp)) {
327 *fp = NULL;
328 } else {
329 *size = i_size_read(file_inode(*fp));
330 }
331 #endif
332 }
333
acamera_read_external_bin(struct file * fp,uint8_t * buf,uint32_t size)334 static int32_t acamera_read_external_bin(struct file *fp, uint8_t *buf, uint32_t size)
335 {
336 loff_t pos = 0;
337 int32_t nread = -1;
338
339 if (fp == NULL || buf == NULL || !size) {
340 LOG(LOG_ERR, "Error input param");
341 return nread;
342 }
343
344 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))
345 nread = vfs_read(fp, buf, size, &pos);
346 #else
347 nread = kernel_read(fp, buf, size, &pos);
348 #endif
349
350 return nread;
351 }
352
acamera_update_external_calibrations(acamera_context_ptr_t p_ctx)353 static void acamera_update_external_calibrations(acamera_context_ptr_t p_ctx)
354 {
355 int32_t nread = 0;
356 uint32_t idx = 0;
357 uint32_t l_size = 0;
358 uint32_t t_size = 0;
359 uint8_t *l_ptr = NULL;
360 uint8_t *b_buf = NULL;
361 uint8_t *p_mem = NULL;
362 uint32_t f_size = 0;
363 struct file *fp = NULL;
364 mm_segment_t fs;
365
366 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))
367 fs = get_fs();
368 set_fs(KERNEL_DS);
369 #endif
370
371 acamera_open_external_bin(p_ctx, &fp, &f_size);
372 if (fp == NULL || !f_size) {
373 LOG(LOG_ERR, "Bin file not exsit");
374 goto error_exit;
375 }
376
377 for (idx = 0; idx < CALIBRATION_TOTAL_SIZE; idx++) {
378 l_size = _GET_SIZE(p_ctx, idx);
379 t_size += l_size;
380 }
381
382 if (t_size != f_size) {
383 LOG(LOG_ERR, "Bin size not match: f_size %u, t_size %u", f_size, t_size);
384 goto error_size;
385 }
386
387 b_buf = kzalloc(t_size, GFP_KERNEL);
388 if (b_buf == NULL) {
389 LOG(LOG_ERR, "Failed to alloc mem");
390 goto error_size;
391 }
392
393 nread = acamera_read_external_bin(fp, b_buf, f_size);
394 if (nread != f_size) {
395 LOG(LOG_ERR, "Failed to read bin");
396 goto error_read;
397 }
398
399 p_mem = b_buf;
400
401 for (idx = 0; idx < CALIBRATION_TOTAL_SIZE; idx++) {
402 l_ptr = (uint8_t *)_GET_LUT_PTR(p_ctx, idx);
403 l_size = _GET_SIZE(p_ctx, idx);
404 if (l_size)
405 memcpy(l_ptr, p_mem, l_size);
406 p_mem += l_size;
407 }
408
409 LOG(LOG_CRIT, "Success update tuning bin");
410
411 error_read:
412 if (b_buf)
413 kfree(b_buf);
414 error_size:
415 if (fp)
416 filp_close(fp, NULL);
417 error_exit:
418 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))
419 set_fs(fs);
420 #endif
421 return ;
422 }
423
acamera_update_calibration_set(acamera_context_ptr_t p_ctx,char * s_name)424 int32_t acamera_update_calibration_set( acamera_context_ptr_t p_ctx, char* s_name)
425 {
426 int32_t result = 0;
427 void *sensor_arg = 0;
428 if ( p_ctx->settings.get_calibrations != NULL ) {
429 {
430 const sensor_param_t *param = NULL;
431 acamera_fsm_mgr_get_param( &p_ctx->fsm_mgr, FSM_PARAM_GET_SENSOR_PARAM, NULL, 0, ¶m, sizeof( param ) );
432
433 uint32_t cur_mode = param->mode;
434 if ( cur_mode < param->modes_num ) {
435 sensor_arg = &( param->modes_table[cur_mode] );
436 }
437 }
438 if ( p_ctx->settings.get_calibrations( p_ctx->context_id, sensor_arg, &p_ctx->acameraCalibrations, s_name) != 0 ) {
439 LOG( LOG_CRIT, "Failed to get calibration set for. Fatal error" );
440 }
441
442 acamera_update_external_calibrations(p_ctx);
443
444 #if defined( ISP_HAS_GENERAL_FSM )
445 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_RELOAD_CALIBRATION, NULL, 0 );
446 #endif
447
448 // Update some FSMs variables which depends on calibration data.
449 #if defined( ISP_HAS_AE_BALANCED_FSM ) || defined( ISP_HAS_AE_MANUAL_FSM )
450 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_AE_INIT, NULL, 0 );
451 #endif
452
453 #if defined( ISP_HAS_IRIDIX_FSM ) || defined( ISP_HAS_IRIDIX_HIST_FSM ) || defined( ISP_HAS_IRIDIX_MANUAL_FSM )
454 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_IRIDIX_INIT, NULL, 0 );
455 #endif
456
457 #if defined( ISP_HAS_COLOR_MATRIX_FSM )
458 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_CCM_CHANGE, NULL, 0 );
459 #endif
460
461 #if defined( ISP_HAS_SBUF_FSM )
462 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_SBUF_CALIBRATION_UPDATE, NULL, 0 );
463 #endif
464 } else {
465 LOG( LOG_CRIT, "Calibration callback is null. Failed to get calibrations" );
466 result = -1;
467 }
468
469 return result;
470 }
471
acamera_init_calibrations(acamera_context_ptr_t p_ctx,char * s_name)472 int32_t acamera_init_calibrations( acamera_context_ptr_t p_ctx , char* s_name)
473 {
474 int32_t result = 0;
475 void *sensor_arg = 0;
476 #ifdef SENSOR_ISP_SEQUENCE_DEFAULT_FULL
477 acamera_load_isp_sequence( p_ctx->settings.isp_base, p_ctx->isp_sequence, SENSOR_ISP_SEQUENCE_DEFAULT_FULL );
478 #endif
479
480 // if "p_ctx->initialized" is 1, that means we are changing the preset and wdr_mode,
481 // we need to update the calibration data and update some FSM variables which
482 // depends on calibration data.
483 if ( p_ctx->initialized == 1 ) {
484 acamera_update_calibration_set( p_ctx, s_name );
485 } else {
486 if ( p_ctx->settings.get_calibrations != NULL ) {
487 const sensor_param_t *param = NULL;
488 acamera_fsm_mgr_get_param( &p_ctx->fsm_mgr, FSM_PARAM_GET_SENSOR_PARAM, NULL, 0, ¶m, sizeof( param ) );
489
490 uint32_t cur_mode = param->mode;
491 if ( cur_mode < param->modes_num ) {
492 sensor_arg = &( param->modes_table[cur_mode] );
493 }
494
495 if ( p_ctx->settings.get_calibrations( p_ctx->context_id, sensor_arg, &p_ctx->acameraCalibrations, s_name ) != 0 ) {
496 LOG( LOG_CRIT, "Failed to get calibration set for. Fatal error" );
497 }
498
499 acamera_update_external_calibrations(p_ctx);
500 } else {
501 LOG( LOG_CRIT, "Calibration callback is null. Failed to get calibrations" );
502 result = -1;
503 }
504 }
505 return result;
506 }
507
acamera_init_context_seq(acamera_context_t * p_ctx)508 int32_t acamera_init_context_seq( acamera_context_t *p_ctx )
509 {
510 int32_t result = 0;
511
512 // if "p_ctx->initialized" is 1, that means we are changing the preset and wdr_mode,
513 // we need to update the calibration data and update some FSM variables which
514 // depends on calibration data.
515 const sensor_param_t *param = NULL;
516 result = acamera_fsm_mgr_get_param( &p_ctx->fsm_mgr, FSM_PARAM_GET_SENSOR_PARAM, NULL, 0, ¶m, sizeof( param ) );
517 if (result != 0) {
518 LOG(LOG_ERR, "WARNING:get isp context seq failed.\n");
519 return 0;
520 }
521 p_ctx->isp_context_seq.sequence = param->isp_context_seq.sequence;
522 p_ctx->isp_context_seq.seq_num = param->isp_context_seq.seq_num;
523 LOG(LOG_ERR, "load isp context sequence[%d]\n", param->isp_context_seq.seq_num);
524
525 acamera_load_sw_sequence( p_ctx->settings.isp_base, p_ctx->isp_context_seq.sequence, p_ctx->isp_context_seq.seq_num );
526 return result;
527 }
528
529
530 #if ISP_HAS_META_CB && defined( ISP_HAS_METADATA_FSM )
internal_callback_metadata(void * ctx,const firmware_metadata_t * fw_metadata)531 static void internal_callback_metadata( void *ctx, const firmware_metadata_t *fw_metadata )
532 {
533 acamera_context_ptr_t p_ctx = (acamera_context_ptr_t)ctx;
534
535 if ( p_ctx->settings.callback_meta != NULL ) {
536 p_ctx->settings.callback_meta( p_ctx->context_id, fw_metadata );
537 }
538 }
539 #endif
540
541 #if ISP_HAS_RAW_CB && ISP_DMA_RAW_CAPTURE
542 //static void internal_callback_raw( void* ctx, tframe_t *tframe, const metadata_t *metadata )
internal_callback_raw(void * ctx,aframe_t * aframe,const metadata_t * metadata,uint8_t exposures_num)543 static void internal_callback_raw( void *ctx, aframe_t *aframe, const metadata_t *metadata, uint8_t exposures_num )
544 {
545 acamera_context_ptr_t p_ctx = (acamera_context_ptr_t)ctx;
546
547 if ( p_ctx->settings.callback_raw != NULL ) {
548 p_ctx->settings.callback_raw( p_ctx->context_id, aframe, metadata, exposures_num );
549 }
550 }
551 #endif
552
553 #if defined( ISP_HAS_DMA_WRITER_FSM )
internal_callback_fr(void * ctx,tframe_t * tframe,const metadata_t * metadata)554 static void internal_callback_fr( void *ctx, tframe_t *tframe, const metadata_t *metadata )
555 {
556 acamera_context_ptr_t p_ctx = (acamera_context_ptr_t)ctx;
557
558 if ( p_ctx->settings.callback_fr != NULL ) {
559 p_ctx->settings.callback_fr( p_ctx->context_id, tframe, metadata );
560 }
561 }
562 #endif
563
564 #if ISP_HAS_DS1 && defined( ISP_HAS_DMA_WRITER_FSM )
565 // Callback from DS1 output pipe
internal_callback_ds1(void * ctx,tframe_t * tframe,const metadata_t * metadata)566 static void internal_callback_ds1( void *ctx, tframe_t *tframe, const metadata_t *metadata )
567 {
568
569 acamera_context_ptr_t p_ctx = (acamera_context_ptr_t)ctx;
570 if ( p_ctx->settings.callback_ds1 != NULL ) {
571 p_ctx->settings.callback_ds1( p_ctx->context_id, tframe, metadata );
572 }
573 }
574 #endif
575
576 #if ISP_HAS_DS2
577 // Callback from DS2 output pipe
external_callback_ds2(void * ctx,tframe_t * tframe,const metadata_t * metadata)578 static void external_callback_ds2( void *ctx, tframe_t *tframe, const metadata_t *metadata )
579 {
580
581 acamera_context_ptr_t p_ctx = (acamera_context_ptr_t)ctx;
582 if ( p_ctx->settings.callback_ds2 != NULL ) {
583 p_ctx->settings.callback_ds2( p_ctx->context_id, tframe, metadata );
584 }
585 }
586 #endif
587
configure_all_frame_buffers(acamera_context_ptr_t p_ctx)588 static void configure_all_frame_buffers( acamera_context_ptr_t p_ctx )
589 {
590
591 #if ISP_HAS_WDR_FRAME_BUFFER
592 acamera_isp_frame_stitch_frame_buffer_frame_write_on_write( p_ctx->settings.isp_base, 0 );
593 aframe_t *frame_stitch_frames = p_ctx->settings.fs_frames;
594 uint32_t frame_stitch_frames_num = p_ctx->settings.fs_frames_number;
595 if ( frame_stitch_frames != NULL && frame_stitch_frames_num != 0 ) {
596 if ( frame_stitch_frames_num == 1 ) {
597 LOG( LOG_INFO, "Only one output buffer will be used for frame_stitch." );
598 acamera_isp_frame_stitch_frame_buffer_bank0_base_write( p_ctx->settings.isp_base, frame_stitch_frames[0].address );
599 acamera_isp_frame_stitch_frame_buffer_bank1_base_write( p_ctx->settings.isp_base, frame_stitch_frames[0].address );
600 acamera_isp_frame_stitch_frame_buffer_line_offset_write( p_ctx->settings.isp_base, frame_stitch_frames[0].line_offset );
601 } else {
602 // double buffering is enabled
603 acamera_isp_frame_stitch_frame_buffer_bank0_base_write( p_ctx->settings.isp_base, frame_stitch_frames[0].address );
604 acamera_isp_frame_stitch_frame_buffer_bank1_base_write( p_ctx->settings.isp_base, frame_stitch_frames[1].address );
605 acamera_isp_frame_stitch_frame_buffer_line_offset_write( p_ctx->settings.isp_base, frame_stitch_frames[0].line_offset );
606 }
607
608 acamera_isp_frame_stitch_frame_buffer_frame_write_on_write( p_ctx->settings.isp_base, 1 );
609 acamera_isp_frame_stitch_frame_buffer_axi_port_enable_write( p_ctx->settings.isp_base, 1 );
610
611 } else {
612 acamera_isp_frame_stitch_frame_buffer_frame_write_on_write( p_ctx->settings.isp_base, 0 );
613 acamera_isp_frame_stitch_frame_buffer_axi_port_enable_write( p_ctx->settings.isp_base, 0 );
614 LOG( LOG_ERR, "No output buffers for frame_stitch block provided in settings. frame_stitch wdr buffer is disabled" );
615 }
616 #endif
617
618
619 #if ISP_HAS_META_CB && defined( ISP_HAS_METADATA_FSM )
620 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_META_REGISTER_CB, internal_callback_metadata, sizeof( metadata_callback_t ) );
621 #endif
622
623
624 #if ISP_HAS_RAW_CB && ISP_DMA_RAW_CAPTURE
625 dma_raw_capture_regist_callback( p_ctx->p_gfw, internal_callback_raw );
626 #endif
627
628 #if defined( ISP_HAS_DMA_WRITER_FSM )
629
630 fsm_param_dma_pipe_setting_t pipe_fr;
631
632 pipe_fr.pipe_id = dma_fr;
633 pipe_fr.buf_array = p_ctx->settings.fr_frames;
634 pipe_fr.buf_len = p_ctx->settings.fr_frames_number;
635 pipe_fr.callback = internal_callback_fr;
636 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_DMA_PIPE_SETTING, &pipe_fr, sizeof( pipe_fr ) );
637
638 acamera_isp_fr_dma_writer_format_write( p_ctx->settings.isp_base, FW_OUTPUT_FORMAT );
639 acamera_isp_fr_uv_dma_writer_format_write( p_ctx->settings.isp_base, FW_OUTPUT_FORMAT_SECONDARY );
640 #endif
641
642
643 #if ISP_HAS_DS1 && defined( ISP_HAS_DMA_WRITER_FSM )
644
645 fsm_param_dma_pipe_setting_t pipe_ds1;
646
647 pipe_ds1.pipe_id = dma_ds1;
648 pipe_ds1.buf_array = p_ctx->settings.ds1_frames;
649 pipe_ds1.buf_len = p_ctx->settings.ds1_frames_number;
650 pipe_ds1.callback = internal_callback_ds1;
651 acamera_fsm_mgr_set_param( &p_ctx->fsm_mgr, FSM_PARAM_SET_DMA_PIPE_SETTING, &pipe_ds1, sizeof( pipe_ds1 ) );
652
653 acamera_isp_ds1_dma_writer_format_write( p_ctx->settings.isp_base, FW_OUTPUT_FORMAT );
654 acamera_isp_ds1_uv_dma_writer_format_write( p_ctx->settings.isp_base, FW_OUTPUT_FORMAT_SECONDARY );
655
656 #endif
657
658 #if ISP_HAS_DS2
659 am_sc_set_callback(p_ctx, external_callback_ds2);
660 #endif
661
662 }
663
acamera_fw_get_sensor_name(uint32_t * sname)664 void acamera_fw_get_sensor_name(uint32_t *sname)
665 {
666 acamera_command(0, TSENSOR, SENSOR_NAME, 0, COMMAND_GET, sname);
667 if (sname == NULL) {
668 LOG(LOG_ERR, "Error input param\n");
669 }
670 }
671
init_stab(acamera_context_ptr_t p_ctx)672 static void init_stab( acamera_context_ptr_t p_ctx )
673 {
674 p_ctx->stab.global_freeze_firmware = 0;
675 p_ctx->stab.global_manual_exposure = 0;
676
677 p_ctx->stab.global_manual_iridix = 0;
678 p_ctx->stab.global_manual_sinter = 0;
679 p_ctx->stab.global_manual_temper = 0;
680 p_ctx->stab.global_manual_awb = 0;
681 p_ctx->stab.global_manual_saturation = 0;
682 p_ctx->stab.global_manual_auto_level = 0;
683 p_ctx->stab.global_manual_frame_stitch = 0;
684 p_ctx->stab.global_manual_raw_frontend = 0;
685 p_ctx->stab.global_manual_black_level = 0;
686 p_ctx->stab.global_manual_shading = 0;
687 p_ctx->stab.global_manual_demosaic = 0;
688 p_ctx->stab.global_manual_cnr = 0;
689 p_ctx->stab.global_manual_sharpen = 0;
690
691 p_ctx->stab.global_exposure = 0;
692 p_ctx->stab.global_long_integration_time = 0;
693 p_ctx->stab.global_short_integration_time = 0;
694 p_ctx->stab.global_manual_exposure_ratio = SYSTEM_MANUAL_EXPOSURE_RATIO_DEFAULT;
695 p_ctx->stab.global_exposure_ratio = SYSTEM_EXPOSURE_RATIO_DEFAULT;
696
697 p_ctx->stab.global_maximum_iridix_strength = SYSTEM_MAXIMUM_IRIDIX_STRENGTH_DEFAULT;
698 p_ctx->stab.global_minimum_iridix_strength = SYSTEM_MINIMUM_IRIDIX_STRENGTH_DEFAULT;
699 p_ctx->stab.global_iridix_strength_target = 0;
700 p_ctx->stab.global_sinter_threshold_target = 0;
701 p_ctx->stab.global_temper_threshold_target = 0;
702 p_ctx->stab.global_awb_red_gain = 256;
703 p_ctx->stab.global_awb_blue_gain = 256;
704 p_ctx->stab.global_saturation_target = 0;
705 p_ctx->stab.global_ae_compensation = SYSTEM_AE_COMPENSATION_DEFAULT;
706 p_ctx->stab.global_calibrate_bad_pixels = 0;
707 }
708
709
710 extern void *get_system_ctx_ptr( void );
711
712 #if USER_MODULE
713
acamera_init_context(acamera_context_t * p_ctx,acamera_settings * settings,acamera_firmware_t * g_fw)714 int32_t acamera_init_context( acamera_context_t *p_ctx, acamera_settings *settings, acamera_firmware_t *g_fw )
715 {
716 int32_t result = 0;
717 // keep the context pointer for debug purposes
718 p_ctx->context_ref = (uint32_t *)p_ctx;
719 p_ctx->p_gfw = g_fw;
720
721 // copy settings
722 system_memcpy( (void *)&p_ctx->settings, (void *)settings, sizeof( acamera_settings ) );
723
724 // each context is initialized to the default state
725 p_ctx->isp_sequence = p_isp_data;
726
727 // reset frame counters
728 p_ctx->isp_frame_counter_raw = 0;
729 p_ctx->isp_frame_counter = 0;
730
731 acamera_fw_init( p_ctx );
732
733 init_stab( p_ctx );
734
735 p_ctx->initialized = 1;
736
737 return result;
738 }
739
740 #else
741
acamera_3aalg_enable(void)742 int acamera_3aalg_enable(void)
743 {
744 #ifdef ACAMERA_PRESET_FREERTOS
745 acamera_alg_preset_t * total_param;
746 char *reserve_virt_addr = phys_to_virt(ACAMERA_ALG_PRE_BASE);
747 if(autowrite_fr_start_address_read())
748 reserve_virt_addr = phys_to_virt(autowrite_fr_start_address_read() + autowrite_fr_writer_memsize_read());
749 else if(autowrite_ds1_start_address_read())
750 reserve_virt_addr = phys_to_virt(autowrite_ds1_start_address_read() + autowrite_ds1_writer_memsize_read());
751
752 //system_memcpy((void *)&total_param, (void *)reserve_virt_addr, sizeof(total_param));
753 total_param = (acamera_alg_preset_t *)reserve_virt_addr;
754
755 if(total_param->ae_pre_info.skip_cnt == 0xFFFF && total_param->awb_pre_info.skip_cnt == 0xFFFF)
756 {
757 return 1;
758 }
759 #endif
760 return 0;
761 }
762
acamera_3aalg_preset(acamera_fsm_mgr_t * p_fsm_mgr)763 void acamera_3aalg_preset(acamera_fsm_mgr_t *p_fsm_mgr)
764 {
765 isp_ae_preset_t ae_param;
766 isp_awb_preset_t awb_param;
767 isp_gamma_preset_t gamma_param;
768 isp_iridix_preset_t iridix_param;
769 fsm_param_sensor_info_t sensor_info;
770
771 acamera_fsm_mgr_get_param( p_fsm_mgr, FSM_PARAM_GET_SENSOR_INFO, NULL, 0, &sensor_info, sizeof( sensor_info ) );
772 if(sensor_info.sensor_exp_number == 2)
773 {
774 ae_param.skip_cnt = 5;
775 ae_param.exposure_log2 = 1726569;
776 ae_param.integrator = 51797079;
777 ae_param.error_log2 = 0;
778 ae_param.exposure_ratio = 512;
779
780 awb_param.skip_cnt = 15;
781 awb_param.wb_log2[0] = 252071;
782 awb_param.wb_log2[1] = 87;
783 awb_param.wb_log2[2] = 87;
784 awb_param.wb_log2[3] = 180394;
785 awb_param.wb[0] = 527;
786 awb_param.wb[1] = 271;
787 awb_param.wb[2] = 271;
788 awb_param.wb[3] = 436;
789 awb_param.global_awb_red_gain = 302;
790 awb_param.global_awb_blue_gain = 234;
791 awb_param.p_high = 78;
792 awb_param.temperature_detected = 6410;
793 awb_param.light_source_candidate = 3;
794
795 gamma_param.skip_cnt = 30;
796 gamma_param.gamma_gain = 266;
797 gamma_param.gamma_offset = 39;
798
799 iridix_param.skip_cnt = 90;
800 iridix_param.strength_target = 30681;
801 iridix_param.iridix_contrast = 3986;
802 iridix_param.dark_enh = 1000;
803 iridix_param.iridix_global_DG = 256;
804 iridix_param.diff = 256;
805 iridix_param.iridix_strength = 30681;
806 LOG(LOG_CRIT, "Enter FS_Lin_2Exp Preset");
807 }
808 else
809 {
810 ae_param.skip_cnt = 5;
811 ae_param.exposure_log2 = 2611011;//2011011; TODO?
812 ae_param.integrator = 33165172;
813 ae_param.error_log2 = 0;
814 ae_param.exposure_ratio = 64;
815
816 awb_param.skip_cnt = 15;
817 awb_param.wb_log2[0] = 252071;
818 awb_param.wb_log2[1] = 87;
819 awb_param.wb_log2[2] = 87;
820 awb_param.wb_log2[3] = 180394;
821 awb_param.wb[0] = 527;
822 awb_param.wb[1] = 271;
823 awb_param.wb[2] = 271;
824 awb_param.wb[3] = 436;
825 awb_param.global_awb_red_gain = 270;
826 awb_param.global_awb_blue_gain = 236;
827 awb_param.p_high = 29;
828 awb_param.temperature_detected = 5400;
829 awb_param.light_source_candidate = 3;
830
831 gamma_param.skip_cnt = 30;
832 gamma_param.gamma_gain = 340;
833 gamma_param.gamma_offset = 15;
834
835 iridix_param.skip_cnt = 90;
836 iridix_param.strength_target = 13708;
837 iridix_param.iridix_contrast = 2464;
838 iridix_param.dark_enh = 400;
839 iridix_param.iridix_global_DG = 256;
840 iridix_param.diff = 256;
841 iridix_param.iridix_strength = 13708;
842 LOG(LOG_CRIT, "Enter Linear Binary Preset");
843 }
844
845 #ifdef ACAMERA_PRESET_FREERTOS
846 acamera_alg_preset_t total_param;
847
848 if ( p_fsm_mgr->isp_seamless ) {
849 char *reserve_virt_addr = phys_to_virt(ACAMERA_ALG_PRE_BASE);
850
851 if ( autowrite_fr_start_address_read() )
852 reserve_virt_addr = phys_to_virt(autowrite_fr_start_address_read() + autowrite_fr_writer_memsize_read());
853 else if ( autowrite_ds1_start_address_read() )
854 reserve_virt_addr = phys_to_virt(autowrite_ds1_start_address_read() + autowrite_ds1_writer_memsize_read());
855
856 system_memcpy((void *)&total_param, (void *)reserve_virt_addr, sizeof(total_param));
857 }
858
859 if(total_param.ae_pre_info.skip_cnt == 0xFFFF && total_param.awb_pre_info.skip_cnt == 0xFFFF)
860 {
861 total_param.ae_pre_info.skip_cnt = 5;
862 total_param.awb_pre_info.skip_cnt = 15;
863 total_param.gamma_pre_info.skip_cnt = 30;
864 total_param.iridix_pre_info.skip_cnt = 90;
865
866 system_memcpy(&ae_param, &total_param.ae_pre_info,sizeof(ae_param));
867 system_memcpy(&awb_param, &total_param.awb_pre_info,sizeof(awb_param));
868 system_memcpy(&gamma_param, &total_param.gamma_pre_info,sizeof(gamma_param));
869 system_memcpy(&iridix_param, &total_param.iridix_pre_info,sizeof(iridix_param));
870
871 LOG(LOG_CRIT, "Preset Value ae_param: %d,%d,%d,%d, Gamma:%d,%d",ae_param.skip_cnt,\
872 ae_param.exposure_log2,ae_param.error_log2,ae_param.integrator,gamma_param.gamma_gain,gamma_param.gamma_offset);
873 }
874 else
875 #endif
876 {
877 uint8_t input = 0xff;
878
879 //Configure donot skip sensor initialization with test pattern command.
880 //mode == 0xff would configure to call sending sensor setting.
881 acamera_fsm_mgr_set_param(p_fsm_mgr, FSM_PARAM_SET_SENSOR_TEST_PATTERN, &input, sizeof(input));
882 }
883
884 ctrl_channel_3aalg_param_init(&ae_param,&awb_param,&gamma_param,&iridix_param);
885
886 acamera_fsm_mgr_set_param( p_fsm_mgr, FSM_PARAM_SET_AE_PRESET, &ae_param, sizeof(ae_param) );
887 acamera_fsm_mgr_set_param( p_fsm_mgr, FSM_PARAM_SET_AWB_PRESET, &awb_param, sizeof(awb_param) );
888 acamera_fsm_mgr_set_param( p_fsm_mgr, FSM_PARAM_SET_GAMMA_PRESET, &gamma_param, sizeof(gamma_param) );
889 acamera_fsm_mgr_set_param( p_fsm_mgr, FSM_PARAM_SET_IRIDIX_PRESET, &iridix_param, sizeof(iridix_param) );
890 }
891
acamera_init_context(acamera_context_t * p_ctx,acamera_settings * settings,acamera_firmware_t * g_fw)892 int32_t acamera_init_context( acamera_context_t *p_ctx, acamera_settings *settings, acamera_firmware_t *g_fw )
893 {
894 int32_t result = 0;
895 // keep the context pointer for debug purposes
896 p_ctx->context_ref = (uint32_t *)p_ctx;
897 p_ctx->p_gfw = g_fw;
898 if ( p_ctx->sw_reg_map.isp_sw_config_map != NULL ) {
899 // copy settings
900 system_memcpy( (void *)&p_ctx->settings, (void *)settings, sizeof( acamera_settings ) );
901
902 p_ctx->settings.isp_base = (uintptr_t)p_ctx->sw_reg_map.isp_sw_config_map;
903
904 // each context is initialized to the default state
905 p_ctx->isp_sequence = p_isp_data;
906
907 #if FW_DO_INITIALIZATION
908 if(seamless)
909 {
910 if(acamera_isp_input_port_mode_status_read( 0 ) != ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_START)
911 acamera_load_isp_sequence( 0, p_ctx->isp_sequence, SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS );
912 }
913 else
914 acamera_load_isp_sequence( 0, p_ctx->isp_sequence, SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS );
915 #endif
916
917 #if defined( SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS_CONTEXT )
918 acamera_load_sw_sequence( p_ctx->settings.isp_base, p_ctx->isp_sequence, SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS_CONTEXT );
919 #endif
920
921 #if defined( SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS_FPGA ) && ISP_HAS_FPGA_WRAPPER
922 // these settings are loaded only for ARM FPGA demo platform and must be ignored on other systems
923 acamera_load_isp_sequence( 0, p_ctx->isp_sequence, SENSOR_ISP_SEQUENCE_DEFAULT_SETTINGS_FPGA );
924 #endif
925
926 // reset frame counters
927 p_ctx->isp_frame_counter_raw = 0;
928 p_ctx->isp_frame_counter = 0;
929
930 acamera_fw_init( p_ctx );
931
932 acamera_init_context_seq(p_ctx);
933
934 configure_all_frame_buffers( p_ctx );
935
936 init_stab( p_ctx );
937
938 // the custom initialization may be required for a context
939 if ( p_ctx->settings.custom_initialization != NULL ) {
940 p_ctx->settings.custom_initialization( p_ctx->context_id );
941 }
942
943 //acamera_isp_input_port_mode_request_write( p_ctx->settings.isp_base, ACAMERA_ISP_INPUT_PORT_MODE_REQUEST_SAFE_START );
944
945 p_ctx->initialized = 1;
946
947 } else {
948 result = -1;
949 LOG( LOG_CRIT, "Failed to allocate memory for ISP config context" );
950 }
951
952 acamera_3aalg_preset(&p_ctx->fsm_mgr);
953
954 return result;
955 }
956 #endif
957
acamera_deinit_context(acamera_context_t * p_ctx)958 void acamera_deinit_context( acamera_context_t *p_ctx )
959 {
960 acamera_fw_deinit( p_ctx );
961 }
962
acamera_general_interrupt_hanlder(acamera_context_ptr_t p_ctx,uint8_t event)963 void acamera_general_interrupt_hanlder( acamera_context_ptr_t p_ctx, uint8_t event )
964 {
965 #ifdef CALIBRATION_INTERRUPTS
966 uint32_t *interrupt_counter = _GET_UINT_PTR( p_ctx, CALIBRATION_INTERRUPTS );
967 interrupt_counter[event]++;
968 #endif
969
970
971 p_ctx->irq_flag++;
972
973 if ( event == ACAMERA_IRQ_FRAME_START ) {
974 p_ctx->frame++;
975 }
976
977 if ( event == ACAMERA_IRQ_FRAME_END ) {
978 // Update frame counter
979 p_ctx->isp_frame_counter++;
980 LOG( LOG_DEBUG, "Meta frame counter = %d", (int)p_ctx->isp_frame_counter );
981
982 #if ISP_DMA_RAW_CAPTURE
983 p_ctx->isp_frame_counter_raw++;
984 #endif
985
986 // check frame counter sync when there is raw callback
987 #if ISP_HAS_RAW_CB
988 if ( p_ctx->isp_frame_counter_raw != p_ctx->isp_frame_counter ) {
989 LOG( LOG_DEBUG, "Sync frame counter : raw = %d, meta = %d",
990 (int)p_ctx->isp_frame_counter_raw, (int)p_ctx->isp_frame_counter );
991 p_ctx->isp_frame_counter = p_ctx->isp_frame_counter_raw;
992 }
993 #endif
994
995 acamera_fw_raise_event( p_ctx, event_id_frame_end );
996
997 #if defined( ACAMERA_ISP_PROFILING ) && ( ACAMERA_ISP_PROFILING == 1 )
998 acamera_profiler_new_frame();
999 #endif
1000 }
1001
1002 if ( ( p_ctx->stab.global_freeze_firmware == 0 )
1003 || (event == ACAMERA_IRQ_FRAME_DROP_FR) || (event == ACAMERA_IRQ_FRAME_DROP_DS)
1004 #if defined( ISP_HAS_DMA_WRITER_FSM )
1005 || ( event == ACAMERA_IRQ_FRAME_WRITER_FR ) // process interrupts for frame buffer anyway (otherwise picture will be frozen)
1006 || ( event == ACAMERA_IRQ_FRAME_WRITER_DS ) // process interrupts for frame buffer anyway (otherwise picture will be frozen)
1007 #endif
1008 #if defined( ISP_HAS_CMOS_FSM )
1009 || ( event == ACAMERA_IRQ_FRAME_START ) || ( event == ACAMERA_IRQ_FPGA_FRAME_END ) // process interrupts for FS anyway (otherwise exposure will be only short)
1010 #endif
1011 #if defined( ISP_HAS_BSP_TEST_FSM )
1012 || event == ACAMERA_IRQ_FRAME_END || event == ACAMERA_IRQ_FRAME_START
1013 #endif
1014 ) {
1015 // firmware not frozen
1016 acamera_fsm_mgr_process_interrupt( &p_ctx->fsm_mgr, event );
1017 }
1018
1019 p_ctx->irq_flag--;
1020 }
1021