• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sensor_fsm.h"
22 
23 
24 #ifdef LOG_MODULE
25 #undef LOG_MODULE
26 #define LOG_MODULE LOG_MODULE_SENSOR
27 #endif
28 
29 /* Use static memory here to make it cross-platform */
30 static sensor_fsm_t sensor_fsm_ctxs[FIRMWARE_CONTEXT_NUMBER];
31 
sensor_get_fsm_common(uint8_t ctx_id)32 fsm_common_t *sensor_get_fsm_common( uint8_t ctx_id )
33 {
34     sensor_fsm_t *p_fsm_ctx = NULL;
35 
36     if ( ctx_id >= FIRMWARE_CONTEXT_NUMBER ) {
37         LOG( LOG_CRIT, "Invalid ctx_id: %d, greater than max: %d.", ctx_id, FIRMWARE_CONTEXT_NUMBER - 1 );
38         return NULL;
39     }
40 
41     p_fsm_ctx = &sensor_fsm_ctxs[ctx_id];
42 
43     p_fsm_ctx->cmn.ctx_id = ctx_id;
44     p_fsm_ctx->cmn.p_fsm = (void *)p_fsm_ctx;
45 
46     p_fsm_ctx->cmn.ops.init = sensor_fsm_init;
47     p_fsm_ctx->cmn.ops.deinit = (FUN_PTR_DEINIT)sensor_deinit;
48     p_fsm_ctx->cmn.ops.run = NULL;
49     p_fsm_ctx->cmn.ops.get_param = sensor_fsm_get_param;
50     p_fsm_ctx->cmn.ops.set_param = sensor_fsm_set_param;
51     p_fsm_ctx->cmn.ops.proc_event = (FUN_PTR_PROC_EVENT)sensor_fsm_process_event;
52     p_fsm_ctx->cmn.ops.proc_interrupt = (FUN_PTR_PROC_INT)NULL;
53 
54     return &( p_fsm_ctx->cmn );
55 }
56