示例#1
0
static T_U32 cam_gc0308_read_id(T_VOID)
{
    T_U8 value = 0x00;
    T_U32 id = 0;

    sccb_init(GPIO_I2C_SCL, GPIO_I2C_SDA);

    value = sccb_read_data(CAMERA_SCCB_ADDR, 0x00);
    id |= value;   
    
    //akprintf(C1, M_DRVSYS, "i2c addr 0x%x, cam_gc0308_read_id = 0x%x\r\n", CAMERA_SCCB_ADDR, id);      
    return id;
}
示例#2
0
static T_U32 cam_ov2643_read_id(T_VOID)
{
    T_U8 value = 0x00;
    T_U32 id = 0;

    sccb_init(GPIO_I2C_SCL, GPIO_I2C_SDA);        //init sccb first here!!
    
    value = sccb_read_data(CAMERA_SCCB_ADDR, 0x0a);
    id = value << 8;
    value = sccb_read_data(CAMERA_SCCB_ADDR, 0x0b);
    id |= value;    
            
    return id;
}
示例#3
0
static T_U32 cam_hm1375_read_id(T_VOID)
{
    T_U8 value = 0x00;
    T_U32 id = 0;

    sccb_init(GPIO_I2C_SCL, GPIO_I2C_SDA);        //init sccb first here!!
    
    value = sccb_read_short(CAMERA_SCCB_ADDR, 0x0001);
    id = value << 8;
    value = sccb_read_short(CAMERA_SCCB_ADDR, 0x0002);
    id |= value;    

    return id;
}
示例#4
0
T_U32 cam_ov3640_read_id(T_VOID)
{
    T_U8 tem_value = 0;
    T_U32 id = 0;
    
    sccb_init(28, 0); 
    
    sccb_read_data3(CAMERA_SCCB_ADDR, 0x300a, &tem_value, 1);
     id = tem_value;    
     sccb_read_data3(CAMERA_SCCB_ADDR, 0x300b, &tem_value, 1);
    id = id << 8;
    id |= tem_value;    
    id &= 0xffff;
    printf("i2c addr 0x%x, cam_ov3640_read_id = %x\r\n", CAMERA_SCCB_ADDR, id);
    return id;         
}
示例#5
0
/*
 * camif_init()
 */
static int __init camif_init(void)
{
	
	u8 err = 0;
	int ret;
	s3c2440camif_dev *cam;
	struct clk * camif_upll_clk;
	
	cam=&camera;
  if((ret=init_s3c2410camif_struct(cam))<0)
		return ret;
	
	/* Register the I2C device */
	err = platform_device_register(&s3c2410camif_v4l2_devices);
	if (err != 0) {
		pr_debug("1.camif_init: platform_device_register failed.\n");
		platform_driver_unregister(&s3c2410camif_v4l2_driver);
		return err;
	}	
	
	/* Register the device driver structure. */
	err = platform_driver_register(&s3c2410camif_v4l2_driver);
	if (err != 0) {
		platform_device_unregister(&s3c2410camif_v4l2_devices);
		pr_debug("camif_init: driver_register failed.\n");
		video_device_release(cam->video_dev);
		return err;
	}	
	
  /* register v4l device */
	if (video_register_device(cam->video_dev, VFL_TYPE_GRABBER, video_nr) == -1) 
	{
		platform_driver_unregister(&s3c2410camif_v4l2_driver);
		platform_device_unregister(&s3c2410camif_v4l2_devices);
		video_device_release(cam->video_dev);
		pr_debug("video_register_device failed\n");
		return -1;
	}
	
	/* set gpio-j to camera mode. */
	s3c2410_gpio_cfgpin(S3C2440_GPJ0, S3C2440_GPJ0_CAMDATA0);
	s3c2410_gpio_cfgpin(S3C2440_GPJ1, S3C2440_GPJ1_CAMDATA1);
	s3c2410_gpio_cfgpin(S3C2440_GPJ2, S3C2440_GPJ2_CAMDATA2);
	s3c2410_gpio_cfgpin(S3C2440_GPJ3, S3C2440_GPJ3_CAMDATA3);
	s3c2410_gpio_cfgpin(S3C2440_GPJ4, S3C2440_GPJ4_CAMDATA4);
	s3c2410_gpio_cfgpin(S3C2440_GPJ5, S3C2440_GPJ5_CAMDATA5);
	s3c2410_gpio_cfgpin(S3C2440_GPJ6, S3C2440_GPJ6_CAMDATA6);
	s3c2410_gpio_cfgpin(S3C2440_GPJ7, S3C2440_GPJ7_CAMDATA7);
	s3c2410_gpio_cfgpin(S3C2440_GPJ8, S3C2440_GPJ8_CAMPCLK);
	s3c2410_gpio_cfgpin(S3C2440_GPJ9, S3C2440_GPJ9_CAMVSYNC);
	s3c2410_gpio_cfgpin(S3C2440_GPJ10, S3C2440_GPJ10_CAMHREF);
	s3c2410_gpio_cfgpin(S3C2440_GPJ11, S3C2440_GPJ11_CAMCLKOUT);
	s3c2410_gpio_cfgpin(S3C2440_GPJ12, S3C2440_GPJ12_CAMRESET);

	/* init camera's virtual memory. */
	if (!request_mem_region((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF, CARD_NAME))
	{
		ret = -EBUSY;
		goto error1;
	}

	/* remap the virtual memory. */
	camif_base_addr = (unsigned long)ioremap_nocache((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF);
	if (camif_base_addr == (unsigned long)NULL)
	{
		ret = -EBUSY;
		goto error2;
	}

	/* init camera clock. */
	cam->clk = clk_get(NULL, "camif");
	if (IS_ERR(cam->clk))
	{
		ret = -ENOENT;
		goto error3;
	}
	clk_enable(cam->clk);

	camif_upll_clk = clk_get(NULL, "camif-upll");
	clk_set_rate(camif_upll_clk, 24000000);//24000000
	mdelay(100);
	
	//sccb error!
	sccb_init();
	hw_reset_camif();
	
	has_ov9650 = cam->sensor_op->init() >= 0;
	

	if(static_allocate)
	{
		cam->sensor_op->get_largest_format(&cam->sensor);
		cam->wndHsize = cam->sensor.width;
		cam->wndVsize = cam->sensor.height;
		
		cam->Ysize=   cam->wndHsize*cam->wndVsize;
		cam->CbCrsize=cam->wndHsize*cam->wndVsize/2;
	  //allocate memory
		
		if((ret=s3c2440camif_allocate_frame_buf(cam,S3C2440_FRAME_NUM))<0) 
			goto error4;
		
	} else {
		cam->sensor_op->get_format(&cam->sensor);
		cam->wndHsize = cam->sensor.width;
		cam->wndVsize = cam->sensor.height;
	}
	
	s3c2410_gpio_setpin(S3C2410_GPG(4), 1);
	
	return 0;
	
error4:
	clk_put(cam->clk);
error3:
	iounmap((void *)camif_base_addr);
error2:
	release_mem_region((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF);
	
error1:
	return ret;
}
/*
 * camif_init()
 */
static int __init camif_init(void)
{
	int ret;
	struct s3c2440camif_dev * pdev;
	struct clk * camif_upll_clk;

	printk(KERN_ALERT"initializing s3c2440 camera interface......\n");

	pdev = &camera;

	/* set gpio-j to camera mode. */
	s3c2410_gpio_cfgpin(S3C2440_GPJ0, S3C2440_GPJ0_CAMDATA0);
	s3c2410_gpio_cfgpin(S3C2440_GPJ1, S3C2440_GPJ1_CAMDATA1);
	s3c2410_gpio_cfgpin(S3C2440_GPJ2, S3C2440_GPJ2_CAMDATA2);
	s3c2410_gpio_cfgpin(S3C2440_GPJ3, S3C2440_GPJ3_CAMDATA3);
	s3c2410_gpio_cfgpin(S3C2440_GPJ4, S3C2440_GPJ4_CAMDATA4);
	s3c2410_gpio_cfgpin(S3C2440_GPJ5, S3C2440_GPJ5_CAMDATA5);
	s3c2410_gpio_cfgpin(S3C2440_GPJ6, S3C2440_GPJ6_CAMDATA6);
	s3c2410_gpio_cfgpin(S3C2440_GPJ7, S3C2440_GPJ7_CAMDATA7);
	s3c2410_gpio_cfgpin(S3C2440_GPJ8, S3C2440_GPJ8_CAMPCLK);
	s3c2410_gpio_cfgpin(S3C2440_GPJ9, S3C2440_GPJ9_CAMVSYNC);
	s3c2410_gpio_cfgpin(S3C2440_GPJ10, S3C2440_GPJ10_CAMHREF);
	s3c2410_gpio_cfgpin(S3C2440_GPJ11, S3C2440_GPJ11_CAMCLKOUT);
	s3c2410_gpio_cfgpin(S3C2440_GPJ12, S3C2440_GPJ12_CAMRESET);

	/* init camera's virtual memory. */
	if (!request_mem_region((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF, CARD_NAME))
	{
		ret = -EBUSY;
		goto error1;
	}

	/* remap the virtual memory. */
	camif_base_addr = (unsigned long)ioremap_nocache((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF);
	if (camif_base_addr == (unsigned long)NULL)
	{
		ret = -EBUSY;
		goto error2;
	}

	/* init camera clock. */
	pdev->clk = clk_get(NULL, "camif");
	if (IS_ERR(pdev->clk))
	{
		ret = -ENOENT;
		goto error3;
	}
	clk_enable(pdev->clk);

	camif_upll_clk = clk_get(NULL, "camif-upll");
	clk_set_rate(camif_upll_clk, 24000000);
	mdelay(100);

	/* init reference counter and its mutex. */
	mutex_init(&pdev->rcmutex);
	pdev->rc = 0;

	/* init image input source. */
	pdev->input = 0;

	/* init camif state and its lock. */
	pdev->state = CAMIF_STATE_FREE;

	/* init command code, command lock and the command wait queue. */
	pdev->cmdcode = CAMIF_CMD_NONE;
	init_waitqueue_head(&pdev->cmdqueue);

	/* register to videodev layer. */
	if (misc_register(&misc) < 0)
	{
		ret = -EBUSY;
		goto error4;
	}
	printk(KERN_ALERT"s3c2440 camif init done\n");
	
	sccb_init();
	hw_reset_camif();
	has_ov9650 = s3c2440_ov9650_init() >= 0;
	s3c2410_gpio_setpin(S3C2410_GPG(4), 1);
	return 0;

error4:
	clk_put(pdev->clk);
error3:
	iounmap((void *)camif_base_addr);
error2:
	release_mem_region((unsigned long)S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF);
	
error1:
	return ret;
}