GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_common / input_formatter_global.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
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.
8  *
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
12  * more details.
13  */
14
15 #ifndef __INPUT_FORMATTER_GLOBAL_H_INCLUDED__
16 #define __INPUT_FORMATTER_GLOBAL_H_INCLUDED__
17
18 #define IS_INPUT_FORMATTER_VERSION2
19 #define IS_INPUT_SWITCH_VERSION2
20
21 #include <type_support.h>
22 #include <system_types.h>
23 #include "if_defs.h"
24 #include "str2mem_defs.h"
25 #include "input_switch_2400_defs.h"
26
27 #define _HIVE_INPUT_SWITCH_GET_FSYNC_REG_LSB(ch_id)        ((ch_id) * 3)
28
29 #define HIVE_SWITCH_N_CHANNELS                          4
30 #define HIVE_SWITCH_N_FORMATTYPES                       32
31 #define HIVE_SWITCH_N_SWITCH_CODE                       4
32 #define HIVE_SWITCH_M_CHANNELS                          0x00000003
33 #define HIVE_SWITCH_M_FORMATTYPES                       0x0000001f
34 #define HIVE_SWITCH_M_SWITCH_CODE                       0x00000003
35 #define HIVE_SWITCH_M_FSYNC                                     0x00000007
36
37 #define HIVE_SWITCH_ENCODE_FSYNC(x) \
38         (1U<<(((x)-1)&HIVE_SWITCH_M_CHANNELS))
39
40 #define _HIVE_INPUT_SWITCH_GET_LUT_FIELD(reg, bit_index) \
41         (((reg) >> (bit_index)) & HIVE_SWITCH_M_SWITCH_CODE)
42 #define _HIVE_INPUT_SWITCH_SET_LUT_FIELD(reg, bit_index, val) \
43         (((reg) & ~(HIVE_SWITCH_M_SWITCH_CODE<<(bit_index))) | (((hrt_data)(val)&HIVE_SWITCH_M_SWITCH_CODE)<<(bit_index)))
44 #define _HIVE_INPUT_SWITCH_GET_FSYNC_FIELD(reg, bit_index) \
45         (((reg) >> (bit_index)) & HIVE_SWITCH_M_FSYNC)
46 #define _HIVE_INPUT_SWITCH_SET_FSYNC_FIELD(reg, bit_index, val) \
47         (((reg) & ~(HIVE_SWITCH_M_FSYNC<<(bit_index))) | (((hrt_data)(val)&HIVE_SWITCH_M_FSYNC)<<(bit_index)))
48
49 typedef struct input_formatter_cfg_s    input_formatter_cfg_t;
50
51 /* Hardware registers */
52 /*#define HIVE_IF_RESET_ADDRESS                   0x000*/ /* deprecated */
53 #define HIVE_IF_START_LINE_ADDRESS              0x004
54 #define HIVE_IF_START_COLUMN_ADDRESS            0x008
55 #define HIVE_IF_CROPPED_HEIGHT_ADDRESS          0x00C
56 #define HIVE_IF_CROPPED_WIDTH_ADDRESS           0x010
57 #define HIVE_IF_VERTICAL_DECIMATION_ADDRESS     0x014
58 #define HIVE_IF_HORIZONTAL_DECIMATION_ADDRESS   0x018
59 #define HIVE_IF_H_DEINTERLEAVING_ADDRESS        0x01C
60 #define HIVE_IF_LEFTPADDING_WIDTH_ADDRESS       0x020
61 #define HIVE_IF_END_OF_LINE_OFFSET_ADDRESS      0x024
62 #define HIVE_IF_VMEM_START_ADDRESS_ADDRESS      0x028
63 #define HIVE_IF_VMEM_END_ADDRESS_ADDRESS        0x02C
64 #define HIVE_IF_VMEM_INCREMENT_ADDRESS          0x030
65 #define HIVE_IF_YUV_420_FORMAT_ADDRESS          0x034
66 #define HIVE_IF_VSYNCK_ACTIVE_LOW_ADDRESS       0x038
67 #define HIVE_IF_HSYNCK_ACTIVE_LOW_ADDRESS       0x03C
68 #define HIVE_IF_ALLOW_FIFO_OVERFLOW_ADDRESS     0x040
69 #define HIVE_IF_BLOCK_FIFO_NO_REQ_ADDRESS       0x044
70 #define HIVE_IF_V_DEINTERLEAVING_ADDRESS        0x048
71 #define HIVE_IF_FSM_CROP_PIXEL_COUNTER          0x110
72 #define HIVE_IF_FSM_CROP_LINE_COUNTER           0x10C
73 #define HIVE_IF_FSM_CROP_STATUS                 0x108
74
75 /* Registers only for simulation */
76 #define HIVE_IF_CRUN_MODE_ADDRESS               0x04C
77 #define HIVE_IF_DUMP_OUTPUT_ADDRESS             0x050
78
79 /* Follow the DMA syntax, "cmd" last */
80 #define IF_PACK(val, cmd)             ((val & 0x0fff) | (cmd /*& 0xf000*/))
81
82 #define HIVE_STR2MEM_SOFT_RESET_REG_ADDRESS                   (_STR2MEM_SOFT_RESET_REG_ID * _STR2MEM_REG_ALIGN)
83 #define HIVE_STR2MEM_INPUT_ENDIANNESS_REG_ADDRESS             (_STR2MEM_INPUT_ENDIANNESS_REG_ID * _STR2MEM_REG_ALIGN)
84 #define HIVE_STR2MEM_OUTPUT_ENDIANNESS_REG_ADDRESS            (_STR2MEM_OUTPUT_ENDIANNESS_REG_ID * _STR2MEM_REG_ALIGN)
85 #define HIVE_STR2MEM_BIT_SWAPPING_REG_ADDRESS                 (_STR2MEM_BIT_SWAPPING_REG_ID * _STR2MEM_REG_ALIGN)
86 #define HIVE_STR2MEM_BLOCK_SYNC_LEVEL_REG_ADDRESS             (_STR2MEM_BLOCK_SYNC_LEVEL_REG_ID * _STR2MEM_REG_ALIGN)
87 #define HIVE_STR2MEM_PACKET_SYNC_LEVEL_REG_ADDRESS            (_STR2MEM_PACKET_SYNC_LEVEL_REG_ID * _STR2MEM_REG_ALIGN)
88 #define HIVE_STR2MEM_READ_POST_WRITE_SYNC_ENABLE_REG_ADDRESS  (_STR2MEM_READ_POST_WRITE_SYNC_ENABLE_REG_ID * _STR2MEM_REG_ALIGN)
89 #define HIVE_STR2MEM_DUAL_BYTE_INPUTS_ENABLED_REG_ADDRESS     (_STR2MEM_DUAL_BYTE_INPUTS_ENABLED_REG_ID * _STR2MEM_REG_ALIGN)
90 #define HIVE_STR2MEM_EN_STAT_UPDATE_ADDRESS                   (_STR2MEM_EN_STAT_UPDATE_ID * _STR2MEM_REG_ALIGN)
91
92 /*
93  * This data structure is shared between host and SP
94  */
95 struct input_formatter_cfg_s {
96         uint32_t        start_line;
97         uint32_t        start_column;
98         uint32_t        left_padding;
99         uint32_t        cropped_height;
100         uint32_t        cropped_width;
101         uint32_t        deinterleaving;
102         uint32_t        buf_vecs;
103         uint32_t        buf_start_index;
104         uint32_t        buf_increment;
105         uint32_t        buf_eol_offset;
106         uint32_t        is_yuv420_format;
107         uint32_t        block_no_reqs;
108 };
109
110 #define DEFAULT_IF_CONFIG \
111 { \
112         0,          /* start_line */\
113         0,          /* start_column */\
114         0,          /* left_padding */\
115         0,          /* cropped_height */\
116         0,          /* cropped_width */\
117         0,          /* deinterleaving */\
118         0,          /*.buf_vecs */\
119         0,          /* buf_start_index */\
120         0,          /* buf_increment */\
121         0,          /* buf_eol_offset */\
122         false,      /* is_yuv420_format */\
123         false       /* block_no_reqs */\
124 }
125
126 extern const hrt_address HIVE_IF_SRST_ADDRESS[N_INPUT_FORMATTER_ID];
127 extern const hrt_data HIVE_IF_SRST_MASK[N_INPUT_FORMATTER_ID];
128 extern const uint8_t HIVE_IF_SWITCH_CODE[N_INPUT_FORMATTER_ID];
129
130 #endif /* __INPUT_FORMATTER_GLOBAL_H_INCLUDED__ */