This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62A-LP: camera-Unable to produce image(ds954+ds953+sensor+isp)

Part Number: SK-AM62A-LP
Other Parts Discussed in Thread: TEST2

hw link: 

ds954+ds953+SG2-OX03CC-5200-FPDLink(sensor+isp->YUV422_8b)

Some of the issues can be found in the following link

AM62A7: AM62A7-支持ub960-ub953 - 处理器论坛 - 处理器 - E2ETm 设计支持 (ti.com)

following,we use ,get noting 

SK-AM62A-LP: debug about csi2rx - Processors forum - Processors - TI E2E support forums

// SPDX-License-Identifier: GPL-2.0
/*
 * Dummy driver for IMX390 self streaming cameras
 *
 */

#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/v4l2-mediabus.h>
#include <linux/videodev2.h>
#include <media/v4l2-subdev.h>

struct imx390_dummy {
	struct device *dev;
	struct i2c_client *client;
	struct v4l2_subdev subdev;
	struct media_pad pad;
};

static inline struct imx390_dummy *to_imx390(struct v4l2_subdev *sd)
{
	return container_of(sd, struct imx390_dummy, subdev);
}

static void imx390_dummy_init_formats(struct v4l2_subdev_state *state)
{
	struct v4l2_mbus_framefmt *format;

	format = v4l2_state_get_stream_format(state, 0, 0);
	format->code = MEDIA_BUS_FMT_UYVY8_2X8;
	format->width = 1920;
	format->height = 1080;
	format->field = V4L2_FIELD_NONE;
	format->colorspace = V4L2_COLORSPACE_SMPTE170M;
}

static int _imx390_dummy_set_routing(struct v4l2_subdev *sd,
			       struct v4l2_subdev_state *state)
{
	struct v4l2_subdev_route routes[] = {
		{
			.source_pad = 0,
			.source_stream = 0,
			.flags = V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
				 V4L2_SUBDEV_ROUTE_FL_SOURCE |
				 V4L2_SUBDEV_ROUTE_FL_ACTIVE,
		},
		{
			.source_pad = 0,
			.source_stream = 1,
			.flags = V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
				 V4L2_SUBDEV_ROUTE_FL_SOURCE,
		}
	};

	struct v4l2_subdev_krouting routing = {
		.num_routes = ARRAY_SIZE(routes),
		.routes = routes,
	};

	int ret;

	ret = v4l2_subdev_set_routing(sd, state, &routing);
	if (ret < 0)
		return ret;

	imx390_dummy_init_formats(state);

	return 0;
}

static int imx390_dummy_init_cfg(struct v4l2_subdev *sd,
			   struct v4l2_subdev_state *state)
{
	int ret;

	v4l2_subdev_lock_state(state);

	ret = _imx390_dummy_set_routing(sd, state);

	v4l2_subdev_unlock_state(state);

	return ret;
}

static int imx390_dummy_enum_mbus_code(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *state,
				 struct v4l2_subdev_mbus_code_enum *code)
{
	code->code = MEDIA_BUS_FMT_UYVY8_2X8;

	return 0;
}

static int imx390_dummy_enum_frame_sizes(struct v4l2_subdev *sd,
				   struct v4l2_subdev_state *state,
				   struct v4l2_subdev_frame_size_enum *fse)
{
	fse->min_width = 1920;
	fse->max_width = fse->min_width;
	fse->max_height = 1080;
	fse->min_height = fse->max_height;

	return 0;
}

static int imx390_dummy_set_fmt(struct v4l2_subdev *sd,
			  struct v4l2_subdev_state *state,
			  struct v4l2_subdev_format *fmt)
{
	struct v4l2_mbus_framefmt *format;
	u32 code;
	int ret = 0;

	code = MEDIA_BUS_FMT_UYVY8_2X8;

	v4l2_subdev_lock_state(state);

	/* Update the stored format and return it. */
	format = v4l2_state_get_stream_format(state, fmt->pad, fmt->stream);

	format->code = code;
	format->width = 1920;
	format->height = 1080;

	fmt->format = *format;

	v4l2_subdev_unlock_state(state);

	return ret;
}

static int imx390_dummy_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
				 struct v4l2_mbus_frame_desc *fd)
{
	struct v4l2_subdev_state *state;
	struct v4l2_mbus_framefmt *fmt;
	u32 bpp;
	int ret = 0;

	if (pad != 0)
		return -EINVAL;

	state = v4l2_subdev_lock_active_state(sd);

	fmt = v4l2_state_get_stream_format(state, 0, 0);
	if (!fmt) {
		ret = -EPIPE;
		goto out;
	}

	memset(fd, 0, sizeof(*fd));

	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;

	/* pixel stream */

	bpp = 12;

	fd->entry[fd->num_entries].stream = 0;

	fd->entry[fd->num_entries].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX;
	fd->entry[fd->num_entries].length = fmt->width * fmt->height * bpp / 8;
	fd->entry[fd->num_entries].pixelcode = fmt->code;
	fd->entry[fd->num_entries].bus.csi2.vc = 0;
	fd->entry[fd->num_entries].bus.csi2.dt = 0x2c; /* SRGGB12 */

	fd->num_entries++;

out:
	v4l2_subdev_unlock_state(state);

	return ret;
}

static int imx390_dummy_set_routing(struct v4l2_subdev *sd,
			      struct v4l2_subdev_state *state,
			      enum v4l2_subdev_format_whence which,
			      struct v4l2_subdev_krouting *routing)
{
	int ret;

	if (routing->num_routes == 0 || routing->num_routes > 1)
		return -EINVAL;

	v4l2_subdev_lock_state(state);

	ret = _imx390_dummy_set_routing(sd, state);

	v4l2_subdev_unlock_state(state);

	return ret;
}

static int imx390_dummy_get_frame_interval(struct v4l2_subdev *sd,
				     struct v4l2_subdev_frame_interval *fi)
{
	fi->interval.numerator = 1;
	fi->interval.denominator = 30;
	return 0;
}

static int imx390_dummy_set_frame_interval(struct v4l2_subdev *sd,
				     struct v4l2_subdev_frame_interval *fi)
{
	int ret = 0;

	fi->interval.numerator = 1;
	fi->interval.denominator = 30;

	return ret;
}

static int imx390_dummy_set_stream(struct v4l2_subdev *sd, int enable)
{
	return 0;
}

static const struct v4l2_subdev_video_ops imx390_dummy_subdev_video_ops = {
	.g_frame_interval = imx390_dummy_get_frame_interval,
	.s_frame_interval = imx390_dummy_set_frame_interval,
	.s_stream = imx390_dummy_set_stream,
};

static const struct v4l2_subdev_pad_ops imx390_dummy_subdev_pad_ops = {
	.init_cfg = imx390_dummy_init_cfg,
	.enum_mbus_code	= imx390_dummy_enum_mbus_code,
	.enum_frame_size = imx390_dummy_enum_frame_sizes,
	.get_fmt = v4l2_subdev_get_fmt,
	.set_fmt = imx390_dummy_set_fmt,
	.set_routing = imx390_dummy_set_routing,
	.get_frame_desc	= imx390_dummy_get_frame_desc,
};

static const struct v4l2_subdev_ops imx390_dummy_subdev_ops = {
	.video	= &imx390_dummy_subdev_video_ops,
	.pad	= &imx390_dummy_subdev_pad_ops,
};

static int imx390_dummy_probe(struct i2c_client *client)
{
	struct imx390_dummy *imx390;
	struct v4l2_subdev *sd;
	int ret;

	imx390 = devm_kzalloc(&client->dev, sizeof(*imx390), GFP_KERNEL);
	if (!imx390)
		return -ENOMEM;

	imx390->dev = &client->dev;

	/* Initialize the subdev and its controls. */
	sd = &imx390->subdev;
	v4l2_i2c_subdev_init(sd, client, &imx390_dummy_subdev_ops);

	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
		     V4L2_SUBDEV_FL_HAS_EVENTS |
		     V4L2_SUBDEV_FL_MULTIPLEXED;

	/* Initialize the media entity. */
	imx390->pad.flags = MEDIA_PAD_FL_SOURCE;
	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
	ret = media_entity_pads_init(&sd->entity, 1, &imx390->pad);
	if (ret < 0) {
		dev_err(imx390->dev,
			"%s: media entity init failed %d\n", __func__, ret);
		return ret;
	}

	ret = v4l2_subdev_init_finalize(sd);
	if (ret < 0)
		goto err_subdev_cleanup;

	/* Finally, register the subdev. */
	ret = v4l2_async_register_subdev(sd);
	if (ret < 0) {
		dev_err(imx390->dev,
			"%s: v4l2 subdev register failed %d\n", __func__, ret);
		goto err_subdev_cleanup;
	}

	dev_info(imx390->dev, "imx390 dummy probed\n");
	return 0;

err_subdev_cleanup:
	v4l2_subdev_cleanup(&imx390->subdev);
	media_entity_cleanup(&imx390->subdev.entity);

	return ret;
}

static int imx390_dummy_remove(struct i2c_client *client)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct imx390_dummy *imx390 = to_imx390(sd);

	v4l2_async_unregister_subdev(sd);
	v4l2_subdev_cleanup(&imx390->subdev);
	media_entity_cleanup(&sd->entity);

	return 0;
}

struct of_device_id imx390_dummy_dt_id[] = {
	{ .compatible = "ottobrite,imx390dummy" },
	{ /* sentinel */ }
};

MODULE_DEVICE_TABLE(of, imx390_dummy_dt_id);

static struct i2c_driver imx390_dummy_i2c_driver = {
	.driver = {
		.name = "imx390dummy",
		.of_match_table = of_match_ptr(imx390_dummy_dt_id),
	},
	.probe_new = imx390_dummy_probe,
	.remove = imx390_dummy_remove,
};

module_i2c_driver(imx390_dummy_i2c_driver);

MODULE_DESCRIPTION("Dummy Driver for self streaming IMX390");
MODULE_AUTHOR("Vaishnav Achath <vaishnav.a@ti.com>");
MODULE_LICENSE("GPL v2");

 sh fmt-dummy.sh 
root@am62axx-evm:/opt/edgeai-gst-apps#  yavta -s 1920x1080 -f UYVY  /dev/video2 -c100^C
root@am62axx-evm:/opt/edgeai-gst-apps# media-ctl  -2023 Feb 27 10:38:50 am62axx-evm Process 1172 (edgeai-gui-app) of user 0 dumped core.
2023 Feb 27 10:38:50 am62axx-evm Process 1172 (edgeai-gui-app) of user 0 dumped core.
p
Media controller API version 5.10.168

Media device information
------------------------
driver          j721e-csi2rx
model           TI-CSI2RX
serial          
bus info        platform:30102000.ticsi2rx
hw revision     0x1
driver version  5.10.168

Device topology
- entity 1: 30102000.ticsi2rx (7 pads, 7 links, 1 route)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        routes:
                0/0 -> 1/0 [ACTIVE]
        pad0: Sink
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
        pad1: Source
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
        pad2: Source
                -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
        pad3: Source
                -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
        pad4: Source
                -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]
        pad5: Source
                -> "30102000.ticsi2rx context 4":0 [ENABLED,IMMUTABLE]
        pad6: Source
                -> "30102000.ticsi2rx context 5":0 [ENABLED,IMMUTABLE]

- entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev1
        pad0: Sink
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
        pad1: Source
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
        pad2: Source
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
        pad3: Source
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
        pad4: Source
                [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]

- entity 15: ds90ub960 4-003d (6 pads, 2 links, 1 route)
             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev2
        routes:
                0/0 -> 4/0 [ACTIVE]
        pad0: Sink
                [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                <- "ds90ub953 4-0044":1 [ENABLED,IMMUTABLE]
        pad1: Sink
        pad2: Sink
        pad3: Sink
        pad4: Source
                [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
        pad5: Source

- entity 24: ds90ub953 4-0044 (2 pads, 2 links, 1 route)
             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev3
        routes:
                0/0 -> 1/0 [ACTIVE]
        pad0: Sink
                [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                <- "imx390dummy 6-001a":0 [ENABLED,IMMUTABLE]
        pad1: Source
                [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                -> "ds90ub960 4-003d":0 [ENABLED,IMMUTABLE]

- entity 29: imx390dummy 6-001a (1 pad, 1 link, 2 routes)
             type V4L2 subdev subtype Sensor flags 0
             device node name /dev/v4l-subdev4
        routes:
                0/0 -> 0/0 [ACTIVE, IMMUTABLE, SOURCE]
                0/0 -> 0/1 [INACTIVE, IMMUTABLE, SOURCE]
        pad0: Source
                [stream:0 fmt:UYVY8_2X8/1920x1080@1/30 field:none colorspace:smpte170m]
                -> "ds90ub953 4-0044":0 [ENABLED,IMMUTABLE]

- entity 35: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video2
        pad0: Sink
                <- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]

- entity 41: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video3
        pad0: Sink
                <- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]

- entity 47: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video4
        pad0: Sink
                <- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]

- entity 53: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video5
        pad0: Sink
                <- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]

- entity 59: 30102000.ticsi2rx context 4 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video6
        pad0: Sink
                <- "30102000.ticsi2rx":5 [ENABLED,IMMUTABLE]

- entity 65: 30102000.ticsi2rx context 5 (1 pad, 1 link, 0 route)
             type Node subtype V4L flags 0
             device node name /dev/video7
        pad0: Sink
                <- "30102000.ticsi2rx":6 [ENABLED,IMMUTABLE]

root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps#  yavta -s 1920x1080 -f UYVY  /dev/video2 -c100
Device /dev/video2 opened.
[   45.194119] zyk ti_csi2rx_queue_setup 823
Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video[   45.202359] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 0, plane 0 offset 0x00000000
 output (without mplanes) device.
Video format set: UYVY (59565[   45.217124] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 1, plane 0 offset 0x003f5000
955) 1920x1080 (stride 3840) field none buffer size 4147200
Vid[   45.232340] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 2, plane 0 offset 0x007ea000
eo format: UYVY (59565955) 1920x1080 (stride 3840) field none bu[   45.247598] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 3, plane 0 offset 0x00bdf000
ffer size 4147200
[   45.262464] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 4, plane 0 offset 0x00fd4000
[   45.273497] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 5, plane 0 offset 0x013c9000
[   45.284784] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 6, plane 0 offset 0x017be000
[   45.296014] videobuf2_common: [cap-00000000cb995559] __setup_offsets: buffer 7, plane 0 offset 0x01bb3000
[   45.305733] videobuf2_common: [cap-00000000cb995559] __vb2_queue_alloc: allocated 8 buffers, 1 plane(s) each
8 buffers requested.
[   45.315896] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 0, plane 0 successfully mapped
length: 4147200 offset: 0 timestamp type/source: mono/EoF
[   45.326905] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 1, plane 0 successfully mapped
Buffer 0/0 mapped at address 0xffff90858000.
length: 4147200 of[   45.340994] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 2, plane 0 successfully mapped
fset: 4149248 timestamp type/source: mono/EoF
Buffer 1/0 mapped[   45.355768] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 3, plane 0 successfully mapped
 at address 0xffff90463000.
length: 4147200 offset: 8298496 tim[   45.370292] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 4, plane 0 successfully mapped
estamp type/source: mono/EoF
Buffer 2/0 mapped at address 0xfff[   45.385079] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 5, plane 0 successfully mapped
f9006e000.
length: 4147200 offset: 12447744 timestamp type/sour[   45.399614] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 6, plane 0 successfully mapped
ce: mono/EoF
Buffer 3/0 mapped at address 0xffff8fc79000.
leng[   45.414405] videobuf2_common: [cap-00000000cb995559] vb2_mmap: buffer 7, plane 0 successfully mapped
th: 4147200 offset: 16596992 timestamp type/source: mono/EoF
Bu[   45.428887] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 0 succeeded
ffer 4/0 mapped at address 0xffff8f884000.
length: 4147200 offs[   45.443092] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 1 succeeded
et: 20746240 timestamp type/source: mono/EoF
Buffer 5/0 mapped [   45.457113] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 2 succeeded
at address 0xffff8f48f000.
length: 4147200 offset: 24895488 tim[   45.471343] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 3 succeeded
estamp type/source: mono/EoF
Buffer 6/0 mapped at address 0xfff[   45.485408] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 4 succeeded
f8f09a000.
length: 4147200 offset: 29044736 timestamp type/sour[   45.485418] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 5 succeeded
ce: mono/EoF
Buffer 7/0 mapped at address 0xffff8eca5000.
[   45.513652] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 6 succeeded
[   45.513664] videobuf2_common: [cap-00000000cb995559] vb2_core_qbuf: qbuf of buffer 7 succeeded
[   45.536178] zyk ti_csi2rx_buffer_queue 875
[   45.540487] zyk ti_csi2rx_buffer_queue 875
[   45.544616] zyk ti_csi2rx_buffer_queue 875
[   45.544622] zyk ti_csi2rx_buffer_queue 875
[   45.552954] zyk ti_csi2rx_buffer_queue 875
[   45.552958] zyk ti_csi2rx_buffer_queue 875
[   45.552961] zyk ti_csi2rx_buffer_queue 875
[   45.552963] zyk ti_csi2rx_buffer_queue 875
[   45.570942] zyk ti_csi2rx_start_dma 771
[   45.574949] videobuf2_common: [cap-00000000cb995559] vb2_core_streamon: successful
[   45.582596] videobuf2_common: [cap-00000000cb995559] __vb2_wait_for_done_vb: will sleep waiting for buffers





^Z[   48.565869] videobuf2_common: [cap-00000000cb995559] __vb2_wait_for_done_vb: sleep was interrupted

[1]+  Stopped(SIGTSTP)        yavta -s 1920x1080 -f UYVY /dev/video2 -c100
root@am62axx-evm:/opt/edgeai-gst-apps# sh C0.sh 
953 config

953 end config
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# 
root@am62axx-evm:/opt/edgeai-gst-apps# fg
yavta -s 1920x1080 -f UYVY /dev/video2 -c100[   54.197831] videobuf2_common: [cap-00000000cb995559] __vb2_wait_for_done_vb: will sleep waiting for buffers

  • Hi Daiwei,

    Your cdns csi-bridge format is incorrect:

    - entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev1
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                    <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
    

    In SDK 8.6, when you set the sensor format, the csi-bridge format should be set automatically. You code may have some issues. Can you try to set it to the same format as the sensor using the same command? For example, 

    media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0 [fmt:UYVY8_2X8/1920x1080 field: none]'

    Regards,

    Jianzhong

  • Now,I send the media-ctrl cmd,and get noting too

    test1:

    media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0 [fmt:UYVY8_2X8/1920x1080 field: none]'

    Media controller API version 5.10.168
    
    Media device information
    ------------------------
    driver          j721e-csi2rx
    model           TI-CSI2RX
    serial          
    bus info        platform:30102000.ticsi2rx
    hw revision     0x1
    driver version  5.10.168
    
    Device topology
    - entity 1: 30102000.ticsi2rx (7 pads, 7 links, 1 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev0
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
            pad3: Source
                    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
            pad4: Source
                    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]
            pad5: Source
                    -> "30102000.ticsi2rx context 4":0 [ENABLED,IMMUTABLE]
            pad6: Source
                    -> "30102000.ticsi2rx context 5":0 [ENABLED,IMMUTABLE]
    
    - entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev1
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad3: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
    
    - entity 15: ds90ub960 4-003d (6 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev2
            routes:
                    0/0 -> 4/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub953 4-0044":1 [ENABLED,IMMUTABLE]
            pad1: Sink
            pad2: Sink
            pad3: Sink
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
            pad5: Source
    
    - entity 24: ds90ub953 4-0044 (2 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev3
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    <- "imx390dummy 6-001a":0 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    -> "ds90ub960 4-003d":0 [ENABLED,IMMUTABLE]
    
    - entity 29: imx390dummy 6-001a (1 pad, 1 link, 2 routes)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev4
            routes:
                    0/0 -> 0/0 [ACTIVE, IMMUTABLE, SOURCE]
                    0/0 -> 0/1 [INACTIVE, IMMUTABLE, SOURCE]
            pad0: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080@1/30 field:none colorspace:smpte170m]
                    -> "ds90ub953 4-0044":0 [ENABLED,IMMUTABLE]
    
    - entity 35: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video2
            pad0: Sink
                    <- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]
    
    - entity 41: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video3
            pad0: Sink
                    <- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]
    
    - entity 47: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video4
            pad0: Sink
                    <- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]
    
    - entity 53: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video5
            pad0: Sink
                    <- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]
    
    - entity 59: 30102000.ticsi2rx context 4 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video6
            pad0: Sink
                    <- "30102000.ticsi2rx":5 [ENABLED,IMMUTABLE]
    
    - entity 65: 30102000.ticsi2rx context 5 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video7
            pad0: Sink
                    <- "30102000.ticsi2rx":6 [ENABLED,IMMUTABLE]
    
    root@am62axx-evm:/opt/edgeai-gst-apps# 
    root@am62axx-evm:/opt/edgeai-gst-apps#  yavta -s 1920x1080 -f UYVY  /dev/video2 -c100
    Device /dev/video2 opened.
    [   72.478289] zyk ti_csi2rx_queue_setup 823
    Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video[   72.486540] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 0, plane 0 offset 0x00000000
     output (without mplanes) device.
    Video format set: UYVY (59565[   72.501326] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 1, plane 0 offset 0x003f5000
    955) 1920x1080 (stride 3840) field none buffer size 4147200
    Vid[   72.516519] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 2, plane 0 offset 0x007ea000
    eo format: UYVY (59565955) 1920x1080 (stride 3840) field none bu[   72.531616] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 3, plane 0 offset 0x00bdf000
    ffer size 4147200
    [   72.547119] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 4, plane 0 offset 0x00fd4000
    [   72.558255] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 5, plane 0 offset 0x013c9000
    [   72.569324] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 6, plane 0 offset 0x017be000
    [   72.580554] videobuf2_common: [cap-0000000043af633a] __setup_offsets: buffer 7, plane 0 offset 0x01bb3000
    [   72.590274] videobuf2_common: [cap-0000000043af633a] __vb2_queue_alloc: allocated 8 buffers, 1 plane(s) each
    8 buffers requested.
    [   72.600404] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 0, plane 0 successfully mapped
    length: 4147200 offset: 0 timestamp type/source: mono/EoF
    [   72.611407] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 1, plane 0 successfully mapped
    Buffer 0/0 mapped at address 0xffff94f64000.
    length: 4147200 of[   72.625515] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 2, plane 0 successfully mapped
    fset: 4149248 timestamp type/source: mono/EoF
    Buffer 1/0 mapped[   72.640156] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 3, plane 0 successfully mapped
     at address 0xffff94b6f000.
    length: 4147200 offset: 8298496 tim[   72.655010] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 4, plane 0 successfully mapped
    estamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xfff[   72.669477] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 5, plane 0 successfully mapped
    f9477a000.
    length: 4147200 offset: 12447744 timestamp type/sour[   72.684291] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 6, plane 0 successfully mapped
    ce: mono/EoF
    Buffer 3/0 mapped at address 0xffff94385000.
    leng[   72.698795] videobuf2_common: [cap-0000000043af633a] vb2_mmap: buffer 7, plane 0 successfully mapped
    th: 4147200 offset: 16596992 timestamp type/source: mono/EoF
    Bu[   72.713503] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 0 succeeded
    ffer 4/0 mapped at address 0xffff93f90000.
    length: 4147200 offs[   72.727513] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 1 succeeded
    et: 20746240 timestamp type/source: mono/EoF
    Buffer 5/0 mapped [   72.741806] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 2 succeeded
    at address 0xffff93b9b000.
    length: 4147200 offset: 24895488 tim[   72.755819] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 3 succeeded
    estamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xfff[   72.755830] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 4 succeeded
    f937a6000.
    length: 4147200 offset: 29044736 timestamp type/sour[   72.784049] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 5 succeeded
    ce: mono/EoF
    Buffer 7/0 mapped at address 0xffff933b1000.
    [   72.784057] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 6 succeeded
    [   72.811973] videobuf2_common: [cap-0000000043af633a] vb2_core_qbuf: qbuf of buffer 7 succeeded
    [   72.820737] zyk ti_csi2rx_buffer_queue 875
    [   72.820746] zyk ti_csi2rx_buffer_queue 875
    [   72.820751] zyk ti_csi2rx_buffer_queue 875
    [   72.833037] zyk ti_csi2rx_buffer_queue 875
    [   72.833042] zyk ti_csi2rx_buffer_queue 875
    [   72.841373] zyk ti_csi2rx_buffer_queue 875
    [   72.841377] zyk ti_csi2rx_buffer_queue 875
    [   72.841379] zyk ti_csi2rx_buffer_queue 875
    [   72.855245] zyk ti_csi2rx_start_dma 771
    [   72.859254] videobuf2_common: [cap-0000000043af633a] vb2_core_streamon: successful
    [   72.866880] videobuf2_common: [cap-0000000043af633a] __vb2_wait_for_done_vb: will sleep waiting for buffers
    ^Z[   73.974595] videobuf2_common: [cap-0000000043af633a] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -s 1920x1080 -f UYVY /dev/video2 -c100
    root@am62axx-evm:/opt/edgeai-gst-apps# sh C0.sh 
    953 config
    953 end config
    root@am62axx-evm:/opt/edgeai-gst-apps# fg
    yavta -s 1920x1080 -f UYVY /dev/video2 -c100[   78.177833] videobuf2_common: [cap-0000000043af633a] __vb2_wait_for_done_vb: will sleep waiting for buffers
    
    
    
    
    
    
    
    
    
    ^Z[  100.054252] videobuf2_common: [cap-0000000043af633a] __vb2_wait_for_done_vb: sleep was interrupted
    

    test2:

    add media-ctl -V '"30102000.ticsi2rx":0 [fmt:UYVY8_2X8/1920x1080 field: none]'

    media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    media-ctl -V '"30102000.ticsi2rx":0 [fmt:UYVY8_2X8/1920x1080 field: none]'

    but I find the format has some problem,the format on 30102000.ticsi2rx can't change

    30102000.ticsi2rx 

    [stream:0 fmt:YUYV8_1X16/1920x1080 field:none]

     cdns_csi2rx.30101000.csi-bridge

     [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]

    check the source code not have format UYVY8_2X8

    ti-processor-sdk-linux-am62axx-evm-08.06.00.45\board-support\linux-kernel\drivers\media\platform\ti\j721e-csi2rx\j721e-csi2rx.c

    static const struct ti_csi2rx_fmt formats[] = {
    	{
    		.fourcc			= V4L2_PIX_FMT_YUYV,
    		.code			= MEDIA_BUS_FMT_YUYV8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_UYVY,
    		.code			= MEDIA_BUS_FMT_UYVY8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_YVYU,
    		.code			= MEDIA_BUS_FMT_YVYU8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_VYUY,
    		.code			= MEDIA_BUS_FMT_VYUY8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR8,
    		.code			= MEDIA_BUS_FMT_SBGGR8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG8,
    		.code			= MEDIA_BUS_FMT_SGBRG8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG8,
    		.code			= MEDIA_BUS_FMT_SGRBG8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB8,
    		.code			= MEDIA_BUS_FMT_SRGGB8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR10,
    		.code			= MEDIA_BUS_FMT_SBGGR10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG10,
    		.code			= MEDIA_BUS_FMT_SGBRG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG10,
    		.code			= MEDIA_BUS_FMT_SGRBG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB10,
    		.code			= MEDIA_BUS_FMT_SRGGB10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR12,
    		.code			= MEDIA_BUS_FMT_SBGGR12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG12,
    		.code			= MEDIA_BUS_FMT_SGBRG12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG12,
    		.code			= MEDIA_BUS_FMT_SGRBG12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB12,
    		.code			= MEDIA_BUS_FMT_SRGGB12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGI10,
    		.code			= MEDIA_BUS_FMT_SRGGI10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRIG10,
    		.code			= MEDIA_BUS_FMT_SGRIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGI10,
    		.code			= MEDIA_BUS_FMT_SBGGI10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBIG10,
    		.code			= MEDIA_BUS_FMT_SGBIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGIRG10,
    		.code			= MEDIA_BUS_FMT_SGRIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SIGGR10,
    		.code			= MEDIA_BUS_FMT_SIGGR10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGIBG10,
    		.code			= MEDIA_BUS_FMT_SGIBG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SIGGB10,
    		.code			= MEDIA_BUS_FMT_SIGGB10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	},
    
    	/* More formats can be supported but they are not listed for now. */
    }


     media-ctl -V '"30102000.ticsi2rx":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    root@am62axx-evm:/opt/edgeai-gst-apps# media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    root@am62axx-evm:/opt/edgeai-gst-apps# media-ctl  -p
    Media controller API version 5.10.168
    
    Media device information
    ------------------------
    driver          j721e-csi2rx
    model           TI-CSI2RX
    serial          
    bus info        platform:30102000.ticsi2rx
    hw revision     0x1
    driver version  5.10.168
    
    Device topology
    - entity 1: 30102000.ticsi2rx (7 pads, 7 links, 1 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev0
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:YUYV8_1X16/1920x1080 field:none]
                    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:YUYV8_1X16/1920x1080 field:none]
                    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
            pad3: Source
                    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
            pad4: Source
                    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]
            pad5: Source
                    -> "30102000.ticsi2rx context 4":0 [ENABLED,IMMUTABLE]
            pad6: Source
                    -> "30102000.ticsi2rx context 5":0 [ENABLED,IMMUTABLE]
    
    - entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev1
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad3: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
    
    - entity 15: ds90ub960 4-003d (6 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev2
            routes:
                    0/0 -> 4/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub953 4-0044":1 [ENABLED,IMMUTABLE]
            pad1: Sink
            pad2: Sink
            pad3: Sink
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
            pad5: Source
    
    - entity 24: ds90ub953 4-0044 (2 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev3
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    <- "imx390dummy 6-001a":0 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    -> "ds90ub960 4-003d":0 [ENABLED,IMMUTABLE]
    
    - entity 29: imx390dummy 6-001a (1 pad, 1 link, 2 routes)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev4
            routes:
                    0/0 -> 0/0 [ACTIVE, IMMUTABLE, SOURCE]
                    0/0 -> 0/1 [INACTIVE, IMMUTABLE, SOURCE]
            pad0: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080@1/30 field:none colorspace:smpte170m]
                    -> "ds90ub953 4-0044":0 [ENABLED,IMMUTABLE]
    
    - entity 35: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video2
            pad0: Sink
                    <- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]
    
    - entity 41: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video3
            pad0: Sink
                    <- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]
    
    - entity 47: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video4
            pad0: Sink
                    <- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]
    
    - entity 53: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video5
            pad0: Sink
                    <- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]
    
    - entity 59: 30102000.ticsi2rx context 4 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video6
            pad0: Sink
                    <- "30102000.ticsi2rx":5 [ENABLED,IMMUTABLE]
    
    - entity 65: 30102000.ticsi2rx context 5 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video7
            pad0: Sink
                    <- "30102000.ticsi2rx":6 [ENABLED,IMMUTABLE]

    test :

       yavta -c -Fcapture -s 1920x1080 -f UYVY  /dev/video2 
    Device /dev/video2 opened.
    [  236.942246] zyk ti_csi2rx_queue_setup 823
    Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video[  236.950487] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 0, plane 0 offset 0x00000000
     output (without mplanes) device.
    Video format set: UYVY (59565[  236.965242] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 1, plane 0 offset 0x003f5000
    955) 1920x1080 (stride 3840) field none buffer size 4147200
    Vid[  236.980453] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 2, plane 0 offset 0x007ea000
    eo format: UYVY (59565955) 1920x1080 (stride 3840) field none bu[  236.995574] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 3, plane 0 offset 0x00bdf000
    ffer size 4147200
    [  237.010711] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 4, plane 0 offset 0x00fd4000
    [  237.021861] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 5, plane 0 offset 0x013c9000
    [  237.032949] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 6, plane 0 offset 0x017be000
    [  237.044175] videobuf2_common: [cap-0000000029faadb1] __setup_offsets: buffer 7, plane 0 offset 0x01bb3000
    [  237.053954] videobuf2_common: [cap-0000000029faadb1] __vb2_queue_alloc: allocated 8 buffers, 1 plane(s) each
    8 buffers requested.
    [  237.064111] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 0, plane 0 successfully mapped
    length: 4147200 offset: 0 timestamp type/source: mono/EoF
    [  237.075102] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 1, plane 0 successfully mapped
    Buffer 0/0 mapped at address 0xffff9fb1f000.
    length: 4147200 of[  237.089220] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 2, plane 0 successfully mapped
    fset: 4149248 timestamp type/source: mono/EoF
    Buffer 1/0 mapped[  237.103960] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 3, plane 0 successfully mapped
     at address 0xffff9f72a000.
    length: 4147200 offset: 8298496 tim[  237.118522] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 4, plane 0 successfully mapped
    estamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xfff[  237.133482] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 5, plane 0 successfully mapped
    f9f335000.
    length: 4147200 offset: 12447744 timestamp type/sour[  237.147833] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 6, plane 0 successfully mapped
    ce: mono/EoF
    Buffer 3/0 mapped at address 0xffff9ef40000.
    leng[  237.162665] videobuf2_common: [cap-0000000029faadb1] vb2_mmap: buffer 7, plane 0 successfully mapped
    th: 4147200 offset: 16596992 timestamp type/source: mono/EoF
    Bu[  237.177119] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 0 succeeded
    ffer 4/0 mapped at address 0xffff9eb4b000.
    length: 4147200 offs[  237.191390] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 1 succeeded
    et: 20746240 timestamp type/source: mono/EoF
    Buffer 5/0 mapped [  237.205355] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 2 succeeded
    at address 0xffff9e756000.
    length: 4147200 offset: 24895488 tim[  237.219588] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 3 succeeded
    estamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xfff[  237.233645] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 4 succeeded
    f9e361000.
    length: 4147200 offset: 29044736 timestamp type/sour[  237.233655] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 5 succeeded
    ce: mono/EoF
    Buffer 7/0 mapped at address 0xffff9df6c000.
    [  237.261895] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 6 succeeded
    [  237.261905] videobuf2_common: [cap-0000000029faadb1] vb2_core_qbuf: qbuf of buffer 7 succeeded
    [  237.284416] zyk ti_csi2rx_buffer_queue 875
    [  237.288664] zyk ti_csi2rx_buffer_queue 875
    [  237.288673] zyk ti_csi2rx_buffer_queue 875
    [  237.288676] zyk ti_csi2rx_buffer_queue 875
    [  237.288679] zyk ti_csi2rx_buffer_queue 875
    [  237.288681] zyk ti_csi2rx_buffer_queue 875
    [  237.288684] zyk ti_csi2rx_buffer_queue 875
    [  237.288687] zyk ti_csi2rx_buffer_queue 875
    [  237.319542] zyk ti_csi2rx_start_dma 771
    [  237.323462] videobuf2_common: [cap-0000000029faadb1] vb2_core_streamon: successful
    [  237.331109] videobuf2_common: [cap-0000000029faadb1] __vb2_wait_for_done_vb: will sleep waiting for buffers
    
    
    ^Z[  239.853478] videobuf2_common: [cap-0000000029faadb1] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -c -Fcapture -s 1920x1080 -f UYVY /dev/video2
    root@am62axx-evm:/opt/edgeai-gst-apps# sh C0.sh 
    953 config
    953 end config
    root@am62axx-evm:/opt/edgeai-gst-apps# fg
    yavta -c -Fcapture -s 1920x1080 -f UYVY /dev/video2
    [  248.165806] videobuf2_common: [cap-0000000029faadb1] __vb2_wait_for_done_vb: will sleep waiting for buffers
    
    
    
    
    
    ^Z[  420.446286] videobuf2_common: [cap-0000000029faadb1] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -c -Fcapture -s 1920x1080 -f UYVY /dev/video2

    debug

    0x438 on ds954 is 1080,0xf00 for 1920 ,and devmem2 0x30101048 CSI_RX_IF_VBUS2APB_DPHY_STATUS is toggling between ‘0x2’ and ‘0x3’

    root@am62axx-evm:/opt/edgeai-gst-apps# sh get_camera_data_info.sh 
    0x33
    0x04
    0x38
    0x0f
    0x00
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffff9cf13000.
    Read at address  0x30101048 (0xffff9cf13048): 0x00333206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffff9e0fb000.
    Read at address  0x30101048 (0xffff9e0fb048): 0x00222206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffffb4b4d000.
    Read at address  0x30101048 (0xffffb4b4d048): 0x00333206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffffa1759000.
    Read at address  0x30101048 (0xffffa1759048): 0x00333206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffff82587000.
    Read at address  0x30101048 (0xffff82587048): 0x00333206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101048
    /dev/mem opened.
    Memory mapped at address 0xffffb4d95000.
    Read at address  0x30101048 (0xffffb4d95048): 0x00222206
    root@am62axx-evm:/opt/edgeai-gst-apps# devmem2 0x30101040
    /dev/mem opened.
    Memory mapped at address 0xffffb9965000.
    Read at address  0x30101040 (0xffffb9965040): 0x0001F01F

    test 3:

    fix ti-processor-sdk-linux-am62axx-evm-08.06.00.45\board-support\linux-kernel\drivers\media\platform\ti\j721e-csi2rx\j721e-csi2rx.c  yuv format

    setting format

    media-ctl -V '"ds90ub953 4-0044":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    media-ctl -V '"ds90ub960 4-003d":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    media-ctl -V '"imx390dummy 6-001a":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0 [fmt:UYVY8_2X8/1920x1080 field: none]'
    media-ctl -V '"30102000.ticsi2rx":0 [fmt:UYVY8_2X8/1920x1080 field: none]'

    print media-ctrl -p

    root@am62axx-evm:/opt/edgeai-gst-apps# media-ctl  -p
    Media controller API version 5.10.168
    
    Media device information
    ------------------------
    driver          j721e-csi2rx
    model           TI-CSI2RX
    serial          
    bus info        platform:30102000.ticsi2rx
    hw revision     0x1
    driver version  5.10.168
    
    Device topology
    - entity 1: 30102000.ticsi2rx (7 pads, 7 links, 1 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev0
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
            pad3: Source
                    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
            pad4: Source
                    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]
            pad5: Source
                    -> "30102000.ticsi2rx context 4":0 [ENABLED,IMMUTABLE]
            pad6: Source
                    -> "30102000.ticsi2rx context 5":0 [ENABLED,IMMUTABLE]
    
    - entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev1
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad3: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
    
    - entity 15: ds90ub960 4-003d (6 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev2
            routes:
                    0/0 -> 4/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    <- "ds90ub953 4-0044":1 [ENABLED,IMMUTABLE]
            pad1: Sink
            pad2: Sink
            pad3: Sink
            pad4: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none]
                    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
            pad5: Source
    
    - entity 24: ds90ub953 4-0044 (2 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev3
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    <- "imx390dummy 6-001a":0 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080 field:none colorspace:smpte170m]
                    -> "ds90ub960 4-003d":0 [ENABLED,IMMUTABLE]
    
    - entity 29: imx390dummy 6-001a (1 pad, 1 link, 2 routes)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev4
            routes:
                    0/0 -> 0/0 [ACTIVE, IMMUTABLE, SOURCE]
                    0/0 -> 0/1 [INACTIVE, IMMUTABLE, SOURCE]
            pad0: Source
                    [stream:0 fmt:UYVY8_2X8/1920x1080@1/30 field:none colorspace:smpte170m]
                    -> "ds90ub953 4-0044":0 [ENABLED,IMMUTABLE]
    
    - entity 35: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video2
            pad0: Sink
                    <- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]
    
    - entity 41: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video3
            pad0: Sink
                    <- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]
    
    - entity 47: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video4
            pad0: Sink
                    <- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]
    
    - entity 53: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video5
            pad0: Sink
                    <- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]
    
    - entity 59: 30102000.ticsi2rx context 4 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video6
            pad0: Sink
                    <- "30102000.ticsi2rx":5 [ENABLED,IMMUTABLE]
    
    - entity 65: 30102000.ticsi2rx context 5 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video7
            pad0: Sink
                    <- "30102000.ticsi2rx":6 [ENABLED,IMMUTABLE]
    

    test ,get noting

      yavta -s 1920x1080 -f UYVY  /dev/video2 -c100
    Device /dev/video2 opened.
    [ 1219.258501] zyk ti_csi2rx_queue_setup 832
    Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video[ 1219.266732] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 0, plane 0 offset 0x00000000
     output (without mplanes) device.
    Video format set: UYVY (59565[ 1219.281492] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 1, plane 0 offset 0x003f5000
    955) 1920x1080 (stride 3840) field none buffer size 4147200
    Vid[ 1219.296798] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 2, plane 0 offset 0x007ea000
    eo format: UYVY (59565955) 1920x1080 (stride 3840) field none bu[ 1219.311839] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 3, plane 0 offset 0x00bdf000
    ffer size 4147200
    [ 1219.326985] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 4, plane 0 offset 0x00fd4000
    [ 1219.338137] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 5, plane 0 offset 0x013c9000
    [ 1219.349340] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 6, plane 0 offset 0x017be000
    [ 1219.360644] videobuf2_common: [cap-000000003165fb16] __setup_offsets: buffer 7, plane 0 offset 0x01bb3000
    [ 1219.370376] videobuf2_common: [cap-000000003165fb16] __vb2_queue_alloc: allocated 8 buffers, 1 plane(s) each
    8 buffers requested.
    [ 1219.380533] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 0, plane 0 successfully mapped
    length: 4147200 offset: 0 timestamp type/source: mono/EoF
    [ 1219.391532] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 1, plane 0 successfully mapped
    Buffer 0/0 mapped at address 0xffff7f1ea000.
    length: 4147200 of[ 1219.405638] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 2, plane 0 successfully mapped
    fset: 4149248 timestamp type/source: mono/EoF
    Buffer 1/0 mapped[ 1219.420370] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 3, plane 0 successfully mapped
     at address 0xffff7edf5000.
    length: 4147200 offset: 8298496 tim[ 1219.434947] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 4, plane 0 successfully mapped
    estamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xfff[ 1219.449766] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 5, plane 0 successfully mapped
    f7ea00000.
    length: 4147200 offset: 12447744 timestamp type/sour[ 1219.464274] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 6, plane 0 successfully mapped
    ce: mono/EoF
    Buffer 3/0 mapped at address 0xffff7e60b000.
    leng[ 1219.479084] videobuf2_common: [cap-000000003165fb16] vb2_mmap: buffer 7, plane 0 successfully mapped
    th: 4147200 offset: 16596992 timestamp type/source: mono/EoF
    Bu[ 1219.493556] zyk ti_csi2rx_buffer_prepare 844
    ffer 4/0 mapped at address 0xffff7e216000.
    length: 4147200 offs[ 1219.503264] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 0 succeeded
    et: 20746240 timestamp type/source: mono/EoF
    Buffer 5/0 mapped [ 1219.517540] zyk ti_csi2rx_buffer_prepare 844
    at address 0xffff7de21000.
    length: 4147200 offset: 24895488 tim[ 1219.527242] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 1 succeeded
    estamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xfff[ 1219.527266] zyk ti_csi2rx_buffer_prepare 844
    f7da2c000.
    length: 4147200 offset: 29044736 timestamp type/sour[ 1219.551150] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 2 succeeded
    ce: mono/EoF
    Buffer 7/0 mapped at address 0xffff7d637000.
    [ 1219.551174] zyk ti_csi2rx_buffer_prepare 844
    [ 1219.574751] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 3 succeeded
    [ 1219.574775] zyk ti_csi2rx_buffer_prepare 844
    [ 1219.587794] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 4 succeeded
    [ 1219.587812] zyk ti_csi2rx_buffer_prepare 844
    [ 1219.600816] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 5 succeeded
    [ 1219.600833] zyk ti_csi2rx_buffer_prepare 844
    [ 1219.613844] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 6 succeeded
    [ 1219.613864] zyk ti_csi2rx_buffer_prepare 844
    [ 1219.626826] videobuf2_common: [cap-000000003165fb16] vb2_core_qbuf: qbuf of buffer 7 succeeded
    [ 1219.635596] zyk ti_csi2rx_buffer_queue 862
    [ 1219.635601] zyk ti_csi2rx_buffer_queue 886
    [ 1219.635604] zyk ti_csi2rx_buffer_queue 862
    [ 1219.635606] zyk ti_csi2rx_buffer_queue 886
    [ 1219.635611] zyk ti_csi2rx_buffer_queue 862
    [ 1219.656074] zyk ti_csi2rx_buffer_queue 886
    [ 1219.660312] zyk ti_csi2rx_buffer_queue 862
    [ 1219.660317] zyk ti_csi2rx_buffer_queue 886
    [ 1219.668521] zyk ti_csi2rx_buffer_queue 862
    [ 1219.668524] zyk ti_csi2rx_buffer_queue 886
    [ 1219.668526] zyk ti_csi2rx_buffer_queue 862
    [ 1219.668529] zyk ti_csi2rx_buffer_queue 886
    [ 1219.668532] zyk ti_csi2rx_buffer_queue 862
    [ 1219.668534] zyk ti_csi2rx_buffer_queue 886
    [ 1219.668536] zyk ti_csi2rx_buffer_queue 862
    [ 1219.668539] zyk ti_csi2rx_buffer_queue 886
    [ 1219.668544] zyk ti_csi2rx_start_streaming 942
    [ 1219.705788] zyk ti_csi2rx_start_streaming 984
    [ 1219.710293] zyk ti_csi2rx_get_vc 908
    [ 1219.713998] zyk ti_csi2rx_setup_shim 624
    [ 1219.719669] zyk ti_csi2rx_start_dma 772
    [ 1219.719695] zyk ti_csi2rx_start_dma 780
    [ 1219.727558] videobuf2_common: [cap-000000003165fb16] vb2_core_streamon: successful
    [ 1219.735266] videobuf2_common: [cap-000000003165fb16] __vb2_wait_for_done_vb: will sleep waiting for buffers
    ^Z[ 1221.208857] videobuf2_common: [cap-000000003165fb16] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -s 1920x1080 -f UYVY /dev/video2 -c100
    root@am62axx-evm:/opt/edgeai-gst-apps# 
    root@am62axx-evm:/opt/edgeai-gst-apps# sh C0.sh 
    953 config
    953 end config
    root@am62axx-evm:/opt/edgeai-gst-apps# fg
    yavta -s 1920x1080 -f UYVY /dev/video2 -c100
    [ 1230.585864] videobuf2_common: [cap-000000003165fb16] __vb2_wait_for_done_vb: will sleep waiting for buffers
    
    
    
    
    
    ^Z[ 1234.350656] videobuf2_common: [cap-000000003165fb16] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -s 1920x1080 -f UYVY /dev/video2 -c100
    root@am62axx-evm:/opt/edgeai-gst-apps# sh get_camera_data_info.sh 
    0x33
    0x04
    0x38
    0x0f
    0x00

  • Hello Daiwei,

    I'm on holiday break and will get back to you in early January.

    Thanks for your patience.

    Regards,

    Jianzhong

  • Hello Daiwei,

    I'm back from holiday break. What's your current debugging status?

    Regards,

    Jianzhong

  • pls see my last reply,I have no update

  • Ok. Thanks.

    fix ti-processor-sdk-linux-am62axx-evm-08.06.00.45\board-support\linux-kernel\drivers\media\platform\ti\j721e-csi2rx\j721e-csi2rx.c  yuv format

    Can you share your code change to j721e-csi2rx.c?

  • // SPDX-License-Identifier: GPL-2.0-only
    /*
     * TI CSI2 RX driver.
     *
     * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
     *
     * Author: Pratyush Yadav <p.yadav@ti.com>
     */
    
    #include <linux/bitfield.h>
    #include <linux/module.h>
    #include <linux/platform_device.h>
    #include <linux/dmaengine.h>
    #include <linux/of_platform.h>
    #include <linux/pm.h>
    
    #include <media/v4l2-device.h>
    #include <media/v4l2-ioctl.h>
    #include <media/videobuf2-dma-contig.h>
    
    #define TI_CSI2RX_MODULE_NAME		"j721e-csi2rx"
    
    #define SHIM_CNTL			0x10
    #define SHIM_CNTL_PIX_RST		BIT(0)
    
    #define SHIM_DMACNTX(i)			(0x20 + ((i) * 0x20))
    #define SHIM_DMACNTX_EN			BIT(31)
    #define SHIM_DMACNTX_YUV422		GENMASK(27, 26)
    #define SHIM_DMACNTX_SIZE		GENMASK(21, 20)
    #define SHIM_DMACNTX_VC			GENMASK(9, 6)
    #define SHIM_DMACNTX_FMT		GENMASK(5, 0)
    #define SHIM_DMACNTX_UYVY		0
    #define SHIM_DMACNTX_VYUY		1
    #define SHIM_DMACNTX_YUYV		2
    #define SHIM_DMACNTX_YVYU		3
    #define SHIM_DMACNTX_SIZE_8		0
    #define SHIM_DMACNTX_SIZE_16		1
    #define SHIM_DMACNTX_SIZE_32		2
    
    #define SHIM_PSI_CFG0(i)		(0x24 + ((i) * 0x20))
    #define SHIM_PSI_CFG0_SRC_TAG		GENMASK(15, 0)
    #define SHIM_PSI_CFG0_DST_TAG		GENMASK(31, 16)
    
    #define CSI_DF_YUV420			0x18
    #define CSI_DF_YUV422			0x1e
    #define CSI_DF_RGB444			0x20
    #define CSI_DF_RGB888			0x24
    #define CSI_DF_RAW8			0x2a
    #define CSI_DF_RAW10			0x2b
    #define CSI_DF_RAW12			0x2c
    
    #define PSIL_WORD_SIZE_BYTES		16
    #define TI_CSI2RX_MAX_CTX		32
    
    /*
     * There are no hard limits on the width or height. The DMA engine can handle
     * all sizes. The max width and height are arbitrary numbers for this driver.
     * Use 16M * 16M as the arbitrary limit. It is large enough that it is unlikely
     * the limit will be hit in practice.
     */
    #define MAX_WIDTH_BYTES			SZ_16M
    #define MAX_HEIGHT_BYTES		SZ_16M
    
    #define TI_CSI2RX_PAD_SINK		0
    #define TI_CSI2RX_PAD_FIRST_SOURCE	1
    #define TI_CSI2RX_MAX_SOURCE_PADS	TI_CSI2RX_MAX_CTX
    #define TI_CSI2RX_MAX_PADS		(1 + TI_CSI2RX_MAX_SOURCE_PADS)
    
    #define DRAIN_TIMEOUT_MS		50
    
    struct ti_csi2rx_fmt {
    	u32				fourcc;	/* Four character code. */
    	u32				code;	/* Mbus code. */
    	enum v4l2_colorspace		colorspace;
    	u32				csi_df;	/* CSI Data format. */
    	u8				bpp;	/* Bits per pixel. */
    	u8				size;	/* Data size shift when unpacking. */
    };
    
    struct ti_csi2rx_buffer {
    	/* Common v4l2 buffer. Must be first. */
    	struct vb2_v4l2_buffer		vb;
    	struct list_head		list;
    	struct ti_csi2rx_ctx		*ctx;
    };
    
    enum ti_csi2rx_dma_state {
    	TI_CSI2RX_DMA_STOPPED,	/* Streaming not started yet. */
    	TI_CSI2RX_DMA_IDLE,	/* Streaming but no pending DMA operation. */
    	TI_CSI2RX_DMA_ACTIVE,	/* Streaming and pending DMA operation. */
    };
    
    struct ti_csi2rx_dma {
    	/* Protects all fields in this struct. */
    	spinlock_t			lock;
    	struct dma_chan			*chan;
    	/* Buffers queued to the driver, waiting to be processed by DMA. */
    	struct list_head		queue;
    	enum ti_csi2rx_dma_state	state;
    	/*
    	 * Current buffer being processed by DMA. NULL if no buffer is being
    	 * processed.
    	 */
    	struct ti_csi2rx_buffer		*curr;
    };
    
    struct ti_csi2rx_dev;
    
    struct ti_csi2rx_ctx {
    	struct ti_csi2rx_dev		*csi;
    	struct video_device		vdev;
    	struct vb2_queue		vidq;
    	struct mutex			mutex; /* To serialize ioctls. */
    	struct v4l2_format		v_fmt;
    	struct ti_csi2rx_dma		dma;
    	struct media_pad		pad;
    	u32				sequence;
    	u32				idx;
    	u32				vc;
    	u32				stream;
    };
    
    struct ti_csi2rx_dev {
    	struct device			*dev;
    	void __iomem			*shim;
    	/* To serialize core subdev ioctls. */
    	struct mutex			mutex;
    	unsigned int			enable_count;
    	unsigned int			num_ctx;
    	struct v4l2_async_notifier	notifier;
    	struct media_device		mdev;
    	struct media_pipeline		pipe;
    	struct media_pad		pads[TI_CSI2RX_MAX_PADS];
    	struct v4l2_device		v4l2_dev;
    	struct v4l2_subdev		*source;
    	struct v4l2_subdev		subdev;
    	struct ti_csi2rx_ctx		ctx[TI_CSI2RX_MAX_CTX];
    };
    
    static const struct ti_csi2rx_fmt formats[] = {
    	{
    		.fourcc			= V4L2_PIX_FMT_UYVY,
    		.code			= MEDIA_BUS_FMT_UYVY8_2X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	},{
    		.fourcc			= V4L2_PIX_FMT_YUYV,
    		.code			= MEDIA_BUS_FMT_YUYV8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_UYVY,
    		.code			= MEDIA_BUS_FMT_UYVY8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_YVYU,
    		.code			= MEDIA_BUS_FMT_YVYU8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_VYUY,
    		.code			= MEDIA_BUS_FMT_VYUY8_1X16,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_YUV422,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR8,
    		.code			= MEDIA_BUS_FMT_SBGGR8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG8,
    		.code			= MEDIA_BUS_FMT_SGBRG8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG8,
    		.code			= MEDIA_BUS_FMT_SGRBG8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB8,
    		.code			= MEDIA_BUS_FMT_SRGGB8_1X8,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW8,
    		.bpp			= 8,
    		.size			= SHIM_DMACNTX_SIZE_8,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR10,
    		.code			= MEDIA_BUS_FMT_SBGGR10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG10,
    		.code			= MEDIA_BUS_FMT_SGBRG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG10,
    		.code			= MEDIA_BUS_FMT_SGRBG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB10,
    		.code			= MEDIA_BUS_FMT_SRGGB10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGR12,
    		.code			= MEDIA_BUS_FMT_SBGGR12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBRG12,
    		.code			= MEDIA_BUS_FMT_SGBRG12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRBG12,
    		.code			= MEDIA_BUS_FMT_SGRBG12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGB12,
    		.code			= MEDIA_BUS_FMT_SRGGB12_1X12,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW12,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SRGGI10,
    		.code			= MEDIA_BUS_FMT_SRGGI10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGRIG10,
    		.code			= MEDIA_BUS_FMT_SGRIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SBGGI10,
    		.code			= MEDIA_BUS_FMT_SBGGI10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGBIG10,
    		.code			= MEDIA_BUS_FMT_SGBIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGIRG10,
    		.code			= MEDIA_BUS_FMT_SGRIG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SIGGR10,
    		.code			= MEDIA_BUS_FMT_SIGGR10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SGIBG10,
    		.code			= MEDIA_BUS_FMT_SGIBG10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	}, {
    		.fourcc			= V4L2_PIX_FMT_SIGGB10,
    		.code			= MEDIA_BUS_FMT_SIGGB10_1X10,
    		.colorspace		= V4L2_COLORSPACE_SRGB,
    		.csi_df			= CSI_DF_RAW10,
    		.bpp			= 16,
    		.size			= SHIM_DMACNTX_SIZE_16,
    	},
    
    	/* More formats can be supported but they are not listed for now. */
    };
    
    static const unsigned int num_formats = ARRAY_SIZE(formats);
    
    /* Forward declaration needed by ti_csi2rx_dma_callback. */
    static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx,
    			       struct ti_csi2rx_buffer *buf);
    
    static const struct ti_csi2rx_fmt *find_format_by_pix(u32 pixelformat)
    {
    	unsigned int i;
    
    	for (i = 0; i < num_formats; i++) {
    		if (formats[i].fourcc == pixelformat)
    			return &formats[i];
    	}
    
    	return NULL;
    }
    
    static const struct ti_csi2rx_fmt *find_format_by_code(u32 code)
    {
    	unsigned int i;
    
    	for (i = 0; i < num_formats; i++) {
    		if (formats[i].code == code)
    			return &formats[i];
    	}
    
    	return NULL;
    }
    
    static void ti_csi2rx_fill_fmt(const struct ti_csi2rx_fmt *csi_fmt,
    			       struct v4l2_format *v4l2_fmt)
    {
    	struct v4l2_pix_format *pix = &v4l2_fmt->fmt.pix;
    	u32 bpl;
    
    	v4l2_fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	pix->pixelformat = csi_fmt->fourcc;
    	pix->colorspace = csi_fmt->colorspace;
    	pix->sizeimage = pix->height * pix->width * (csi_fmt->bpp / 8);
    
    	bpl = (pix->width * ALIGN(csi_fmt->bpp, 8)) >> 3;
    	pix->bytesperline = ALIGN(bpl, 16);
    }
    
    static int ti_csi2rx_querycap(struct file *file, void *priv,
    			      struct v4l2_capability *cap)
    {
    	struct ti_csi2rx_ctx *ctx = video_drvdata(file);
    
    	strscpy(cap->driver, TI_CSI2RX_MODULE_NAME, sizeof(cap->driver));
    	strscpy(cap->card, TI_CSI2RX_MODULE_NAME, sizeof(cap->card));
    
    	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
    		 dev_name(ctx->csi->dev));
    
    	return 0;
    }
    
    static int ti_csi2rx_enum_fmt_vid_cap(struct file *file, void *priv,
    				      struct v4l2_fmtdesc *f)
    {
    	if (f->index >= num_formats)
    		return -EINVAL;
    
    	memset(f->reserved, 0, sizeof(f->reserved));
    	f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	f->pixelformat = formats[f->index].fourcc;
    
    	return 0;
    }
    
    static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov,
    				   struct v4l2_format *f)
    {
    	struct ti_csi2rx_ctx *ctx = video_drvdata(file);
    
    	*f = ctx->v_fmt;
    
    	return 0;
    }
    
    static int ti_csi2rx_try_fmt_vid_cap(struct file *file, void *priv,
    				     struct v4l2_format *f)
    {
    	const struct ti_csi2rx_fmt *fmt;
    
    	/*
    	 * Default to the first format if the requested pixel format code isn't
    	 * supported.
    	 */
    	fmt = find_format_by_pix(f->fmt.pix.pixelformat);
    	if (!fmt)
    		fmt = &formats[0];
    
    	if (f->fmt.pix.field == V4L2_FIELD_ANY)
    		f->fmt.pix.field = V4L2_FIELD_NONE;
    
    	if (f->fmt.pix.field != V4L2_FIELD_NONE)
    		return -EINVAL;
    
    	ti_csi2rx_fill_fmt(fmt, f);
    
    	return 0;
    }
    
    static int ti_csi2rx_s_fmt_vid_cap(struct file *file, void *priv,
    				   struct v4l2_format *f)
    {
    	struct ti_csi2rx_ctx *ctx = video_drvdata(file);
    	struct vb2_queue *q = &ctx->vidq;
    	int ret;
    
    	if (vb2_is_busy(q))
    		return -EBUSY;
    
    	ret = ti_csi2rx_try_fmt_vid_cap(file, priv, f);
    	if (ret < 0)
    		return ret;
    
    	ctx->v_fmt = *f;
    
    	return 0;
    }
    
    static int ti_csi2rx_enum_framesizes(struct file *file, void *fh,
    				     struct v4l2_frmsizeenum *fsize)
    {
    	const struct ti_csi2rx_fmt *fmt;
    	unsigned int pixels_in_word;
    	u8 bpp;
    
    	fmt = find_format_by_pix(fsize->pixel_format);
    	if (!fmt || fsize->index != 0)
    		return -EINVAL;
    
    	bpp = ALIGN(fmt->bpp, 8);
    
    	/*
    	 * Number of pixels in one PSI-L word. The transfer happens in multiples
    	 * of PSI-L word sizes.
    	 */
    	pixels_in_word = PSIL_WORD_SIZE_BYTES * 8 / bpp;
    
    	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
    	fsize->stepwise.min_width = pixels_in_word;
    	fsize->stepwise.max_width = rounddown(MAX_WIDTH_BYTES, pixels_in_word);
    	fsize->stepwise.step_width = pixels_in_word;
    	fsize->stepwise.min_height = 1;
    	fsize->stepwise.max_height = MAX_HEIGHT_BYTES;
    	fsize->stepwise.step_height = 1;
    
    	return 0;
    }
    
    static const struct v4l2_ioctl_ops csi_ioctl_ops = {
    	.vidioc_querycap      = ti_csi2rx_querycap,
    	.vidioc_enum_fmt_vid_cap = ti_csi2rx_enum_fmt_vid_cap,
    	.vidioc_try_fmt_vid_cap = ti_csi2rx_try_fmt_vid_cap,
    	.vidioc_g_fmt_vid_cap = ti_csi2rx_g_fmt_vid_cap,
    	.vidioc_s_fmt_vid_cap = ti_csi2rx_s_fmt_vid_cap,
    	.vidioc_enum_framesizes = ti_csi2rx_enum_framesizes,
    	.vidioc_reqbufs       = vb2_ioctl_reqbufs,
    	.vidioc_create_bufs   = vb2_ioctl_create_bufs,
    	.vidioc_prepare_buf   = vb2_ioctl_prepare_buf,
    	.vidioc_querybuf      = vb2_ioctl_querybuf,
    	.vidioc_qbuf          = vb2_ioctl_qbuf,
    	.vidioc_dqbuf         = vb2_ioctl_dqbuf,
    	.vidioc_expbuf        = vb2_ioctl_expbuf,
    	.vidioc_streamon      = vb2_ioctl_streamon,
    	.vidioc_streamoff     = vb2_ioctl_streamoff,
    };
    
    static const struct v4l2_file_operations csi_fops = {
    	.owner = THIS_MODULE,
    	.open = v4l2_fh_open,
    	.release = vb2_fop_release,
    	.read = vb2_fop_read,
    	.poll = vb2_fop_poll,
    	.unlocked_ioctl = video_ioctl2,
    	.mmap = vb2_fop_mmap,
    };
    
    static int ti_csi2rx_video_register(struct ti_csi2rx_ctx *ctx)
    {
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	struct video_device *vdev = &ctx->vdev;
    	int ret;
    
    	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
    	if (ret)
    		return ret;
    
    	ret = media_create_pad_link(&csi->subdev.entity,
    				    TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx,
    				    &vdev->entity, 0,
    				    MEDIA_LNK_FL_IMMUTABLE |
    				    MEDIA_LNK_FL_ENABLED);
    	if (ret) {
    		video_unregister_device(vdev);
    		return ret;
    	}
    
    	return 0;
    }
    
    static int csi_async_notifier_bound(struct v4l2_async_notifier *notifier,
    				    struct v4l2_subdev *subdev,
    				    struct v4l2_async_subdev *asd)
    {
    	struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev);
    
    	/* Should register only one source. */
    	WARN_ON(csi->source);
    
    	csi->source = subdev;
    
    	return 0;
    }
    
    static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier)
    {
    	struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev);
    	int ret, i, src_pad;
    
    	src_pad = media_entity_get_fwnode_pad(&csi->source->entity,
    					      csi->source->fwnode,
    					      MEDIA_PAD_FL_SOURCE);
    	if (src_pad < 0) {
    		dev_err(csi->dev, "Couldn't find source pad for subdev\n");
    		return src_pad;
    	}
    
    	ret = media_create_pad_link(&csi->source->entity, src_pad,
    				    &csi->subdev.entity, TI_CSI2RX_PAD_SINK,
    				    MEDIA_LNK_FL_IMMUTABLE |
    				    MEDIA_LNK_FL_ENABLED);
    	if (ret)
    		return ret;
    
    	for (i = 0; i < csi->num_ctx; i++) {
    		ret = ti_csi2rx_video_register(&csi->ctx[i]);
    		if (ret)
    			return ret;
    	}
    
    	return v4l2_device_register_subdev_nodes(&csi->v4l2_dev);
    }
    
    static const struct v4l2_async_notifier_operations csi_async_notifier_ops = {
    	.bound = csi_async_notifier_bound,
    	.complete = csi_async_notifier_complete,
    };
    
    static int ti_csi2rx_init_subdev(struct ti_csi2rx_dev *csi)
    {
    	struct fwnode_handle *fwnode;
    	struct v4l2_async_subdev *asd;
    	struct device_node *node;
    	int ret;
    
    	node = of_get_child_by_name(csi->dev->of_node, "csi-bridge");
    	if (!node)
    		return -EINVAL;
    
    	fwnode = of_fwnode_handle(node);
    	if (!fwnode) {
    		of_node_put(node);
    		return -EINVAL;
    	}
    
    	v4l2_async_notifier_init(&csi->notifier);
    	csi->notifier.ops = &csi_async_notifier_ops;
    
    	asd = v4l2_async_notifier_add_fwnode_subdev(&csi->notifier, fwnode,
    						    sizeof(struct v4l2_async_subdev));
    	of_node_put(node);
    	if (IS_ERR(asd)) {
    		v4l2_async_notifier_cleanup(&csi->notifier);
    		return PTR_ERR(asd);
    	}
    
    	ret = v4l2_async_notifier_register(&csi->v4l2_dev, &csi->notifier);
    	if (ret) {
    		v4l2_async_notifier_cleanup(&csi->notifier);
    		return ret;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	return 0;
    }
    
    static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx)
    {
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	const struct ti_csi2rx_fmt *fmt;
    	unsigned int reg;
    
    	fmt = find_format_by_pix(ctx->v_fmt.fmt.pix.pixelformat);
    	if (!fmt) {
    		dev_err(csi->dev, "Unknown format\n");
    		return;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	reg = SHIM_DMACNTX_EN;
    	reg |= FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_df);
    
    	/*
    	 * Using the values from the documentation gives incorrect ordering for
    	 * the luma and chroma components. In practice, the "reverse" format
    	 * gives the correct image. So for example, if the image is in UYVY, the
    	 * reverse would be YVYU.
    	 */
    	switch (fmt->fourcc) {
    	case V4L2_PIX_FMT_UYVY:
    		reg |= FIELD_PREP(SHIM_DMACNTX_YUV422,
    					SHIM_DMACNTX_YVYU);
    		break;
    	case V4L2_PIX_FMT_VYUY:
    		reg |= FIELD_PREP(SHIM_DMACNTX_YUV422,
    					SHIM_DMACNTX_YUYV);
    		break;
    	case V4L2_PIX_FMT_YUYV:
    		reg |= FIELD_PREP(SHIM_DMACNTX_YUV422,
    					SHIM_DMACNTX_VYUY);
    		break;
    	case V4L2_PIX_FMT_YVYU:
    		reg |= FIELD_PREP(SHIM_DMACNTX_YUV422,
    					SHIM_DMACNTX_UYVY);
    		break;
    	default:
    		/* Ignore if not YUV 4:2:2 */
    		break;
    	}
    
    	reg |= FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size);
    	reg |= FIELD_PREP(SHIM_DMACNTX_VC, ctx->vc);
    
    	writel(reg, csi->shim + SHIM_DMACNTX(ctx->idx));
    
    	reg = FIELD_PREP(SHIM_PSI_CFG0_SRC_TAG, 0) |
    	      FIELD_PREP(SHIM_PSI_CFG0_DST_TAG, 0);
    	writel(reg, csi->shim + SHIM_PSI_CFG0(ctx->idx));
    }
    
    static void ti_csi2rx_drain_callback(void *param)
    {
    	struct completion *drain_complete = param;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	complete(drain_complete);
    }
    
    static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *csi)
    {
    	struct dma_async_tx_descriptor *desc;
    	struct device *dev = csi->dma.chan->device->dev;
    	struct completion drain_complete;
    	void *buf;
    	size_t len = csi->v_fmt.fmt.pix.sizeimage;
    	dma_addr_t addr;
    	dma_cookie_t cookie;
    	int ret;
    
    	init_completion(&drain_complete);
    
    	buf = dma_alloc_coherent(dev, len, &addr, GFP_KERNEL | GFP_ATOMIC);
    	if (!buf)
    		return -ENOMEM;
    
    	desc = dmaengine_prep_slave_single(csi->dma.chan, addr, len,
    					   DMA_DEV_TO_MEM,
    					   DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
    	if (!desc) {
    		ret = -EIO;
    		goto out;
    	}
    
    	desc->callback = ti_csi2rx_drain_callback;
    	desc->callback_param = &drain_complete;
    
    	cookie = dmaengine_submit(desc);
    	ret = dma_submit_error(cookie);
    	if (ret)
    		goto out;
    
    	dma_async_issue_pending(csi->dma.chan);
    
    	if (!wait_for_completion_timeout(&drain_complete,
    					 msecs_to_jiffies(DRAIN_TIMEOUT_MS))) {
    		dmaengine_terminate_sync(csi->dma.chan);
    		ret = -ETIMEDOUT;
    		goto out;
    	}
    out:
    	dma_free_coherent(dev, len, buf, addr);
    	return ret;
    }
    
    static void ti_csi2rx_dma_callback(void *param)
    {
    	struct ti_csi2rx_buffer *buf = param;
    	struct ti_csi2rx_ctx *ctx = buf->ctx;
    	struct ti_csi2rx_dma *dma = &ctx->dma;
    	unsigned long flags = 0;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	buf->vb.vb2_buf.timestamp = ktime_get_ns();
    	buf->vb.sequence = ctx->sequence++;
    
    	spin_lock_irqsave(&dma->lock, flags);
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	WARN_ON(dma->curr != buf);
    	vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	/* If there are more buffers to process then start their transfer. */
    	dma->curr = NULL;
    	
    	printk("zyk %s %d\n",__func__,__LINE__);
    	while (!list_empty(&dma->queue)) {
    		buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
    		list_del(&buf->list);
    
    		if (ti_csi2rx_start_dma(ctx, buf)) {
    			dev_err(ctx->csi->dev,
    				"Failed to queue the next buffer for DMA\n");
    			vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
    		} else {
    			dma->curr = buf;
    			break;
    		}
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	if (!dma->curr)
    		dma->state = TI_CSI2RX_DMA_IDLE;
    
    	spin_unlock_irqrestore(&dma->lock, flags);
    }
    
    static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx,
    			       struct ti_csi2rx_buffer *buf)
    {
    	unsigned long addr;
    	struct dma_async_tx_descriptor *desc;
    	size_t len = ctx->v_fmt.fmt.pix.sizeimage;
    	dma_cookie_t cookie;
    	int ret = 0;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
    	desc = dmaengine_prep_slave_single(ctx->dma.chan, addr, len,
    					   DMA_DEV_TO_MEM,
    					   DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
    	if (!desc)
    		return -EIO;
    	printk("zyk %s %d\n",__func__,__LINE__);
    	desc->callback = ti_csi2rx_dma_callback;
    	desc->callback_param = buf;
    
    	cookie = dmaengine_submit(desc);
    	ret = dma_submit_error(cookie);
    	if (ret)
    		return ret;
    
    	dma_async_issue_pending(ctx->dma.chan);
    
    	return 0;
    }
    
    static int ti_csi2rx_restart_dma(struct ti_csi2rx_ctx *ctx,
    				 struct ti_csi2rx_buffer *buf)
    {
    	struct ti_csi2rx_dma *dma = &ctx->dma;
    	unsigned long flags = 0;
    	int ret = 0;
    
    	ret = ti_csi2rx_drain_dma(ctx);
    	if (ret)
    		dev_warn(ctx->csi->dev,
    			 "Failed to drain DMA. Next frame might be bogus\n");
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ret = ti_csi2rx_start_dma(ctx, buf);
    	if (ret) {
    		dev_err(ctx->csi->dev, "Failed to start DMA: %d\n", ret);
    		spin_lock_irqsave(&dma->lock, flags);
    		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
    		dma->curr = NULL;
    		dma->state = TI_CSI2RX_DMA_IDLE;
    		spin_unlock_irqrestore(&dma->lock, flags);
    	}
    
    	return ret;
    }
    
    static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers,
    				 unsigned int *nplanes, unsigned int sizes[],
    				 struct device *alloc_devs[])
    {
    	struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(q);
    	unsigned int size = ctx->v_fmt.fmt.pix.sizeimage;
    
    	if (*nplanes) {
    		if (sizes[0] < size)
    			return -EINVAL;
    		size = sizes[0];
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	*nplanes = 1;
    	sizes[0] = size;
    
    	return 0;
    }
    
    static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb)
    {
    	struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
    	unsigned long size = ctx->v_fmt.fmt.pix.sizeimage;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	if (vb2_plane_size(vb, 0) < size) {
    		dev_err(ctx->csi->dev, "Data will not fit into plane\n");
    		return -EINVAL;
    	}
    
    	vb2_set_plane_payload(vb, 0, size);
    	return 0;
    }
    
    static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb)
    {
    	struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
    	struct ti_csi2rx_buffer *buf;
    	struct ti_csi2rx_dma *dma = &ctx->dma;
    	bool restart_dma = false;
    	unsigned long flags = 0;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	buf = container_of(vb, struct ti_csi2rx_buffer, vb.vb2_buf);
    	buf->ctx = ctx;
    
    	spin_lock_irqsave(&dma->lock, flags);
    	/*
    	 * Usually the DMA callback takes care of queueing the pending buffers.
    	 * But if DMA has stalled due to lack of buffers, restart it now.
    	 */
    	if (dma->state == TI_CSI2RX_DMA_IDLE) {
    		/*
    		 * Do not restart DMA with the lock held because
    		 * ti_csi2rx_drain_dma() might block when allocating a buffer.
    		 * There won't be a race on queueing DMA anyway since the
    		 * callback is not being fired.
    		 */
    		restart_dma = true;
    		dma->curr = buf;
    		dma->state = TI_CSI2RX_DMA_ACTIVE;
    	} else {
    		list_add_tail(&buf->list, &dma->queue);
    	}
    	spin_unlock_irqrestore(&dma->lock, flags);
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	if (restart_dma) {
    		/*
    		 * Once frames start dropping, some data gets stuck in the DMA
    		 * pipeline somewhere. So the first DMA transfer after frame
    		 * drops gives a partial frame. This is obviously not useful to
    		 * the application and will only confuse it. Issue a DMA
    		 * transaction to drain that up.
    		 */
    		ti_csi2rx_restart_dma(ctx, buf);
    		
    		printk("zyk %s %d\n",__func__,__LINE__);
    	}
    }
    
    static int ti_csi2rx_get_vc(struct ti_csi2rx_ctx *ctx)
    {
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	struct v4l2_mbus_frame_desc fd;
    	struct media_pad *pad;
    	int ret, i;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	pad = media_entity_remote_pad(&csi->pads[TI_CSI2RX_PAD_SINK]);
    	if (!pad)
    		return -ENODEV;
    
    	ret = v4l2_subdev_call(csi->source, pad, get_frame_desc, pad->index,
    			       &fd);
    	if (ret)
    		return ret;
    
    	if (fd.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2)
    		return -EINVAL;
    
    	for (i = 0; i < fd.num_entries; i++) {
    		if (ctx->stream == fd.entry[i].stream)
    			return fd.entry[i].bus.csi2.vc;
    	}
    
    	return -ENODEV;
    }
    
    static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count)
    {
    	struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq);
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	struct ti_csi2rx_dma *dma = &ctx->dma;
    	struct ti_csi2rx_buffer *buf, *tmp;
    	struct v4l2_subdev_krouting *routing;
    	struct v4l2_subdev_route *route = NULL;
    	struct media_pad *remote_pad;
    	unsigned long flags = 0;
    	int ret = 0, i;
    	struct v4l2_subdev_state *state;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	spin_lock_irqsave(&dma->lock, flags);
    	if (list_empty(&dma->queue))
    		ret = -EIO;
    	spin_unlock_irqrestore(&dma->lock, flags);
    	if (ret)
    		return ret;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ret = media_pipeline_start(ctx->vdev.entity.pads, &csi->pipe);
    	if (ret)
    		goto err;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	remote_pad = media_entity_remote_pad(&ctx->pad);
    	if (!remote_pad) {
    		ret = -ENODEV;
    		goto err_pipeline;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	state = v4l2_subdev_lock_active_state(&csi->subdev);
    
    	routing = &state->routing;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	/* Find the stream to process. */
    	for (i = 0; i < routing->num_routes; i++) {
    		struct v4l2_subdev_route *r = &routing->routes[i];
    
    		if (!(r->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE))
    			continue;
    
    		if (r->source_pad != remote_pad->index)
    			continue;
    
    		route = r;
    		break;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	if (!route) {
    		ret = -ENODEV;
    		v4l2_subdev_unlock_state(state);
    		goto err_pipeline;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ctx->stream = route->sink_stream;
    
    	v4l2_subdev_unlock_state(state);
    
    	ret = ti_csi2rx_get_vc(ctx);
    	if (ret == -ENOIOCTLCMD)
    		ctx->vc = 0;
    	else if (ret < 0)
    		goto err_pipeline;
    	else
    		ctx->vc = ret;
    
    	ti_csi2rx_setup_shim(ctx);
    
    	ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 1);
    	if (ret)
    		goto err_pipeline;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ctx->sequence = 0;
    
    	spin_lock_irqsave(&dma->lock, flags);
    	buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
    	list_del(&buf->list);
    	dma->state = TI_CSI2RX_DMA_ACTIVE;
    
    	ret = ti_csi2rx_start_dma(ctx, buf);
    	if (ret) {
    		dev_err(csi->dev, "Failed to start DMA: %d\n", ret);
    		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
    		spin_unlock_irqrestore(&dma->lock, flags);
    		goto err_stream;
    	}
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	dma->curr = buf;
    	spin_unlock_irqrestore(&dma->lock, flags);
    
    	return 0;
    
    err_stream:
    	v4l2_subdev_call(&csi->subdev, video, s_stream, 0);
    err_pipeline:
    	media_pipeline_stop(ctx->vdev.entity.pads);
    err:
    	spin_lock_irqsave(&dma->lock, flags);
    	list_for_each_entry_safe(buf, tmp, &dma->queue, list) {
    		list_del(&buf->list);
    		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
    	}
    	ctx->dma.state = TI_CSI2RX_DMA_STOPPED;
    	spin_unlock_irqrestore(&dma->lock, flags);
    
    	return ret;
    }
    
    static void ti_csi2rx_stop_streaming(struct vb2_queue *vq)
    {
    	struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq);
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	struct ti_csi2rx_buffer *buf = NULL, *tmp;
    	struct ti_csi2rx_dma *dma = &ctx->dma;
    	unsigned long flags = 0;
    	enum ti_csi2rx_dma_state state;
    	int ret;
    
    	media_pipeline_stop(ctx->vdev.entity.pads);
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 0);
    	if (ret)
    		dev_err(csi->dev, "Failed to stop subdev stream\n");
    
    	ret = dmaengine_terminate_sync(ctx->dma.chan);
    	if (ret)
    		dev_err(csi->dev, "Failed to stop DMA\n");
    
    	writel(0, csi->shim + SHIM_DMACNTX(ctx->idx));
    
    	spin_lock_irqsave(&dma->lock, flags);
    	list_for_each_entry_safe(buf, tmp, &ctx->dma.queue, list) {
    		list_del(&buf->list);
    		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
    	}
    
    	if (dma->curr)
    		vb2_buffer_done(&dma->curr->vb.vb2_buf, VB2_BUF_STATE_ERROR);
    
    	state = dma->state;
    
    	dma->curr = NULL;
    	dma->state = TI_CSI2RX_DMA_STOPPED;
    	spin_unlock_irqrestore(&dma->lock, flags);
    
    	/*
    	 * TODO: For some reason the first frame is wrong if we don't toggle
    	 * the pixel reset. But at the same time, drain does not work either.
    	 * Figure this one out.
    	 */
    	if (state != TI_CSI2RX_DMA_STOPPED) {
    		ret = ti_csi2rx_drain_dma(ctx);
    		if (ret)
    			dev_dbg(csi->dev,
    				"Failed to drain DMA. Next frame might be bogus\n");
    	}
    }
    
    static const struct vb2_ops csi_vb2_qops = {
    	.queue_setup = ti_csi2rx_queue_setup,
    	.buf_prepare = ti_csi2rx_buffer_prepare,
    	.buf_queue = ti_csi2rx_buffer_queue,
    	.start_streaming = ti_csi2rx_start_streaming,
    	.stop_streaming = ti_csi2rx_stop_streaming,
    	.wait_prepare = vb2_ops_wait_prepare,
    	.wait_finish = vb2_ops_wait_finish,
    };
    
    static inline struct ti_csi2rx_dev *to_csi2rx_dev(struct v4l2_subdev *sd)
    {
    	return container_of(sd, struct ti_csi2rx_dev, subdev);
    }
    
    static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev *sd,
    				struct v4l2_subdev_state *state,
    				struct v4l2_subdev_format *format)
    {
    	struct v4l2_mbus_framefmt *fmt;
    	int ret = 0;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	/* No transcoding, don't allow setting source fmt */
    	if (format->pad >= TI_CSI2RX_PAD_FIRST_SOURCE)
    		return v4l2_subdev_get_fmt(sd, state, format);
    
    	if (!find_format_by_code(format->format.code))
    		format->format.code = formats[0].code;
    
    	v4l2_subdev_lock_state(state);
    
    	fmt = v4l2_state_get_stream_format(state, format->pad, format->stream);
    	if (!fmt) {
    		ret = -EINVAL;
    		goto out;
    	}
    	*fmt = format->format;
    
    	fmt = v4l2_state_get_opposite_stream_format(state, format->pad,
    						    format->stream);
    	if (!fmt) {
    		ret = -EINVAL;
    		goto out;
    	}
    	*fmt = format->format;
    
    out:
    	v4l2_subdev_unlock_state(state);
    	return ret;
    }
    
    static int _ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd,
    				    struct v4l2_subdev_state *state,
    				    struct v4l2_subdev_krouting *routing)
    {
    	int ret;
    
    	const struct v4l2_mbus_framefmt format = {
    		.width = 1920,
    		.height = 1080,
    		.code = MEDIA_BUS_FMT_UYVY8_1X16,
    		.field = V4L2_FIELD_NONE,
    		.colorspace = V4L2_COLORSPACE_SRGB,
    		.ycbcr_enc = V4L2_YCBCR_ENC_601,
    		.quantization = V4L2_QUANTIZATION_LIM_RANGE,
    		.xfer_func = V4L2_XFER_FUNC_SRGB,
    	};
    
    	v4l2_subdev_lock_state(state);
    
    	ret = v4l2_subdev_set_routing_with_fmt(sd, state, routing, &format);
    
    	v4l2_subdev_unlock_state(state);
    
    	return ret;
    }
    
    static int ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd,
    				    struct v4l2_subdev_state *state,
    				     enum v4l2_subdev_format_whence which,
    				    struct v4l2_subdev_krouting *routing)
    {
    	return _ti_csi2rx_sd_set_routing(sd, state, routing);
    }
    
    static int ti_csi2rx_sd_init_cfg(struct v4l2_subdev *sd,
    				 struct v4l2_subdev_state *state)
    {
    	struct v4l2_subdev_route routes[] = { {
    		.sink_pad = 0,
    		.sink_stream = 0,
    		.source_pad = TI_CSI2RX_PAD_FIRST_SOURCE,
    		.source_stream = 0,
    		.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
    	} };
    
    	struct v4l2_subdev_krouting routing = {
    		.num_routes = 1,
    		.routes = routes,
    	};
    
    	/* Initialize routing to single route to the fist source pad */
    	return _ti_csi2rx_sd_set_routing(sd, state, &routing);
    }
    
    static int ti_csi2rx_sd_s_stream(struct v4l2_subdev *sd, int enable)
    {
    	struct ti_csi2rx_dev *csi = to_csi2rx_dev(sd);
    	int ret = 0;
    
    	mutex_lock(&csi->mutex);
    
    	if (enable) {
    		if (csi->enable_count > 0) {
    			csi->enable_count++;
    			goto out;
    		}
    
    		ret = v4l2_subdev_call(csi->source, video, s_stream, 1);
    		if (ret)
    			goto out;
    
    		csi->enable_count++;
    	} else {
    		if (csi->enable_count == 0) {
    			ret = -EINVAL;
    			goto out;
    		}
    
    		if (--csi->enable_count > 0)
    			goto out;
    
    		ret = v4l2_subdev_call(csi->source, video, s_stream, 0);
    	}
    
    out:
    	mutex_unlock(&csi->mutex);
    	return ret;
    }
    
    static const struct v4l2_subdev_video_ops ti_csi2rx_subdev_video_ops = {
    	.s_stream = ti_csi2rx_sd_s_stream,
    };
    
    static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops = {
    	.init_cfg = ti_csi2rx_sd_init_cfg,
    	.set_routing = ti_csi2rx_sd_set_routing,
    	.get_fmt = v4l2_subdev_get_fmt,
    	.set_fmt = ti_csi2rx_sd_set_fmt,
    };
    
    static const struct v4l2_subdev_ops ti_csi2rx_subdev_ops = {
    	.video = &ti_csi2rx_subdev_video_ops,
    	.pad = &ti_csi2rx_subdev_pad_ops,
    };
    
    static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_ctx *ctx)
    {
    	dma_release_channel(ctx->dma.chan);
    }
    
    static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi)
    {
    	media_device_unregister(&csi->mdev);
    	v4l2_device_unregister(&csi->v4l2_dev);
    	media_device_cleanup(&csi->mdev);
    }
    
    static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi)
    {
    	v4l2_async_notifier_unregister(&csi->notifier);
    	v4l2_async_notifier_cleanup(&csi->notifier);
    }
    
    static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_ctx *ctx)
    {
    	vb2_queue_release(&ctx->vidq);
    }
    
    static void ti_csi2rx_cleanup_ctx(struct ti_csi2rx_ctx *ctx)
    {
    	ti_csi2rx_cleanup_dma(ctx);
    	ti_csi2rx_cleanup_vb2q(ctx);
    
    	video_unregister_device(&ctx->vdev);
    
    	mutex_destroy(&ctx->mutex);
    }
    
    static int ti_csi2rx_init_vb2q(struct ti_csi2rx_ctx *ctx)
    {
    	struct vb2_queue *q = &ctx->vidq;
    	int ret;
    
    	q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
    	q->drv_priv = ctx;
    	q->buf_struct_size = sizeof(struct ti_csi2rx_buffer);
    	q->ops = &csi_vb2_qops;
    	q->mem_ops = &vb2_dma_contig_memops;
    	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
    	q->dev = dmaengine_get_dma_device(ctx->dma.chan);
    	q->lock = &ctx->mutex;
    	q->min_buffers_needed = 1;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	ret = vb2_queue_init(q);
    	if (ret)
    		return ret;
    
    	ctx->vdev.queue = q;
    
    	return 0;
    }
    
    static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx)
    {
    	struct dma_slave_config cfg;
    	char name[32];
    	int ret;
    
    	INIT_LIST_HEAD(&ctx->dma.queue);
    	spin_lock_init(&ctx->dma.lock);
    
    	ctx->dma.state = TI_CSI2RX_DMA_STOPPED;
    	printk("zyk %s %d\n",__func__,__LINE__);
    
    	snprintf(name, sizeof(name), "rx%u", ctx->idx);
    	ctx->dma.chan = dma_request_chan(ctx->csi->dev, name);
    	if (IS_ERR(ctx->dma.chan))
    		return PTR_ERR(ctx->dma.chan);
    
    	memset(&cfg, 0, sizeof(cfg));
    
    	cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES;
    
    	ret = dmaengine_slave_config(ctx->dma.chan, &cfg);
    	if (ret)
    		return ret;
    
    	return 0;
    }
    
    static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi)
    {
    	struct media_device *mdev = &csi->mdev;
    	struct v4l2_subdev *sd = &csi->subdev;
    	int ret, i;
    
    	mdev->dev = csi->dev;
    	mdev->hw_revision = 1;
    	strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model));
    	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
    		 dev_name(mdev->dev));
    
    	media_device_init(mdev);
    
    	csi->v4l2_dev.mdev = mdev;
    
    	ret = v4l2_device_register(csi->dev, &csi->v4l2_dev);
    	if (ret)
    		goto cleanup_media;
    
    	ret = media_device_register(mdev);
    	if (ret)
    		goto unregister_v4l2;
    
    	v4l2_subdev_init(sd, &ti_csi2rx_subdev_ops);
    	sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
    	sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_MULTIPLEXED;
    	strscpy(sd->name, dev_name(csi->dev), sizeof(sd->name));
    	sd->dev = csi->dev;
    
    	csi->pads[TI_CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
    
    	for (i = TI_CSI2RX_PAD_FIRST_SOURCE;
    	     i < TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx; i++)
    		csi->pads[i].flags = MEDIA_PAD_FL_SOURCE;
    
    	ret = media_entity_pads_init(&sd->entity,
    				     TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx,
    				     csi->pads);
    	if (ret)
    		goto unregister_media;
    
    	ret = v4l2_subdev_init_finalize(sd);
    	if (ret)
    		goto unregister_media;
    
    	ret = v4l2_device_register_subdev(&csi->v4l2_dev, sd);
    	if (ret)
    		goto cleanup_subdev;
    
    	return 0;
    
    cleanup_subdev:
    	v4l2_subdev_cleanup(sd);
    unregister_media:
    	media_device_unregister(mdev);
    unregister_v4l2:
    	v4l2_device_unregister(&csi->v4l2_dev);
    cleanup_media:
    	media_device_cleanup(mdev);
    
    	return ret;
    }
    
    static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx)
    {
    	struct ti_csi2rx_dev *csi = ctx->csi;
    	struct video_device *vdev = &ctx->vdev;
    	const struct ti_csi2rx_fmt *fmt;
    	struct v4l2_pix_format *pix_fmt = &ctx->v_fmt.fmt.pix;
    	int ret;
    
    	mutex_init(&ctx->mutex);
    
    	fmt = find_format_by_pix(V4L2_PIX_FMT_UYVY);
    	if (!fmt)
    		return -EINVAL;
    
    	pix_fmt->width = 1920;
    	pix_fmt->height = 1080;
    
    	ti_csi2rx_fill_fmt(fmt, &ctx->v_fmt);
    
    	ctx->pad.flags = MEDIA_PAD_FL_SINK;
    	ret = media_entity_pads_init(&ctx->vdev.entity, 1, &ctx->pad);
    	if (ret)
    		return ret;
    
    	snprintf(vdev->name, sizeof(vdev->name), "%s context %u",
    		 dev_name(csi->dev), ctx->idx);
    	vdev->v4l2_dev = &csi->v4l2_dev;
    	vdev->vfl_dir = VFL_DIR_RX;
    	vdev->fops = &csi_fops;
    	vdev->ioctl_ops = &csi_ioctl_ops;
    	vdev->release = video_device_release_empty;
    	vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
    			    V4L2_CAP_STREAMING | V4L2_CAP_IO_MC;
    	vdev->lock = &ctx->mutex;
    
    	video_set_drvdata(vdev, ctx);
    
    	ret = ti_csi2rx_init_dma(ctx);
    	if (ret)
    		return ret;
    
    	ret = ti_csi2rx_init_vb2q(ctx);
    	if (ret)
    		goto cleanup_dma;
    
    	return 0;
    
    cleanup_dma:
    	ti_csi2rx_cleanup_dma(ctx);
    	return ret;
    }
    
    #ifdef CONFIG_PM
    static int ti_csi2rx_suspend(struct device *dev)
    {
    	struct ti_csi2rx_dev *csi = dev_get_drvdata(dev);
    	struct ti_csi2rx_ctx *ctx;
    	struct ti_csi2rx_dma *dma;
    	unsigned long flags = 0;
    	int i, ret = 0;
    
    	for (i = 0; i < csi->num_ctx; i++) {
    		ctx = &csi->ctx[i];
    		dma = &ctx->dma;
    
    		spin_lock_irqsave(&dma->lock, flags);
    		if (dma->state != TI_CSI2RX_DMA_STOPPED) {
    			spin_unlock_irqrestore(&dma->lock, flags);
    			ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 0);
    			if (ret)
    				dev_err(csi->dev, "Failed to stop subdev stream\n");
    			/* Terminate DMA */
    			ret = dmaengine_terminate_sync(ctx->dma.chan);
    			if (ret)
    				dev_err(csi->dev, "Failed to stop DMA\n");
    		} else {
    			spin_unlock_irqrestore(&dma->lock, flags);
    		}
    
    		/* Stop any on-going streams */
    		writel(0, csi->shim + SHIM_DMACNTX(ctx->idx));
    	}
    
    	/* Assert the pixel reset. */
    	writel(0, csi->shim + SHIM_CNTL);
    
    	return ret;
    }
    
    static int ti_csi2rx_resume(struct device *dev)
    {
    	struct ti_csi2rx_dev *csi = dev_get_drvdata(dev);
    	struct ti_csi2rx_ctx *ctx;
    	struct ti_csi2rx_dma *dma;
    	struct ti_csi2rx_buffer *buf;
    	unsigned long flags = 0;
    	unsigned int reg;
    	int i, ret = 0;
    
    	reg = SHIM_CNTL_PIX_RST;
    	writel(reg, csi->shim + SHIM_CNTL);
    
    	for (i = 0; i < csi->num_ctx; i++) {
    		ctx = &csi->ctx[i];
    		dma = &ctx->dma;
    		spin_lock_irqsave(&dma->lock, flags);
    		if (dma->state != TI_CSI2RX_DMA_STOPPED) {
    			buf = dma->curr;
    			spin_unlock_irqrestore(&dma->lock, flags);
    
    			/* Restore stream config */
    			ti_csi2rx_setup_shim(ctx);
    
    			ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 1);
    			if (ret)
    				dev_err(ctx->csi->dev, "Failed to start subdev\n");
    
    			/* Restart DMA */
    			if (buf)
    				ti_csi2rx_restart_dma(ctx, buf);
    		} else {
    			spin_unlock_irqrestore(&dma->lock, flags);
    		}
    	}
    
    	return ret;
    }
    
    static const struct dev_pm_ops ti_csi2rx_pm_ops = {
    	SET_SYSTEM_SLEEP_PM_OPS(ti_csi2rx_suspend, ti_csi2rx_resume)
    };
    #endif /* CONFIG_PM */
    
    static int ti_csi2rx_probe(struct platform_device *pdev)
    {
    	struct device_node *np = pdev->dev.of_node;
    	struct ti_csi2rx_dev *csi;
    	struct resource *res;
    	int ret, i, count;
    	unsigned int reg;
    
    	csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL);
    	if (!csi)
    		return -ENOMEM;
    
    	csi->dev = &pdev->dev;
    	platform_set_drvdata(pdev, csi);
    
    	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    	csi->shim = devm_ioremap_resource(&pdev->dev, res);
    	if (IS_ERR(csi->shim))
    		return PTR_ERR(csi->shim);
    
    	/* Only use as many contexts as the number of DMA channels allocated. */
    	count = of_property_count_strings(np, "dma-names");
    	if (count < 0) {
    		dev_err(csi->dev, "Failed to get DMA channel count: %d\n",
    			count);
    		return count;
    	}
    
    	csi->num_ctx = count;
    	if (csi->num_ctx > TI_CSI2RX_MAX_CTX) {
    		dev_warn(csi->dev,
    			 "%u DMA channels passed. Maximum is %u. Ignoring the rest.\n",
    			 csi->num_ctx, TI_CSI2RX_MAX_CTX);
    		csi->num_ctx = TI_CSI2RX_MAX_CTX;
    	}
    
    	mutex_init(&csi->mutex);
    
    	ret = ti_csi2rx_v4l2_init(csi);
    	if (ret)
    		return ret;
    
    	for (i = 0; i < csi->num_ctx; i++) {
    		csi->ctx[i].idx = i;
    		csi->ctx[i].csi = csi;
    		ret = ti_csi2rx_init_ctx(&csi->ctx[i]);
    		if (ret)
    			goto cleanup_ctx;
    	}
    
    	ret = ti_csi2rx_init_subdev(csi);
    	if (ret)
    		goto cleanup_ctx;
    
    	ret = of_platform_populate(csi->dev->of_node, NULL, NULL, csi->dev);
    	if (ret) {
    		dev_err(csi->dev, "Failed to create children: %d\n", ret);
    		goto cleanup_subdev;
    	}
    
    	/* De-assert the pixel interface reset. */
    	reg = SHIM_CNTL_PIX_RST;
    	writel(reg, csi->shim + SHIM_CNTL);
    
    	return 0;
    
    cleanup_subdev:
    	ti_csi2rx_cleanup_subdev(csi);
    cleanup_ctx:
    
    	i--;
    	for (; i >= 0; i--)
    		ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
    
    	ti_csi2rx_cleanup_v4l2(csi);
    	return ret;
    }
    
    static int ti_csi2rx_remove(struct platform_device *pdev)
    {
    	struct ti_csi2rx_dev *csi = platform_get_drvdata(pdev);
    	int i;
    
    	for (i = 0; i < csi->num_ctx; i++) {
    		if (vb2_is_busy(&csi->ctx[i].vidq))
    			return -EBUSY;
    	}
    
    	for (i = 0; i < csi->num_ctx; i++)
    		ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
    
    	ti_csi2rx_cleanup_subdev(csi);
    	ti_csi2rx_cleanup_v4l2(csi);
    
    	/* Assert the pixel reset. */
    	writel(0, csi->shim + SHIM_CNTL);
    
    	mutex_destroy(&csi->mutex);
    
    	return 0;
    }
    
    static const struct of_device_id ti_csi2rx_of_match[] = {
    	{ .compatible = "ti,j721e-csi2rx", },
    	{ },
    };
    MODULE_DEVICE_TABLE(of, ti_csi2rx_of_match);
    
    static struct platform_driver ti_csi2rx_pdrv = {
    	.probe = ti_csi2rx_probe,
    	.remove = ti_csi2rx_remove,
    	.driver = {
    		.name		= TI_CSI2RX_MODULE_NAME,
    		.of_match_table	= ti_csi2rx_of_match,
    #ifdef CONFIG_PM
    		.pm		= &ti_csi2rx_pm_ops,
    #endif
    	},
    };
    
    module_platform_driver(ti_csi2rx_pdrv);
    
    MODULE_DESCRIPTION("TI J721E CSI2 RX Driver");
    MODULE_AUTHOR("Pratyush Yadav <p.yadav@ti.com>");
    MODULE_LICENSE("GPL v2");
    MODULE_VERSION("1.0");
    

    file upload

  • Hello Daiwei,

    Thanks for sharing the code. I checked internally, and found out UYVY8_2X8 is not supported by TI's CSI RX driver, because 2X8 is not a valid format for CSI. Please use "YUYV8_1X16", "UYVY8_1X16", etc, instead of 2X8, in your sensor driver. 

    I would also recommend you to switch to SDK 9.1 release: www.ti.com/.../PROCESSOR-SDK-AM62A. There has been major upgrades to UB960 driver since 9.0 release.

    Regards,

    Jianzhong

  • Media controller API version 5.10.168
    
    Media device information
    ------------------------
    driver          j721e-csi2rx
    model           TI-CSI2RX
    serial          
    bus info        platform:30102000.ticsi2rx
    hw revision     0x1
    driver version  5.10.168
    
    Device topology
    - entity 1: 30102000.ticsi2rx (7 pads, 7 links, 1 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev0
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
            pad3: Source
                    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
            pad4: Source
                    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]
            pad5: Source
                    -> "30102000.ticsi2rx context 4":0 [ENABLED,IMMUTABLE]
            pad6: Source
                    -> "30102000.ticsi2rx context 5":0 [ENABLED,IMMUTABLE]
    
    - entity 9: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
                type V4L2 subdev subtype Unknown flags 0
                device node name /dev/v4l-subdev1
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    <- "ds90ub960 4-003d":4 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
            pad2: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
            pad3: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
            pad4: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
    
    - entity 15: ds90ub960 4-003d (6 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev2
            routes:
                    0/0 -> 4/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    <- "ds90ub953 4-0044":1 [ENABLED,IMMUTABLE]
            pad1: Sink
            pad2: Sink
            pad3: Sink
            pad4: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none]
                    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
            pad5: Source
    
    - entity 24: ds90ub953 4-0044 (2 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev3
            routes:
                    0/0 -> 1/0 [ACTIVE]
            pad0: Sink
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none colorspace:smpte170m]
                    <- "imx390dummy 5-001a":0 [ENABLED,IMMUTABLE]
            pad1: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080 field:none colorspace:smpte170m]
                    -> "ds90ub960 4-003d":0 [ENABLED,IMMUTABLE]
    
    - entity 29: imx390dummy 5-001a (1 pad, 1 link, 2 routes)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev4
            routes:
                    0/0 -> 0/0 [ACTIVE, IMMUTABLE, SOURCE]
                    0/0 -> 0/1 [INACTIVE, IMMUTABLE, SOURCE]
            pad0: Source
                    [stream:0 fmt:UYVY8_1X16/1920x1080@1/30 field:none colorspace:smpte170m]
                    -> "ds90ub953 4-0044":0 [ENABLED,IMMUTABLE]
    
    - entity 35: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video2
            pad0: Sink
                    <- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]
    
    - entity 41: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video3
            pad0: Sink
                    <- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]
    
    - entity 47: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video4
            pad0: Sink
                    <- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]
    
    - entity 53: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video5
            pad0: Sink
                    <- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]
    
    - entity 59: 30102000.ticsi2rx context 4 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video6
            pad0: Sink
                    <- "30102000.ticsi2rx":5 [ENABLED,IMMUTABLE]
    
    - entity 65: 30102000.ticsi2rx context 5 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video7
            pad0: Sink
                    <- "30102000.ticsi2rx":6 [ENABLED,IMMUTABLE]
    

     yavta -s 1920x1280 -f UYVY /dev/video2 -c125 -Fframe-#.bin

    Device /dev/video2 opened.
    [  163.183367] zyk ti_csi2rx_queue_setup 832
    Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video[  163.191734] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 0, plane 0 offset 0x00000000
     output (without mplanes) device.
    Video format set: UYVY (59565[  163.206385] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 1, plane 0 offset 0x004b0000
    955) 1920x1280 (stride 3840) field none buffer size 4915200
    Vid[  163.221531] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 2, plane 0 offset 0x00960000
    eo format: UYVY (59565955) 1920x1280 (stride 3840) field none bu[  163.237086] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 3, plane 0 offset 0x00e10000
    ffer size 4915200
    [  163.251977] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 4, plane 0 offset 0x012c0000
    [  163.263233] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 5, plane 0 offset 0x01770000
    [  163.274334] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 6, plane 0 offset 0x01c20000
    [  163.285930] videobuf2_common: [cap-00000000494f17ea] __setup_offsets: buffer 7, plane 0 offset 0x020d0000
    [  163.295652] videobuf2_common: [cap-00000000494f17ea] __vb2_queue_alloc: allocated 8 buffers, 1 plane(s) each
    8 buffers requested.
    [  163.305792] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 0, plane 0 successfully mapped
    length: 4915200 offset: 0 timestamp type/source: mono/EoF
    [  163.316794] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 1, plane 0 successfully mapped
    Buffer 0/0 mapped at address 0xffffac5b3000.
    length: 4915200 of[  163.330909] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 2, plane 0 successfully mapped
    fset: 4915200 timestamp type/source: mono/EoF
    Buffer 1/0 mapped[  163.345668] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 3, plane 0 successfully mapped
     at address 0xffffac103000.
    length: 4915200 offset: 9830400 tim[  163.360213] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 4, plane 0 successfully mapped
    estamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xfff[  163.374986] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 5, plane 0 successfully mapped
    fabc53000.
    length: 4915200 offset: 14745600 timestamp type/sour[  163.389532] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 6, plane 0 successfully mapped
    ce: mono/EoF
    Buffer 3/0 mapped at address 0xffffab7a3000.
    leng[  163.404289] videobuf2_common: [cap-00000000494f17ea] vb2_mmap: buffer 7, plane 0 successfully mapped
    th: 4915200 offset: 19660800 timestamp type/source: mono/EoF
    Bu[  163.418798] zyk ti_csi2rx_buffer_prepare 844
    ffer 4/0 mapped at address 0xffffab2f3000.
    length: 4915200 offs[  163.428671] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 0 succeeded
    et: 24576000 timestamp type/source: mono/EoF
    Buffer 5/0 mapped [  163.442710] zyk ti_csi2rx_buffer_prepare 844
    at address 0xffffaae43000.
    length: 4915200 offset: 29491200 tim[  163.442717] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 1 succeeded
    estamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xfff[  163.442724] zyk ti_csi2rx_buffer_prepare 844
    faa993000.
    length: 4915200 offset: 34406400 timestamp type/sour[  163.476427] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 2 succeeded
    ce: mono/EoF
    Buffer 7/0 mapped at address 0xffffaa4e3000.
    [  163.476449] zyk ti_csi2rx_buffer_prepare 844
    [  163.500016] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 3 succeeded
    [  163.500037] zyk ti_csi2rx_buffer_prepare 844
    [  163.513042] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 4 succeeded
    [  163.513059] zyk ti_csi2rx_buffer_prepare 844
    [  163.526064] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 5 succeeded
    [  163.526084] zyk ti_csi2rx_buffer_prepare 844
    [  163.539101] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 6 succeeded
    [  163.539119] zyk ti_csi2rx_buffer_prepare 844
    [  163.552165] videobuf2_common: [cap-00000000494f17ea] vb2_core_qbuf: qbuf of buffer 7 succeeded
    [  163.552188] zyk ti_csi2rx_buffer_queue 862
    [  163.564998] zyk ti_csi2rx_buffer_queue 886
    [  163.565006] zyk ti_csi2rx_buffer_queue 862
    [  163.573360] zyk ti_csi2rx_buffer_queue 886
    [  163.573370] zyk ti_csi2rx_buffer_queue 862
    [  163.581661] zyk ti_csi2rx_buffer_queue 886
    [  163.581668] zyk ti_csi2rx_buffer_queue 862
    [  163.589998] zyk ti_csi2rx_buffer_queue 886
    [  163.590001] zyk ti_csi2rx_buffer_queue 862
    [  163.590004] zyk ti_csi2rx_buffer_queue 886
    [  163.590007] zyk ti_csi2rx_buffer_queue 862
    [  163.590009] zyk ti_csi2rx_buffer_queue 886
    [  163.590011] zyk ti_csi2rx_buffer_queue 862
    [  163.590014] zyk ti_csi2rx_buffer_queue 886
    [  163.590016] zyk ti_csi2rx_buffer_queue 862
    [  163.590023] zyk ti_csi2rx_buffer_queue 886
    [  163.626999] zyk ti_csi2rx_start_streaming 942
    [  163.627006] zyk ti_csi2rx_start_streaming 950
    [  163.635874] zyk ti_csi2rx_start_streaming 955
    [  163.640455] zyk ti_csi2rx_start_streaming 962
    [  163.644839] zyk ti_csi2rx_start_streaming 967
    [  163.644844] zyk ti_csi2rx_start_streaming 982
    [  163.653701] zyk ti_csi2rx_start_streaming 989
    [  163.653705] zyk ti_csi2rx_get_vc 908
    [  163.653719] zyk ti_csi2rx_setup_shim 624
    [  163.667084] zyk ti_csi2rx_start_streaming 1008
    [  163.667093] zyk ti_csi2rx_start_dma 772
    [  163.675375] zyk ti_csi2rx_start_dma 780
    [  163.679212] zyk ti_csi2rx_start_streaming 1024
    [  163.679402] videobuf2_common: [cap-00000000494f17ea] vb2_core_streamon: successful
    [  163.691300] videobuf2_common: [cap-00000000494f17ea] __vb2_wait_for_done_vb: will sleep waiting for buffers
    ^Z[  164.727154] videobuf2_common: [cap-00000000494f17ea] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -s 1920x1280 -f UYVY /dev/video2 -c125 -Fframe-#.bin
    root@am62axx-evm:/opt/edgeai-gst-apps# sh C0.sh 
    953 config
    953 end config
    root@am62axx-evm:/opt/edgeai-gst-apps# fg
    yavta -s 1920x1280 -f UYVY /dev/video2 -c125 -Fframe-#.bin
    [  169.558925] videobuf2_common: [cap-00000000494f17ea] __vb2_wait_for_done_vb: will sleep waiting for buffers
    
    
    
    
    
    
    ^Z[  175.992255] videobuf2_common: [cap-00000000494f17ea] __vb2_wait_for_done_vb: sleep was interrupted
    
    [1]+  Stopped(SIGTSTP)        yavta -s 1920x1280 -f UYVY /dev/video2 -c125 -Fframe-#.bin
    root@am62axx-evm:/opt/edgeai-gst-apps# sh get_camera_data_info.sh 
    0x13
    0x04
    0x38
    0x0f
    0x00

    and got nothing to,no irq update

    I would also recommend you to switch to SDK 9.1 release: www.ti.com/.../PROCESSOR-SDK-AM62A. There has been major upgrades to UB960 driver since 9.0 release.

    update ub960 make compile error so much 

  • update ub960 make compile error so much 

    How did you build it? Can you provide a log of all the steps you took to build?

  • copy ti-processor-sdk-linux-edgeai-am62axx-evm-09_00_00_08\board-support\linux-6.1.33+gitAUTOINC+8f7f371be2-g8f7f371be2\drivers\media\i2c\ds90ub960.c-》

     ti-processor-sdk-linux-am62axx-evm-08.06.00.45\board-support\linux-kernel\drivers\media\i2c\ds90ub960.c 

    copy related header files

    and make linux -j,Um, is there a problem with this operation?

    make linux -j
    =====================================
    Building the Linux Kernel DTBs
    =====================================
    make -C /extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel ARCH=arm64 CROSS_COMPILE=/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-none-linux-gnu- tisdk_am62axx-evm_defconfig
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    #
    # No change to .config
    #
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    =================================
    Building the Linux Kernel
    =================================
    make -C /extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel ARCH=arm64 CROSS_COMPILE=/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-none-linux-gnu- tisdk_am62axx-evm_defconfig
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    #
    # No change to .config
    #
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make -j 8 -C /extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel ARCH=arm64 CROSS_COMPILE=/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-none-linux-gnu-  Image
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
      CALL    scripts/atomic/check-atomics.sh
      CALL    scripts/checksyscalls.sh
      CHK     include/generated/compile.h
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make -j 8 -C /extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel ARCH=arm64 CROSS_COMPILE=/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-none-linux-gnu- modules
    make[1]: Entering directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
      CALL    scripts/atomic/check-atomics.sh
      CALL    scripts/checksyscalls.sh
      CHK     include/generated/compile.h
      CC [M]  drivers/media/i2c/ds90ub960.o
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_atr_attach_client’:
    drivers/media/i2c/ds90ub960.c:1038:28: error: implicit declaration of function ‘i2c_atr_get_driver_data’; did you mean ‘i2c_atr_get_clientdata’? [-Werror=implicit-function-declaration]
     1038 |  struct ub960_data *priv = i2c_atr_get_driver_data(atr);
          |                            ^~~~~~~~~~~~~~~~~~~~~~~
          |                            i2c_atr_get_clientdata
    drivers/media/i2c/ds90ub960.c:1038:28: warning: initialization of ‘struct ub960_data *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_atr_detach_client’:
    drivers/media/i2c/ds90ub960.c:1069:28: warning: initialization of ‘struct ub960_data *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     1069 |  struct ub960_data *priv = i2c_atr_get_driver_data(atr);
          |                            ^~~~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c: At top level:
    drivers/media/i2c/ds90ub960.c:1094:19: error: initialization of ‘int (*)(struct i2c_atr *, u32,  const struct i2c_board_info *, const struct i2c_client *, u16 *)’ {aka ‘int (*)(struct i2c_atr *, unsigned int,  const struct i2c_board_info *, const struct i2c_client *, short unsigned int *)’} from incompatible pointer type ‘int (*)(struct i2c_atr *, u32,  const struct i2c_client *, u16)’ {aka ‘int (*)(struct i2c_atr *, unsigned int,  const struct i2c_client *, short unsigned int)’} [-Werror=incompatible-pointer-types]
     1094 |  .attach_client = ub960_atr_attach_client,
          |                   ^~~~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:1094:19: note: (near initialization for ‘ub960_atr_ops.attach_client’)
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_init_atr’:
    drivers/media/i2c/ds90ub960.c:1108:2: error: implicit declaration of function ‘i2c_atr_set_driver_data’; did you mean ‘i2c_atr_set_clientdata’? [-Werror=implicit-function-declaration]
     1108 |  i2c_atr_set_driver_data(priv->atr, priv);
          |  ^~~~~~~~~~~~~~~~~~~~~~~
          |  i2c_atr_set_clientdata
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_configure_ports_for_streaming’:
    drivers/media/i2c/ds90ub960.c:2412:2: error: implicit declaration of function ‘for_each_active_route’; did you mean ‘for_each_active_irq’? [-Werror=implicit-function-declaration]
     2412 |  for_each_active_route(&state->routing, route) {
          |  ^~~~~~~~~~~~~~~~~~~~~
          |  for_each_active_irq
    drivers/media/i2c/ds90ub960.c:2412:47: error: expected ‘;’ before ‘{’ token
     2412 |  for_each_active_route(&state->routing, route) {
          |                                               ^~
          |                                               ;
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_enable_streams’:
    drivers/media/i2c/ds90ub960.c:2569:47: error: expected ‘;’ before ‘{’ token
     2569 |  for_each_active_route(&state->routing, route) {
          |                                               ^~
          |                                               ;
    drivers/media/i2c/ds90ub960.c:2626:9: error: implicit declaration of function ‘v4l2_subdev_disable_streams’ [-Werror=implicit-function-declaration]
     2626 |   ret = v4l2_subdev_disable_streams(
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2618:1: warning: label ‘err’ defined but not used [-Wunused-label]
     2618 | err:
          | ^~~
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_disable_streams’:
    drivers/media/i2c/ds90ub960.c:2663:47: error: expected ‘;’ before ‘{’ token
     2663 |  for_each_active_route(&state->routing, route) {
          |                                               ^~
          |                                               ;
    drivers/media/i2c/ds90ub960.c:2660:6: warning: unused variable ‘ret’ [-Wunused-variable]
     2660 |  int ret;
          |      ^~~
    drivers/media/i2c/ds90ub960.c:2659:15: warning: unused variable ‘nport’ [-Wunused-variable]
     2659 |  unsigned int nport;
          |               ^~~~~
    drivers/media/i2c/ds90ub960.c:2657:6: warning: unused variable ‘sink_streams’ [-Wunused-variable]
     2657 |  u64 sink_streams[UB960_MAX_RX_NPORTS] = {};
          |      ^~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2656:17: warning: unused variable ‘dev’ [-Wunused-variable]
     2656 |  struct device *dev = &priv->client->dev;
          |                 ^~~
    drivers/media/i2c/ds90ub960.c: In function ‘_ub960_set_routing’:
    drivers/media/i2c/ds90ub960.c:2733:8: error: implicit declaration of function ‘v4l2_subdev_routing_validate’; did you mean ‘v4l2_subdev_link_validate’? [-Werror=implicit-function-declaration]
     2733 |  ret = v4l2_subdev_routing_validate(sd, routing,
          |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |        v4l2_subdev_link_validate
    drivers/media/i2c/ds90ub960.c:2734:9: error: ‘V4L2_SUBDEV_ROUTING_ONLY_1_TO_1’ undeclared (first use in this function); did you mean ‘V4L2_SUBDEV_ROUTE_FL_ACTIVE’?
     2734 |         V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 |
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |         V4L2_SUBDEV_ROUTE_FL_ACTIVE
    drivers/media/i2c/ds90ub960.c:2734:9: note: each undeclared identifier is reported only once for each function it appears in
    drivers/media/i2c/ds90ub960.c:2735:9: error: ‘V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX’ undeclared (first use in this function)
     2735 |         V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_get_frame_desc’:
    drivers/media/i2c/ds90ub960.c:2781:10: error: implicit declaration of function ‘v4l2_subdev_lock_and_get_active_state’; did you mean ‘v4l2_subdev_lock_active_state’? [-Werror=implicit-function-declaration]
     2781 |  state = v4l2_subdev_lock_and_get_active_state(&priv->sd);
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          v4l2_subdev_lock_active_state
    drivers/media/i2c/ds90ub960.c:2781:8: warning: assignment to ‘struct v4l2_subdev_state *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2781 |  state = v4l2_subdev_lock_and_get_active_state(&priv->sd);
          |        ^
    drivers/media/i2c/ds90ub960.c:2785:47: error: expected ‘;’ before ‘{’ token
     2785 |  for_each_active_route(&state->routing, route) {
          |                                               ^~
          |                                               ;
    drivers/media/i2c/ds90ub960.c:2771:17: warning: unused variable ‘dev’ [-Wunused-variable]
     2771 |  struct device *dev = &priv->client->dev;
          |                 ^~~
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_set_fmt’:
    drivers/media/i2c/ds90ub960.c:2889:8: error: implicit declaration of function ‘v4l2_subdev_state_get_stream_format’; did you mean ‘v4l2_state_get_stream_format’? [-Werror=implicit-function-declaration]
     2889 |  fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
          |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |        v4l2_state_get_stream_format
    drivers/media/i2c/ds90ub960.c:2889:6: warning: assignment to ‘struct v4l2_mbus_framefmt *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2889 |  fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
          |      ^
    drivers/media/i2c/ds90ub960.c:2896:8: error: implicit declaration of function ‘v4l2_subdev_state_get_opposite_stream_format’; did you mean ‘v4l2_state_get_opposite_stream_format’? [-Werror=implicit-function-declaration]
     2896 |  fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad,
          |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |        v4l2_state_get_opposite_stream_format
    drivers/media/i2c/ds90ub960.c:2896:6: warning: assignment to ‘struct v4l2_mbus_framefmt *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2896 |  fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad,
          |      ^
    drivers/media/i2c/ds90ub960.c: At top level:
    drivers/media/i2c/ds90ub960.c:2930:3: error: ‘const struct v4l2_subdev_pad_ops’ has no member named ‘enable_streams’
     2930 |  .enable_streams = ub960_enable_streams,
          |   ^~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2930:20: error: initialization of ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *)’ from incompatible pointer type ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *, u32,  u64)’ {aka ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *, unsigned int,  long long unsigned int)’} [-Werror=incompatible-pointer-types]
     2930 |  .enable_streams = ub960_enable_streams,
          |                    ^~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2930:20: note: (near initialization for ‘ub960_pad_ops.init_cfg’)
    drivers/media/i2c/ds90ub960.c:2931:3: error: ‘const struct v4l2_subdev_pad_ops’ has no member named ‘disable_streams’
     2931 |  .disable_streams = ub960_disable_streams,
          |   ^~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2931:21: error: initialization of ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *, struct v4l2_subdev_mbus_code_enum *)’ from incompatible pointer type ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *, u32,  u64)’ {aka ‘int (*)(struct v4l2_subdev *, struct v4l2_subdev_state *, unsigned int,  long long unsigned int)’} [-Werror=incompatible-pointer-types]
     2931 |  .disable_streams = ub960_disable_streams,
          |                     ^~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:2931:21: note: (near initialization for ‘ub960_pad_ops.enum_mbus_code’)
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_log_status’:
    drivers/media/i2c/ds90ub960.c:2953:8: warning: assignment to ‘struct v4l2_subdev_state *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2953 |  state = v4l2_subdev_lock_and_get_active_state(sd);
          |        ^
    drivers/media/i2c/ds90ub960.c: At top level:
    drivers/media/i2c/ds90ub960.c:3098:3: error: ‘const struct media_entity_operations’ has no member named ‘has_pad_interdep’
     3098 |  .has_pad_interdep = v4l2_subdev_has_pad_interdep,
          |   ^~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:3098:22: error: ‘v4l2_subdev_has_pad_interdep’ undeclared here (not in a function); did you mean ‘v4l2_subdev_has_route’?
     3098 |  .has_pad_interdep = v4l2_subdev_has_pad_interdep,
          |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                      v4l2_subdev_has_route
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_v4l2_notifier_register’:
    drivers/media/i2c/ds90ub960.c:3603:2: error: implicit declaration of function ‘v4l2_async_nf_init’; did you mean ‘v4l2_async_notifier_init’? [-Werror=implicit-function-declaration]
     3603 |  v4l2_async_nf_init(&priv->notifier);
          |  ^~~~~~~~~~~~~~~~~~
          |  v4l2_async_notifier_init
    drivers/media/i2c/ds90ub960.c:3612:9: error: implicit declaration of function ‘v4l2_async_nf_add_fwnode’ [-Werror=implicit-function-declaration]
     3612 |   asd = v4l2_async_nf_add_fwnode(&priv->notifier,
          |         ^~~~~~~~~~~~~~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:3614:13: error: expected expression before ‘struct’
     3614 |             struct ub960_asd);
          |             ^~~~~~
    drivers/media/i2c/ds90ub960.c:3618:4: error: implicit declaration of function ‘v4l2_async_nf_cleanup’; did you mean ‘v4l2_async_notifier_cleanup’? [-Werror=implicit-function-declaration]
     3618 |    v4l2_async_nf_cleanup(&priv->notifier);
          |    ^~~~~~~~~~~~~~~~~~~~~
          |    v4l2_async_notifier_cleanup
    drivers/media/i2c/ds90ub960.c:3627:8: error: implicit declaration of function ‘v4l2_async_subdev_nf_register’; did you mean ‘v4l2_async_subdev_notifier_register’? [-Werror=implicit-function-declaration]
     3627 |  ret = v4l2_async_subdev_nf_register(&priv->sd, &priv->notifier);
          |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |        v4l2_async_subdev_notifier_register
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_v4l2_notifier_unregister’:
    drivers/media/i2c/ds90ub960.c:3639:2: error: implicit declaration of function ‘v4l2_async_nf_unregister’; did you mean ‘v4l2_async_notifier_unregister’? [-Werror=implicit-function-declaration]
     3639 |  v4l2_async_nf_unregister(&priv->notifier);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~
          |  v4l2_async_notifier_unregister
    drivers/media/i2c/ds90ub960.c: In function ‘ub960_create_subdev’:
    drivers/media/i2c/ds90ub960.c:3664:34: error: ‘V4L2_SUBDEV_FL_STREAMS’ undeclared (first use in this function); did you mean ‘V4L2_SUBDEV_FL_IS_SPI’?
     3664 |      V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_STREAMS;
          |                                  ^~~~~~~~~~~~~~~~~~~~~~
          |                                  V4L2_SUBDEV_FL_IS_SPI
    drivers/media/i2c/ds90ub960.c:3681:10: error: ‘struct v4l2_subdev’ has no member named ‘state_lock’
     3681 |  priv->sd.state_lock = priv->sd.ctrl_handler->lock;
          |          ^
    drivers/media/i2c/ds90ub960.c: At top level:
    drivers/media/i2c/ds90ub960.c:4039:13: error: initialization of ‘int (*)(struct i2c_client *)’ from incompatible pointer type ‘void (*)(struct i2c_client *)’ [-Werror=incompatible-pointer-types]
     4039 |  .remove  = ub960_remove,
          |             ^~~~~~~~~~~~
    drivers/media/i2c/ds90ub960.c:4039:13: note: (near initialization for ‘ds90ub960_driver.remove’)
    drivers/media/i2c/ds90ub960.c:2374:12: warning: ‘ub960_enable_rx_port’ defined but not used [-Wunused-function]
     2374 | static int ub960_enable_rx_port(struct ub960_data *priv, unsigned int nport)
          |            ^~~~~~~~~~~~~~~~~~~~
    cc1: some warnings being treated as errors
    make[4]: *** [scripts/Makefile.build:286: drivers/media/i2c/ds90ub960.o] Error 1
    make[3]: *** [scripts/Makefile.build:503: drivers/media/i2c] Error 2
    make[2]: *** [scripts/Makefile.build:503: drivers/media] Error 2
    make[1]: *** [Makefile:1822: drivers] Error 2
    make[1]: Leaving directory '/extstorage/zyk/ti_am/0806/sdk0806/ti-processor-sdk-linux-am62axx-evm-08.06.00.45/board-support/linux-kernel'
    make: *** [Makefile:22: linux] Error 2
    

  • You'll need to port your sensor driver to 9.0 SDK (or the latest 9.1 release). You can't just copy the ub960 driver code from 9.0 to 8.6. Many dependencies  were updated from 8.6 to 9.0.

  • I think this issue is related to the version of ub960, because we configured camera later on, and this is related to the issue

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1308194/sk-am62a-lp-sk-am62a-lp-camera-kkc-a002-32--the-effect-of-taking-photos

    The same operation method is also used in the middle

  • The other issue was resolved by using YUV 1X16 instead of YUV 2X8.

    For this one, I recommended to use YUV 1X16 in your sensor driver and use ub960 driver from SDK 9.1. Did this help?

  • The other issue 

    use imx219 SRGGB10 also catpure frame,It seems unrelated to the format

    YUV 1X16 case on other issue,green is exist,you said the data from sensor has problem

    this case:

    YUV 1X16

    In the previous reply, I have already replied but there has been no improvement,

     use ub960 driver from SDK 9.1

    I have no porting successful

  • Can you port your sensor driver to SDK 9.1?

  • there is a error on sdk9.1 when I porting,I try to fix it 

  • The V4L2 framework has changed quite a lot from 8.6 to 9.1.