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 #ifndef __INPUT_FORMATTER_LOCAL_H_INCLUDED__
17 #define __INPUT_FORMATTER_LOCAL_H_INCLUDED__
18 
19 #include "input_formatter_global.h"
20 
21 #include "isp.h"		/* ISP_VEC_ALIGN */
22 
23 typedef struct input_formatter_switch_state_s	input_formatter_switch_state_t;
24 typedef struct input_formatter_state_s			input_formatter_state_t;
25 typedef struct input_formatter_bin_state_s		input_formatter_bin_state_t;
26 
27 #define HIVE_IF_FSM_SYNC_STATUS                 0x100
28 #define HIVE_IF_FSM_SYNC_COUNTER                0x104
29 #define HIVE_IF_FSM_DEINTERLEAVING_IDX          0x114
30 #define HIVE_IF_FSM_DECIMATION_H_COUNTER        0x118
31 #define HIVE_IF_FSM_DECIMATION_V_COUNTER        0x11C
32 #define HIVE_IF_FSM_DECIMATION_BLOCK_V_COUNTER  0x120
33 #define HIVE_IF_FSM_PADDING_STATUS              0x124
34 #define HIVE_IF_FSM_PADDING_ELEMENT_COUNTER     0x128
35 #define HIVE_IF_FSM_VECTOR_SUPPORT_ERROR        0x12C
36 #define HIVE_IF_FSM_VECTOR_SUPPORT_BUFF_FULL    0x130
37 #define HIVE_IF_FSM_VECTOR_SUPPORT              0x134
38 #define HIVE_IF_FIFO_SENSOR_STATUS              0x138
39 
40 /*
41  * The switch LUT's coding defines a sink for each
42  * single channel ID + channel format type. Conversely
43  * the sink (i.e. an input formatter) can be reached
44  * from multiple channel & format type combinations
45  *
46  * LUT[0,1] channel=0, format type {0,1,...31}
47  * LUT[2,3] channel=1, format type {0,1,...31}
48  * LUT[4,5] channel=2, format type {0,1,...31}
49  * LUT[6,7] channel=3, format type {0,1,...31}
50  *
51  * Each register hold 16 2-bit fields encoding the sink
52  * {0,1,2,3}, "0" means unconnected.
53  *
54  * The single FSYNCH register uses four 3-bit fields of 1-hot
55  * encoded sink information, "0" means unconnected.
56  *
57  * The encoding is redundant. The FSYNCH setting will connect
58  * a channel to a sink. At that point the LUT's belonging to
59  * that channel can be directed to another sink. Thus the data
60  * goes to another place than the synch
61  */
62 struct input_formatter_switch_state_s {
63 	int	if_input_switch_lut_reg[8];
64 	int	if_input_switch_fsync_lut;
65 	int	if_input_switch_ch_id_fmt_type;
66 	bool if_input_switch_map[HIVE_SWITCH_N_CHANNELS][HIVE_SWITCH_N_FORMATTYPES];
67 };
68 
69 struct input_formatter_state_s {
70 	/*	int	reset; */
71 	int	start_line;
72 	int	start_column;
73 	int	cropped_height;
74 	int	cropped_width;
75 	int	ver_decimation;
76 	int	hor_decimation;
77 	int	ver_deinterleaving;
78 	int	hor_deinterleaving;
79 	int	left_padding;
80 	int	eol_offset;
81 	int	vmem_start_address;
82 	int	vmem_end_address;
83 	int	vmem_increment;
84 	int	is_yuv420;
85 	int	vsync_active_low;
86 	int	hsync_active_low;
87 	int	allow_fifo_overflow;
88 	int block_fifo_when_no_req;
89 	int	fsm_sync_status;
90 	int	fsm_sync_counter;
91 	int	fsm_crop_status;
92 	int	fsm_crop_line_counter;
93 	int	fsm_crop_pixel_counter;
94 	int	fsm_deinterleaving_index;
95 	int	fsm_dec_h_counter;
96 	int	fsm_dec_v_counter;
97 	int	fsm_dec_block_v_counter;
98 	int	fsm_padding_status;
99 	int	fsm_padding_elem_counter;
100 	int	fsm_vector_support_error;
101 	int	fsm_vector_buffer_full;
102 	int	vector_support;
103 	int	sensor_data_lost;
104 };
105 
106 struct input_formatter_bin_state_s {
107 	u32	reset;
108 	u32	input_endianness;
109 	u32	output_endianness;
110 	u32	bitswap;
111 	u32	block_synch;
112 	u32	packet_synch;
113 	u32	readpostwrite_synch;
114 	u32	is_2ppc;
115 	u32	en_status_update;
116 };
117 
118 static const unsigned int input_formatter_alignment[N_INPUT_FORMATTER_ID] = {
119 	ISP_VEC_ALIGN, ISP_VEC_ALIGN, HIVE_ISP_CTRL_DATA_BYTES
120 };
121 
122 #endif /* __INPUT_FORMATTER_LOCAL_H_INCLUDED__ */
123