android camera摄像头驱动 - 图文

在S5PV210中,FIMC初始设置代码在 /drivers/ arch/arm/mach-s5pv210/mach-smdkv310.c中:

[cpp] view plaincopy

1. static struct s3c_platform_fimc fimc_plat = { 2. .srclk_name = \, 3. .clk_name = \, 4. .lclk_name = \, 5. .clk_rate = 166750000, 6. .default_cam = CAMERA_CSI_C, 7. .camera = { 8. &mt9p111,//5M back cam 9. &s5k6aafx,///1.3M front cam 10. },

11. .hw_ver = 0x43, 12. };

对于GPIO的配置代码在 /drivers/ arch/arm/mach-s5pv210/setup-fimc0.c中:

[cpp] view plaincopy

1. oid s3c_fimc0_cfg_gpio(struct platform_device *pdev) 2. {

3. int i = 0; 4.

5. /* CAM A port(b0010) : PCLK, VSYNC, HREF, DATA[0-4] */ 6. for (i = 0; i < 8; i++) {

7. s3c_gpio_cfgpin(S5PV210_GPE0(i), S3C_GPIO_SFN(2)); 8. s3c_gpio_setpull(S5PV210_GPE0(i), S3C_GPIO_PULL_NONE); 9. }

10. /* CAM A port(b0010) : DATA[5-7], CLKOUT(MIPI CAM also), FIELD */ 11. for (i = 0; i < 5; i++) {

12. s3c_gpio_cfgpin(S5PV210_GPE1(i), S3C_GPIO_SFN(2)); 13. s3c_gpio_setpull(S5PV210_GPE1(i), S3C_GPIO_PULL_NONE); 14. }

15. /* CAM B port(b0011) : DATA[0-7] */ 16. for (i = 0; i < 8; i++) {

17. s3c_gpio_cfgpin(S5PV210_GPJ0(i), S3C_GPIO_SFN(3)); 18. s3c_gpio_setpull(S5PV210_GPJ0(i), S3C_GPIO_PULL_NONE); 19. }

20. /* CAM B port(b0011) : PCLK, VSYNC, HREF, FIELD, CLCKOUT */ 21. for (i = 0; i < 5; i++) {

22. s3c_gpio_cfgpin(S5PV210_GPJ1(i), S3C_GPIO_SFN(3)); 23. s3c_gpio_setpull(S5PV210_GPJ1(i), S3C_GPIO_PULL_NONE); 24. } 25. }

4)接口函数

FIMC的主要回调函数如下,实现在fimc_v4l2.c中:

[cpp] view plaincopy

1. onst struct v4l2_ioctl_ops fimc_v4l2_ops = { 2. .vidioc_querycap = fimc_querycap, 3. .vidioc_reqbufs = fimc_reqbufs, 4. .vidioc_querybuf = fimc_querybuf, 5. .vidioc_g_ctrl = fimc_g_ctrl, 6. .vidioc_s_ctrl = fimc_s_ctrl, 7. .vidioc_s_ext_ctrls = fimc_s_ext_ctrls, 8. .vidioc_cropcap = fimc_cropcap, 9. .vidioc_g_crop = fimc_g_crop, 10. .vidioc_s_crop = fimc_s_crop, 11. .vidioc_streamon = fimc_streamon, 12. .vidioc_streamoff = fimc_streamoff, 13. .vidioc_qbuf = fimc_qbuf, 14. .vidioc_dqbuf = fimc_dqbuf,

15. .vidioc_enum_fmt_vid_cap = fimc_enum_fmt_vid_capture, 16. .vidioc_g_fmt_vid_cap = fimc_g_fmt_vid_capture, 17. .vidioc_s_fmt_vid_cap = fimc_s_fmt_vid_capture, 18. .vidioc_try_fmt_vid_cap = fimc_try_fmt_vid_capture, 19. .vidioc_enum_input = fimc_enum_input, 20. .vidioc_g_input = fimc_g_input, 21. .vidioc_s_input = fimc_s_input, 22. .vidioc_g_parm = fimc_g_parm, 23. .vidioc_s_parm = fimc_s_parm, 24. .vidioc_queryctrl = fimc_queryctrl, 25. .vidioc_querymenu = fimc_querymenu,

26. .vidioc_g_fmt_vid_out = fimc_g_fmt_vid_out, 27. .vidioc_s_fmt_vid_out = fimc_s_fmt_vid_out, 28. .vidioc_try_fmt_vid_out = fimc_try_fmt_vid_out, 29. .vidioc_g_fbuf = fimc_g_fbuf, 30. .vidioc_s_fbuf = fimc_s_fbuf,

31. .vidioc_try_fmt_vid_overlay = fimc_try_fmt_overlay,

32. .vidioc_g_fmt_vid_overlay = fimc_g_fmt_vid_overlay, 33. .vidioc_s_fmt_vid_overlay = fimc_s_fmt_vid_overlay, 34. };

对于寄存器的操作,实现都在fimc_regs.c文件中,如

[cpp] view plaincopy

1. int fimc_hwset_camera_source(struct fimc_control *ctrl) 2. {

3. struct s3c_platform_camera *cam = ctrl->cam; 4. u32 cfg = 0; 5.

6. cfg |= S3C_CISRCFMT_ITU601_8BIT; 7. cfg |= cam->order422; 8.

9. if (cam->type == CAM_TYPE_ITU) 10. cfg |= cam->fmt; 11.

12. cfg |= S3C_CISRCFMT_SOURCEHSIZE(cam->width); 13. cfg |= S3C_CISRCFMT_SOURCEVSIZE(cam->height); 14.

15. writel(cfg, ctrl->regs + S3C_CISRCFMT); 16.

17. return 0; 18. } 19.

20. int fimc_hwset_enable_irq(struct fimc_control *ctrl, int overflow, int level

) 21. {

22. u32 cfg = readl(ctrl->regs + S3C_CIGCTRL); 23.

24. cfg &= ~(S3C_CIGCTRL_IRQ_OVFEN | S3C_CIGCTRL_IRQ_LEVEL); 25. cfg |= S3C_CIGCTRL_IRQ_ENABLE; 26.

27. if (overflow)

28. cfg |= S3C_CIGCTRL_IRQ_OVFEN; 29.

30. if (level)

31. cfg |= S3C_CIGCTRL_IRQ_LEVEL; 32.

33. writel(cfg, ctrl->regs + S3C_CIGCTRL); 34.

35. return 0;

36. }

android camera(四):camera 驱动 GT2005

关键词:android camera CMM 模组 camera参数 GT2005 摄像头常见问题 平台信息: 内核:linux 系统:android

平台:S5PV310(samsung exynos 4210) android camera(一):camera模组CMM介绍

android camera(二):摄像头工作原理、s5PV310 摄像头接口(CAMIF) android camera(三):camera V4L2 FIMC android camera(四):camera 驱动 GT2005

摄像头主要参数: 1、MCLK 24MHz; 2、PCLK 48~52MHz~; 3、电压 1.8V(1.5V)、2.8V;

4、scl(IIC时钟)100KHz或者400KHz。

下载:常用摄像头规格书(个别有android驱动程序) :bf3703 30W、gc0308 30W、ov7670、gt2005 200W、gt2015 200W、NT99250 200W、s5k5ba 200W、s5k4ba 一、摄像头驱动

我们以GT2005为例,来讲述一个摄像头驱动的调试过程: 摄像头和主控的关系图,如下:

联系客服:779662525#qq.com(#替换为@)