1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010-2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #include "assert_support.h"
17 #include "gp_device.h"
18 
19 #ifndef __INLINE_GP_DEVICE__
20 #include "gp_device_private.h"
21 #endif /* __INLINE_GP_DEVICE__ */
22 
gp_device_get_state(const gp_device_ID_t ID,gp_device_state_t * state)23 void gp_device_get_state(
24     const gp_device_ID_t		ID,
25     gp_device_state_t			*state)
26 {
27 	assert(ID < N_GP_DEVICE_ID);
28 	assert(state);
29 
30 	state->syncgen_enable = gp_device_reg_load(ID,
31 				_REG_GP_SYNCGEN_ENABLE_ADDR);
32 	state->syncgen_free_running = gp_device_reg_load(ID,
33 				      _REG_GP_SYNCGEN_FREE_RUNNING_ADDR);
34 	state->syncgen_pause = gp_device_reg_load(ID,
35 			       _REG_GP_SYNCGEN_PAUSE_ADDR);
36 	state->nr_frames = gp_device_reg_load(ID,
37 					      _REG_GP_NR_FRAMES_ADDR);
38 	state->syngen_nr_pix = gp_device_reg_load(ID,
39 			       _REG_GP_SYNGEN_NR_PIX_ADDR);
40 	state->syngen_nr_pix = gp_device_reg_load(ID,
41 			       _REG_GP_SYNGEN_NR_PIX_ADDR);
42 	state->syngen_nr_lines = gp_device_reg_load(ID,
43 				 _REG_GP_SYNGEN_NR_LINES_ADDR);
44 	state->syngen_hblank_cycles = gp_device_reg_load(ID,
45 				      _REG_GP_SYNGEN_HBLANK_CYCLES_ADDR);
46 	state->syngen_vblank_cycles = gp_device_reg_load(ID,
47 				      _REG_GP_SYNGEN_VBLANK_CYCLES_ADDR);
48 	state->isel_sof = gp_device_reg_load(ID,
49 					     _REG_GP_ISEL_SOF_ADDR);
50 	state->isel_eof = gp_device_reg_load(ID,
51 					     _REG_GP_ISEL_EOF_ADDR);
52 	state->isel_sol = gp_device_reg_load(ID,
53 					     _REG_GP_ISEL_SOL_ADDR);
54 	state->isel_eol = gp_device_reg_load(ID,
55 					     _REG_GP_ISEL_EOL_ADDR);
56 	state->isel_lfsr_enable = gp_device_reg_load(ID,
57 				  _REG_GP_ISEL_LFSR_ENABLE_ADDR);
58 	state->isel_lfsr_enable_b = gp_device_reg_load(ID,
59 				    _REG_GP_ISEL_LFSR_ENABLE_B_ADDR);
60 	state->isel_lfsr_reset_value = gp_device_reg_load(ID,
61 				       _REG_GP_ISEL_LFSR_RESET_VALUE_ADDR);
62 	state->isel_tpg_enable = gp_device_reg_load(ID,
63 				 _REG_GP_ISEL_TPG_ENABLE_ADDR);
64 	state->isel_tpg_enable_b = gp_device_reg_load(ID,
65 				   _REG_GP_ISEL_TPG_ENABLE_B_ADDR);
66 	state->isel_hor_cnt_mask = gp_device_reg_load(ID,
67 				   _REG_GP_ISEL_HOR_CNT_MASK_ADDR);
68 	state->isel_ver_cnt_mask = gp_device_reg_load(ID,
69 				   _REG_GP_ISEL_VER_CNT_MASK_ADDR);
70 	state->isel_xy_cnt_mask = gp_device_reg_load(ID,
71 				  _REG_GP_ISEL_XY_CNT_MASK_ADDR);
72 	state->isel_hor_cnt_delta = gp_device_reg_load(ID,
73 				    _REG_GP_ISEL_HOR_CNT_DELTA_ADDR);
74 	state->isel_ver_cnt_delta = gp_device_reg_load(ID,
75 				    _REG_GP_ISEL_VER_CNT_DELTA_ADDR);
76 	state->isel_tpg_mode = gp_device_reg_load(ID,
77 			       _REG_GP_ISEL_TPG_MODE_ADDR);
78 	state->isel_tpg_red1 = gp_device_reg_load(ID,
79 			       _REG_GP_ISEL_TPG_RED1_ADDR);
80 	state->isel_tpg_green1 = gp_device_reg_load(ID,
81 				 _REG_GP_ISEL_TPG_GREEN1_ADDR);
82 	state->isel_tpg_blue1 = gp_device_reg_load(ID,
83 				_REG_GP_ISEL_TPG_BLUE1_ADDR);
84 	state->isel_tpg_red2 = gp_device_reg_load(ID,
85 			       _REG_GP_ISEL_TPG_RED2_ADDR);
86 	state->isel_tpg_green2 = gp_device_reg_load(ID,
87 				 _REG_GP_ISEL_TPG_GREEN2_ADDR);
88 	state->isel_tpg_blue2 = gp_device_reg_load(ID,
89 				_REG_GP_ISEL_TPG_BLUE2_ADDR);
90 	state->isel_ch_id = gp_device_reg_load(ID,
91 					       _REG_GP_ISEL_CH_ID_ADDR);
92 	state->isel_fmt_type = gp_device_reg_load(ID,
93 			       _REG_GP_ISEL_FMT_TYPE_ADDR);
94 	state->isel_data_sel = gp_device_reg_load(ID,
95 			       _REG_GP_ISEL_DATA_SEL_ADDR);
96 	state->isel_sband_sel = gp_device_reg_load(ID,
97 				_REG_GP_ISEL_SBAND_SEL_ADDR);
98 	state->isel_sync_sel = gp_device_reg_load(ID,
99 			       _REG_GP_ISEL_SYNC_SEL_ADDR);
100 	state->syncgen_hor_cnt = gp_device_reg_load(ID,
101 				 _REG_GP_SYNCGEN_HOR_CNT_ADDR);
102 	state->syncgen_ver_cnt = gp_device_reg_load(ID,
103 				 _REG_GP_SYNCGEN_VER_CNT_ADDR);
104 	state->syncgen_frame_cnt = gp_device_reg_load(ID,
105 				   _REG_GP_SYNCGEN_FRAME_CNT_ADDR);
106 	state->soft_reset = gp_device_reg_load(ID,
107 					       _REG_GP_SOFT_RESET_ADDR);
108 	return;
109 }
110