fimc_capture.c在FIMC系统中的位置,网上偷来的一幅图片
- 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 };
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格式
- 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 }
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寄存器的,因此这个上电位置是有问题的。
- 368 static int fimc_add_inqueue(struct fimc_control *ctrl, int i)
- 369 {
- 370 struct fimc_capinfo *cap = ctrl->cap; </