Lines Matching +full:input +full:- +full:pixel +full:- +full:format

5  * SPDX-License-Identifier: Apache-2.0
39 const struct device *dev = data->dev; in __frame_done_cb()
40 const struct video_mcux_csi_config *config = dev->config; in __frame_done_cb()
51 status = CSI_TransferGetFullBuffer(config->base, &(data->csi_handle), &buffer_addr); in __frame_done_cb()
58 while ((vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT))) { in __frame_done_cb()
59 if ((uint32_t)vbuf->buffer == buffer_addr) { in __frame_done_cb()
67 k_fifo_put(&data->fifo_in, vbuf); in __frame_done_cb()
83 vbuf->timestamp = k_uptime_get_32(); in __frame_done_cb()
86 DCACHE_InvalidateByRange(buffer_addr, vbuf->bytesused); in __frame_done_cb()
89 k_fifo_put(&data->fifo_out, vbuf); in __frame_done_cb()
93 if (IS_ENABLED(CONFIG_POLL) && data->signal) { in __frame_done_cb()
94 k_poll_signal_raise(data->signal, result); in __frame_done_cb()
104 * On i.MX RT11xx SoCs which have MIPI CSI-2 Rx, image data from the camera sensor after passing
105 * through the pipeline (MIPI CSI-2 Rx --> Video Mux --> CSI) will be implicitly converted to a
106 * 32-bits pixel format. For example, an input in RGB565 or YUYV (2-bytes format) will become a
107 * XRGB32 or XYUV32 (4-bytes format) respectively, at the output of the CSI.
111 switch (fmt->pixelformat) { in video_pix_fmt_convert()
113 fmt->pixelformat = isGetFmt ? VIDEO_PIX_FMT_XRGB32 : VIDEO_PIX_FMT_RGB565; in video_pix_fmt_convert()
116 fmt->pixelformat = isGetFmt ? VIDEO_PIX_FMT_XYUV32 : VIDEO_PIX_FMT_YUYV; in video_pix_fmt_convert()
119 fmt->pixelformat = isGetFmt ? VIDEO_PIX_FMT_XRGB32 : VIDEO_PIX_FMT_RGB565; in video_pix_fmt_convert()
122 fmt->pixelformat = isGetFmt ? VIDEO_PIX_FMT_XYUV32 : VIDEO_PIX_FMT_YUYV; in video_pix_fmt_convert()
126 fmt->pitch = fmt->width * video_pix_fmt_bpp(fmt->pixelformat); in video_pix_fmt_convert()
133 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_set_fmt()
134 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_set_fmt()
135 unsigned int bpp = video_pix_fmt_bpp(fmt->pixelformat); in video_mcux_csi_set_fmt()
137 struct video_format format = *fmt; in video_mcux_csi_set_fmt() local
140 return -EINVAL; in video_mcux_csi_set_fmt()
143 data->csi_config.bytesPerPixel = bpp; in video_mcux_csi_set_fmt()
144 data->csi_config.linePitch_Bytes = fmt->pitch; in video_mcux_csi_set_fmt()
146 if (fmt->pixelformat != VIDEO_PIX_FMT_XRGB32 && fmt->pixelformat != VIDEO_PIX_FMT_XYUV32) { in video_mcux_csi_set_fmt()
147 return -ENOTSUP; in video_mcux_csi_set_fmt()
149 video_pix_fmt_convert(&format, false); in video_mcux_csi_set_fmt()
150 data->csi_config.dataBus = kCSI_DataBus24Bit; in video_mcux_csi_set_fmt()
152 data->csi_config.dataBus = kCSI_DataBus8Bit; in video_mcux_csi_set_fmt()
154 data->csi_config.polarityFlags = kCSI_HsyncActiveHigh | kCSI_DataLatchOnRisingEdge; in video_mcux_csi_set_fmt()
155 data->csi_config.workMode = kCSI_GatedClockMode; /* use VSYNC, HSYNC, and PIXCLK */ in video_mcux_csi_set_fmt()
156 data->csi_config.useExtVsync = true; in video_mcux_csi_set_fmt()
157 data->csi_config.height = fmt->height; in video_mcux_csi_set_fmt()
158 data->csi_config.width = fmt->width; in video_mcux_csi_set_fmt()
160 ret = CSI_Init(config->base, &data->csi_config); in video_mcux_csi_set_fmt()
162 return -EIO; in video_mcux_csi_set_fmt()
165 ret = CSI_TransferCreateHandle(config->base, &data->csi_handle, __frame_done_cb, data); in video_mcux_csi_set_fmt()
167 return -EIO; in video_mcux_csi_set_fmt()
170 if (config->source_dev && video_set_format(config->source_dev, ep, &format)) { in video_mcux_csi_set_fmt()
171 return -EIO; in video_mcux_csi_set_fmt()
180 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_get_fmt()
183 return -EINVAL; in video_mcux_csi_get_fmt()
186 if (config->source_dev && !video_get_format(config->source_dev, ep, fmt)) { in video_mcux_csi_get_fmt()
194 return -EIO; in video_mcux_csi_get_fmt()
199 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_stream_start()
200 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_stream_start()
203 ret = CSI_TransferStart(config->base, &data->csi_handle); in video_mcux_csi_stream_start()
205 return -EIO; in video_mcux_csi_stream_start()
208 if (config->source_dev && video_stream_start(config->source_dev)) { in video_mcux_csi_stream_start()
209 return -EIO; in video_mcux_csi_stream_start()
217 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_stream_stop()
218 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_stream_stop()
221 if (config->source_dev && video_stream_stop(config->source_dev)) { in video_mcux_csi_stream_stop()
222 return -EIO; in video_mcux_csi_stream_stop()
225 ret = CSI_TransferStop(config->base, &data->csi_handle); in video_mcux_csi_stream_stop()
227 return -EIO; in video_mcux_csi_stream_stop()
235 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_flush()
236 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_flush()
245 } while (!k_fifo_is_empty(&data->fifo_in)); in video_mcux_csi_flush()
249 ret = CSI_TransferGetFullBuffer(config->base, &(data->csi_handle), in video_mcux_csi_flush()
253 while ((vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT))) { in video_mcux_csi_flush()
254 k_fifo_put(&data->fifo_out, vbuf); in video_mcux_csi_flush()
255 if (IS_ENABLED(CONFIG_POLL) && data->signal) { in video_mcux_csi_flush()
256 k_poll_signal_raise(data->signal, VIDEO_BUF_ABORTED); in video_mcux_csi_flush()
267 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_enqueue()
268 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_enqueue()
273 return -EINVAL; in video_mcux_csi_enqueue()
276 to_read = data->csi_config.linePitch_Bytes * data->csi_config.height; in video_mcux_csi_enqueue()
277 vbuf->bytesused = to_read; in video_mcux_csi_enqueue()
278 vbuf->line_offset = 0; in video_mcux_csi_enqueue()
280 ret = CSI_TransferSubmitEmptyBuffer(config->base, &data->csi_handle, in video_mcux_csi_enqueue()
281 (uint32_t)vbuf->buffer); in video_mcux_csi_enqueue()
283 return -EIO; in video_mcux_csi_enqueue()
286 k_fifo_put(&data->fifo_in, vbuf); in video_mcux_csi_enqueue()
294 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_dequeue()
297 return -EINVAL; in video_mcux_csi_dequeue()
300 *vbuf = k_fifo_get(&data->fifo_out, timeout); in video_mcux_csi_dequeue()
302 return -EAGAIN; in video_mcux_csi_dequeue()
310 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_set_ctrl()
311 int ret = -ENOTSUP; in video_mcux_csi_set_ctrl()
314 if (config->source_dev) { in video_mcux_csi_set_ctrl()
315 ret = video_set_ctrl(config->source_dev, cid, value); in video_mcux_csi_set_ctrl()
323 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_get_ctrl()
324 int ret = -ENOTSUP; in video_mcux_csi_get_ctrl()
327 if (config->source_dev) { in video_mcux_csi_get_ctrl()
328 ret = video_get_ctrl(config->source_dev, cid, value); in video_mcux_csi_get_ctrl()
337 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_get_caps()
338 int err = -ENODEV; in video_mcux_csi_get_caps()
341 return -EINVAL; in video_mcux_csi_get_caps()
345 if (config->source_dev) { in video_mcux_csi_get_caps()
346 err = video_get_caps(config->source_dev, ep, caps); in video_mcux_csi_get_caps()
349 * On i.MX RT11xx SoCs which have MIPI CSI-2 Rx, image data from the camera sensor in video_mcux_csi_get_caps()
350 * after passing through the pipeline (MIPI CSI-2 Rx --> Video Mux --> CSI) will be in video_mcux_csi_get_caps()
351 * implicitly converted to a 32-bits pixel format. For example, an input in RGB565 in video_mcux_csi_get_caps()
352 * or YUYV (2-bytes format) will become an XRGB32 or XYUV32 (4-bytes format) in video_mcux_csi_get_caps()
353 * respectively, at the output of the CSI. So, we change the pixel formats of the in video_mcux_csi_get_caps()
358 while (caps->format_caps[ind].pixelformat) { in video_mcux_csi_get_caps()
366 memcpy(&fmts[i], &caps->format_caps[i], sizeof(fmts[i])); in video_mcux_csi_get_caps()
373 caps->format_caps = fmts; in video_mcux_csi_get_caps()
378 caps->min_vbuf_count = 2; in video_mcux_csi_get_caps()
380 caps->min_line_count = caps->max_line_count = LINE_COUNT_HEIGHT; in video_mcux_csi_get_caps()
395 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_init()
396 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_init()
399 k_fifo_init(&data->fifo_in); in video_mcux_csi_init()
400 k_fifo_init(&data->fifo_out); in video_mcux_csi_init()
402 CSI_GetDefaultConfig(&data->csi_config); in video_mcux_csi_init()
407 if (config->source_dev == NULL) { in video_mcux_csi_init()
408 return -ENODEV; in video_mcux_csi_init()
411 err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); in video_mcux_csi_init()
423 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_set_signal()
425 if (data->signal && signal != NULL) { in video_mcux_csi_set_signal()
426 return -EALREADY; in video_mcux_csi_set_signal()
429 data->signal = signal; in video_mcux_csi_set_signal()
438 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_set_frmival()
440 return video_set_frmival(config->source_dev, ep, frmival); in video_mcux_csi_set_frmival()
446 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_get_frmival()
448 return video_get_frmival(config->source_dev, ep, frmival); in video_mcux_csi_get_frmival()
454 const struct video_mcux_csi_config *config = dev->config; in video_mcux_csi_enum_frmival()
455 const struct video_format *fie_fmt = fie->format; in video_mcux_csi_enum_frmival()
459 struct video_format converted_fmt = *fie->format; in video_mcux_csi_enum_frmival()
462 fie->format = &converted_fmt; in video_mcux_csi_enum_frmival()
465 ret = video_enum_frmival(config->source_dev, ep, fie); in video_mcux_csi_enum_frmival()
466 fie->format = fie_fmt; in video_mcux_csi_enum_frmival()
503 struct video_mcux_csi_data *data = dev->data; in video_mcux_csi_init_0()
509 data->dev = dev; in video_mcux_csi_init_0()