Esempio n. 1
0
	INT32 omap_v4l2_open(struct inode *inode,struct file *file)
#endif
{
	INT32 err = 0;
	struct video_device *dev = video_devdata(file);
	cam_data *cam;
	FNRESLT ret_val;

	ret_val	= v4l2_base_struct(&cam,GET_ADDRESS);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to get base node of camera device\n");
		TRACE_ERR_AND_RET(FAIL);		
	}
	
	if (cam	== NULL)
	{
		printk(KERN_ERR "Internal error, cam_data not found!\n");
		TRACE_ERR_AND_RET(-EBADF);
	}
	file->private_data = dev;

	strcpy(cam->v4l2_cap.driver, "omap_v4l2");
	cam->v4l2_cap.version		= KERNEL_VERSION(0, 1, 11);
	cam->v4l2_cap.capabilities 	=	V4L2_CAP_VIDEO_CAPTURE	|	\
						V4L2_CAP_READWRITE	|	\
						V4L2_CAP_STREAMING;

	cam->v4l2_cap.card[0]		= '\0';
	cam->v4l2_cap.bus_info[0]	= '\0';

	return err;
}
Esempio n. 2
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	stcf03_probe
 *  Parameter1	:	struct i2c_client *client
 *  Parameter2	:	const struct i2c_device_id *id
 *  Returns	:	LINT32	- On sucess returns 0
 *  				- On Failure a negative number be returned
 *
 *  Description	: 	Configure the gpio levels for ov3640 driver
 *  Comments	:  	
 ************************************************************************************************************/
static INT32 __init stcf03_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	cam_data *cam	= NULL;
	FNRESLT ret_val;

	if (i2c_get_clientdata(client))
	{
		TRACE_ERR_AND_RET(FAIL);
	}

	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");
		goto exit;
	}
	
/*
 * 	set the client data 
 */
	cam->cam_flash.client =	client;

	return 0;
	exit:
	{
		return -EINVAL;
	}	
}
Esempio n. 3
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	isp_probe
 *  Parameter1	:	struct platform_device *pdev
 *  Returns	:	INT32	- On sucess returns 0
 *  				- On Failure a negative number be returned
 *  Description	: 	
 *  Comments	:  	
 ************************************************************************************************************/
static INT32 isp_probe(struct platform_device *pdev)
{

	FNRESLT ret_val;
	cam_data *cam;
/*
 * register the camera base pointer
 */

	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);
	}

	cam->pdev	= pdev;
	
/*
 * register the driver content into platform
 */
	platform_set_drvdata(pdev, cam);

/*
 * Have a device structure copy in the driver
 */
	cam->dev = &pdev->dev;


	return SUCCESS;
}
Esempio n. 4
0
static __init int cam_driver_init(void)
{
	int ret_val;
	cam_data *cam;

	printk(KERN_INFO "Driver Module info : "MODULE_NAME "\n");
	printk(KERN_INFO "Version info : "VERSION_NO "\n");
	
	cam = kmalloc(sizeof(cam_data), GFP_KERNEL);

	if (!cam) {
		printk(KERN_ERR "Mem alloc fail for camera device\n");
		return -ENOMEM;
	}

	memset(cam, 0, sizeof(cam_data));

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

	if (init_phy_mem())
		return -1;

	cam->omap3isp_driver.probe = isp_probe;
	cam->omap3isp_driver.remove = isp_remove;
	cam->omap3isp_driver.driver.name = "omap3isp";

	if (platform_driver_register(&cam->omap3isp_driver)) {
		printk(KERN_ALERT "platform_driver_register failed\n");
		return -1;
	}
		

	if (isp_probe_late_init(cam)) {
		platform_driver_unregister(&cam->omap3isp_driver);
		v4l2_base_struct(&cam, MAKE_ADDRESS_INVALID);
		return -1;
	}

	return 0;
}
Esempio n. 5
0
	INT32 omap_v4l2_close(struct inode *inode,struct file *file)
#endif
{
	INT32 err = 0;
	FNRESLT ret_val;

	cam_data *cam;

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

	if (cam	== NULL)
	{
		printk(KERN_ERR "Internal error, cam_data not found!\n");
		return -EBADF;
	}

	ret_val	= omap_v4l2_stream_off(cam,NULL);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}

	cam->cmd	= SET_DATA;
	cam->ctrl.id	= V4L2_SENS_FLASH_FLASH;
	cam->ctrl.value	= DISABLE;

	if(cam->cam_flash.flash)
	{
		ret_val = cam->cam_flash.flash(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			TRACE_ERR_AND_RET(ret_val);
		}
	}

	cam->cmd	= SET_DATA;
	cam->ctrl.id	= V4L2_SENS_FLASH_TORCH;
	cam->ctrl.value	= DISABLE;

	if(cam->cam_flash.flash)
	{
		ret_val = cam->cam_flash.torch(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			TRACE_ERR_AND_RET(ret_val);
		}
	}
	return err;
}
Esempio n. 6
0
static int isp_probe(struct platform_device *pdev)
{
	int ret_val;
	cam_data *cam;

	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);
	}

	cam->pdev = pdev;
	
	platform_set_drvdata(pdev, cam);

	cam->dev = &pdev->dev;

	return 0;
}
Esempio n. 7
0
	LINT32 omap_v4l2_do_ioctl(struct inode *inode, struct file *file,UINT32 ioctlnr,PINT0 arg)
#endif
{
	FNRESLT ret_val;
	cam_data *cam = NULL;

	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);		
	}
//	printk(KERN_ERR MODULE_NAME ": IOCTL Number is :%d\n",_IOC_NR(ioctlnr));

	switch (ioctlnr)
	{
		case VIDIOC_QUERYCAP:
		{
			struct v4l2_capability *cap = arg;
			ret_val = omap_v4l2_capability(cam,cap);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(FAIL);
			}	
	
		}break;

		case VIDIOC_S_FMT:
		{
			struct v4l2_format *sf = arg;
			ret_val = omap_v4l2_s_fmt(cam, sf);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(FAIL);
			}	
		}break;

		case VIDIOC_G_FMT:
		{
			struct v4l2_format *gf = arg;
			ret_val = omap_v4l2_g_fmt(cam, gf);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(FAIL);
			}	
		}break;

		case VIDIOC_G_CTRL:
		{
			cam->cmd	= GET_DATA;
			memcpy(&cam->ctrl,arg,sizeof(struct v4l2_control));

			ret_val	= omap_v4l2_ctrl(cam);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(FAIL);
			}
			memcpy(arg,&cam->ctrl,sizeof(struct v4l2_control));
		}break;

		case VIDIOC_S_CTRL:
		{
			cam->cmd	= SET_DATA;
			memcpy(&cam->ctrl,arg,sizeof(struct v4l2_control));

			ret_val	= omap_v4l2_ctrl(cam);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(FAIL);
			}
		}break;

		case VIDIOC_QUERYCTRL:
		{
			struct v4l2_queryctrl *qctrl	= arg;
			memset(&cam->qctrl,0x00,sizeof(struct v4l2_queryctrl));
			cam->cmd	= QUERY_DATA;

			cam->ctrl.id	= qctrl->id;
			
			ret_val	= omap_v4l2_ctrl(cam);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				cam->qctrl.flags	= V4L2_CTRL_FLAG_DISABLED;
				memcpy(qctrl,&cam->qctrl,sizeof(struct v4l2_queryctrl));
				TRACE_ERR_AND_RET(-EINVAL);
			}
			memcpy(qctrl,&cam->qctrl,sizeof(struct v4l2_queryctrl));
		}break;
//--------------------------------------------------------------------------------------------------
		case VIDIOC_REQBUFS:
		{
			ret_val	= omap_v4l2_req_buf(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_QUERYBUF:
		{
			ret_val	= omap_v4l2_query_buf(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_QBUF:
		{
			ret_val	= omap_v4l2_queue_buf(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_DQBUF:
		{
			ret_val	= omap_v4l2_dqueue_buf(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_STREAMON:
		{
			ret_val	= omap_v4l2_stream_on(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_STREAMOFF:
		{
			ret_val	= omap_v4l2_stream_off(cam, arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_ENUMINPUT:
		{
			struct v4l2_input *vinp_arg	= arg;
			if(vinp_arg->index	== 0)
			{
				strlcpy(cam->vinp.name, "camera", sizeof(cam->vinp.name));
				cam->vinp.type = V4L2_INPUT_TYPE_CAMERA;
				
				strlcpy(vinp_arg->name, "camera", sizeof(vinp_arg->name));
				vinp_arg->type = V4L2_INPUT_TYPE_CAMERA;

			}else
			{
				TRACE_ERR_AND_RET(-EINVAL);
			}
		}break;
		case VIDIOC_G_INPUT:
		{
			int *index	= arg;
			*index	= 0;
		}break;

		case VIDIOC_ENUM_FMT:
		{
			ret_val	= omap_v4l2_enum_fmt(cam,arg);
			if(CHECK_IN_FAIL_LIMIT(ret_val))
			{
				TRACE_ERR_AND_RET(ret_val);
			}

		}break;

		case VIDIOC_ENUMSTD:
		{
			TRACE_ERR_AND_RET(-EINVAL);
		}break;

		case VIDIOC_S_INPUT:
		{
			printk("FUNCTION %s FILE %s LINE %d\n",__func__,__FILE__,__LINE__);
		}break;

		case VIDIOC_G_STD:
		{
			v4l2_std_id *std	=  arg;
			*std	= V4L2_STD_PAL;
		}break;

		case VIDIOC_TRY_FMT:
		{
			struct v4l2_format *cam_try_fmt = arg;
			memcpy(&cam->cam_sensor.qfmt,cam_try_fmt,sizeof(struct v4l2_format));
			if(cam->cam_sensor.qfmt_support)
			{
				ret_val	= cam->cam_sensor.qfmt_support(cam);
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(ret_val);
				}
			}else
			{
				TRACE_ERR_AND_RET(FAIL);
			}
		}break;

		case VIDIOC_G_PARM:
		{
			struct v4l2_streamparm *s_parm	= arg;

#if defined(CONFIG_CTRL_FRAME_RATE_FRM_SENSOR)
			memcpy(&cam->cam_sensor.s_parm,s_parm,sizeof(struct v4l2_streamparm));
			cam->cmd	= GET_DATA;

			if(cam->cam_sensor.frame_rate_ctrl)
			{
				ret_val	= cam->cam_sensor.frame_rate_ctrl(cam);
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(ret_val);
				}

			}
#else
			if(s_parm->type	== V4L2_BUF_TYPE_VIDEO_CAPTURE)
			{
				/* do nothing */
			}
#endif
			else
			{
				TRACE_ERR_AND_RET(-EINVAL);
			}
#if defined (CONFIG_CTRL_FRAME_RATE_FRM_SENSOR)
			memcpy(s_parm,&cam->cam_sensor.s_parm,sizeof(struct v4l2_streamparm));
#else
			memcpy(s_parm,&cam->capture.s_parm,sizeof(struct v4l2_streamparm));
#endif
		}break;

		case VIDIOC_S_PARM:
		{
			struct v4l2_streamparm *s_parm	= arg;

#if defined(CONFIG_CTRL_FRAME_RATE_FRM_SENSOR)
			memcpy(&cam->cam_sensor.s_parm,s_parm,sizeof(struct v4l2_streamparm));
			cam->cmd	= SET_DATA;

			if(cam->cam_sensor.frame_rate_ctrl)
			{
				ret_val	= cam->cam_sensor.frame_rate_ctrl(cam);
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(ret_val);
				}
			}
#else
			memcpy(&cam->capture.s_parm,s_parm,sizeof(struct v4l2_streamparm));
			if(cam->capture.s_parm.type	!= V4L2_BUF_TYPE_VIDEO_CAPTURE)
			{
				TRACE_ERR_AND_RET(-EINVAL);
			}

			if (cam->capture.s_parm.parm.capture.timeperframe.denominator > SENS_MAX_FPS)
			{
				cam->capture.s_parm.parm.capture.timeperframe.denominator	= SENS_MAX_FPS;
			}			

#endif			
		}break;

		case VIDIOC_ENUM_FRAMESIZES:
		{
			cam->cmd	= GET_DATA;
			cam->cam_sensor.fmt_frm_user	= arg;

			if(cam->cam_sensor.supported_formats)
			{
				ret_val	= cam->cam_sensor.supported_formats(cam);
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(ret_val);
				}
			}else
			{
				TRACE_ERR_AND_RET(-EINVAL);
			}
		}break;

		case VIDIOC_ENUM_FRAMEINTERVALS:
		{
			cam->cmd		= GET_DATA;
			cam->cam_sensor.frame_interval_frm_user	= arg;

			if(cam->cam_sensor.frame_interval)
			{
				ret_val	= cam->cam_sensor.frame_interval(cam);
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(ret_val);
				}

			}else
			{
				TRACE_ERR_AND_RET(-EINVAL);
			}
		}break;

#if 0

		case VIDIOC_CROPCAP:
		{
///			struct v4l2_cropcap *crp_cap;
			printk("FUNCTION %s FILE %s LINE %d\n",__func__,__FILE__,__LINE__);
		}break;

		case VIDIOC_S_CROP:
		{
			printk("FUNCTION %s FILE %s LINE %d\n",__func__,__FILE__,__LINE__);
		}break;

		case VIDIOC_G_CROP:
		{
			printk("FUNCTION %s FILE %s LINE %d\n",__func__,__FILE__,__LINE__);
		}break;

		case VIDIOC_S_STD:
		{
			printk("FUNCTION %s FILE %s LINE %d\n",__func__,__FILE__,__LINE__);
		}break;

#endif		
//--------------------------------------------------------------------------------------------------
		default:
		{
			printk(KERN_ERR MODULE_NAME "Ioctl currently not implemented IOCTL Number is :%d\n",_IOC_NR(ioctlnr));
			TRACE_ERR_AND_RET(-EINVAL);
		}
	}
	return SUCCESS;

}
Esempio n. 8
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;
	}
}
Esempio n. 9
0
static __init INT32 cam_driver_init(INT0)
{
#if (CONFIG_USE_TI_RESIZER == DISABLE)
	INT32 plat_ret;
#endif
	FNRESLT ret_val;

	cam_data *cam	= NULL;
/*
 * Print the Tracking information of application
 */

	printk(KERN_INFO "-------------------------------------------------\n");
	printk(KERN_INFO "PRODUCT_NAME       : %s\n", PRODUCT_NAME);
	printk(KERN_INFO "SVN_REVISION       : %s\n", SVN_REVISION);
	printk(KERN_INFO "SVN_DATE           : %s\n", SVN_DATE);
	printk(KERN_INFO "SVN_TIME           : %s\n", SVN_TIME);
	printk(KERN_INFO "THS_VERSIONID      : %s\n", THS_VERSION_ID);
	printk(KERN_INFO "Driver Module info : "MODULE_NAME"\n");
	printk(KERN_INFO "Build Time stamp   : "__TIMESTAMP__"\n");
	printk(KERN_INFO "-------------------------------------------------\n");

	if ((cam = kmalloc(sizeof(cam_data), GFP_KERNEL)) == NULL)
	{
		printk(KERN_ERR "Failed to allocate memory to register the camera device\n");
		TRACE_ERR_AND_RET(FAIL);
	}
/*
 * Clear the memory 
 */
	memset(cam, 0, sizeof(cam_data));

	ret_val	= v4l2_base_struct(&cam,SET_ADDRESS);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to register the camera device\n");
		TRACE_ERR_AND_RET(FAIL);
	}
/*
 * init the reserved memory for camera 
 */

	ret_val	= init_phy_mem();
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}

#if (CONFIG_USE_TI_RESIZER == DISABLE)
	cam->omap3isp_driver.probe		= isp_probe;
	cam->omap3isp_driver.remove		= isp_remove;
	cam->omap3isp_driver.driver.name	= "omap3isp";

	plat_ret = platform_driver_register(&cam->omap3isp_driver);
	if (plat_ret)
	{
		TRACE_ERR_AND_RET(plat_ret);
	}
#endif
	ret_val	= isp_probe_late_init(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		goto exit;
	}
	return SUCCESS;

	exit:
	{
		platform_driver_unregister(&cam->omap3isp_driver);
		
		ret_val	= v4l2_base_struct(&cam,MAKE_ADDRESS_INVALID);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			printk(KERN_ERR "Failed to register the camera device\n");
			TRACE_ERR_AND_RET(FAIL);
		}
		TRACE_ERR_AND_RET(FAIL);
	}
}
Esempio n. 10
0
FNRESLT isp_probe_late_init(cam_data *cam)
{
	FNRESLT ret_val;
	INT32 ret;

/*
 * initialize the camera structre
 */

	ret_val	= init_v4l2_base_struct(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to initialize camera device\n");
		TRACE_ERR_AND_RET(FAIL);
	}
/*
 * Get the platform resource
 */
#if (CONFIG_USE_TI_RESIZER == DISABLE)
	ret_val	= init_plat_res(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}
#endif
	ret_val	= init_plat_irq(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}
/*
 * TODO: initialize the hardware 
 *
 */
/*
 * initialize the camera structure
 */
	ret_val	= init_cam_struct(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}
/*
 * Configure the camera interface lines
 */

	ret_val	= init_hwr_clock(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}

	ret_val	= all_clk_enable(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}

	ret_val	= init_omap_hwr(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to initialize omap hardware device\n");
		TRACE_ERR_AND_RET(ret_val);
	}
/*
 * 	initialize the sensor 
 */

	ret_val	= register_sensor_bus(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}

	if(cam->cam_sensor.init)
	{
		ret_val	= cam->cam_sensor.init(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			return ret_val;
		}
	}

/*
 * register the flash driver
 */
	ret_val	= register_flash_driver(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		return ret_val;
	}

	if(cam->cam_flash.init)
	{
		ret_val	= cam->cam_flash.init(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			return ret_val;
		}
	}
/*
 * register the video device
 */
	ret	= video_register_device(cam->video_dev, VFL_TYPE_GRABBER, video_nr);
	if (ret	== FAIL)
	{
		video_device_release(cam->video_dev);
		cam->video_dev	= NULL;

		v4l2_base_struct(&cam,MAKE_ADDRESS_INVALID);
		printk(KERN_ERR "video_register_device failed\n");
		TRACE_ERR_AND_RET(ret_val);
	}
	return SUCCESS;
}
Esempio n. 11
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	flash_i2c_client_xfer
 *  Parameter1	:	INT32 addr
 *  Parameter2	:	UPINT8 reg
 *  Parameter3	:	PINT8 buf
 *  Parameter4	:	INT32 num
 *  Parameter5	:	INT32 tran_flag
 *  Returns	:	FNRESLT		- On Success Zero (or) positive value be returned to the calling
 *  					  Functions and On error a negative value be returned
 *
 *  					  Note: 
 *  					  	For more detail about the return values please refer
 *  					  error.c and error.h file available in the current project
 *  Description	: 	
 *  Comments	:  	
 ************************************************************************************************************/
FNRESLT flash_i2c_client_xfer(INT32 addr, UPINT8 reg, PINT8 buf, INT32 num, INT32 tran_flag)
{

	struct i2c_msg msg[2];
	FNRESLT ret_val;
	INT32 ret;
	cam_data *cam	= NULL;

	ret_val	= v4l2_base_struct(&cam,GET_ADDRESS);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(FAIL);	
	}

/*
 * FIXME:
 * 	
 * 	I2C Write:
 *	 	In i2c msg[0] "address part in write is success" but if we put data in msg [1] 
 * 		that is not properly sent to device.
 *
 * 		so in the msg[0] part itself the data also sent here.
 *
 * 	I2CRead:
 * 		But in read No problem is found and working fine
 */

	if(tran_flag & I2C_FLAG_READ)
	{

		msg[0].addr	= addr;
		msg[0].len	= 1;
		msg[0].buf	= reg;
		msg[0].flags	= tran_flag;
		msg[0].flags	&= ~I2C_M_RD;

		msg[1].addr	= addr;
		msg[1].len	= num;
		msg[1].buf	= buf;
		msg[1].flags	= tran_flag;

		if (tran_flag & I2C_FLAG_READ)
		{
			msg[1].flags |= I2C_M_RD;
		}else
		{
			msg[1].flags &= ~I2C_M_RD;
		}

		if (cam->cam_flash.client->adapter == NULL)
		{
			printk("%s:adapter error\n", __func__);
			return -1;
		}

		ret = i2c_transfer(cam->cam_flash.client->adapter, msg, 2);
		if (ret >= 0)
		{
			/* printk("%s:i2c transfer num:%d\n", __func__, ret); */
			return SUCCESS;
		}

	}else
	{
		UINT8 reg_addr_data[2];
		
		reg_addr_data[0] = *reg;
		reg_addr_data[1] = *buf;
		
		msg[0].addr	= addr;
		msg[0].len	= 2;
		msg[0].buf	= reg_addr_data;
		msg[0].flags	= tran_flag;
		msg[0].flags	&= ~I2C_M_RD;

		ret = i2c_transfer(cam->cam_flash.client->adapter, msg, 1);
		if (ret >= 0)
		{
			/* printk("%s:i2c transfer num:%d\n", __func__, ret); */
			return SUCCESS;
		}
	}
	printk("%s:i2c transfer error:%d\n", __func__, ret);
	return FAIL;

}
Esempio n. 12
0
static int isp_probe_late_init(cam_data *cam)
{
	int ret_val;
	int ret;

	ret_val	= init_v4l2_base_struct(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		printk(KERN_ERR "Failed to initialize camera device\n");
		return -1;
	}

	if (!cam)
		return -1;

	if (init_plat_res(cam))
		return -1;

	if (init_plat_irq(cam))
		return -1;

	init_cam_struct(cam);

	if (init_hwr_clock(cam))
		return -1;

	if (all_clk_enable(cam))
		return -1;


	if (init_omap_hwr(cam)) {
		printk(KERN_ERR "Failed to initialize omap hardware device\n");
		return -1;
	}

	ret_val	= register_sensor_bus(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		TRACE_ERR_AND_RET(ret_val);
	}

	if(cam->cam_sensor.init)
	{
		ret_val	= cam->cam_sensor.init(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			return ret_val;
		}
	}

#if defined(CONFIG_HAVE_LED_FLASH)
	ret_val	= register_flash_driver(cam);
	if(CHECK_IN_FAIL_LIMIT(ret_val))
	{
		return ret_val;
	}
#endif
	if(cam->cam_flash.init)
	{
		ret_val	= cam->cam_flash.init(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			return ret_val;
		}
	}

	ret = video_register_device(cam->video_dev, VFL_TYPE_GRABBER, video_nr);
	if (ret	== FAIL)
	{
		video_device_release(cam->video_dev);
		cam->video_dev	= NULL;

		v4l2_base_struct(&cam, MAKE_ADDRESS_INVALID);
		printk(KERN_ERR "video_register_device failed\n");
		TRACE_ERR_AND_RET(ret_val);
	}
	return SUCCESS;
}