@@ -337,13 +337,10 @@ static void isp_vb2_buf_queue(struct vb2_buffer *vb)
337337 isp_submit_buffers (isp );
338338}
339339
340- static int isp_vb2_start_streaming (struct vb2_queue * q , unsigned int count )
340+ static int apple_isp_start_streaming (struct apple_isp * isp )
341341{
342- struct apple_isp * isp = vb2_get_drv_priv (q );
343342 int err ;
344343
345- isp -> sequence = 0 ;
346-
347344 err = apple_isp_start_camera (isp );
348345 if (err ) {
349346 dev_err (isp -> dev , "failed to start camera: %d\n" , err );
@@ -373,16 +370,55 @@ static int isp_vb2_start_streaming(struct vb2_queue *q, unsigned int count)
373370 return err ;
374371}
375372
376- static void isp_vb2_stop_streaming (struct vb2_queue * q )
373+ static void apple_isp_stop_streaming (struct apple_isp * isp )
377374{
378- struct apple_isp * isp = vb2_get_drv_priv (q );
379-
380375 clear_bit (ISP_STATE_STREAMING , & isp -> state );
381376 apple_isp_stop_capture (isp );
382377 apple_isp_stop_camera (isp );
378+ }
379+
380+ static int isp_vb2_start_streaming (struct vb2_queue * q , unsigned int count )
381+ {
382+ struct apple_isp * isp = vb2_get_drv_priv (q );
383+
384+ isp -> sequence = 0 ;
385+
386+ return apple_isp_start_streaming (isp );
387+ }
388+
389+ static void isp_vb2_stop_streaming (struct vb2_queue * q )
390+ {
391+ struct apple_isp * isp = vb2_get_drv_priv (q );
392+
393+ apple_isp_stop_streaming (isp );
383394 isp_vb2_release_buffers (isp , VB2_BUF_STATE_ERROR );
384395}
385396
397+ int apple_isp_video_suspend (struct apple_isp * isp )
398+ {
399+ /* Swap into STATE_SLEEPING as isp_vb2_buf_queue() submits on
400+ * STATE_STREAMING.
401+ */
402+ if (test_bit (ISP_STATE_STREAMING , & isp -> state )) {
403+ /* Signal buffers to be recycled for clean shutdown */
404+ isp_vb2_release_buffers (isp , VB2_BUF_STATE_QUEUED );
405+ apple_isp_stop_streaming (isp );
406+ set_bit (ISP_STATE_SLEEPING , & isp -> state );
407+ }
408+
409+ return 0 ;
410+ }
411+
412+ int apple_isp_video_resume (struct apple_isp * isp )
413+ {
414+ if (test_bit (ISP_STATE_SLEEPING , & isp -> state )) {
415+ clear_bit (ISP_STATE_SLEEPING , & isp -> state );
416+ apple_isp_start_streaming (isp );
417+ }
418+
419+ return 0 ;
420+ }
421+
386422static const struct vb2_ops isp_vb2_ops = {
387423 .queue_setup = isp_vb2_queue_setup ,
388424 .buf_init = isp_vb2_buf_init ,
0 commit comments