コード例 #1
0
ファイル: iss_csi2.c プロジェクト: lchao-bit/linaro-kernel
/*
 * csi2_set_stream - Enable/Disable streaming on the CSI2 module
 * @sd: ISS CSI2 V4L2 subdevice
 * @enable: ISS pipeline stream state
 *
 * Return 0 on success or a negative error code otherwise.
 */
static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
{
	struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd);
	struct iss_device *iss = csi2->iss;
	struct iss_pipeline *pipe = to_iss_pipeline(&csi2->subdev.entity);
	struct iss_video *video_out = &csi2->video_out;

	if (csi2->state == ISS_PIPELINE_STREAM_STOPPED) {
		if (enable == ISS_PIPELINE_STREAM_STOPPED)
			return 0;

		omap4iss_subclk_enable(iss, OMAP4_ISS_SUBCLK_CSI2_A);
	}

	switch (enable) {
	case ISS_PIPELINE_STREAM_CONTINUOUS:
		if (omap4iss_csiphy_acquire(csi2->phy) < 0)
			return -ENODEV;
		csi2->use_fs_irq = pipe->do_propagation;
		csi2_configure(csi2);
		csi2_print_status(csi2);

		/*
		 * When outputting to memory with no buffer available, let the
		 * buffer queue handler start the hardware. A DMA queue flag
		 * ISS_VIDEO_DMAQUEUE_QUEUED will be set as soon as there is
		 * a buffer available.
		 */
		if (csi2->output & CSI2_OUTPUT_MEMORY &&
		    !(video_out->dmaqueue_flags & ISS_VIDEO_DMAQUEUE_QUEUED))
			break;
		/* Enable context 0 and IRQs */
		atomic_set(&csi2->stopping, 0);
		csi2_ctx_enable(csi2, 0, 1);
		csi2_if_enable(csi2, 1);
		iss_video_dmaqueue_flags_clr(video_out);
		break;

	case ISS_PIPELINE_STREAM_STOPPED:
		if (csi2->state == ISS_PIPELINE_STREAM_STOPPED)
			return 0;
		if (omap4iss_module_sync_idle(&sd->entity, &csi2->wait,
					      &csi2->stopping))
			dev_dbg(iss->dev, "%s: module stop timeout.\n",
				sd->name);
		csi2_ctx_enable(csi2, 0, 0);
		csi2_if_enable(csi2, 0);
		csi2_irq_ctx_set(csi2, 0);
		omap4iss_csiphy_release(csi2->phy);
		omap4iss_subclk_disable(iss, OMAP4_ISS_SUBCLK_CSI2_A);
		iss_video_dmaqueue_flags_clr(video_out);
		break;
	}

	csi2->state = enable;
	return 0;
}
コード例 #2
0
ファイル: ispcsi2.c プロジェクト: Sangil-Lee/ZynqFPGA
/*
 * csi2_set_stream - Enable/Disable streaming on the CSI2 module
 * @sd: ISP CSI2 V4L2 subdevice
 * @enable: ISP pipeline stream state
 *
 * Return 0 on success or a negative error code otherwise.
 */
static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
{
    struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
    struct isp_device *isp = csi2->isp;
    struct isp_video *video_out = &csi2->video_out;

    switch (enable) {
    case ISP_PIPELINE_STREAM_CONTINUOUS:
        if (omap3isp_csiphy_acquire(csi2->phy) < 0)
            return -ENODEV;
        if (csi2->output & CSI2_OUTPUT_MEMORY)
            omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CSI2A_WRITE);
        csi2_configure(csi2);
        csi2_print_status(csi2);

        /*
         * When outputting to memory with no buffer available, let the
         * buffer queue handler start the hardware. A DMA queue flag
         * ISP_VIDEO_DMAQUEUE_QUEUED will be set as soon as there is
         * a buffer available.
         */
        if (csi2->output & CSI2_OUTPUT_MEMORY &&
                !(video_out->dmaqueue_flags & ISP_VIDEO_DMAQUEUE_QUEUED))
            break;
        /* Enable context 0 and IRQs */
        atomic_set(&csi2->stopping, 0);
        csi2_ctx_enable(isp, csi2, 0, 1);
        csi2_if_enable(isp, csi2, 1);
        isp_video_dmaqueue_flags_clr(video_out);
        break;

    case ISP_PIPELINE_STREAM_STOPPED:
        if (csi2->state == ISP_PIPELINE_STREAM_STOPPED)
            return 0;
        if (omap3isp_module_sync_idle(&sd->entity, &csi2->wait,
                                      &csi2->stopping))
            dev_dbg(isp->dev, "%s: module stop timeout.\n",
                    sd->name);
        csi2_ctx_enable(isp, csi2, 0, 0);
        csi2_if_enable(isp, csi2, 0);
        csi2_irq_ctx_set(isp, csi2, 0);
        omap3isp_csiphy_release(csi2->phy);
        isp_video_dmaqueue_flags_clr(video_out);
        omap3isp_sbl_disable(isp, OMAP3_ISP_SBL_CSI2A_WRITE);
        break;
    }

    csi2->state = enable;
    return 0;
}