Пример #1
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	init_plat_res
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 init_plat_res(cam_data *cam)
{
/*
 * Allocate the memory region in the isp
 */

	if(cam->pdev == NULL)
	{
		TRACE_ERR_AND_RET(FAIL);
	}
		
	cam->mem = platform_get_resource(cam->pdev, IORESOURCE_MEM, 0);
	if (!cam->mem)
	{
		TRACE_ERR_AND_RET(FAIL);
	}
/*
 * FIXME :
 * 	Unable to request the memory region
 */
#if 0
	if (!request_mem_region(cam->mem->start, MAP_ISP_REGION,cam->pdev->name))
	{
		TRACE_ERR_AND_RET(FAIL);
	}
#endif
	/* map the region */
	cam->isp = (isp_reg_bit_access*)ioremap_nocache(cam->mem->start,MAP_ISP_REGION);
	if (cam->isp	== NULL)
	{
		TRACE_ERR_AND_RET(FAIL);
	}
	
	return SUCCESS;
}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	stcf03_flash
 *  Parameter1	:	cam_data *cam
 *  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 stcf03_flash(cam_data *cam)
{
	FNRESLT ret_val;
	switch(cam->cmd)
	{
		case GET_DATA:
		{
			cam->ctrl.value	= cam->cam_sensor.sens_strobe_en;
		}break;

		case SET_DATA:
		{
			if((cam->ctrl.value >= 0) && (cam->ctrl.value <= 1))
			{
				if(cam->ctrl.value)
				{
/*
 * Flash (or) Torch can be enabled, So proper routine to disable torch
 */
					cam->cmd	= SET_DATA;
					cam->ctrl.value	= DISABLE;
					ret_val = cam->cam_flash.torch(cam);
					if(CHECK_IN_FAIL_LIMIT(ret_val))
					{
						TRACE_ERR_AND_RET(FAIL);
					}

					cam->cam_sensor.sens_strobe_en	= ENABLE;
					ret_val = stcf03_write(0x00,0xCF);
					if(CHECK_IN_FAIL_LIMIT(ret_val))
					{
						TRACE_ERR_AND_RET(FAIL);
					}
				}else
				{
					cam->cam_sensor.sens_strobe_en	= DISABLE;
				}
			}
		}break;

		case QUERY_DATA:
		{
			cam->qctrl.id	= V4L2_SENS_FLASH_FLASH;
			cam->qctrl.type	= V4L2_CTRL_TYPE_BOOLEAN;
			strncpy(cam->qctrl.name,"flash ctrl",strlen("flash ctrl"));
			cam->qctrl.minimum = 0;
			cam->qctrl.maximum = 1;
			cam->qctrl.step = 1;
			cam->qctrl.default_value = 0;
		}break;
	}
	return SUCCESS;
}
Пример #5
0
/************************************************************************************************************
 *
 *  MODULE TYPE	:	FUNCTION				MODULE ID	: OMAP_CAM_INTERFACE_01
 *  Name	:	omap_pin_base_struct
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  Parameter2	:	UINT8 option	- command to the current function to perfom the mentioned task.
 *  						CREATE_ADDRESS
 *						SET_ADDRESS
 *						GET_ADDRESS
 *						MAKE_ADDRESS_INVALID
 *
 *  Returns	:	FNRESLT		- On Success Zero (or) positive value be returned to the calling
 *  					  Functions and On error a negative error be returned
 *
 *  					  Note:
 *  					  	For more detail about the return values please refer
 *  					  error.c and error.h file available in the current project
 *
 *  Description	: 	stores the omap pin base structure pointer
 *  			and returns the base pointer when a request of GET_ADDRESS
 *  			command be obtained from the calling functions
 *  Comments	:
 ************************************************************************************************************/
FNRESLT omap_pin_base_struct(cam_data *cam,UINT8 option)
{
    static UINT32 g_cam_interface;

    if(cam == NULL)
    {
        TRACE_ERR_AND_RET(MEMORY_NOT_VALID);
    }
    switch(option)
    {
    case SET_ADDRESS:
    {
        g_cam_interface =(UINT32)cam->pin;
    }
    break;

    case GET_ADDRESS:
    {
        cam->pin	= (cam_interface_pin_config*)g_cam_interface;
    }
    break;

    case MAKE_ADDRESS_INVALID:
    {
        if(cam->pin	== NULL)
        {
            TRACE_ERR_AND_RET(FAIL);
        }
        iounmap(cam->pin);
        cam->pin	= NULL;
        g_cam_interface	= DISABLE;
    }
    break;
    case CREATE_ADDRESS:
    {
        cam->pin	= ioremap(REG_CONTROL_PADCONF_CAM_HS,4*1024);
        if(cam->pin	== NULL)
        {
            printk(KERN_ERR "Unable to remap the padconfig registers\n");
            TRACE_ERR_AND_RET(FAIL);
        }
    }
    break;
    default:
    {
        TRACE_ERR_AND_RET(FAIL);
    }
    }
    return SUCCESS;
}
Пример #6
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;
}
Пример #7
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;
	}	
}
Пример #8
0
static int init_plat_res(cam_data *cam)
{
	/* Allocate the memory region in the isp */
	if (!cam->pdev) {
		printk(KERN_ALERT "init_plat_res: cam->pdev is NULL\n");
		return -1;
	}
		
	cam->mem = platform_get_resource(cam->pdev, IORESOURCE_MEM, 0);

	if (!cam->mem) {
		printk(KERN_ALERT "init_plat_res: fail get IORESOURCE_MEM\n");
		return -1;
	} 

	/* FIXME : Unable to request the memory region */
#if 0
	if (!request_mem_region(cam->mem->start, MAP_ISP_REGION,
				cam->pdev->name))
	{
		TRACE_ERR_AND_RET(FAIL);
	}
#endif

	cam->isp = (isp_reg_bit_access*)ioremap_nocache(cam->mem->start, 
							MAP_ISP_REGION);
	
	if (!cam->isp) {
		printk(KERN_ALERT "init_plat_res: ioremap failed\n");
		return -1;
	}
	
	return 0;
}
Пример #9
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	init_cam_struct
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 init_cam_struct(cam_data *cam)
{
	if(cam == NULL)
	{
		TRACE_ERR_AND_RET(FAIL);
	}

	
	cam->capture.v2f.fmt.pix.width		= SENS_DEFAULT_WIDTH;
	cam->capture.v2f.fmt.pix.height		= SENS_DEFAULT_HEIGHT;
	cam->capture.v2f.type			= V4L2_BUF_TYPE_VIDEO_CAPTURE;
	cam->capture.v2f.fmt.pix.pixelformat	= V4L2_PIX_FMT_UYVY;

/*
 * init S_PARM type
 */
	cam->capture.s_parm.type		= V4L2_BUF_TYPE_VIDEO_CAPTURE;

/*
 * init the wait queue
 */

	init_waitqueue_head(&cam->still.dma_frame_complete_still);
	init_waitqueue_head(&cam->capture.capture_frame_complete);	
	
	return SUCCESS;
}
Пример #10
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	init_plat_irq
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 init_plat_irq(cam_data *cam)
{
#if (CONFIG_USE_TI_RESIZER == DISABLE)
	cam->irq	= platform_get_irq(cam->pdev, 0);
	if (cam->irq <= 0)
	{
		TRACE_ERR_AND_RET(FAIL);
	}
#endif
	cam->irq	= INT_34XX_CAM_IRQ;
	if (request_irq(cam->irq, omap34xx_isp_isr, IRQF_SHARED,
				"e-cam camera isp",cam))
	{
		TRACE_ERR_AND_RET(FAIL);
	}

	return SUCCESS;
}
Пример #11
0
/************************************************************************************************************
 *
 *  MODULE TYPE	:	FUNCTION				MODULE ID	: OMAP_CAM_INTERFACE_04
 *  Name	:	exit_cam_interface
 *  Parameter1	:	INT0
 *  Returns	:	FNRESLT		- On Success Zero (or) positive value be returned to the calling
 *  					  Functions and On error a negative error be returned
 *  					  Note: For more detail about the return values please refer
 *  					  error.c and error.h file available in the current project
 *  Description	: 	exit part of code in the camera interface configuration.
 *  Comments	:  	Each .c code have init and exit functions calling the init_xxx will initlize the
 *  			the local variables and structure variable in the main structure.
 *
 ************************************************************************************************************/
FNRESLT exit_cam_interface(cam_data *cam)
{
    FNRESLT ret_val;
    /*
     * Validate the input
     */
    if(cam == NULL)
    {
        TRACE_ERR_AND_RET(FAIL);
    }

    ret_val	= omap_pin_base_struct(cam,MAKE_ADDRESS_INVALID);
    if(CHECK_IN_FAIL_LIMIT(ret_val))
    {
        printk(KERN_ERR "Failed to unmap the camera interface registers\n");
        TRACE_ERR_AND_RET(FAIL);
    }
    return SUCCESS;
}
Пример #12
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	v4l2_base_struct
 *  Parameter1	:	cam_data **cam	- pointer need to register
 *  Parameter2	:	unsigned char option	- set or get the address
 *  Returns	:	int		- 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	:  	
 ************************************************************************************************************/
int v4l2_base_struct(cam_data **cam,unsigned char option)
{

/*
 * SET_ADDRESS 
 * GET_ADDRESS 
 * MAKE_ADDRESS_INVALID
 */
	static unsigned int g_cam_st_addr;

	if(cam == NULL)
	{
		TRACE_ERROR(MEMORY_NOT_VALID);	
		return MEMORY_NOT_VALID;
	}

	if(option == SET_ADDRESS)
	{
		g_cam_st_addr =(unsigned int)*cam;
	}else if(option == GET_ADDRESS)
	{
		if(g_cam_st_addr)
		{
			*cam	= (cam_data *)g_cam_st_addr;
		}else
		{
			TRACE_ERR_AND_RET(FAIL);
		}
	}else if(option == MAKE_ADDRESS_INVALID)
	{
		g_cam_st_addr =0;
		kfree(*cam);
	}else
	{
		TRACE_ERR_AND_RET(FAIL);
	}
		
	return SUCCESS;
}
Пример #13
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	stcf03_init
 *  Parameter1	:	cam_data *cam
 *  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 stcf03_init(cam_data *cam)
{
	FNRESLT ret_val;
/*
 * i2c driver init
 */
	static const struct i2c_device_id stcf03_id[] =			\
	{
		{ STCF03_DRIVER_NAME, 0 },
		{ },
	};
	MODULE_DEVICE_TABLE(i2c, stcf03_id);
	
	cam->cam_flash.i2c.driver.name	= STCF03_DRIVER_NAME;
	cam->cam_flash.i2c.driver.owner	= THIS_MODULE;
	cam->cam_flash.i2c.probe	= stcf03_probe;
	cam->cam_flash.i2c.remove	= __exit_p(stcf03_remove);
	cam->cam_flash.i2c.id_table	= stcf03_id;

	if(i2c_add_driver(&cam->cam_flash.i2c))
	{
		TRACE_ERR_AND_RET(FAIL);
	}

	if(cam->cam_flash.client	== NULL)
	{
		ret_val	= cam->cam_flash.exit(cam);
		if(CHECK_IN_FAIL_LIMIT(ret_val))
		{
			TRACE_ERR_AND_RET(FAIL);
		}
		return SUCCESS;
	}

	return SUCCESS;
}
Пример #14
0
/************************************************************************************************************
 *
 *  MODULE TYPE	:	FUNCTION				MODULE ID	: OMAP_CAM_INTERFACE_03
 *  Name	:	init_cam_interface
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  Returns	:	FNRESLT		- On Success Zero (or) positive value be returned to the calling
 *  					  Functions and On error a negative error be returned
 *
 *  					  Note:
 *  					  	For more detail about the return values please refer
 *  					  error.c and error.h file available in the current project
 *
 *  Description	: 	init the camera interface configuration.
 *  Comments	:  	Each .c code have init and exit functions calling the init_xxx will initlize the
 *  			the local variables and structure variable in the main structure.
 ************************************************************************************************************/
FNRESLT init_cam_interface(cam_data *cam)
{
    FNRESLT ret_val;
    /*
     * Validate the input
     */
    if(cam == NULL)
    {
        TRACE_ERR_AND_RET(FAIL);
    }

    ret_val	= omap_pin_base_struct(cam,CREATE_ADDRESS);
    if(CHECK_IN_FAIL_LIMIT(ret_val))
    {
        printk(KERN_ERR "Failed to map the camera interface registers\n");
        TRACE_ERR_AND_RET(FAIL);
    }

    ret_val	= omap_pin_base_struct(cam,SET_ADDRESS);
    if(CHECK_IN_FAIL_LIMIT(ret_val))
    {
        printk(KERN_ERR "Failed to map the camera interface registers\n");
        TRACE_ERR_AND_RET(FAIL);
    }
    /*
     * Configured the camera interface
     */
    ret_val	= configure_cam_interface(cam);
    if(CHECK_IN_FAIL_LIMIT(ret_val))
    {
        printk(KERN_ERR "Failed to map the camera interface registers\n");
        TRACE_ERR_AND_RET(FAIL);
    }

    return SUCCESS;
}
Пример #15
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	init_v4l2_base_struct	
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  Parameter2	:	
 *  Returns	:	int		- 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	:  	
 ************************************************************************************************************/
int init_v4l2_base_struct(cam_data *cam)
{

	static struct v4l2_file_operations omap_v4l_fops = 	\
	{
		.owner		= THIS_MODULE,
		.ioctl		= omap_v4l2_ioctl,
//		.poll		= ,
		.mmap		= omap_mmap,
		.open		= omap_v4l2_open,
		.release	= omap_v4l2_close,
		.read		= omap_v4l2_read,

	};

	static struct video_device omap_v4l_template =		\
	{
		.minor		= -1,
		.fops		= &omap_v4l_fops,
		.ioctl_ops	= NULL,

		.name		= "omap camera",
//		.type		= 0,
//		.type2		= VID_TYPE_CAPTURE,
		.release	= video_device_release,
	};

	if(cam == NULL)
	{
		TRACE_ERR_AND_RET(FAIL);
	}

	cam->video_dev		= video_device_alloc();
	if (cam->video_dev == NULL)
	{
		return ALLOCATION_MEMORY_FAILED;
	}

	*(cam->video_dev)	= omap_v4l_template;
	video_set_drvdata(cam->video_dev, cam);
	cam->video_dev->minor	= -1;


	return SUCCESS;
}
Пример #16
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;
}
Пример #17
0
FNRESLT cam_free_pages(UINT32 addr, UINT32 bufsize)
{
        UINT32 size, ad = addr;

        size = PAGE_SIZE << (get_order(bufsize));
        if (!addr)
	{
                TRACE_ERR_AND_RET(FAIL);
	}

        while (size > 0)
	{
                ClearPageReserved(virt_to_page(addr));
                addr += PAGE_SIZE;
                size -= PAGE_SIZE;
        }

        free_pages(ad, get_order(bufsize));
	return SUCCESS;
}
Пример #18
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;
}
Пример #19
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	
 *  Name	:	stcf03_lum_ctrl
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 stcf03_flash_lum_ctrl(cam_data *cam)
{
	FNRESLT ret_val;
	switch(cam->cmd)
	{
		case GET_DATA:
		{
			cam->ctrl.value	= flash_lum_value;
		}break;

		case SET_DATA:
		{
			if((cam->ctrl.value >= 0) && (cam->ctrl.value <= 15))
			{
				ret_val	= stcf03_write(0x01,(0xF0 & torch_lum_value) | (0xF & cam->ctrl.value));
				if(CHECK_IN_FAIL_LIMIT(ret_val))
				{
					TRACE_ERR_AND_RET(FAIL);
				}
				flash_lum_value	= cam->ctrl.value;
			}

		}break;

		case QUERY_DATA:
		{
			cam->qctrl.id	= V4L2_SENS_FLASH_FLASH_LUM;
			cam->qctrl.type	= V4L2_CTRL_TYPE_INTEGER;
			strncpy(cam->qctrl.name,"flash lum ctrl",strlen("flash lum ctrl"));
			cam->qctrl.minimum = 0;
			cam->qctrl.maximum = 15;
			cam->qctrl.step = 1;
			cam->qctrl.default_value = 0;
			cam->qctrl.flags = V4L2_CTRL_FLAG_SLIDER;
		}break;
	}
	return SUCCESS;
}
Пример #20
0
/************************************************************************************************************
 *
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_CAM_INTERFACE_02
 *  Name	:	configure_cam_interface
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  Returns	:	FNRESLT		- On Success Zero (or) positive value be returned to the calling
 *  					  Functions and On error a negative error be returned
 *
 *  					  Note:
 *  					  	For more detail about the return values please refer
 *  					  error.c and error.h file available in the current project
 *
 *  Description	:	Confgure the interface lines between sensor and ccdc unit as camera interface lines
 *  Comments	:
 ************************************************************************************************************/
FNRESLT configure_cam_interface(cam_data *cam)
{
    /*
     * Validate the input
     */
    if(cam == NULL || cam->pin == NULL)
    {
        TRACE_ERR_AND_RET(FAIL);
    }
    /*
     * perform operation
     */
    cam->pin->bit_hs_vs.bit.cam_hs.MUXMODE				= DISABLE;
    cam->pin->bit_hs_vs.bit.cam_hs.INPUTENABLE			= ENABLE;
    cam->pin->bit_hs_vs.bit.cam_hs.PULLUDENABLE			= ENABLE;
    cam->pin->bit_hs_vs.bit.cam_hs.PULLTYPESELECT			= ENABLE;

    cam->pin->bit_hs_vs.bit.cam_vs.MUXMODE				= DISABLE;
    cam->pin->bit_hs_vs.bit.cam_vs.INPUTENABLE			= ENABLE;
    cam->pin->bit_hs_vs.bit.cam_vs.PULLUDENABLE			= ENABLE;
    cam->pin->bit_hs_vs.bit.cam_vs.PULLTYPESELECT			= ENABLE;

    cam->pin->bit_xclka_pclk.bit.cam_xclka.MUXMODE			= DISABLE;
    cam->pin->bit_xclka_pclk.bit.cam_xclka.INPUTENABLE		= ENABLE;
    cam->pin->bit_xclka_pclk.bit.cam_xclka.PULLUDENABLE		= DISABLE;
    cam->pin->bit_xclka_pclk.bit.cam_xclka.PULLTYPESELECT		= DISABLE;

    cam->pin->bit_xclka_pclk.bit.cam_pclk.MUXMODE			= DISABLE;
    cam->pin->bit_xclka_pclk.bit.cam_pclk.INPUTENABLE		= ENABLE;
    cam->pin->bit_xclka_pclk.bit.cam_pclk.PULLUDENABLE		= ENABLE;
    cam->pin->bit_xclka_pclk.bit.cam_pclk.PULLTYPESELECT		= ENABLE;

    cam->pin->bit_fld_d0.bit.cam_d0.MUXMODE				= DISABLE;
    cam->pin->bit_fld_d0.bit.cam_d0.INPUTENABLE			= ENABLE;
    cam->pin->bit_fld_d0.bit.cam_d0.PULLUDENABLE			= DISABLE;
    cam->pin->bit_fld_d0.bit.cam_d0.PULLTYPESELECT			= DISABLE;


    cam->pin->bit_d1_d2.bit.cam_d1.MUXMODE				= DISABLE;
    cam->pin->bit_d1_d2.bit.cam_d1.INPUTENABLE			= ENABLE;
    cam->pin->bit_d1_d2.bit.cam_d1.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d1_d2.bit.cam_d1.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d1_d2.bit.cam_d2.MUXMODE				= DISABLE;
    cam->pin->bit_d1_d2.bit.cam_d2.INPUTENABLE			= ENABLE;
    cam->pin->bit_d1_d2.bit.cam_d2.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d1_d2.bit.cam_d2.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d3_d4.bit.cam_d3.MUXMODE				= DISABLE;
    cam->pin->bit_d3_d4.bit.cam_d3.INPUTENABLE			= ENABLE;
    cam->pin->bit_d3_d4.bit.cam_d3.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d3_d4.bit.cam_d3.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d3_d4.bit.cam_d4.MUXMODE				= DISABLE;
    cam->pin->bit_d3_d4.bit.cam_d4.INPUTENABLE			= ENABLE;
    cam->pin->bit_d3_d4.bit.cam_d4.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d3_d4.bit.cam_d4.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d5_d6.bit.cam_d5.MUXMODE				= DISABLE;
    cam->pin->bit_d5_d6.bit.cam_d5.INPUTENABLE			= ENABLE;
    cam->pin->bit_d5_d6.bit.cam_d5.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d5_d6.bit.cam_d5.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d5_d6.bit.cam_d6.MUXMODE				= DISABLE;
    cam->pin->bit_d5_d6.bit.cam_d6.INPUTENABLE			= ENABLE;
    cam->pin->bit_d5_d6.bit.cam_d6.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d5_d6.bit.cam_d6.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d7_d8.bit.cam_d7.MUXMODE				= DISABLE;
    cam->pin->bit_d7_d8.bit.cam_d7.INPUTENABLE			= ENABLE;
    cam->pin->bit_d7_d8.bit.cam_d7.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d7_d8.bit.cam_d7.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d7_d8.bit.cam_d8.MUXMODE				= DISABLE;
    cam->pin->bit_d7_d8.bit.cam_d8.INPUTENABLE			= ENABLE;
    cam->pin->bit_d7_d8.bit.cam_d8.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d7_d8.bit.cam_d8.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d9_d10.bit.cam_d9.MUXMODE				= DISABLE;
    cam->pin->bit_d9_d10.bit.cam_d9.INPUTENABLE			= ENABLE;
    cam->pin->bit_d9_d10.bit.cam_d9.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d9_d10.bit.cam_d9.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d9_d10.bit.cam_d10.MUXMODE			= DISABLE;
    cam->pin->bit_d9_d10.bit.cam_d10.INPUTENABLE			= ENABLE;
    cam->pin->bit_d9_d10.bit.cam_d10.PULLUDENABLE			= DISABLE;
    cam->pin->bit_d9_d10.bit.cam_d10.PULLTYPESELECT			= DISABLE;

    cam->pin->bit_d11_xclkb.bit.cam_d11.MUXMODE			= DISABLE;
    cam->pin->bit_d11_xclkb.bit.cam_d11.INPUTENABLE			= ENABLE;
    cam->pin->bit_d11_xclkb.bit.cam_d11.PULLUDENABLE		= DISABLE;
    cam->pin->bit_d11_xclkb.bit.cam_d11.PULLTYPESELECT		= DISABLE;

    cam->pin->bit_d11_xclkb.bit.cam_xclkb.MUXMODE			= DISABLE;
    cam->pin->bit_d11_xclkb.bit.cam_xclkb.INPUTENABLE		= ENABLE;
    cam->pin->bit_d11_xclkb.bit.cam_xclkb.PULLUDENABLE		= DISABLE;
    cam->pin->bit_d11_xclkb.bit.cam_xclkb.PULLTYPESELECT		= DISABLE;
    /*
     * Reset
     */
    cam->pin->bit_fld_d0.bit.cam_fld.MUXMODE			= 4;
    cam->pin->bit_fld_d0.bit.cam_fld.INPUTENABLE			= DISABLE;
    cam->pin->bit_fld_d0.bit.cam_fld.PULLUDENABLE			= DISABLE;
    cam->pin->bit_fld_d0.bit.cam_fld.PULLTYPESELECT			= DISABLE;

    /*
     * power down
     */
#if (STANDBY_GPIO == 167)
    /*
     * GPIO 167
     */
    cam->pin->bit_wen_strobe.bit.cam_wen.MUXMODE			= 4;
    cam->pin->bit_wen_strobe.bit.cam_wen.INPUTENABLE		= DISABLE;
    cam->pin->bit_wen_strobe.bit.cam_wen.PULLUDENABLE		= DISABLE;
    cam->pin->bit_wen_strobe.bit.cam_wen.PULLTYPESELECT		= DISABLE;
#elif (STANDBY_GPIO == 157)
    /*
     * GPIO 157
     */
    cam->pin->bit_cklr.bit.mcbsp1_fsr.MUXMODE			= 4;
    cam->pin->bit_cklr.bit.mcbsp1_fsr.INPUTENABLE			= DISABLE;
    cam->pin->bit_cklr.bit.mcbsp1_fsr.PULLUDENABLE			= DISABLE;
    cam->pin->bit_cklr.bit.mcbsp1_fsr.PULLTYPESELECT		= DISABLE;
#endif
    /*
     * I2C
     */
    cam->pin->bit_i2c2_i2c3.bit.i2c3_scl.MUXMODE			= DISABLE;
    cam->pin->bit_i2c2_i2c3.bit.i2c3_scl.INPUTENABLE		= ENABLE;
    cam->pin->bit_i2c2_i2c3.bit.i2c3_scl.PULLUDENABLE		= ENABLE;
    cam->pin->bit_i2c2_i2c3.bit.i2c3_scl.PULLTYPESELECT		= ENABLE;

    cam->pin->bit_i2c3_hdq_sio.bit.i2c3_sda.MUXMODE			= DISABLE;
    cam->pin->bit_i2c3_hdq_sio.bit.i2c3_sda.INPUTENABLE		= ENABLE;
    cam->pin->bit_i2c3_hdq_sio.bit.i2c3_sda.PULLUDENABLE		= ENABLE;
    cam->pin->bit_i2c3_hdq_sio.bit.i2c3_sda.PULLTYPESELECT		= ENABLE;
    return SUCCESS;
}
Пример #21
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;
}
Пример #22
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;

}
Пример #23
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;
	}
}
Пример #24
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);
	}
}
Пример #25
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;
}
Пример #26
0
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	init_hwr_clock
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 init_hwr_clock(cam_data *cam)
{
	struct device_driver camera_drv =	\
	{
		.name = "camera"
	};

	struct device camera_dev = 		\
	{
		.driver = &camera_drv,
	};
	
	cam->cam_ick = clk_get(&camera_dev, "cam_ick");
	if (IS_ERR(cam->cam_ick))
	{
//		ret_err = PTR_ERR(isp_obj.cam_ick);
		TRACE_ERR_AND_RET(FAIL);		

	}
	cam->cam_mclk = clk_get(&camera_dev, "cam_mclk");
	if (IS_ERR(cam->cam_mclk))
	{
//		ret_err = PTR_ERR(cam->cam_mclk);
		TRACE_ERR_AND_RET(FAIL);		
	}

	cam->cam_dpll4 = clk_get(&camera_dev, "dpll4_m4x2_ck");
	if (IS_ERR(cam->cam_dpll4))
	{
//		ret_err = PTR_ERR(cam->cam_dpll4);
		TRACE_ERR_AND_RET(FAIL);		
	}
	return SUCCESS;
}
/************************************************************************************************************
 *  
 *  MODULE TYPE	:	FUNCTION				MODULE ID	:	OMAP_V4L2_BASE
 *  Name	:	all_clk_enable
 *  Parameter1	:	cam_data *cam	- Base address of camera structure pointer
 *  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 all_clk_enable(cam_data *cam)
{
	INT32 ret_err = DISABLE;

	if(cam->clk_enable	== DISABLE)
	{
		cam->clk_enable	= ENABLE;
	}else
	{
		return SUCCESS;
	}
	
	ret_err = clk_enable(cam->cam_mclk);
	if(ret_err)
	{
		goto err;
	}

	ret_err = clk_enable(cam->cam_ick);
	if(ret_err)
	{
		clk_disable(cam->cam_mclk);
		goto err;
	}

	ret_err = clk_enable(cam->cam_dpll4);
	if(ret_err)
	{
		clk_disable(cam->cam_ick);
		clk_disable(cam->cam_mclk);
		goto err;
	}
	return SUCCESS;

	err:
	{
		cam->clk_enable	= DISABLE;
		TRACE_ERR_AND_RET(FAIL);		
	}
}
Пример #27
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;

}