Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video pipeline on rt10xx: Fix chicken-egg issue in init priority #80052

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cf630f0
include: video: Add an utility function to get bytes per pixel
ngphibang Jun 25, 2024
4fe2143
drivers: video: mcux_csi: Remove obsolete comment
ngphibang Jul 24, 2024
d1c8a46
drivers: video: mcux_csi: Fix start stop issue
trunghieulenxp Aug 29, 2024
143ec5d
drivers: video: mcux_csi: Add support for changing frame rate
trunghieulenxp Jul 22, 2024
759f16c
drivers: video: mcux_csi: Add NXP copyright
ngphibang Jul 24, 2024
673d0c7
dts-bindings: video: mipicsi2rx: Use video interfaces bindings
ngphibang Oct 15, 2024
8c7e1c2
dts-bindings: video: csi: Use video interfaces bindings
ngphibang Oct 15, 2024
af8d55c
dts-bindings: video: ov7725: Use video interfaces binding
ngphibang Oct 15, 2024
2b8d454
dts-bindings: video: ov5640: Use video interfaces binding
ngphibang Oct 15, 2024
785df66
tests: drivers: build_all: video: Use the new endpoint binding
ngphibang Oct 16, 2024
8b6f262
boards: shields: dvp_fpc24_mt9m114: Use the new endpoint bindings
ngphibang Oct 17, 2024
25a8065
boards: shields: nxp_btb44_ov5640: Add some endpoint properties
ngphibang Oct 15, 2024
968925c
drivers: video: mcux_mipi_csi2rx: Get data lanes number from devicetree
ngphibang Jun 19, 2024
9b58769
drivers: video: mcux_mipi_csi2rx: Add set_ctrl callback
0xFarahFl Jul 16, 2024
425a1df
drivers: video: mcux_mipi_csi2rx: Set clocks according to pixel rate
trunghieulenxp Jul 24, 2024
1385de9
drivers: video: mcux_mipi_csi2rx: Add support for changing frame rate
trunghieulenxp Jul 23, 2024
2b855b8
drivers: video: mipi_csi2rx: Remove sensor device phandle
ngphibang Oct 21, 2024
b3b0388
drivers: video: csi: Remove source device phandle
ngphibang Oct 21, 2024
6c68e6b
drivers: video: csi: Increase init priority
ngphibang Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions boards/madmachine/mm_swiftio/mm_swiftio.dts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

port {
ov7725_ep_out: endpoint {
remote-endpoint = <&csi_ep_in>;
remote-endpoint-label = "csi_ep_in";
};
};
};
Expand Down Expand Up @@ -192,13 +192,12 @@

&csi {
status = "okay";
source = <&ov7725>;
pinctrl-0 = <&pinmux_csi>;
pinctrl-names = "default";

port {
csi_ep_in: endpoint {
remote-endpoint = <&ov7725_ep_out>;
remote-endpoint-label = "ov7725_ep_out";
};
};
};
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions boards/shields/dvp_fpc24_mt9m114/dvp_fpc24_mt9m114.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

port {
mt9m114_ep_out: endpoint {
remote-endpoint = <&dfi_ep_in>;
remote-endpoint-label = "dfi_ep_in";
};
};
};
Expand All @@ -28,7 +28,7 @@

port {
dfi_ep_in: endpoint {
remote-endpoint = <&mt9m114_ep_out>;
remote-endpoint-label = "mt9m114_ep_out";
};
};
};
11 changes: 7 additions & 4 deletions boards/shields/nxp_btb44_ov5640/nxp_btb44_ov5640.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/video/video-interfaces.h>

/{
chosen {
zephyr,camera = &nxp_csi;
Expand All @@ -21,7 +23,9 @@

port {
ov5640_ep_out: endpoint {
remote-endpoint = <&mipi_csi2rx_ep_in>;
remote-endpoint-label = "mipi_csi2rx_ep_in";
bus-type = <VIDEO_BUS_TYPE_CSI2_DPHY>;
data-lanes = <1 2>;
};
};
};
Expand All @@ -30,14 +34,13 @@
&nxp_mipi_csi {
status = "okay";

sensor = <&ov5640>;

ports {
port@1 {
reg = <1>;

mipi_csi2rx_ep_in: endpoint {
remote-endpoint = <&ov5640_ep_out>;
remote-endpoint-label = "ov5640_ep_out";
data-lanes = <1 2>;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/Kconfig.mcux_csi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config VIDEO_MCUX_CSI

config VIDEO_MCUX_CSI_INIT_PRIORITY
int "NXP MCUX CSI init priority"
default 61
default 59
depends on VIDEO_MCUX_CSI
help
Initialization priority for the CSI interface on an NXP MCUX device.
81 changes: 56 additions & 25 deletions drivers/video/video_mcux_csi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019, Linaro Limited
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -17,6 +18,16 @@
#include <fsl_cache.h>
#endif

#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX)
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
DEVICE_DT_GET(DT_PARENT(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label)))))
#else
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label))))
#endif

struct video_mcux_csi_config {
CSI_Type *base;
const struct device *source_dev;
Expand All @@ -32,25 +43,6 @@ struct video_mcux_csi_data {
struct k_poll_signal *signal;
};

static inline unsigned int video_pix_fmt_bpp(uint32_t pixelformat)
{
switch (pixelformat) {
case VIDEO_PIX_FMT_BGGR8:
case VIDEO_PIX_FMT_GBRG8:
case VIDEO_PIX_FMT_GRBG8:
case VIDEO_PIX_FMT_RGGB8:
return 1;
case VIDEO_PIX_FMT_RGB565:
case VIDEO_PIX_FMT_YUYV:
return 2;
case VIDEO_PIX_FMT_XRGB32:
case VIDEO_PIX_FMT_XYUV32:
return 4;
default:
return 0;
}
}

static void __frame_done_cb(CSI_Type *base, csi_handle_t *handle, status_t status, void *user_data)
{
struct video_mcux_csi_data *data = user_data;
Expand Down Expand Up @@ -217,6 +209,11 @@ static int video_mcux_csi_stream_start(const struct device *dev)
const struct video_mcux_csi_config *config = dev->config;
struct video_mcux_csi_data *data = dev->data;
status_t ret;
struct video_buf *vbuf;

while ((vbuf = k_fifo_get(&data->fifo_out, K_NO_WAIT))) {
k_fifo_put(&data->fifo_in, vbuf);
};

ret = CSI_TransferStart(config->base, &data->csi_handle);
if (ret != kStatus_Success) {
Expand Down Expand Up @@ -450,6 +447,42 @@ static int video_mcux_csi_set_signal(const struct device *dev, enum video_endpoi
}
#endif

static int video_mcux_csi_set_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival *frmival)
{
const struct video_mcux_csi_config *config = dev->config;

return video_set_frmival(config->source_dev, ep, frmival);
}

static int video_mcux_csi_get_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival *frmival)
{
const struct video_mcux_csi_config *config = dev->config;

return video_get_frmival(config->source_dev, ep, frmival);
}

static int video_mcux_csi_enum_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival_enum *fie)
{
const struct video_mcux_csi_config *config = dev->config;
const struct video_format *fie_fmt = fie->format;
int ret;

#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX)
struct video_format converted_fmt = *fie->format;

video_pix_fmt_convert(&converted_fmt, false);
fie->format = &converted_fmt;
#endif

ret = video_enum_frmival(config->source_dev, ep, fie);
fie->format = fie_fmt;

return ret;
}

static const struct video_driver_api video_mcux_csi_driver_api = {
.set_format = video_mcux_csi_set_fmt,
.get_format = video_mcux_csi_get_fmt,
Expand All @@ -461,6 +494,9 @@ static const struct video_driver_api video_mcux_csi_driver_api = {
.set_ctrl = video_mcux_csi_set_ctrl,
.get_ctrl = video_mcux_csi_get_ctrl,
.get_caps = video_mcux_csi_get_caps,
.set_frmival = video_mcux_csi_set_frmival,
.get_frmival = video_mcux_csi_get_frmival,
.enum_frmival = video_mcux_csi_enum_frmival,
#ifdef CONFIG_POLL
.set_signal = video_mcux_csi_set_signal,
#endif
Expand All @@ -471,7 +507,7 @@ PINCTRL_DT_INST_DEFINE(0);

static const struct video_mcux_csi_config video_mcux_csi_config_0 = {
.base = (CSI_Type *)DT_INST_REG_ADDR(0),
.source_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, source)),
.source_dev = DEVICE_DT_INST_GET_SOURCE_DEV(0),
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};

Expand All @@ -490,11 +526,6 @@ static int video_mcux_csi_init_0(const struct device *dev)
return video_mcux_csi_init(dev);
}

/* CONFIG_KERNEL_INIT_PRIORITY_DEVICE is used to make sure the
* CSI peripheral is initialized before the camera, which is
* necessary since the clock to the camera is provided by the
* CSI peripheral.
*/
DEVICE_DT_INST_DEFINE(0, &video_mcux_csi_init_0, NULL, &video_mcux_csi_data_0,
&video_mcux_csi_config_0, POST_KERNEL, CONFIG_VIDEO_MCUX_CSI_INIT_PRIORITY,
&video_mcux_csi_driver_api);
Expand Down
Loading
Loading