示例#1
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	: 
 *  Name	:	omap_v4l2_read
 *  Parameter1	:	struct file *file
 *  Parameter2	:	INT8 *buf
 *  Parameter3	:	size_t count
 *  Parameter4	:	loff_t * ppos
 *  Returns	:	INT32	- On sucess returns 0
 *  				- On Failure a negative number be returned	
 *  Description	: 	perform read operation of camera driver
 *  Comments	:  	
 ************************************************************************************************************/
INT32 omap_v4l2_read(struct file *file, INT8 *buf, size_t count, loff_t * ppos)
{

//	struct video_device *dev = video_devdata(file);
	FNRESLT ret_val;
	cam_data *cam = NULL;
	INT32 err;
	UINT32 wait_event_ret_val	= DISABLE;
	UINT32 retry_count		= 0;
	UINT32 old_width,old_height;

	ret_val	= v4l2_base_struct(&cam,GET_ADDRESS);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to register the camera device\n");
		TRACE_ERR_AND_RET(FAIL);		
	}

	if(cam->task.bit.capture	== ENABLE)
	{
		TRACE_ERR_AND_RET(-EBUSY);	
	}

start_read_again:

	cam->task.bit.still	= ENABLE;

/*
 * configure the sensor
 */

	if(cam->cam_sensor.config_dim)
	{
		ret_val	= cam->cam_sensor.config_dim(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			goto exit;
		}
	}else
	{
		goto exit;
	}
/*
 * reset the isp 
 */

	ret_val	= isp_reset(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	ret_val	= isp_configure(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

/*
 * Get the memory from the kernel
 */

	ret_val	= get_free_phy_mem(cam->capture.v2f.fmt.pix.sizeimage,&cam->still.phy_addr,&cam->still.vir_addr);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	ret_val	= isp_prg_sdram_addr(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	cam->still.frame_count	= DISABLE;
	cam->still.wait_queue_head_t_dma_frame_complete_still	= DISABLE;

/*
 * Enable sensor strobe
 */
	if(cam->cam_sensor.sens_strobe)
	{
		cam->ctrl.id	= V4L2_SENS_FLASH_STROBE;
		cam->ctrl.value	= ENABLE;
		ret_val	= cam->cam_sensor.sens_strobe(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			goto exit;
		}
	}


	ret_val	= enable_ccdc(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	ret_val	= enable_isp_irq0(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}
/*
 * Wait for interrupt from the isp interrupt service routine
 */
	if(cam->still.wait_queue_head_t_dma_frame_complete_still	== DISABLE)
	{
		wait_event_ret_val	= wait_event_interruptible_timeout(cam->still.dma_frame_complete_still,		\
					      cam->still.frame_count >= STILL_IMAGE_CAPTURE_FRAME_NUMBER,		\
						20 * HZ);
	}
	
/*
 * Disable sensor strobe
 */
	if(cam->cam_sensor.sens_strobe)
	{
		cam->ctrl.id	= V4L2_SENS_FLASH_STROBE;
		cam->ctrl.value	= DISABLE;
		ret_val	= cam->cam_sensor.sens_strobe(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			goto exit;
		}

	}

	ret_val	= disable_ccdc(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	ret_val	= disable_isp_irq0(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	if(wait_event_ret_val == DISABLE)
	{
		cam->task.bit.still = DISABLE;

		printk(KERN_DEBUG "wait_event_interruptible_timeout %s %d \n",__FUNCTION__,__LINE__);	
		printk(KERN_ERR "omap_v4l_read timeout - Frame count %d\n",cam->still.frame_count);
	
		ret_val	= free_phy_mem(cam->still.phy_addr);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			goto exit;
		}

		if(retry_count)
		{
			old_width	= cam->cam_sensor.fmt.fmt.pix.width;
			old_height	= cam->cam_sensor.fmt.fmt.pix.height;

			cam->cam_sensor.fmt.fmt.pix.width	= 640;
			cam->cam_sensor.fmt.fmt.pix.height	= 480;

			ret_val	= cam->cam_sensor.config_dim(cam);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				goto exit;
			}

			cam->cam_sensor.fmt.fmt.pix.width	= old_width;
			cam->cam_sensor.fmt.fmt.pix.height	= old_height;

			mdelay(200);

			retry_count--;

			goto start_read_again;
		}		
		return -ETIME;
	}
	err = copy_to_user(buf,(UPINT8)cam->still.vir_addr, cam->capture.v2f.fmt.pix.sizeimage);

	ret_val	= free_phy_mem(cam->still.phy_addr);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

	cam->task.bit.still	= DISABLE;

	return cam->capture.v2f.fmt.pix.sizeimage;

	exit:
	{
		cam->task.bit.still	= DISABLE;
		return 0;
	}
}
示例#2
0
irqreturn_t omap34xx_isp_isr(int irq, void *_cam)
{
	cam_data *cam	= _cam;
	int ret_val;

	if (cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_vd0_irq == 1) {
		if (cam->task.bit.still == 1) {
			cam->still.frame_count++;
		
			if (cam->still.frame_count >= STILL_IMAGE_CAPTURE_FRAME_NUMBER) {
				wake_up_interruptible(&cam->still.dma_frame_complete_still);
				cam->still.wait_queue_head_t_dma_frame_complete_still = 1;
			}
		}
		else if (cam->task.bit.capture == 1) {
			/* Trigger the wake up event */
			ret_val	= isp_prg_sdram_addr(cam);

			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				
			}
		}
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_vd1_irq			== ENABLED)
	{	
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_vd2_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_err_irq			== ENABLED)
	{
	}
	
	if(cam->isp->isp_main.reg.isp_irq0status.bit.h3a_af_done_irq			== ENABLED)
	{
	}
	
	if(cam->isp->isp_main.reg.isp_irq0status.bit.h3a_awb_done_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.hist_done_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_lsc_done			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_lsc_prefectch_completed	== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ccdc_lsc_prefectch_error		== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.prv_done_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.cbuff_irq				== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.rsz_done_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.ovf_irq				== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.mmu_err_irq			== ENABLED)
	{
	}
	
	if(cam->isp->isp_main.reg.isp_irq0status.bit.ocp_err_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.sec_err_irq			== ENABLED)
	{
	}

	if(cam->isp->isp_main.reg.isp_irq0status.bit.hs_vs_irq				== ENABLED)
	{
	}

	cam->isp->isp_main.reg.isp_irq0status.ISP_IRQ0STATUS	= cam->isp->isp_main.reg.isp_irq0status.ISP_IRQ0STATUS;
	cam->isp->isp_main.reg.isp_irq1status.ISP_IRQ1STATUS	= cam->isp->isp_main.reg.isp_irq1status.ISP_IRQ1STATUS;

	return IRQ_HANDLED;
}