@@ -92,6 +92,29 @@ static bool sun6i_video_format_check(u32 format)
92
92
return false;
93
93
}
94
94
95
+ /* Video */
96
+
97
+ static void sun6i_video_buffer_configure (struct sun6i_csi_device * csi_dev ,
98
+ struct sun6i_csi_buffer * csi_buffer )
99
+ {
100
+ csi_buffer -> queued_to_csi = true;
101
+ sun6i_csi_update_buf_addr (csi_dev , csi_buffer -> dma_addr );
102
+ }
103
+
104
+ static void sun6i_video_configure (struct sun6i_csi_device * csi_dev )
105
+ {
106
+ struct sun6i_video * video = & csi_dev -> video ;
107
+ struct sun6i_csi_config config = { 0 };
108
+
109
+ config .pixelformat = video -> format .fmt .pix .pixelformat ;
110
+ config .code = video -> mbus_code ;
111
+ config .field = video -> format .fmt .pix .field ;
112
+ config .width = video -> format .fmt .pix .width ;
113
+ config .height = video -> format .fmt .pix .height ;
114
+
115
+ sun6i_csi_update_config (csi_dev , & config );
116
+ }
117
+
95
118
/* Queue */
96
119
97
120
static int sun6i_video_queue_setup (struct vb2_queue * queue ,
@@ -160,7 +183,6 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
160
183
struct video_device * video_dev = & video -> video_dev ;
161
184
struct sun6i_csi_buffer * buf ;
162
185
struct sun6i_csi_buffer * next_buf ;
163
- struct sun6i_csi_config config ;
164
186
struct v4l2_subdev * subdev ;
165
187
unsigned long flags ;
166
188
int ret ;
@@ -182,22 +204,13 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
182
204
goto error_media_pipeline ;
183
205
}
184
206
185
- config .pixelformat = video -> format .fmt .pix .pixelformat ;
186
- config .code = video -> mbus_code ;
187
- config .field = video -> format .fmt .pix .field ;
188
- config .width = video -> format .fmt .pix .width ;
189
- config .height = video -> format .fmt .pix .height ;
190
-
191
- ret = sun6i_csi_update_config (csi_dev , & config );
192
- if (ret < 0 )
193
- goto error_media_pipeline ;
207
+ sun6i_video_configure (csi_dev );
194
208
195
209
spin_lock_irqsave (& video -> dma_queue_lock , flags );
196
210
197
211
buf = list_first_entry (& video -> dma_queue ,
198
212
struct sun6i_csi_buffer , list );
199
- buf -> queued_to_csi = true;
200
- sun6i_csi_update_buf_addr (csi_dev , buf -> dma_addr );
213
+ sun6i_video_buffer_configure (csi_dev , buf );
201
214
202
215
sun6i_csi_set_stream (csi_dev , true);
203
216
@@ -219,8 +232,7 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
219
232
* would also drop frame when lacking of queued buffer.
220
233
*/
221
234
next_buf = list_next_entry (buf , list );
222
- next_buf -> queued_to_csi = true;
223
- sun6i_csi_update_buf_addr (csi_dev , next_buf -> dma_addr );
235
+ sun6i_video_buffer_configure (csi_dev , next_buf );
224
236
225
237
spin_unlock_irqrestore (& video -> dma_queue_lock , flags );
226
238
@@ -294,8 +306,7 @@ void sun6i_video_frame_done(struct sun6i_csi_device *csi_dev)
294
306
* for next ISR call.
295
307
*/
296
308
if (!next_buf -> queued_to_csi ) {
297
- next_buf -> queued_to_csi = true;
298
- sun6i_csi_update_buf_addr (csi_dev , next_buf -> dma_addr );
309
+ sun6i_video_buffer_configure (csi_dev , next_buf );
299
310
dev_dbg (csi_dev -> dev , "Frame dropped!\n" );
300
311
goto complete ;
301
312
}
@@ -309,8 +320,7 @@ void sun6i_video_frame_done(struct sun6i_csi_device *csi_dev)
309
320
/* Prepare buffer for next frame but one. */
310
321
if (!list_is_last (& next_buf -> list , & video -> dma_queue )) {
311
322
next_buf = list_next_entry (next_buf , list );
312
- next_buf -> queued_to_csi = true;
313
- sun6i_csi_update_buf_addr (csi_dev , next_buf -> dma_addr );
323
+ sun6i_video_buffer_configure (csi_dev , next_buf );
314
324
} else {
315
325
dev_dbg (csi_dev -> dev , "Next frame will be dropped!\n" );
316
326
}
0 commit comments