@@ -92,6 +92,29 @@ static bool sun6i_video_format_check(u32 format)
9292 return false;
9393}
9494
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+
95118/* Queue */
96119
97120static int sun6i_video_queue_setup (struct vb2_queue * queue ,
@@ -160,7 +183,6 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
160183 struct video_device * video_dev = & video -> video_dev ;
161184 struct sun6i_csi_buffer * buf ;
162185 struct sun6i_csi_buffer * next_buf ;
163- struct sun6i_csi_config config ;
164186 struct v4l2_subdev * subdev ;
165187 unsigned long flags ;
166188 int ret ;
@@ -182,22 +204,13 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
182204 goto error_media_pipeline ;
183205 }
184206
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 );
194208
195209 spin_lock_irqsave (& video -> dma_queue_lock , flags );
196210
197211 buf = list_first_entry (& video -> dma_queue ,
198212 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 );
201214
202215 sun6i_csi_set_stream (csi_dev , true);
203216
@@ -219,8 +232,7 @@ static int sun6i_video_start_streaming(struct vb2_queue *queue,
219232 * would also drop frame when lacking of queued buffer.
220233 */
221234 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 );
224236
225237 spin_unlock_irqrestore (& video -> dma_queue_lock , flags );
226238
@@ -294,8 +306,7 @@ void sun6i_video_frame_done(struct sun6i_csi_device *csi_dev)
294306 * for next ISR call.
295307 */
296308 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 );
299310 dev_dbg (csi_dev -> dev , "Frame dropped!\n" );
300311 goto complete ;
301312 }
@@ -309,8 +320,7 @@ void sun6i_video_frame_done(struct sun6i_csi_device *csi_dev)
309320 /* Prepare buffer for next frame but one. */
310321 if (!list_is_last (& next_buf -> list , & video -> dma_queue )) {
311322 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 );
314324 } else {
315325 dev_dbg (csi_dev -> dev , "Next frame will be dropped!\n" );
316326 }
0 commit comments