コード例 #1
0
/*
 * camif_open()
 */
static int camif_open(struct inode *inode, struct file *file)
{
	struct s3c2440camif_dev *pdev;
	struct s3c2440camif_fh *fh;

	int ret;

	if (!has_ov9650) {
		return -ENODEV;
	}
	pdev = &camera;


	fh = kzalloc(sizeof(*fh),GFP_KERNEL); // alloc memory for filehandle
	if (NULL == fh)
	{
		return -ENOMEM;
	}
	fh->dev = pdev;

		pdev->state = CAMIF_STATE_READY;

		init_camif_config(fh);

		ret = init_image_buffer();	// init image buffer.
		if (ret < 0)
		{
			goto error1;
		}

		request_irq(IRQ_S3C2440_CAM_C, on_camif_irq_c, IRQF_DISABLED, "CAM_C", pdev);	// setup ISRs
		if (ret < 0)
		{
			goto error2;
		}

		request_irq(IRQ_S3C2440_CAM_P, on_camif_irq_p, IRQF_DISABLED, "CAM_P", pdev);
		if (ret < 0)
		{
			goto error3;
		}

		clk_enable(pdev->clk);		// and enable camif clock.

		soft_reset_camif();

	file->private_data = fh;
	fh->dev  = pdev;
	update_camif_config(fh, 0);
	return 0;

error3:
	free_irq(IRQ_S3C2440_CAM_C, pdev);
error2:
	free_image_buffer();
error1:
	kfree(fh);
	return ret;
}
コード例 #2
0
ファイル: s3c2440camif.c プロジェクト: IngenicC/OV9560
/* switch camif from codec path to preview path. */
static void __inline__ camif_c2p(s3c2440camif_dev * pdev)
{
	/* 1. stop codec. */
	{
		u32 cicoscctrl;
		cicoscctrl = ioread32(S3C244X_CICOSCCTRL);
		cicoscctrl &= ~(1<<15);	// stop preview scaler.
		iowrite32(cicoscctrl, S3C244X_CICOSCCTRL);
	}

	/* 2. soft-reset camif. */
	soft_reset_camif();

	/* 3. clear all overflow. */
	{
		u32 ciwdofst;
		ciwdofst = ioread32(S3C244X_CIWDOFST);
		ciwdofst |= (1<<30)|(1<<15)|(1<<14)|(1<<13)|(1<<12);
		iowrite32(ciwdofst, S3C244X_CIWDOFST);

		ciwdofst &= ~((1<<30)|(1<<15)|(1<<14)|(1<<13)|(1<<12));
		iowrite32(ciwdofst, S3C244X_CIWDOFST);
	}
}