2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2010-2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include "system_global.h"
17 #ifdef USE_INPUT_SYSTEM_VERSION_2
19 #include "input_formatter.h"
20 #include <type_support.h>
21 #include "gp_device.h"
23 #include "assert_support.h"
25 #ifndef __INLINE_INPUT_FORMATTER__
26 #include "input_formatter_private.h"
27 #endif /* __INLINE_INPUT_FORMATTER__ */
29 const hrt_address HIVE_IF_SRST_ADDRESS[N_INPUT_FORMATTER_ID] = {
30 INPUT_FORMATTER0_SRST_OFFSET,
31 INPUT_FORMATTER1_SRST_OFFSET,
32 INPUT_FORMATTER2_SRST_OFFSET,
33 INPUT_FORMATTER3_SRST_OFFSET};
35 const hrt_data HIVE_IF_SRST_MASK[N_INPUT_FORMATTER_ID] = {
36 INPUT_FORMATTER0_SRST_MASK,
37 INPUT_FORMATTER1_SRST_MASK,
38 INPUT_FORMATTER2_SRST_MASK,
39 INPUT_FORMATTER3_SRST_MASK};
41 const uint8_t HIVE_IF_SWITCH_CODE[N_INPUT_FORMATTER_ID] = {
42 HIVE_INPUT_SWITCH_SELECT_IF_PRIM,
43 HIVE_INPUT_SWITCH_SELECT_IF_PRIM,
44 HIVE_INPUT_SWITCH_SELECT_IF_SEC,
45 HIVE_INPUT_SWITCH_SELECT_STR_TO_MEM};
47 /* MW Should be part of system_global.h, where we have the main enumeration */
48 const bool HIVE_IF_BIN_COPY[N_INPUT_FORMATTER_ID] = {
49 false, false, false, true};
51 void input_formatter_rst(
52 const input_formatter_ID_t ID)
57 assert(ID < N_INPUT_FORMATTER_ID);
59 addr = HIVE_IF_SRST_ADDRESS[ID];
60 rst = HIVE_IF_SRST_MASK[ID];
62 /* TEMPORARY HACK: THIS RESET BREAKS THE METADATA FEATURE
63 * WICH USES THE STREAM2MEMRY BLOCK.
64 * MUST BE FIXED PROPERLY
66 if (!HIVE_IF_BIN_COPY[ID]) {
67 input_formatter_reg_store(ID, addr, rst);
73 unsigned int input_formatter_get_alignment(
74 const input_formatter_ID_t ID)
76 assert(ID < N_INPUT_FORMATTER_ID);
78 return input_formatter_alignment[ID];
81 void input_formatter_set_fifo_blocking_mode(
82 const input_formatter_ID_t ID,
85 assert(ID < N_INPUT_FORMATTER_ID);
87 /* cnd_input_formatter_reg_store() */
88 if (!HIVE_IF_BIN_COPY[ID]) {
89 input_formatter_reg_store(ID,
90 HIVE_IF_BLOCK_FIFO_NO_REQ_ADDRESS, enable);
95 void input_formatter_get_switch_state(
96 const input_formatter_ID_t ID,
97 input_formatter_switch_state_t *state)
99 assert(ID < N_INPUT_FORMATTER_ID);
100 assert(state != NULL);
102 /* We'll change this into an intelligent function to get switch info per IF */
105 state->if_input_switch_lut_reg[0] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg0);
106 state->if_input_switch_lut_reg[1] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg1);
107 state->if_input_switch_lut_reg[2] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg2);
108 state->if_input_switch_lut_reg[3] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg3);
109 state->if_input_switch_lut_reg[4] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg4);
110 state->if_input_switch_lut_reg[5] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg5);
111 state->if_input_switch_lut_reg[6] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg6);
112 state->if_input_switch_lut_reg[7] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg7);
113 state->if_input_switch_fsync_lut = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_fsync_lut);
114 state->if_input_switch_ch_id_fmt_type = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_ch_id_fmt_type);
119 void input_formatter_get_state(
120 const input_formatter_ID_t ID,
121 input_formatter_state_t *state)
123 assert(ID < N_INPUT_FORMATTER_ID);
124 assert(state != NULL);
126 state->reset = input_formatter_reg_load(ID,
127 HIVE_IF_RESET_ADDRESS);
129 state->start_line = input_formatter_reg_load(ID,
130 HIVE_IF_START_LINE_ADDRESS);
131 state->start_column = input_formatter_reg_load(ID,
132 HIVE_IF_START_COLUMN_ADDRESS);
133 state->cropped_height = input_formatter_reg_load(ID,
134 HIVE_IF_CROPPED_HEIGHT_ADDRESS);
135 state->cropped_width = input_formatter_reg_load(ID,
136 HIVE_IF_CROPPED_WIDTH_ADDRESS);
137 state->ver_decimation = input_formatter_reg_load(ID,
138 HIVE_IF_VERTICAL_DECIMATION_ADDRESS);
139 state->hor_decimation = input_formatter_reg_load(ID,
140 HIVE_IF_HORIZONTAL_DECIMATION_ADDRESS);
141 state->hor_deinterleaving = input_formatter_reg_load(ID,
142 HIVE_IF_H_DEINTERLEAVING_ADDRESS);
143 state->left_padding = input_formatter_reg_load(ID,
144 HIVE_IF_LEFTPADDING_WIDTH_ADDRESS);
145 state->eol_offset = input_formatter_reg_load(ID,
146 HIVE_IF_END_OF_LINE_OFFSET_ADDRESS);
147 state->vmem_start_address = input_formatter_reg_load(ID,
148 HIVE_IF_VMEM_START_ADDRESS_ADDRESS);
149 state->vmem_end_address = input_formatter_reg_load(ID,
150 HIVE_IF_VMEM_END_ADDRESS_ADDRESS);
151 state->vmem_increment = input_formatter_reg_load(ID,
152 HIVE_IF_VMEM_INCREMENT_ADDRESS);
153 state->is_yuv420 = input_formatter_reg_load(ID,
154 HIVE_IF_YUV_420_FORMAT_ADDRESS);
155 state->vsync_active_low = input_formatter_reg_load(ID,
156 HIVE_IF_VSYNCK_ACTIVE_LOW_ADDRESS);
157 state->hsync_active_low = input_formatter_reg_load(ID,
158 HIVE_IF_HSYNCK_ACTIVE_LOW_ADDRESS);
159 state->allow_fifo_overflow = input_formatter_reg_load(ID,
160 HIVE_IF_ALLOW_FIFO_OVERFLOW_ADDRESS);
161 state->block_fifo_when_no_req = input_formatter_reg_load(ID,
162 HIVE_IF_BLOCK_FIFO_NO_REQ_ADDRESS);
163 state->ver_deinterleaving = input_formatter_reg_load(ID,
164 HIVE_IF_V_DEINTERLEAVING_ADDRESS);
166 state->fsm_sync_status = input_formatter_reg_load(ID,
167 HIVE_IF_FSM_SYNC_STATUS);
168 state->fsm_sync_counter = input_formatter_reg_load(ID,
169 HIVE_IF_FSM_SYNC_COUNTER);
170 state->fsm_crop_status = input_formatter_reg_load(ID,
171 HIVE_IF_FSM_CROP_STATUS);
172 state->fsm_crop_line_counter = input_formatter_reg_load(ID,
173 HIVE_IF_FSM_CROP_LINE_COUNTER);
174 state->fsm_crop_pixel_counter = input_formatter_reg_load(ID,
175 HIVE_IF_FSM_CROP_PIXEL_COUNTER);
176 state->fsm_deinterleaving_index = input_formatter_reg_load(ID,
177 HIVE_IF_FSM_DEINTERLEAVING_IDX);
178 state->fsm_dec_h_counter = input_formatter_reg_load(ID,
179 HIVE_IF_FSM_DECIMATION_H_COUNTER);
180 state->fsm_dec_v_counter = input_formatter_reg_load(ID,
181 HIVE_IF_FSM_DECIMATION_V_COUNTER);
182 state->fsm_dec_block_v_counter = input_formatter_reg_load(ID,
183 HIVE_IF_FSM_DECIMATION_BLOCK_V_COUNTER);
184 state->fsm_padding_status = input_formatter_reg_load(ID,
185 HIVE_IF_FSM_PADDING_STATUS);
186 state->fsm_padding_elem_counter = input_formatter_reg_load(ID,
187 HIVE_IF_FSM_PADDING_ELEMENT_COUNTER);
188 state->fsm_vector_support_error = input_formatter_reg_load(ID,
189 HIVE_IF_FSM_VECTOR_SUPPORT_ERROR);
190 state->fsm_vector_buffer_full = input_formatter_reg_load(ID,
191 HIVE_IF_FSM_VECTOR_SUPPORT_BUFF_FULL);
192 state->vector_support = input_formatter_reg_load(ID,
193 HIVE_IF_FSM_VECTOR_SUPPORT);
194 state->sensor_data_lost = input_formatter_reg_load(ID,
195 HIVE_IF_FIFO_SENSOR_STATUS);
200 void input_formatter_bin_get_state(
201 const input_formatter_ID_t ID,
202 input_formatter_bin_state_t *state)
204 assert(ID < N_INPUT_FORMATTER_ID);
205 assert(state != NULL);
207 state->reset = input_formatter_reg_load(ID,
208 HIVE_STR2MEM_SOFT_RESET_REG_ADDRESS);
209 state->input_endianness = input_formatter_reg_load(ID,
210 HIVE_STR2MEM_INPUT_ENDIANNESS_REG_ADDRESS);
211 state->output_endianness = input_formatter_reg_load(ID,
212 HIVE_STR2MEM_OUTPUT_ENDIANNESS_REG_ADDRESS);
213 state->bitswap = input_formatter_reg_load(ID,
214 HIVE_STR2MEM_BIT_SWAPPING_REG_ADDRESS);
215 state->block_synch = input_formatter_reg_load(ID,
216 HIVE_STR2MEM_BLOCK_SYNC_LEVEL_REG_ADDRESS);
217 state->packet_synch = input_formatter_reg_load(ID,
218 HIVE_STR2MEM_PACKET_SYNC_LEVEL_REG_ADDRESS);
219 state->readpostwrite_synch = input_formatter_reg_load(ID,
220 HIVE_STR2MEM_READ_POST_WRITE_SYNC_ENABLE_REG_ADDRESS);
221 state->is_2ppc = input_formatter_reg_load(ID,
222 HIVE_STR2MEM_DUAL_BYTE_INPUTS_ENABLED_REG_ADDRESS);
223 state->en_status_update = input_formatter_reg_load(ID,
224 HIVE_STR2MEM_EN_STAT_UPDATE_ADDRESS);