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 "color_matrix_fsm.h"
22
23 #ifdef LOG_MODULE
24 #undef LOG_MODULE
25 #define LOG_MODULE LOG_MODULE_COLOR_MATRIX
26 #endif
27
28 /* Use static memory here to make it cross-platform */
29 static color_matrix_fsm_t color_matrix_fsm_ctxs[FIRMWARE_CONTEXT_NUMBER];
30
color_matrix_get_fsm_common(uint8_t ctx_id)31 fsm_common_t *color_matrix_get_fsm_common( uint8_t ctx_id )
32 {
33 color_matrix_fsm_t *p_fsm_ctx = NULL;
34
35 if ( ctx_id >= FIRMWARE_CONTEXT_NUMBER ) {
36 LOG( LOG_CRIT, "Invalid ctx_id: %d, greater than max: %d.", ctx_id, FIRMWARE_CONTEXT_NUMBER - 1 );
37 return NULL;
38 }
39
40 p_fsm_ctx = &color_matrix_fsm_ctxs[ctx_id];
41
42 p_fsm_ctx->cmn.ctx_id = ctx_id;
43 p_fsm_ctx->cmn.p_fsm = (void *)p_fsm_ctx;
44
45 p_fsm_ctx->cmn.ops.init = color_matrix_fsm_init;
46 p_fsm_ctx->cmn.ops.deinit = NULL;
47 p_fsm_ctx->cmn.ops.run = NULL;
48 p_fsm_ctx->cmn.ops.get_param = color_matrix_fsm_get_param;
49 p_fsm_ctx->cmn.ops.set_param = color_matrix_fsm_set_param;
50 p_fsm_ctx->cmn.ops.proc_event = (FUN_PTR_PROC_EVENT)color_matrix_fsm_process_event;
51 p_fsm_ctx->cmn.ops.proc_interrupt = NULL;
52
53 return &( p_fsm_ctx->cmn );
54 }
55