S5PV210开发板 摄像头ov3640 fimc驱动分析 :fimc_capture.c 分析

fimc_capture.c在FIMC系统中的位置,网上偷来的一幅图片



  1. 43 static const struct v4l2_fmtdesc capture_fmts[] = {
  2. 44 {
  3. 45 .index = 0,
  4. 46 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  5. 47 .flags = FORMAT_FLAGS_PACKED,
  6. 48 .description = "RGB-5-6-5",
  7. 49 .pixelformat = V4L2_PIX_FMT_RGB565,
  8. 50 }, {
  9. 51 .index = 1,
  10. 52 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  11. 53 .flags = FORMAT_FLAGS_PACKED,
  12. 54 .description = "RGB-8-8-8, unpacked 24 bpp",
  13. 55 .pixelformat = V4L2_PIX_FMT_RGB32,
  14. 56 }, {
  15. 57 .index = 2,
  16. 58 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  17. 59 .flags = FORMAT_FLAGS_PACKED,
  18. 60 .description = "YUV 4:2:2 packed, YCbYCr",
  19. 61 .pixelformat = V4L2_PIX_FMT_YUYV,
  20. 62 }, {
  21. 63 .index = 3,
  22. 64 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  23. 65 .flags = FORMAT_FLAGS_PACKED,
  24. 66 .description = "YUV 4:2:2 packed, CbYCrY",
  25. 67 .pixelformat = V4L2_PIX_FMT_UYVY,
  26. 68 }, {
  27. 69 .index = 4,
  28. 70 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  29. 71 .flags = FORMAT_FLAGS_PACKED,
  30. 72 .description = "YUV 4:2:2 packed, CrYCbY",
  31. 73 .pixelformat = V4L2_PIX_FMT_VYUY,
  32. 74 }, {
  33. 75 .index = 5,
  34. 76 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  35. 77 .flags = FORMAT_FLAGS_PACKED,
  36. 78 .description = "YUV 4:2:2 packed, YCrYCb",
  37. 79 .pixelformat = V4L2_PIX_FMT_YVYU,
  38. 80 }, {
  39. 81 .index = 6,
  40. 82 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  41. 83 .flags = FORMAT_FLAGS_PLANAR,
  42. 84 .description = "YUV 4:2:2 planar, Y/Cb/Cr",
  43. 85 .pixelformat = V4L2_PIX_FMT_YUV422P,
  44. 86 }, {
  45. 87 .index = 7,
  46. 88 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  47. 89 .flags = FORMAT_FLAGS_PLANAR,
  48. 90 .description = "YUV 4:2:0 planar, Y/CbCr",
  49. 91 .pixelformat = V4L2_PIX_FMT_NV12,
  50. 92 }, {
  51. 93 .index = 8,
  52. 94 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  53. 95 .flags = FORMAT_FLAGS_PLANAR,
  54. 96 .description = "YUV 4:2:0 planar, Y/CbCr, Tiled",
  55. 97 .pixelformat = V4L2_PIX_FMT_NV12T,
  56. 98 }, {
  57. 99 .index = 9,
  58. 100 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  59. 101 .flags = FORMAT_FLAGS_PLANAR,
  60. 102 .description = "YUV 4:2:0 planar, Y/CrCb",
  61. 103 .pixelformat = V4L2_PIX_FMT_NV21,
  62. 104 }, {
  63. 105 .index = 10,
  64. 106 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  65. 107 .flags = FORMAT_FLAGS_PLANAR,
  66. 108 .description = "YUV 4:2:2 planar, Y/CbCr",
  67. 109 .pixelformat = V4L2_PIX_FMT_NV16,
  68. 110 }, {
  69. 111 .index = 11,
  70. 112 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  71. 113 .flags = FORMAT_FLAGS_PLANAR,
  72. 114 .description = "YUV 4:2:2 planar, Y/CrCb",
  73. 115 .pixelformat = V4L2_PIX_FMT_NV61,
  74. 116 }, {
  75. 117 .index = 12,
  76. 118 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  77. 119 .flags = FORMAT_FLAGS_PLANAR,
  78. 120 .description = "YUV 4:2:0 planar, Y/Cb/Cr",
  79. 121 .pixelformat = V4L2_PIX_FMT_YUV420,
  80. 122 }, {
  81. 123 .index = 13,
  82. 124 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  83. 125 .flags = FORMAT_FLAGS_ENCODED,
  84. 126 .description = "Encoded JPEG bitstream",
  85. 127 .pixelformat = V4L2_PIX_FMT_JPEG,
  86. 128 },
  87. 129 };
 43 static const struct v4l2_fmtdesc capture_fmts[] = {
  44     {
  45         .index      = 0,
  46         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  47         .flags      = FORMAT_FLAGS_PACKED,
  48         .description    = "RGB-5-6-5",
  49         .pixelformat    = V4L2_PIX_FMT_RGB565,
  50     }, {
  51         .index      = 1,
  52         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  53         .flags      = FORMAT_FLAGS_PACKED,
  54         .description    = "RGB-8-8-8, unpacked 24 bpp",
  55         .pixelformat    = V4L2_PIX_FMT_RGB32,
  56     }, {
  57         .index      = 2,
  58         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  59         .flags      = FORMAT_FLAGS_PACKED,
  60         .description    = "YUV 4:2:2 packed, YCbYCr",
  61         .pixelformat    = V4L2_PIX_FMT_YUYV,
  62     }, {
  63         .index      = 3,
  64         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  65         .flags      = FORMAT_FLAGS_PACKED,
  66         .description    = "YUV 4:2:2 packed, CbYCrY",
  67         .pixelformat    = V4L2_PIX_FMT_UYVY,
  68     }, {
  69         .index      = 4,
  70         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  71         .flags      = FORMAT_FLAGS_PACKED,
  72         .description    = "YUV 4:2:2 packed, CrYCbY",
  73         .pixelformat    = V4L2_PIX_FMT_VYUY,
  74     }, {
  75         .index      = 5,
  76         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  77         .flags      = FORMAT_FLAGS_PACKED,
  78         .description    = "YUV 4:2:2 packed, YCrYCb",
  79         .pixelformat    = V4L2_PIX_FMT_YVYU,
  80     }, {
  81         .index      = 6,
  82         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  83         .flags      = FORMAT_FLAGS_PLANAR,
  84         .description    = "YUV 4:2:2 planar, Y/Cb/Cr",
 85         .pixelformat    = V4L2_PIX_FMT_YUV422P,
  86     }, {
  87         .index      = 7,
  88         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  89         .flags      = FORMAT_FLAGS_PLANAR,
  90         .description    = "YUV 4:2:0 planar, Y/CbCr",
  91         .pixelformat    = V4L2_PIX_FMT_NV12,
  92     }, {
  93         .index      = 8,
  94         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  95         .flags      = FORMAT_FLAGS_PLANAR,
  96         .description    = "YUV 4:2:0 planar, Y/CbCr, Tiled",
  97         .pixelformat    = V4L2_PIX_FMT_NV12T,
  98     }, {
  99         .index      = 9,
 100         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 101         .flags      = FORMAT_FLAGS_PLANAR,
 102         .description    = "YUV 4:2:0 planar, Y/CrCb",
 103         .pixelformat    = V4L2_PIX_FMT_NV21,
 104     }, {
 105         .index      = 10,
 106         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 107         .flags      = FORMAT_FLAGS_PLANAR,
 108         .description    = "YUV 4:2:2 planar, Y/CbCr",
 109         .pixelformat    = V4L2_PIX_FMT_NV16,
 110     }, {
 111         .index      = 11,
 112         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 113         .flags      = FORMAT_FLAGS_PLANAR,
 114         .description    = "YUV 4:2:2 planar, Y/CrCb",
 115         .pixelformat    = V4L2_PIX_FMT_NV61,
 116     }, {
 117         .index      = 12,
 118         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 119         .flags      = FORMAT_FLAGS_PLANAR,
 120         .description    = "YUV 4:2:0 planar, Y/Cb/Cr",
 121         .pixelformat    = V4L2_PIX_FMT_YUV420,
 122     }, {
 123         .index      = 13,
 124         .type       = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 125         .flags      = FORMAT_FLAGS_ENCODED,
 126         .description    = "Encoded JPEG bitstream",
 127         .pixelformat    = V4L2_PIX_FMT_JPEG,
 128     },
 129 };

这个列表列出了FIMC支持的capture格式,app可以通过vidioc_s_fmt设置capture的输出格式,capture的输出格式必须在上面的列表中

这里的flags标志位并不符合V4L2标准,V4L2只支持一种标志:V4L2_FMT_FLAG_COMPRESSED。

samsung扩展了flags标志:

FORMAT_FLAGS_PACKED: 图片的像素点分量放在一同一个buffer中

FORMAT_FLAGS_PLANAR:图片像素的分量放在不同的buffer中

FORMAT_FLAGS_ENCODED:图片数据编码存储,如jpeg格式


  1. static int fimc_camera_init(struct fimc_control *ctrl)
  2. 202 {
  3. 203 int ret;
  4. 204
  5. 205 fimc_dbg("%s\n", __func__);
  6. 206
  7. 207 /* do nothing if already initialized */
  8. 208 if (ctrl->cam->initialized)
  9. 209 return 0;
  10. 210
  11. 211 /* enable camera power if needed */
  12. 212 if (ctrl->cam->cam_power)
  13. 213 ctrl->cam->cam_power(1);
  14. 214
  15. 215 /* subdev call for init */
  16. 216 ret = subdev_call(ctrl, core, init, 0);
  17. 217 if (ret == -ENOIOCTLCMD) {
  18. 218 fimc_err("%s: init subdev api not supported\n",
  19. 219 __func__);
  20. 220 return ret;
  21. 221 }
  22. 222
  23. 223 if (ctrl->cam->type == CAM_TYPE_MIPI) {
  24. 224 /* subdev call for sleep/wakeup:
  25. 225 * no error although no s_stream api support
  26. 226 */
  27. 227 u32 pixelformat;
  28. 228 if (ctrl->cap->fmt.pixelformat == V4L2_PIX_FMT_JPEG)
  29. 229 pixelformat = V4L2_PIX_FMT_JPEG;
  30. 230 else
  31. 231 pixelformat = ctrl->cam->pixelformat;
  32. 232
  33. 233 subdev_call(ctrl, video, s_stream, 0);
  34. 234 s3c_csis_start(ctrl->cam->mipi_lanes, ctrl->cam->mipi_settle, \
  35. 235 ctrl->cam->mipi_align, ctrl->cam->width, \
  36. 236 ctrl->cam->height, pixelformat);
  37. 237 subdev_call(ctrl, video, s_stream, 1);
  38. 238 }
  39. 239
  40. 240 ctrl->cam->initialized = 1;
  41. 241
  42. 242 return 0;
  43. 243 }
 201 static int fimc_camera_init(struct fimc_control *ctrl)
 202 {
 203     int ret;
 204 
 205     fimc_dbg("%s\n", __func__);
 206 
 207     /* do nothing if already initialized */
 208     if (ctrl->cam->initialized)
 209         return 0;
 210 
 211     /* enable camera power if needed */
 212     if (ctrl->cam->cam_power)
 213         ctrl->cam->cam_power(1);
 214 
 215     /* subdev call for init */
 216     ret = subdev_call(ctrl, core, init, 0);
 217     if (ret == -ENOIOCTLCMD) {
 218         fimc_err("%s: init subdev api not supported\n",
 219             __func__);
 220         return ret;
 221     }
 222 
 223     if (ctrl->cam->type == CAM_TYPE_MIPI) {
 224         /* subdev call for sleep/wakeup:
 225          * no error although no s_stream api support
 226          */
 227         u32 pixelformat;
 228         if (ctrl->cap->fmt.pixelformat == V4L2_PIX_FMT_JPEG)
 229             pixelformat = V4L2_PIX_FMT_JPEG;
 230         else
 231             pixelformat = ctrl->cam->pixelformat;
 232 
 233         subdev_call(ctrl, video, s_stream, 0);
 234         s3c_csis_start(ctrl->cam->mipi_lanes, ctrl->cam->mipi_settle, \
 235                 ctrl->cam->mipi_align, ctrl->cam->width, \
 236                 ctrl->cam->height, pixelformat);
 237         subdev_call(ctrl, video, s_stream, 1);
 238     }
 239 
 240     ctrl->cam->initialized = 1;
 241 
 242     return 0;
 243 }

这个函数主要对camera的sensor进行上电,初始化,这个函数最早的调用位置是streamon。

但是有一个问题,假定外围电路是一个video AD转换芯片托多个cvbs s-video或者YPbPr输入,那么在执行streamon之前,要首先执行s_input操作选择哪个video AD芯片的输入。选择video AD 的input输入是要操作AD芯片I2C寄存器的,因此这个上电位置是有问题的。


  1. 368 static int fimc_add_inqueue(struct fimc_control *ctrl, int i)
  2. 369 {
  3. 370 struct fimc_capinfo *cap = ctrl->cap; </
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值