1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 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 _css_receiver_2400_common_defs_h_
17 #define _css_receiver_2400_common_defs_h_
18 #ifndef _mipi_backend_common_defs_h_
19 #define _mipi_backend_common_defs_h_
20 
21 #define _HRT_CSS_RECEIVER_2400_GEN_SHORT_DATA_WIDTH     16
22 #define _HRT_CSS_RECEIVER_2400_GEN_SHORT_CH_ID_WIDTH     2
23 #define _HRT_CSS_RECEIVER_2400_GEN_SHORT_FMT_TYPE_WIDTH  3
24 #define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_REAL_WIDTH (_HRT_CSS_RECEIVER_2400_GEN_SHORT_DATA_WIDTH + _HRT_CSS_RECEIVER_2400_GEN_SHORT_CH_ID_WIDTH + _HRT_CSS_RECEIVER_2400_GEN_SHORT_FMT_TYPE_WIDTH)
25 #define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_WIDTH      32 /* use 32 to be compatibel with streaming monitor !, MSB's of interface are tied to '0' */
26 
27 /* Definition of data format ID at the interface CSS_receiver capture/acquisition units */
28 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8          24   /* 01 1000 YUV420 8-bit                                        */
29 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_10         25   /* 01 1001  YUV420 10-bit                                      */
30 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8L         26   /* 01 1010   YUV420 8-bit legacy                               */
31 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV422_8          30   /* 01 1110   YUV422 8-bit                                      */
32 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV422_10         31   /* 01 1111   YUV422 10-bit                                     */
33 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB444            32   /* 10 0000   RGB444                                            */
34 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB555            33   /* 10 0001   RGB555                                            */
35 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB565            34   /* 10 0010   RGB565                                            */
36 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB666            35   /* 10 0011   RGB666                                            */
37 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB888            36   /* 10 0100   RGB888                                            */
38 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW6              40   /* 10 1000   RAW6                                              */
39 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW7              41   /* 10 1001   RAW7                                              */
40 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW8              42   /* 10 1010   RAW8                                              */
41 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW10             43   /* 10 1011   RAW10                                             */
42 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW12             44   /* 10 1100   RAW12                                             */
43 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW14             45   /* 10 1101   RAW14                                             */
44 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_1         48   /* 11 0000    JPEG [User Defined 8-bit Data Type 1]            */
45 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_2         49   /* 11 0001    User Defined 8-bit Data Type 2                   */
46 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_3         50   /* 11 0010    User Defined 8-bit Data Type 3                   */
47 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_4         51   /* 11 0011    User Defined 8-bit Data Type 4                   */
48 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_5         52   /* 11 0100    User Defined 8-bit Data Type 5                   */
49 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_6         53   /* 11 0101    User Defined 8-bit Data Type 6                   */
50 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_7         54   /* 11 0110    User Defined 8-bit Data Type 7                   */
51 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_8         55   /* 11 0111    User Defined 8-bit Data Type 8                   */
52 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_Emb               18   /* 01 0010    embedded eight bit non image data                */
53 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_SOF                0   /* 00 0000    frame start                                      */
54 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_EOF                1   /* 00 0001    frame end                                        */
55 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_SOL                2   /* 00 0010    line start                                       */
56 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_EOL                3   /* 00 0011    line end                                         */
57 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH1            8   /* 00 1000  Generic Short Packet Code 1                        */
58 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH2            9   /* 00 1001    Generic Short Packet Code 2                      */
59 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH3           10   /* 00 1010    Generic Short Packet Code 3                      */
60 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH4           11   /* 00 1011    Generic Short Packet Code 4                      */
61 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH5           12   /* 00 1100    Generic Short Packet Code 5                      */
62 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH6           13   /* 00 1101    Generic Short Packet Code 6                      */
63 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH7           14   /* 00 1110    Generic Short Packet Code 7                      */
64 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH8           15   /* 00 1111    Generic Short Packet Code 8                      */
65 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8_CSPS     28   /* 01 1100   YUV420 8-bit (Chroma Shifted Pixel Sampling)      */
66 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_10_CSPS    29   /* 01 1101   YUV420 10-bit (Chroma Shifted Pixel Sampling)     */
67 /* used reserved mipi positions for these */
68 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW16             46
69 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18             47
70 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18_2           37
71 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18_3           38
72 
73 #define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_WIDTH              6
74 
75 /* Definition of format_types at the interface CSS --> input_selector*/
76 /* !! Changes here should be copied to systems/isp/isp_css/bin/conv_transmitter_cmd.tcl !! */
77 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB888           0  // 36 'h24
78 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB555           1  // 33 'h
79 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB444           2  // 32
80 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB565           3  // 34
81 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB666           4  // 35
82 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW8             5  // 42
83 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW10            6  // 43
84 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW6             7  // 40
85 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW7             8  // 41
86 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW12            9  // 43
87 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW14           10  // 45
88 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8        11  // 30
89 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_10       12  // 25
90 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV422_8        13  // 30
91 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV422_10       14  // 31
92 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_1       15  // 48
93 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8L       16  // 26
94 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_Emb             17  // 18
95 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_2       18  // 49
96 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_3       19  // 50
97 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_4       20  // 51
98 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_5       21  // 52
99 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_6       22  // 53
100 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_7       23  // 54
101 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_8       24  // 55
102 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8_CSPS   25  // 28
103 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_10_CSPS  26  // 29
104 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW16           27  // ?
105 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18           28  // ?
106 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18_2         29  // ? Option 2 for depacketiser
107 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18_3         30  // ? Option 3 for depacketiser
108 #define _HRT_CSS_RECEIVER_2400_FMT_TYPE_CUSTOM          31  // to signal custom decoding
109 
110 /* definition for state machine of data FIFO for decode different type of data */
111 #define _HRT_CSS_RECEIVER_2400_YUV420_8_REPEAT_PTN                 1
112 #define _HRT_CSS_RECEIVER_2400_YUV420_10_REPEAT_PTN                5
113 #define _HRT_CSS_RECEIVER_2400_YUV420_8L_REPEAT_PTN                1
114 #define _HRT_CSS_RECEIVER_2400_YUV422_8_REPEAT_PTN                 1
115 #define _HRT_CSS_RECEIVER_2400_YUV422_10_REPEAT_PTN                5
116 #define _HRT_CSS_RECEIVER_2400_RGB444_REPEAT_PTN                   2
117 #define _HRT_CSS_RECEIVER_2400_RGB555_REPEAT_PTN                   2
118 #define _HRT_CSS_RECEIVER_2400_RGB565_REPEAT_PTN                   2
119 #define _HRT_CSS_RECEIVER_2400_RGB666_REPEAT_PTN                   9
120 #define _HRT_CSS_RECEIVER_2400_RGB888_REPEAT_PTN                   3
121 #define _HRT_CSS_RECEIVER_2400_RAW6_REPEAT_PTN                     3
122 #define _HRT_CSS_RECEIVER_2400_RAW7_REPEAT_PTN                     7
123 #define _HRT_CSS_RECEIVER_2400_RAW8_REPEAT_PTN                     1
124 #define _HRT_CSS_RECEIVER_2400_RAW10_REPEAT_PTN                    5
125 #define _HRT_CSS_RECEIVER_2400_RAW12_REPEAT_PTN                    3
126 #define _HRT_CSS_RECEIVER_2400_RAW14_REPEAT_PTN                    7
127 
128 #define _HRT_CSS_RECEIVER_2400_MAX_REPEAT_PTN                      _HRT_CSS_RECEIVER_2400_RGB666_REPEAT_PTN
129 
130 #define _HRT_CSS_RECEIVER_2400_BE_COMP_FMT_IDX                     0
131 #define _HRT_CSS_RECEIVER_2400_BE_COMP_FMT_WIDTH                   3
132 #define _HRT_CSS_RECEIVER_2400_BE_COMP_PRED_IDX                    3
133 #define _HRT_CSS_RECEIVER_2400_BE_COMP_PRED_WIDTH                  1
134 #define _HRT_CSS_RECEIVER_2400_BE_COMP_USD_BITS                    4  /* bits per USD type */
135 
136 #define _HRT_CSS_RECEIVER_2400_BE_RAW16_DATAID_IDX                 0
137 #define _HRT_CSS_RECEIVER_2400_BE_RAW16_EN_IDX                     6
138 #define _HRT_CSS_RECEIVER_2400_BE_RAW18_DATAID_IDX                 0
139 #define _HRT_CSS_RECEIVER_2400_BE_RAW18_OPTION_IDX                 6
140 #define _HRT_CSS_RECEIVER_2400_BE_RAW18_EN_IDX                     8
141 
142 #define _HRT_CSS_RECEIVER_2400_BE_COMP_NO_COMP                     0
143 #define _HRT_CSS_RECEIVER_2400_BE_COMP_10_6_10                     1
144 #define _HRT_CSS_RECEIVER_2400_BE_COMP_10_7_10                     2
145 #define _HRT_CSS_RECEIVER_2400_BE_COMP_10_8_10                     3
146 #define _HRT_CSS_RECEIVER_2400_BE_COMP_12_6_12                     4
147 #define _HRT_CSS_RECEIVER_2400_BE_COMP_12_7_12                     5
148 #define _HRT_CSS_RECEIVER_2400_BE_COMP_12_8_12                     6
149 
150 /* packet bit definition */
151 #define _HRT_CSS_RECEIVER_2400_PKT_SOP_IDX                        32
152 #define _HRT_CSS_RECEIVER_2400_PKT_SOP_BITS                        1
153 #define _HRT_CSS_RECEIVER_2400_PKT_CH_ID_IDX                      22
154 #define _HRT_CSS_RECEIVER_2400_PKT_CH_ID_BITS                      2
155 #define _HRT_CSS_RECEIVER_2400_PKT_FMT_ID_IDX                     16
156 #define _HRT_CSS_RECEIVER_2400_PKT_FMT_ID_BITS                     6
157 #define _HRT_CSS_RECEIVER_2400_PH_DATA_FIELD_IDX                   0
158 #define _HRT_CSS_RECEIVER_2400_PH_DATA_FIELD_BITS                 16
159 #define _HRT_CSS_RECEIVER_2400_PKT_PAYLOAD_IDX                     0
160 #define _HRT_CSS_RECEIVER_2400_PKT_PAYLOAD_BITS                   32
161 
162 /*************************************************************************************************/
163 /* Custom Decoding                                                                               */
164 /* These Custom Defs are defined based on design-time config in "csi_be_pixel_formatter.chdl" !! */
165 /*************************************************************************************************/
166 #define BE_CUST_EN_IDX                     0     /* 2bits */
167 #define BE_CUST_EN_DATAID_IDX              2     /* 6bits MIPI DATA ID */
168 #define BE_CUST_EN_WIDTH                   8
169 #define BE_CUST_MODE_ALL                   1     /* Enable Custom Decoding for all DATA IDs */
170 #define BE_CUST_MODE_ONE                   3     /* Enable Custom Decoding for ONE DATA ID, programmed in CUST_EN_DATA_ID */
171 
172 /* Data State config = {get_bits(6bits), valid(1bit)}  */
173 #define BE_CUST_DATA_STATE_S0_IDX          0     /* 7bits */
174 #define BE_CUST_DATA_STATE_S1_IDX          7     /* 7bits */
175 #define BE_CUST_DATA_STATE_S2_IDX          14    /* 7bits */
176 #define BE_CUST_DATA_STATE_WIDTH           21
177 #define BE_CUST_DATA_STATE_VALID_IDX       0     /* 1bits */
178 #define BE_CUST_DATA_STATE_GETBITS_IDX     1     /* 6bits */
179 
180 /* Pixel Extractor config */
181 #define BE_CUST_PIX_EXT_DATA_ALIGN_IDX     0     /* 5bits */
182 #define BE_CUST_PIX_EXT_PIX_ALIGN_IDX      5     /* 5bits */
183 #define BE_CUST_PIX_EXT_PIX_MASK_IDX       10    /* 18bits */
184 #define BE_CUST_PIX_EXT_PIX_EN_IDX         28    /* 1bits */
185 #define BE_CUST_PIX_EXT_WIDTH              29
186 
187 /* Pixel Valid & EoP config = {[eop,valid](especial), [eop,valid](normal)} */
188 #define BE_CUST_PIX_VALID_EOP_P0_IDX        0    /* 4bits */
189 #define BE_CUST_PIX_VALID_EOP_P1_IDX        4    /* 4bits */
190 #define BE_CUST_PIX_VALID_EOP_P2_IDX        8    /* 4bits */
191 #define BE_CUST_PIX_VALID_EOP_P3_IDX        12   /* 4bits */
192 #define BE_CUST_PIX_VALID_EOP_WIDTH         16
193 #define BE_CUST_PIX_VALID_EOP_NOR_VALID_IDX 0    /* Normal (NO less get_bits case) Valid - 1bits */
194 #define BE_CUST_PIX_VALID_EOP_NOR_EOP_IDX   1    /* Normal (NO less get_bits case) EoP - 1bits */
195 #define BE_CUST_PIX_VALID_EOP_ESP_VALID_IDX 2    /* Especial (less get_bits case) Valid - 1bits */
196 #define BE_CUST_PIX_VALID_EOP_ESP_EOP_IDX   3    /* Especial (less get_bits case) EoP - 1bits */
197 
198 #endif /* _mipi_backend_common_defs_h_ */
199 #endif /* _css_receiver_2400_common_defs_h_ */
200