linux/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
/* abort streaming and wait for last buffer */
abort streaming and wait for last buffer
abort streaming and wait for last buffer
static void stop_streaming(struct vb2_queue *vq)
{
	int ret;
	unsigned long timeout;
	struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq);
	v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
		 __func__, dev);
	init_completion(&dev->capture.frame_cmplt);
	dev->capture.frame_count = 0;
	if (!dev->capture.port) {
		v4l2_err(&dev->v4l2_dev,
			 "no capture port - stream not started?\n");
		return;
	}
	v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "stopping capturing\n");
	vchiq_mmal_port_parameter_set(dev->instance,
				      dev->capture.camera_port,
				      MMAL_PARAMETER_CAPTURE,
				      &dev->capture.frame_count,
				      sizeof(dev->capture.frame_count));
	timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, HZ);
	if (timeout == 0)
		v4l2_err(&dev->v4l2_dev,
			 "timed out waiting for frame completion\n");
	v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
		 "disabling connection\n");
	ret = vchiq_mmal_port_disable(dev->instance, dev->capture.camera_port);
	if (!ret && dev->capture.camera_port != dev->capture.port) {
		v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
			 "disabling port\n");
		ret = vchiq_mmal_port_disable(dev->instance, dev->capture.port);
	} else if (dev->capture.camera_port != dev->capture.port) {
		v4l2_err(&dev->v4l2_dev, "port_disable failed, error %d\n",
			 ret);
	}
	if (disable_camera(dev) < 0)
		v4l2_err(&dev->v4l2_dev, "Failed to disable camera\n");
}
static void stop_streaming ( struct vb2_queue * vq ) { int ret ; unsigned long timeout ; struct bm2835_mmal_dev * dev = vb2_get_drv_priv ( vq ) ; v4l2_dbg ( 1 , bcm2835_v4l2_debug , & dev -> v4l2_dev , " \n " , __func__ , dev ) ; init_completion ( & dev -> capture . frame_cmplt ) ; dev -> capture . frame_count = 0 ; if ( ! dev -> capture . port ) { v4l2_err ( & dev -> v4l2_dev , " \n " ) ; return ; } v4l2_dbg ( 1 , bcm2835_v4l2_debug , & dev -> v4l2_dev , " \n " ) ; vchiq_mmal_port_parameter_set ( dev -> instance , dev -> capture . camera_port , MMAL_PARAMETER_CAPTURE , & dev -> capture . frame_count , sizeof ( dev -> capture . frame_count ) ) ; timeout = wait_for_completion_timeout ( & dev -> capture . frame_cmplt , HZ ) ; if ( timeout == 0 ) v4l2_err ( & dev -> v4l2_dev , " \n " ) ; v4l2_dbg ( 1 , bcm2835_v4l2_debug , & dev -> v4l2_dev , " \n " ) ; ret = vchiq_mmal_port_disable ( dev -> instance , dev -> capture . camera_port ) ; if ( ! ret && dev -> capture . camera_port != dev -> capture . port ) { v4l2_dbg ( 1 , bcm2835_v4l2_debug , & dev -> v4l2_dev , " \n " ) ; ret = vchiq_mmal_port_disable ( dev -> instance , dev -> capture . port ) ; } else if ( dev -> capture . camera_port != dev -> capture . port ) { v4l2_err ( & dev -> v4l2_dev , " \n " , ret ) ; } if ( disable_camera ( dev ) < 0 ) v4l2_err ( & dev -> v4l2_dev , " \n " ) ; }
abort streaming and wait for last buffer
abort streaming and wait for last buffer
/* ensure a format has actually been set */ /* stop capturing frames */ /* wait for last frame to complete */ /* disable the connection from camera to encoder */