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 "autocapture_fsm.h"
22
23 #ifdef LOG_MODULE
24 #undef LOG_MODULE
25 #define LOG_MODULE LOG_MODULE_AUTOCAPTURE
26 #endif
27
autocapture_fsm_clear(autocapture_fsm_t * p_fsm)28 void autocapture_fsm_clear( autocapture_fsm_t *p_fsm )
29 {
30
31 }
32
autocapture_fsm_init(void * fsm,fsm_init_param_t * init_param)33 void autocapture_fsm_init( void *fsm, fsm_init_param_t *init_param )
34 {
35 autocapture_fsm_t *p_fsm = (autocapture_fsm_t *)fsm;
36 p_fsm->cmn.p_fsm_mgr = init_param->p_fsm_mgr;
37 p_fsm->cmn.isp_base = init_param->isp_base;
38 p_fsm->p_fsm_mgr = init_param->p_fsm_mgr;
39
40 autocapture_fsm_clear( p_fsm );
41
42 autocapture_initialize( p_fsm );
43 }
44
45
autocapture_fsm_set_param(void * fsm,uint32_t param_id,void * input,uint32_t input_size)46 int autocapture_fsm_set_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size )
47 {
48 int rc = 0;
49
50 //autocapture_fsm_t *p_fsm = (autocapture_fsm_t *)fsm;
51 switch ( param_id ) {
52 case FSM_PARAM_SET_AUTOCAP_FR_ADDR:
53 case FSM_PARAM_SET_AUTOCAP_DS1_ADDR:{
54 if ( !input || input_size != sizeof( fsm_param_dma_pipe_setting_t ) ) {
55 LOG( LOG_ERR, "Invalid param, param_id: %d.", param_id );
56 rc = -1;
57 break;
58 }
59
60 fsm_param_dma_pipe_setting_t *p_new = (fsm_param_dma_pipe_setting_t *)input;
61 struct module_cfg_info m_cfg;
62
63 if(param_id == FSM_PARAM_SET_AUTOCAP_FR_ADDR)
64 m_cfg.p_type = dma_fr;
65 else
66 m_cfg.p_type = dma_ds1;
67
68 m_cfg.frame_buffer_start0 = p_new->buf_array->primary.address;
69 m_cfg.frame_size0 = p_new->buf_array->primary.size;
70 m_cfg.frame_buffer_start1 = p_new->buf_array->secondary.address;
71 m_cfg.frame_size1 = p_new->buf_array->secondary.size;
72
73 autocap_set_new_param(&m_cfg);
74
75 break;
76 }
77 case FSM_PARAM_SET_AUTOCAP_HW_RESET:
78 {
79 autocapture_hwreset((autocapture_fsm_t *)fsm);
80 break;
81 }
82 default:
83 rc = -1;
84 break;
85 }
86 return rc;
87 }
88
autocapture_fsm_process_event(autocapture_fsm_t * p_fsm,event_id_t event_id)89 uint8_t autocapture_fsm_process_event( autocapture_fsm_t *p_fsm, event_id_t event_id )
90 {
91 uint8_t b_event_processed = 0;
92
93 return b_event_processed;
94 }
95