For iMX6DQ, there are two IPUs, so they can support up to 4 cameras at the same time. But the default BSP can only support up to two cameras at the same time.
The attached patch can make the BSP support up to 4 cameras based on 3.10.53 GA 1.1.0 BSP.
The 4 cameras can be:
- 1xCSI, 3xMIPI
- 2xCSI, 2xMIPI
- 4xMIPI
For 4xMIPI case, the four cameras should be combined on the single MIPI CSI2 interface, and each camera data should be transfered on a mipi virtual channel.
In this patch, we given the example driver for Intersil ISL79985. The input to ISL79985 is four CVBS camera.
There are four patches:
0001-IPU-update-IPU-capture-driver-to-support-up-to-four-.patch
Updated IPU common code to support up to four cameras.
0002-Add-Intersil-ISL79985-MIPI-Video-Decoder-Driver-for-.patch
ISL79985 driver, which can support both 1 lanes and 2 lanes mode.
0003-Remove-the-page-size-align-requirement-for-v4l2-capt.patch
With this patch, the mxc_v4l2_tvin test application can use overlay framebuffer as V4l2 capture buffer directly.
0004-IPU-CSI-Drop-1-2-frame-on-MIPI-interface-for-interla.patch
This patch is option, it will drop one field data, so for each camera, the input will be 720*240 30 FPS.
For 720P HD solution, it is based on Maxim MAX9286: iMX6DQ MAX9286 MIPI CSI2 720P camera surround view solution for Linux BSP
How to builld the kernel with ISL79985 support:
make imx_v7_defconfig
make menuconfig (In this command, you should select the ISL79985 driver:
Device Drivers --->
<*> Multimedia support --->
[*] V4L platform devices --->
<*> MXC Video For Linux Video Capture
MXC Camera/V4L2 PRP Features support --->
<*>Intersil ISL79985 Video Decoder support
<*>mxc VADC support
<*>Select Overlay Rounting (Queue ipu device for overlay library)
<*>Pre-processor Encoder library
<*>IPU CSI Encoder library)
make zImage
make dtbs
The built out image file:
arch/arm/boot/dts/imx6q-sabresd.dtb
arch/arm/boot/zImage
"mxc_v4l2_tvin.zip" is the test application, test command to capture the four cameras and render on 1080P HDMI display:
/mxc_v4l2_tvin.out -ol 0 -ot 0 -ow 960 -oh 540 -d 1 -x 0 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 0 -ow 960 -oh 540 -d 1 -x 1 -g2d &
/mxc_v4l2_tvin.out -ol 0 -ot 540 -ow 960 -oh 540 -d 1 -x 2 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 540 -ow 960 -oh 540 -d 1 -x 3 -g2d &
2015-10-10 Update:
Updated the test application "mxc_v4l2_tvin_isl79985.tar.gz" to fix the Yocto build errors.
Updated ISL79985 register setting "page5, isl79985_write_reg(0x07, 0x46)" in patch "0002-Add-Intersil-ISL79985-MIPI-Video-Decoder-Driver-for-.patch", which can fix the green line issue.
2016-01-25 Update:
Added de-interlace support, L3.10.53_ISL79985_Surroundview_Patch_20160125.tar.gz
New test capplication for de-interlance: mxc_v4l2_tvin_isl79985_vdi_20160125.tar.gz
New test commands:
/mxc_v4l2_tvin.out -ol 0 -ot 0 -ow 960 -oh 540 -d 1 -x 0 -g2d -m &
/mxc_v4l2_tvin.out -ol 960 -ot 0 -ow 960 -oh 540 -d 1 -x 1 -g2d -m &
/mxc_v4l2_tvin.out -ol 0 -ot 540 -ow 960 -oh 540 -d 1 -x 2 -g2d -m &
/mxc_v4l2_tvin.out -ol 960 -ot 540 -ow 960 -oh 540 -d 1 -x 3 -g2d -m &
Note: with the 0005-Add-interlaced-mode-capture-for-ISL79985.patch, the V4l2 capture driver will return 720x480 video size, but only odd lines have the video data, they are filled in line skip line mode.
2016-11-21 Update:
Added ISL79987 support, L3.10.53_ISL7998x_Surroundview_Patch_20161121.zip
New test capplication for de-interlance support: mxc_v4l2_tvin_isl7998x.tar.gz
Test commands (without de-interlace):
/mxc_v4l2_tvin.out -ol 0 -ot 0 -ow 960 -oh 540 -d 1 -x 0 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 0 -ow 960 -oh 540 -d 1 -x 1 -g2d &
/mxc_v4l2_tvin.out -ol 0 -ot 540 -ow 960 -oh 540 -d 1 -x 2 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 540 -ow 960 -oh 540 -d 1 -x 3 -g2d &
Test commands (with de-interlace, for ISL79987 only):
/mxc_v4l2_tvin.out -ol 0 -ot 0 -ow 960 -oh 540 -d 1 -x 0 -m 1 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 0 -ow 960 -oh 540 -d 1 -x 1 -m 1 -g2d &
/mxc_v4l2_tvin.out -ol 0 -ot 540 -ow 960 -oh 540 -d 1 -x 2 -m 1 -g2d &
/mxc_v4l2_tvin.out -ol 960 -ot 540 -ow 960 -oh 540 -d 1 -x 3 -m 1 -g2d &
Now the same patch can support both ISL79985 and ISL79987, with NTSC CVBS camera, for ISL79985, it captures 60fps 720*240; for ISL79987, it captures 30fps 720*480.
2016-11-22 Update:
Added patch for L4.1.15 BSP, it supports both ISL79985 and ISL79987, L4.1.15_ISL7998x_Surroundview_Patch_20161122.zip
Test capplication mxc_v4l2_tvin_isl7998x.tar.gz is re-used.
Hi shilong, for iMX6DL, it can only support up to two cameras with MAX9286.
Please contact Intersil for ISL79985 documents and reference schematics.
Hi, Qiang Li:
I have meeting some trouble about debug mipi interface. Now, I dump the csi2 controller register like follow:
[ 64.524300] MIPI CSI2 dump register
[ 64.526636] 0x3130302a
[ 64.527609] 0x0
[ 64.528158] 0x1
[ 64.528521] 0x1
[ 64.529070] 0x1
[ 64.529432] 0x300
[ 64.530154] 0x0
[ 64.530516] 0x0
[ 64.531065] 0x0
[ 64.531427] 0x0
[ 64.531975] 0x0
[ 64.532338] 0x0
[ 64.532886] 0x0
[ 64.533249] 0x2626
according these register. I think front end to csi2 controller is working correctly. csi2ipu gasket, i never setting it, i think it not a key problem to data flow. In this status, i think we don't care ipu to application layer. In fact, driver can't get data from csi2 interface, because enc->count = 0 always.
Can you help me to solve this problem, this is a important issue.
B.R
John.ding
In Shanghai
There is no error messages from your MIPI CSI2 registers, of cource, if your application isn't running, the driver will not start to capture data because no one tells it to capture.
Hi, Qiang Li:
Thanks!
How can i confirm the data flow is working correctly. Which register can prove the data flow in IPU. I have setting the virtual channel in front end. So i think the gasket route correctly.
Please create your question in a new discussion since it is not related to ISL79985 solution.
Hi, Qiang Li:
I have created in important! some quetions about mipi apply to imx6dl. I hope you give me some advice. It is blocked a few weeks.
Hi, Qiang Li:
Do you know Gstreamer 1.0 command list ?
Workable command always gstreamer 0.10 command.
Working
gst-launch-0.10 imxv4l2src device=/dev/video0 ! imxv4l2sink
gst-launch tvsrc ! imxv4l2sink
Fail command
gst-launch-1.0 imxv4l2src ! imxv4l2sink
Hi,
After modify driver, following command is working
gst-launch-1.0 imxv4l2src device=/dev/video0 ! imxv4l2sink
or
gst-launch-1.0 imxv4l2src device=/dev/video0 ! overlaysink
but when I add recording while render to display
if use imxv4l2sink, video & recording is work fine.
gst-launch-1.0 imxv4l2src device=/dev/video0 ! tee name=t1 \
t1. ! queue ! imxv4l2sink \
t1. ! queue ! vpuenc ! avimux ! filesink location=./test.avi
if us overlaysink, recording is work but video become flashing
gst-launch-1.0 imxv4l2src device=/dev/video0 ! tee name=t1 \
t1. ! queue ! overlaysink \
t1. ! queue ! vpuenc ! avimux ! filesink location=./test.avi
I found that when "tee" and "overlaysink" in same pipeline, video become flashing
gst-launch-1.0 imxv4l2src device=/dev/video0 ! overlaysink ==> ok
gst-launch-1.0 imxv4l2src device=/dev/video0 ! tee name=t1 ! overlaysink => flashing
gst-launch-1.0 imxv4l2src device=/dev/video0 ! tee name=t1 ! imxv4l2sink => ok
Due to I need to display 4-camera at the same time, only "overlaysink" can do this.
Does any one know how to fix this problem?
Hello,
Thanks for posting this! Have this patch been committed into any of the released BSPs? If not, is there a updated patch for newer kernels (specifically 3.14.38) that could be posted?
Regards,
David
Hi ,I can not find isl79985 i2c address, Can you tell me??
The address is configurable but the default is 0x88 (0x44 in 7 bit notation). Alternate addresses are 0x8A, 0x78 and 0x7A.
Hi Qiang Li,
i use your patch files for my source (kernel 4.1.15), and i can build OK!
My target is using 4 analog camera, 4xMIPI, each camera on a mipi virtual channel.
However, i don't know how to declare correctly for isl79985 in device tree, could you please help me?
I declare as follow:
isl7998x_mipi@44 {
compatible = "isl7998x_mipi";
pinctrl-names = "default";
reg = <0x44>;
clocks = <&clks 200>;
clock-names = "csi_mclk";
ipu_id = <0>; /* not sure is it correct? */
csi_id = <0>; /* not sure is it correct?*/
status = "okay";
};
&mipi_csi {
status = "okay";
lanes = <2>;
mipi-csi2-channel@0 {
ipu_id = <0>;
csi_id = <0>;
v_channel = <0>;
status = "okay";
};
mipi-csi2-channel@1 {
ipu_id = <0>;
csi_id = <1>;
v_channel = <1>;
status = "okay";
};
mipi-csi2-channel@2 {
ipu_id = <1>;
csi_id = <0>;
v_channel = <2>;
status = "okay";
};
mipi-csi2-channel@3 {
ipu_id = <1>;
csi_id = <1>;
v_channel = <3>;
status = "okay";
};
};
With above declare, i can probe isl79985, can read chip id (0x85), however it can not receive sensor clock when running isl7998x_hardware_init function
here is some messages:
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: mipi_lane_bps = 432 Mbps
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: value = 0xc.
mipi csi2 can not receive sensor clk! MIPI_CSI_PHY_STATE = 0x200.
In hardware of isl79985 i use crystal of 27MHz, Power Down pin connected to GND, i check MIPI_CLKP, MIPI_CLKN signal by oscilloscope and see that has not any clock signal!
Can you please give me any advice how to config isl79985 and make it output video (ex. pattern video sample)?
Thank you!
Regards!
Nguyen
Hi Nguyen, the L4.1.15 patch had already been released here, you can reference to it for your device tree setting.
By the way, you should also make sure there is no other camera drivers installed, if some other camera drivers are loaded before ISL7998x driver, it will use some IPU CSI port, then ISL7998x can't get 4 CSI ports.
Hi Nguyen,
The ISL79985 generated FS(Frame Start) and FE(Frame End) for each field, so to iMX6 MIPI CSI2 input, it is 60 frames of 720*240. And we can't identify which is the ODD field and which is the EVEN field.
You can modify the driver code "isl7998x_mipi.c", let ISL79985 goto to the same code as ISL79987, then IPU can use 720*480 buffer to capture. In this case, you will get IPU error NFB4EOF, but you still can capture 720*480 frames. But in this buffer, each time you start to capture the video, sometimes ODD field is first line, but sometimes EVEN filed is the first line.
Function ioctl_try_fmt_cap():
static int ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
{
struct sensor_data *sensor = s->priv;
if (sensor->i2c_client != NULL) {
g_isl7998x_width = f->fmt.pix.width;
if (chip_id == CHIP_ID_79987)
g_isl7998x_frame_height = f->fmt.pix.height;
else if (chip_id == CHIP_ID_79985)
- g_isl7998x_field_height = f->fmt.pix.height;
+ g_isl7998x_frame_height = f->fmt.pix.height;
}
sensor->pix.width = g_isl7998x_width;
if (chip_id == CHIP_ID_79987)
sensor->pix.height = g_isl7998x_frame_height;
else if (chip_id == CHIP_ID_79985)
- sensor->pix.height = g_isl7998x_field_height;
+ sensor->pix.height = g_isl7998x_frame_height;
ioctl_dev_init(s);
return 0;
}
Function isl7998x_probe():
if (chip_id == CHIP_ID_79987) {
isl7998x_data[0].pix.height = g_isl7998x_frame_height;
isl7998x_data[0].is_mipi_interlaced = 1;
} else if (chip_id == CHIP_ID_79985)
- isl7998x_data[0].pix.height = g_isl7998x_field_height;
+ {
+ isl7998x_data[0].pix.height = g_isl7998x_frame_height;
+ isl7998x_data[0].is_mipi_interlaced = 1;
+ }
Hi Qiang,
i modify isl7998x_mipi.c as your suggestion, and i can capture image to .jpg in 720*480, but it has interlaced line when capture moving object, same as this picture:
is there any way to fix this problem?
If i use isl79987, can i capture in 720*480 without interlaced line as above?
Thanks!
Nguyen
Hi Qiang Li,
i try this patch: iMX6 camera patch to support CSI->VDI->IC->MEM and CSI->VDI->MEM capture
to use VDI:
g_input = 3; /* 0: CSI->IC->MEM; 1: CSI->MEM; 2: CSI->VDI->IC->MEM; 3: CSI->VDI->MEM */
ioctl(cam->fd, VIDIOC_S_INPUT, &g_input);
but when i turn on STREAM:
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ioctl(cam->fd, VIDIOC_STREAMON, &type);
it's ERROR!
I also try g_input = 2 but it's Error too.
Can you help me?
Thanks!
The captured frame is UYVY format (YUV422) in memory buffer, then you can use any process method for post processing as you wanted.
Hi,
this is answer:
"The ISLl79985/87 chip has not frame buffer inside, so we can’t do de-interlacing for the video.
The output is always interlace @720x240 with odd/even field.
You have to convert it to progressive then record..."
Do anyone know how to de-interlace (convert to progressive) video? i tried to use VDI (CSI->VDI->IC->MEM; CSI->VDI->MEM) on iMX6q but cannot open STREAM
iMX6DL can only support up to two MIPI virtual channel at the same time (Due to there is only one IPU). So this patch can't work on it.
ISL79987 can combine two cameras into one MIPI virtual channel, in this case, it can be used on iMX6DL, then after received each combined frame, the software should split it to two pictures for two camera. I haven't verified such use case, you can check with Itersil for how to set ISL79987 in such mode.
To use IPU VDI for de-interlace, the IPU needs know which field is ODD and which field is EVEN.
But the input from ISL79985 is in followed order:
(Frame Start) -> (ODD Field) -> (Frame End) -> (Frame Start) -> (EVEN Field) -> (Frame End) -> (Frame Start) -> (ODD Field) -> (Frame End) -> ... ...
So from IPU CSI side of view, they are 720*240 60fps input. From video data, we can't idntify the field.
For ISL79987, it can support the followed order:
(Frame Start) -> (ODD Field) -> (EVEN Field) -> (Frame End) -> (Frame Start) -> (ODD Field) -> (EVEN Field) -> (Frame End) -> ... ...
In this case, the IPU can receive the two fields into one frame with line skip line mode. And the first line is always ODD data. Then VDI de-interlace can be used.
That is OK.
Thanks for you clarification, that's clear my doubt.
So for isl79985, our options are either keep all fields and accept the flickering as in you current patch, or drop all the even or odd fields as in you previous patch? Unless we are able to determine the odd/even field somehow.
I think you should focus on IOMUX_GPR register setting to map the two cameras to VC 0 and 1 on IPU CSI0 and CSI1.
In isl7998x_mipi.c, you can set max camera numbers to 2.
Yes. By the way, Intersil had told me, the ISL 79985 can set to send metadata in each line, then the metadata can include the field information.
For example, the video data will be changed from 728*240, the 8 bytes meta data can include field data, but I haven't tried it. And in this mode, the IPU hardware still can't identify the field, but software can.
Hi Nick,
I have no PAL cameras, but I think there should be some different setting in ISL7998x registers for PAL camera.
my bsp is 3.10.53, i have patched the patch files ,and there is no other camera drivers installed,but when i run mxc_v4l2_tvin_isl7998x,it always printf:
SENSOR_NUM 4 lanes 1
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: mipi_lane_bps = 432 Mbps
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: value = 0xc.
g_in_width = 720, g_in_height = 480.
fb_fix.id = DISP3 FG.
fb: smem_start = 0x72800000, smem_len = 0xbdd800.
fb: frame buffer size = 0x3f4800 bytes.
fb: g_screen_info.xres = 1920, g_screen_info.yres = 1080.
fb: g_display_left = 0.
fb: g_display_top = 0.
fb: g_display_width = 960.
fb: g_display_height = 540.
start time = 12 s, 553006 us
ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
VIDIOC_DQBUF failed.
i use oscillometer to measure MIPI_CLK MIPID0 MIPID1 i can get signal.
CLK
Dx
data lane只是数据传输的物理连接;不同camera的数据是用MIPI Virtual channel来区分的,所以ISL79987是4个camera的图像,在同样的2个data lane上传输;然后进入iMX6内部后,通过MIPI Virtual channel把不同camera的图像转发到不同的IPU CSI端口。
1片ISL79987+IMX6D/Q可以实现4路摄像头输入。
3.14.x编译mxc_v4l2_tvin_isl7998x.tar.gz失败,出现错误:gnu/stubs-soft.h: No such file or directory,请教原因,如何解决?
3.10.x编译ok!
区别在于,3.10.x sysroots\x86_64-linux\usr\bin\目录下编译文件夹是:cortexa9hf-vfp-neon-poky-linux-gnueabi
而3.14.x 变成了:arm-poky-linux-gnueabi
对比两者arm-poky-linux-gnueabi-gcc -v也有所不同。
谢谢。
For 3.14.52, the Makefile for mxc_v4l2_tvin can be followed:
TOOL_DIR=/home/b19715/L3.14.52_GA1.1.0/build-imx6qsabresd-X11/tmp/sysroots/x86_64-linux/usr/bin/arm-poky-linux-gnueabi
ROOTFS_DIR = /home/b19715/L3.14.52_GA1.1.0/build-imx6qsabresd-X11/tmp/sysroots/imx6qsabresd
CC=$(TOOL_DIR)/arm-poky-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=$(ROOTFS_DIR)
LD=$(TOOL_DIR)/arm-poky-linux-gnueabi-ld --sysroot=$(ROOTFS_DIR)
CFLAGS = -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 -I$(ROOTFS_DIR)/usr/include
LFLAGS += -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -L $(ROOTFS_DIR)/lib -L $(ROOTFS_DIR)/usr/lib -lg2d
OBJS = mxc_v4l2_tvin.o
TARGET = mxc_v4l2_tvin.out
$(TARGET): $(OBJS)
$(CC) $(FLAGS) -o $(TARGET) $(OBJS) $(LFLAGS)
clean:
rm -f *.o *.out
Nguyen,
What did you do to fix your problem? I'm seeing the same error message "mipi csi2 can not receive sensor clk! MIPI_CSI_PHY_STATE = 0x200."
# ./mxc_v4l2_tvin.out -ol 0 -ot 0 -ow 960 -oh 540 -d 1 -x 0 -g2d
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: mipi_lane_bps = 432 Mbps
mxc_mipi_csi2 21dc000.mipi_csi: mipi_csi2_reset: value = 0xc.
mipi csi2 can not receive sensor clk! MIPI_CSI_PHY_STATE = 0x200.
g_in_width = 720, g_in_height = 240.
fb_fix.id = DISP3 FG.
fb: smem_start = 0x44800000, smem_len = 0x708000.
fb: frame buffer size = 0x258000 bytes.
fb: g_screen_info.xres = 1024, g_screen_info.yres = 600.
fb: g_display_left = 0.
fb: g_display_top = 0.
fb: g_display_width = 960.
fb: g_display_height = 540.
start time = 1498657957 s, 147951 us
ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
VIDIOC_DQBUF failed.
"mipi csi2 can not receive sensor clk! MIPI_CSI_PHY_STATE = 0x200"
This error means iMX6 MIPI CSI2 PHY can't identify the input MIPI signal.
Hi Qiang Li,
Could you record video successfully using "grecorder-1.0" tool?
I try the gstreamer command below to preview and record video, and it is working.
gst-launch-1.0 imxv4l2src device=/dev/video0 ! tee name=t1 \
t1. ! queue ! imxv4l2sink \
t1. ! queue ! vpuenc_mpeg4 ! filesink location=./test.mp4
But, when I use the "grecorder-1.0" in imx-gst1.0-plugin-4.1.4 package, it has the following errors:
[Current Media Time] 000:00:01ERROR: v4l2 capture: VIDIOC_QBUF: buffer already queued
(grecorder-1.0:759): GStreamer-CRITICAL **: gst_buffer_iterate_meta: assertion 'buffer != NULL' failed
(grecorder-1.0:759): GStreamer-CRITICAL **: gst_buffer_add_meta: assertion 'buffer != NULL' failed
Segmentation fault
=================================================================================
I try to set the arguments ""--camera_id 0 --video_format 4 --width 720 --height 240 --fps 30" to grecorder-1.0 tool, and then it can record video successfully.
Thank you for help.