Skip to content

Commit

Permalink
drivers: video: csi: Rename sensor to source
Browse files Browse the repository at this point in the history
The CSI can connect to either a camera sensor (as on i.MX RT10xx) or
a MIPI CSI-2 receiver (as on i.MX RT11xx). To be generic, change the
naming from sensor to source.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
  • Loading branch information
ngphibang authored and nashif committed May 15, 2024
1 parent aad76a9 commit ba1565b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion boards/madmachine/mm_swiftio/mm_swiftio.dts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

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

Expand Down
2 changes: 1 addition & 1 deletion boards/nxp/mimxrt1064_evk/mimxrt1064_evk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ zephyr_udc0: &usb1 {

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

Expand Down
38 changes: 19 additions & 19 deletions drivers/video/video_mcux_csi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

struct video_mcux_csi_config {
CSI_Type *base;
const struct device *sensor_dev;
const struct device *source_dev;
const struct pinctrl_dev_config *pincfg;
};

Expand Down Expand Up @@ -144,7 +144,7 @@ static int video_mcux_csi_set_fmt(const struct device *dev, enum video_endpoint_
return -EIO;
}

if (config->sensor_dev && video_set_format(config->sensor_dev, ep, fmt)) {
if (config->source_dev && video_set_format(config->source_dev, ep, fmt)) {
return -EIO;
}

Expand All @@ -160,8 +160,8 @@ static int video_mcux_csi_get_fmt(const struct device *dev, enum video_endpoint_
return -EINVAL;
}

if (config->sensor_dev && !video_get_format(config->sensor_dev, ep, fmt)) {
/* align CSI with sensor fmt */
if (config->source_dev && !video_get_format(config->source_dev, ep, fmt)) {
/* align CSI with source fmt */
return video_mcux_csi_set_fmt(dev, ep, fmt);
}

Expand All @@ -179,7 +179,7 @@ static int video_mcux_csi_stream_start(const struct device *dev)
return -EIO;
}

if (config->sensor_dev && video_stream_start(config->sensor_dev)) {
if (config->source_dev && video_stream_start(config->source_dev)) {
return -EIO;
}

Expand All @@ -192,7 +192,7 @@ static int video_mcux_csi_stream_stop(const struct device *dev)
struct video_mcux_csi_data *data = dev->data;
status_t ret;

if (config->sensor_dev && video_stream_stop(config->sensor_dev)) {
if (config->source_dev && video_stream_stop(config->source_dev)) {
return -EIO;
}

Expand Down Expand Up @@ -283,9 +283,9 @@ static inline int video_mcux_csi_set_ctrl(const struct device *dev, unsigned int
const struct video_mcux_csi_config *config = dev->config;
int ret = -ENOTSUP;

/* Forward to sensor dev if any */
if (config->sensor_dev) {
ret = video_set_ctrl(config->sensor_dev, cid, value);
/* Forward to source dev if any */
if (config->source_dev) {
ret = video_set_ctrl(config->source_dev, cid, value);
}

return ret;
Expand All @@ -296,9 +296,9 @@ static inline int video_mcux_csi_get_ctrl(const struct device *dev, unsigned int
const struct video_mcux_csi_config *config = dev->config;
int ret = -ENOTSUP;

/* Forward to sensor dev if any */
if (config->sensor_dev) {
ret = video_get_ctrl(config->sensor_dev, cid, value);
/* Forward to source dev if any */
if (config->source_dev) {
ret = video_get_ctrl(config->source_dev, cid, value);
}

return ret;
Expand All @@ -314,15 +314,15 @@ static int video_mcux_csi_get_caps(const struct device *dev, enum video_endpoint
return -EINVAL;
}

/* Just forward to sensor dev for now */
if (config->sensor_dev) {
err = video_get_caps(config->sensor_dev, ep, caps);
/* Just forward to source dev for now */
if (config->source_dev) {
err = video_get_caps(config->source_dev, ep, caps);
}

/* NXP MCUX CSI request at least 2 buffer before starting */
caps->min_vbuf_count = 2;

/* no sensor dev */
/* no source dev */
return err;
}

Expand All @@ -344,10 +344,10 @@ static int video_mcux_csi_init(const struct device *dev)

CSI_GetDefaultConfig(&data->csi_config);

/* check if there is any sensor device (video ctrl device)
/* check if there is any source device (video ctrl device)
* the device is not yet initialized so we only check if it exists
*/
if (config->sensor_dev == NULL) {
if (config->source_dev == NULL) {
return -ENODEV;
}

Expand Down Expand Up @@ -396,7 +396,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),
.sensor_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, sensor)),
.source_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, source)),
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};

Expand Down
5 changes: 3 additions & 2 deletions dts/bindings/video/nxp,imx-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ properties:
interrupts:
required: true

sensor:
source:
required: true
type: phandle
description: phandle of connected sensor device
description: the connected source device,
e.g., a mipi csi or a camera sensor

0 comments on commit ba1565b

Please sign in to comment.