@@ -48,14 +48,17 @@ enum rkisp1_plane {
48
48
* @fmt_type: helper filed for pixel format
49
49
* @uv_swap: if cb cr swapped, for yuv
50
50
* @yc_swap: if y and cb/cr swapped, for yuv
51
+ * @byte_swap: if byte pairs are swapped, for raw
51
52
* @write_format: defines how YCbCr self picture data is written to memory
52
- * @output_format: defines sp output format
53
+ * @output_format: defines the output format (RKISP1_CIF_MI_INIT_MP_OUTPUT_* for
54
+ * the main path and RKISP1_MI_CTRL_SP_OUTPUT_* for the self path)
53
55
* @mbus: the mbus code on the src resizer pad that matches the pixel format
54
56
*/
55
57
struct rkisp1_capture_fmt_cfg {
56
58
u32 fourcc ;
57
59
u32 uv_swap : 1 ;
58
60
u32 yc_swap : 1 ;
61
+ u32 byte_swap : 1 ;
59
62
u32 write_format ;
60
63
u32 output_format ;
61
64
u32 mbus ;
@@ -96,131 +99,166 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
96
99
.fourcc = V4L2_PIX_FMT_YUYV ,
97
100
.uv_swap = 0 ,
98
101
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT ,
102
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
99
103
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
100
104
}, {
101
105
.fourcc = V4L2_PIX_FMT_UYVY ,
102
106
.uv_swap = 0 ,
103
107
.yc_swap = 1 ,
104
108
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT ,
109
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
105
110
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
106
111
}, {
107
112
.fourcc = V4L2_PIX_FMT_YUV422P ,
108
113
.uv_swap = 0 ,
109
114
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
115
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
110
116
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
111
117
}, {
112
118
.fourcc = V4L2_PIX_FMT_NV16 ,
113
119
.uv_swap = 0 ,
114
120
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
121
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
115
122
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
116
123
}, {
117
124
.fourcc = V4L2_PIX_FMT_NV61 ,
118
125
.uv_swap = 1 ,
119
126
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
127
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
120
128
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
121
129
}, {
122
130
.fourcc = V4L2_PIX_FMT_NV16M ,
123
131
.uv_swap = 0 ,
124
132
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
133
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
125
134
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
126
135
}, {
127
136
.fourcc = V4L2_PIX_FMT_NV61M ,
128
137
.uv_swap = 1 ,
129
138
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
139
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
130
140
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
131
141
}, {
132
142
.fourcc = V4L2_PIX_FMT_YVU422M ,
133
143
.uv_swap = 1 ,
134
144
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
145
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV422 ,
135
146
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
136
147
},
137
148
/* yuv400 */
138
149
{
139
150
.fourcc = V4L2_PIX_FMT_GREY ,
140
151
.uv_swap = 0 ,
141
152
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
153
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV400 ,
142
154
.mbus = MEDIA_BUS_FMT_YUYV8_2X8 ,
143
155
},
144
156
/* yuv420 */
145
157
{
146
158
.fourcc = V4L2_PIX_FMT_NV21 ,
147
159
.uv_swap = 1 ,
148
160
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
161
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
149
162
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
150
163
}, {
151
164
.fourcc = V4L2_PIX_FMT_NV12 ,
152
165
.uv_swap = 0 ,
153
166
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
167
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
154
168
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
155
169
}, {
156
170
.fourcc = V4L2_PIX_FMT_NV21M ,
157
171
.uv_swap = 1 ,
158
172
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
173
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
159
174
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
160
175
}, {
161
176
.fourcc = V4L2_PIX_FMT_NV12M ,
162
177
.uv_swap = 0 ,
163
178
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ,
179
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
164
180
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
165
181
}, {
166
182
.fourcc = V4L2_PIX_FMT_YUV420 ,
167
183
.uv_swap = 0 ,
168
184
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
185
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
169
186
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
170
187
}, {
171
188
.fourcc = V4L2_PIX_FMT_YVU420 ,
172
189
.uv_swap = 1 ,
173
190
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
191
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_YUV420 ,
174
192
.mbus = MEDIA_BUS_FMT_YUYV8_1_5X8 ,
175
193
},
176
194
/* raw */
177
195
{
178
196
.fourcc = V4L2_PIX_FMT_SRGGB8 ,
179
197
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
198
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW8 ,
180
199
.mbus = MEDIA_BUS_FMT_SRGGB8_1X8 ,
181
200
}, {
182
201
.fourcc = V4L2_PIX_FMT_SGRBG8 ,
183
202
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
203
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW8 ,
184
204
.mbus = MEDIA_BUS_FMT_SGRBG8_1X8 ,
185
205
}, {
186
206
.fourcc = V4L2_PIX_FMT_SGBRG8 ,
187
207
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
208
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW8 ,
188
209
.mbus = MEDIA_BUS_FMT_SGBRG8_1X8 ,
189
210
}, {
190
211
.fourcc = V4L2_PIX_FMT_SBGGR8 ,
191
212
.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8 ,
213
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW8 ,
192
214
.mbus = MEDIA_BUS_FMT_SBGGR8_1X8 ,
193
215
}, {
194
216
.fourcc = V4L2_PIX_FMT_SRGGB10 ,
217
+ .byte_swap = 1 ,
195
218
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
219
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW10 ,
196
220
.mbus = MEDIA_BUS_FMT_SRGGB10_1X10 ,
197
221
}, {
198
222
.fourcc = V4L2_PIX_FMT_SGRBG10 ,
223
+ .byte_swap = 1 ,
199
224
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
225
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW10 ,
200
226
.mbus = MEDIA_BUS_FMT_SGRBG10_1X10 ,
201
227
}, {
202
228
.fourcc = V4L2_PIX_FMT_SGBRG10 ,
229
+ .byte_swap = 1 ,
203
230
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
231
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW10 ,
204
232
.mbus = MEDIA_BUS_FMT_SGBRG10_1X10 ,
205
233
}, {
206
234
.fourcc = V4L2_PIX_FMT_SBGGR10 ,
235
+ .byte_swap = 1 ,
207
236
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
237
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW10 ,
208
238
.mbus = MEDIA_BUS_FMT_SBGGR10_1X10 ,
209
239
}, {
210
240
.fourcc = V4L2_PIX_FMT_SRGGB12 ,
241
+ .byte_swap = 1 ,
211
242
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
243
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW12 ,
212
244
.mbus = MEDIA_BUS_FMT_SRGGB12_1X12 ,
213
245
}, {
214
246
.fourcc = V4L2_PIX_FMT_SGRBG12 ,
247
+ .byte_swap = 1 ,
215
248
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
249
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW12 ,
216
250
.mbus = MEDIA_BUS_FMT_SGRBG12_1X12 ,
217
251
}, {
218
252
.fourcc = V4L2_PIX_FMT_SGBRG12 ,
253
+ .byte_swap = 1 ,
219
254
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
255
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW12 ,
220
256
.mbus = MEDIA_BUS_FMT_SGBRG12_1X12 ,
221
257
}, {
222
258
.fourcc = V4L2_PIX_FMT_SBGGR12 ,
259
+ .byte_swap = 1 ,
223
260
.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12 ,
261
+ .output_format = RKISP1_CIF_MI_INIT_MP_OUTPUT_RAW12 ,
224
262
.mbus = MEDIA_BUS_FMT_SBGGR12_1X12 ,
225
263
},
226
264
};
@@ -484,11 +522,16 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)
484
522
*/
485
523
if (rkisp1_has_feature (rkisp1 , MAIN_STRIDE )) {
486
524
reg = rkisp1_read (rkisp1 , RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT );
487
- if (cap -> pix .cfg -> yc_swap )
525
+ if (cap -> pix .cfg -> yc_swap || cap -> pix . cfg -> byte_swap )
488
526
reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES ;
489
527
else
490
528
reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES ;
529
+
530
+ reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_LSB_ALIGNMENT ;
491
531
rkisp1_write (rkisp1 , RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT , reg );
532
+
533
+ rkisp1_write (rkisp1 , RKISP1_CIF_MI_INIT ,
534
+ cap -> pix .cfg -> output_format );
492
535
}
493
536
494
537
rkisp1_mi_config_ctrl (cap );
@@ -951,19 +994,40 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap)
951
994
spin_lock_irq (& cap -> buf .lock );
952
995
rkisp1_set_next_buf (cap );
953
996
cap -> ops -> enable (cap );
954
- /* It's safe to configure ACTIVE and SHADOW registers for the
955
- * first stream. While when the second is starting, do NOT
956
- * force update because it also updates the first one.
997
+
998
+ /*
999
+ * It's safe to configure ACTIVE and SHADOW registers for the first
1000
+ * stream. While when the second is starting, do NOT force update
1001
+ * because it also updates the first one.
957
1002
*
958
- * The latter case would drop one more buffer(that is 2) since
959
- * there's no buffer in a shadow register when the second FE received.
960
- * This's also required because the second FE maybe corrupt
961
- * especially when run at 120fps.
1003
+ * The latter case would drop one more buffer(that is 2) since there's
1004
+ * no buffer in a shadow register when the second FE received. This's
1005
+ * also required because the second FE maybe corrupt especially when
1006
+ * run at 120fps.
962
1007
*/
963
1008
if (!has_self_path || !other -> is_streaming ) {
964
- /* force cfg update */
965
- rkisp1_write (rkisp1 , RKISP1_CIF_MI_INIT ,
966
- RKISP1_CIF_MI_INIT_SOFT_UPD );
1009
+ u32 reg ;
1010
+
1011
+ /*
1012
+ * Force cfg update.
1013
+ *
1014
+ * The ISP8000 (implementing the MAIN_STRIDE feature) as a
1015
+ * mp_output_format field in the CIF_MI_INIT register that must
1016
+ * be preserved. It can be read back, but it is not clear what
1017
+ * other register bits will return. Mask them out.
1018
+ *
1019
+ * On Rockchip platforms, the CIF_MI_INIT register is marked as
1020
+ * write-only and reads as zeros. We can skip reading it.
1021
+ */
1022
+ if (rkisp1_has_feature (rkisp1 , MAIN_STRIDE ))
1023
+ reg = rkisp1_read (rkisp1 , RKISP1_CIF_MI_INIT )
1024
+ & RKISP1_CIF_MI_INIT_MP_OUTPUT_MASK ;
1025
+ else
1026
+ reg = 0 ;
1027
+
1028
+ reg |= RKISP1_CIF_MI_INIT_SOFT_UPD ;
1029
+ rkisp1_write (rkisp1 , RKISP1_CIF_MI_INIT , reg );
1030
+
967
1031
rkisp1_set_next_buf (cap );
968
1032
}
969
1033
spin_unlock_irq (& cap -> buf .lock );
0 commit comments