We try to interface ADV7282-m sensor with MIPI for imx6 quad plus on custom board under linux 3.14.52 (yocto-jethro compatible).
We configure in our device tree with the following definitions:
&mipi_csi{
status = "okay";
ipu_id = <0>; /* IPU1 is selected */
csi_id = <0>; /* CSI0 is selected */
v_channel = <0>; /* virtual channel0 selected */
lanes = <1>; /* DATA0 only */
};
v4l2_cap_1 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <0>; /* IPU1 selected */
csi_id = <0>; /* virtual channel0 selected */
mclk_source = <0>;
mipi_camera = <1>;
status = "okay";
};
/*
* I2C-1 bus management
*/
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
adv7282-m {
compatible = "adv7282";
pinctrl-names = "default";
reg = <0x21>;
csi_id = <0>; /* video source : CSI0 */
cvbs = <1>; /* ANALOGIC channel INPUT#1 */
DOVDD-supply = <®_3p3v>; // 3.3v
AVDD-supply = <®_3p3v>; // 1.8v
DVDD-supply = <®_3p3v>; // 1.8v
PVDD-supply = <®_3p3v>; // 1.8v
clocks = <&clks 201>;
clock-names = "csi_mclk";
mipi_camera = <1>; /* Needed for v4l2 configuration */
mclk_source = <0>;
mclk = <24000000>;
ipu_id = <0>; /* IPU1 selected */
status = "okay";
};
};
Driver configure MIPI with YUV442 configuration and we measure MIPI clock signal with 108MHz frequency so we add a path in mxc_mipi_csi2.c file
(from “Some Experience When Enable MIPI Camera” : https://community.nxp.com/thread/307065 & Debug steps for customer MIPI sensor.docx )
And our mipi initialization configuration is as follow :
mipi_csi2_write(info, 0x00000002, CSI2_PHY_TST_CTRL0);
mipi_csi2_write(info, 0x00010044, CSI2_PHY_TST_CTRL1);
mipi_csi2_write(info, 0x00000000, CSI2_PHY_TST_CTRL0);
- mipi_csi2_write(info, 0x00000014, CSI2_PHY_TST_CTRL1);
+ mipi_csi2_write(info, 0x00000026, CSI2_PHY_TST_CTRL1);
mipi_csi2_write(info, 0x00000002, CSI2_PHY_TST_CTRL0);
mipi_csi2_write(info, 0x00000000, CSI2_PHY_TST_CTRL0);
In custom driver, we configure i2c initialization with these definitions (AUTODETECT CVBS Single Ended In Ain 1, MIPI Out):
42 0F 00 ; Exit Power Down Mode
42 00 00 ; INSEL = CVBS in on Ain 1
42 0E 80 ; ADI Required Write
42 9C 00 ; ADI Required Write
42 9C FF ; ADI Required Write
42 0E 00 ; Enter User Sub Map
42 03 4E ; ADI Required Write
42 04 57 ; Power-up INTRQ pin
42 13 00 ; Enable INTRQ output driver
42 17 41 ; select SH1
42 1D C0 ; Tri-State LLC output driver
42 52 CD ; ADI Required Write
42 80 51 ; ADI Required Write
42 81 51 ; ADI Required Write
42 82 68 ; ADI Required Write
42 5D 1C ; Enable Diagnostic pin 1 - Level=1.125V
42 5E 1C ; Enable Diagnostic pin 2 - Level=1.125V
42 FE 88 ; Set CSI Map Address
88 DE 02 ; Power up MIPI D-PHY
88 D2 F7 ; ADI Required Write
88 D8 65 ; ADI Required Write
88 E0 09 ; ADI Required Write
88 2C 00 ; ADI Required Write
88 00 00 ; Power up MIPI CSI-2 Tx --done--
As a result: no acquisition display…
So we tried another ADV7282-m configuration (Color Bars 576i MIPI Out with free-run):
42 0F 00 ; Exit Power Down Mode
42 00 04 ; ADI Required Write
42 0C 37 ; Force Free-run mode
42 02 84 ; Force standard to PAL
42 14 11 ; Set Free-run pattern to color bars
42 03 4E ; ADI Required Write
42 04 57 ; Power-up INTRQ pin
42 13 00 ; Enable INTRQ output driver
42 17 41 ; select SH1
42 1D C0 ; Tri-State LLC output driver
42 52 CD ; ADI Required Write
42 80 51 ; ADI Required Write
42 81 51 ; ADI Required Write
42 82 68 ; ADI Required Write
42 5D 1C ; Enable Diagnostic pin 1 - Level=1.125V
42 5E 1C ; Enable Diagnostic pin 2 - Level=1.125V
42 FE 88 ; Set CSI Map Address
88 DE 02 ; Power up MIPI D-PHY
88 D2 F7 ; ADI Required Write
88 D8 65 ; ADI Required Write
88 E0 09 ; ADI Required Write
88 2C 00 ; ADI Required Write
88 00 00 ; Power up MIPI CSI-2 Tx --done—
As a result:
If we start acquisition:
gst-launch-1.0 --gst-debug=*:1 -v imxv4l2src device=/dev/video0 ! imxv4l2sink
====== IMXV4L2SRC: 4.0.8 build on Jul 13 2016 15:19:44. ======
====== IMXV4L2SINK: 4.0.8 build on Jul 13 2016 15:19:44. ======
Setting pipeline to PAUSED ...
display(/dev/fb0) resolution is (1024x768).
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstImxV4l2Src:imxv4l2src0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)720\,\ height\=\(int\)576\,\ framerate\=\(fraction\)25/1\,\ interlace-mode\=\(string\)interleaved"
/GstPipeline:pipeline0/GstImxV4l2Sink:imxv4l2sink0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)720\,\ height\=\(int\)576\,\ framerate\=\(fraction\)25/1\,\ interlace-mode\=\(string\)interleaved"
V4L debug command gives:
v4l2-ctl -d /dev/video0 --all
Driver Info (not using libv4l2):
Driver name : mxc_v4l2
Card type :
Bus info :
Driver version: 0.1.11
Capabilities : 0x05000005
Video Capture
Video Overlay
Read/Write
Streaming
Video input : 1 (CSI MEM: no power)
Video output: 0 (DISP3 BG)
Video Standard = 0x00ffffff
PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60
NTSC-M/M-JP/443/M-KR
SECAM-B/D/G/H/K/K1/L/Lc
Format Video Capture:
Width/Height : 720/576
Pixel Format : 'NV12'
Field : Any
Bytes per Line: 720
Size Image : 622080
Colorspace : Unknown (00000000)
Format Video Overlay:
Left/Top : 0/0
Width/Height: 160/160
Field : Any
Chroma Key : 0x00000000
Global Alpha: 0x00
Clip Count : 0
Clip Bitmap : No
Framebuffer Format:
Capability : Extern Overlay
Flags : Overlay Matches Capture/Output Size
Width : 0
Height : 0
Pixel Format : ''
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 720, Height 625
Default : Left 0, Top 0, Width 720, Height 625
Pixel Aspect: 0/0
Crop: Left 0, Top 0, Width 720, Height 625
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers : 0
Streaming Parameters Video Output:
Frames per second: invalid (0/0)
Write buffers : 0
Try with low-level tool :
/unit_tests/mxc_v4l2_capture.out -d /dev/video0 -m 1
in_width = 176, in_height = 144
out_width = 176, out_height = 144
top = 0, left = 0
sensor chip is adv7282-m_decoder
sensor supported frame size:
720x576
Width = 176 Height = 144 Image size = 38016
pixelformat: YU12
VIDIOC_DQBUF failed.
VIDIOC_QBUF failed
Can you help us to understand why there is no acquisition display?
Witch control can we do?
Original Attachment has been moved to: LOG.txt.zip
Eureka,
We success in display first acquisition from adv7282-m device.
We set Virtual Channel #1 under ADV7282-m with adv7282_csi_write(0x0D,0x40) command and we finally use ipu_id=0 and csi_id=1 configuration to capture video over mipi bus.
Now we have synchro problem and pixel frequency acquisition problem.
The current device tree configuration is :
v4l2_cap_1 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <0>; /* IPU1 selected */
csi_id = <1>; /* virtual channel1 selected */
mclk_source = <0>;
mipi_camera = <1>;
status = "okay";
};
&mipi_csi{
status = "okay";
ipu_id = <0>; /* IPU1 is selected */
csi_id = <1>; /* CSI0/channel1 is selected */
v_channel = <1>; /* virtual channel1 selected */
lanes = <1>; /* only one lane */
};
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
adv7282-m {
compatible = "adv7282";
pinctrl-names = "default";
reg = <0x21>;
csi_id = <1>;
cvbs = <1>; /* ANALOGIC channel INPUT#1 */
DOVDD-supply = <®_3p3v>; // 3.3v
AVDD-supply = <®_3p3v>; // 1.8v
DVDD-supply = <®_3p3v>; // 1.8v
PVDD-supply = <®_3p3v>; // 1.8v
clocks = <&clks 200>;
clock-names = "csi_mclk";
mipi_camera = <1>; /* Needed for v4l2 configuration */
ipu_id = <0>; /* IPU1 selected */
status = "okay";
};
};
We use PAL video signal and we test without adv7282 progressive format, and with progressive format (mipi clock is double). In these two adv7282 configuration case, we don't reach to synchronise output display image acquisition.
The ADV7282-M output data is 8-bit YCrCb 4:2:2 format with one lane.
Routing MIPI stream into CSI2 is Ok.
It displays :
gst-launch-1.0 --gst-debug=*:1 -v imxv4l2src device=/dev/video0 ! imxv4l2sink
====== IMXV4L2SRC: 4.0.8 build on Jul 13 2016 15:19:44. ======
====== IMXV4L2SINK: 4.0.8 build on Jul 13 2016 15:19:44. ======
Setting pipeline to PAUSED ...
display(/dev/fb0) resolution is (1024x768).
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstImxV4l2Src:imxv4l2src0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)720\,\ height\=\(int\)576\,\ framerate\=\(fraction\)25/1\,\ interlace-mode\=\(string\)interleaved"
/GstPipeline:pipeline0/GstImxV4l2Sink:imxv4l2sink0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)720\,\ height\=\(int\)576\,\ framerate\=\(fraction\)25/1\,\ interlace-mode\=\(string\)interleaved"
v4l2sink need allocate 3 buffers.
Colors are wrong and there is also a vertical scrolling (see mp4 file).
We don't know if we have iMX6 IPU or V4L2 configuration to complete or change.
We study "MIPI–CSI2 Peripheral on i.MX6 MPUs" freescale document and we noticed the current status :
IPU1_IDMAC_CH_EN_1(0x2608004) = 0x00201002 --> IDMAC channel is enabled,
IPU1_CH_DB_MODE_SEL1(@0x2600154) = 0x00000002 --> Double buffer is used for this channel.
IPU1_CONF(@0x2600000) = 0x20000106 --> CSI0 selected, mipi connected to CSI1, ic is enable, csi1 is enable,
IPU1_SMFC_MAP(@0x2650000) = 0x00000028 --> CSI0, ID=1 mapped to DMASMFC channel 1
IPU1_SMFC_BS(@0x2650008) = 0x00000070 --> Burst Size of SMFCDMA channel 1 = 8-1
IPU1_CSI1_SENS_CONF(@0x2638000) =0x04000A30 --> YUV422 8 bits per color, CCIR interlaced mode (BT.656)
IPU1_CSI1_SENS_FRM_SIZE(@0x2638004) =0x027002CF --> row=625-1, width=720-1
IPU1_CSI1_ACT_FRM_SIZE(@0x2638008) =0x023F02CF --> row=576-1, width=720-1
IPU1_CSI1_OUT_FRM_CTRL(@0x263800C) =0x00000000
Is MIPI/IPU settings have to match with 640x480@15 configuration ?
How can I check IPU configuration ?
Regards,
Gabriel Grange
Hi Gabriel,
i'm trying interface ADV7280M with imx6q board using mipi csi, but i don't find adv7280.c driver anywhere, i've tried to used adv7180 in /media/i2c/ folde of kernel 4.1.15 but not successfull. It's only run shows "adv7180_tvin 0-0021: chip found @ 0x21 (21a0000.i2c)" and "ERROR: v4l2 capture: slave not found!"
Can you share me your drivers which you used for adv7282m?
Thank you!
Regards,
Nguyen
Hi Nguyen,
We tried adv7282m under Linux4.1.15 with a linux source kernel from Yocto-krogoth. As we use Toradex Apalis for our tests, we extract 4_1_15_ga_next-linux-toradex.tar.gz to generate our Linux kernel.
The default adv7280.c file is under driver/media/platform/mxc/capture directory.
We finally stay in Yocto-jethro with linux kernel 3.14.52 version and a lot of ipu patch to allow interface management with mipi and adv7282m thanks to NPX community but the solution is not very standard and clean. I put our curent source files for your information.
Hope these informations help you
Regards,
Gabriel Grange
Thank you, Gabriel!
i will try with your driver and show the result soon. I spend many time to find the standard solution but seem that it's not
available. Thanks for your information!
Regards,
Nguyen
Hi Gabrirel,
i build kernel with your code and it shows error because undeclared something as following:
in: ipu_ic.c and ipu_common.c:
- CSI_VDI_PRP_VF_MEM is undeclared
- CSI_VDI_MEM is undeclared
- ipu_channel_params_t has no member named "csi_vdi_mem", "csi_vdi_prp_mem",
Could you please tell me where did you define them?
Thanks!
Regards,
Nguyen
Hi G.Grange,
I've build kernel OK and it can probes adv7280m. I saw video0 in /dev/ folder
root@sabresd_6dq:/dev # ls video*
video0
video16
video17
video18
But when i try to use command cat /dev/video0 then it shows:
root@sabresd_6dq:/ # cat /dev/video0
ERROR: v4l2 capture: mxc_v4l_read timeout counter 0
/system/bin/sh: cat: /dev/video0: Timer expired
Debug print out when probe adv7280 as following:
adv7282 0-0021: adv7282_probe sensor data is at c126d078
adv7282 0-0021: Read ipu_id=1 from device tree.
adv7282 0-0021: Read csi_id=0 from device tree.
adv7282 0-0021: adv7282_probe: ADV7280 probe i2c address is 0x21
adv7282 0-0021: adv7282_probe: ADV7280_IDENT = 0x42
adv7282 0-0021: mipi_csi2_get_status function is done.
adv7282 0-0021: ADV7282_Dbg: mipi_get_error1/MIPI_CSI_ERR1=00000000
adv7282 0-0021: ADV7282_Dbg: mipi_get_error2/MIPI_CSI_ERR2=00000000
adv7282 0-0021: ADV7282_Dbg: mipi_virtual_channel:2
adv7282 0-0021: ADV7282_Dbg: mipi_csi_config:0
adv7282 0-0021: ADV7282_Dbg: mipi_ipu_config:1
adv7282 0-0021: mipi_csi2 configure data type in YUV442!
mipi_csi2_reset: Centralp mipi PATCH to adjust CLOCK... value=0x26
adv7282 0-0021: In adv7282:adv7282_hard_reset
VC_REF = 0x40
CSI_CSITX_PWRDN = 0x00
CSI_TLPX = 0x18
CSI_THSPREP = 0x18
CSI_THSZEROS = 0x30
CSI_THSTRAIL = 0x20
CSI_THSEXIT = 0x28
CSI_TCLK_PREP = 0x40
CSI_TCLK_ZEROS = 0x58
CSI_TCLK_TRAIL = 0x30
CSI_VC_REF = 0x40
CSI_ESC_MODE_CTL = 0x50
CSI_DPHY_PWDN_CTL = 0x02
VPP_DEINT_RESET = 0x00
VPP_I2C_DEINT_ENABLE = 0x80
VPP_ADV_TIMING_MODE_EN = 0x00
type is 2 (expect 2)
num ioctls is 13
adv7282 0-0021: ADV7282: Dbg: STATUS1=0x4B
adv7282 0-0021: ADV7282: Dbg: STATUS2=0x00
adv7282 0-0021: ADV7282: Dbg: STATUS3=0x2D
adv7282 0-0021: In adv7282_get_std
adv7282_get_std: status1=0x49, locked=1, standard=0x40
adv7282_get_std: set ADV7282_PAL
adv7282_get_std: set video_idx=1
mxc_v4l2_master_attach: ipu1:/csi0 mipi attached adv7282:mxc_v4l2_cap0
v4l2 device created, status is 0
Dbg: mipi_csi2 receive sensor clock! mipi_csi2_dphy_status=0x210
Dbg: mipi_csi2 can receive data, mipi_csi2_get_error1=0
ADV7282_Dbg: MIPI_CSI_ERR1=00000000
ADV7282_Dbg: MIPI_CSI_ERR2=00000010
adv7282_probe: ADV7280M initial done, ret=0
I used EVAL_ADV7280M/Rev.A kit from Analog Device to connect to analog camera.
Can you give me any advice?
Thank you!
Regards,
Nguyen
Hi Nguyen,
We have not exaclty the same hardware context. We use adv7282-m instead of 7082-m and we use iMX6 quad plus CPU.
Please check adv definitions in devicetree, for us we have :
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
adv7282-m {
compatible = "adv7282";
pinctrl-names = "default";
reg = <0x21>;
csi_id = <1>; /* video source : CSI1 */
cvbs = <1>; /* ANALOGIC channel INPUT#1 */
DOVDD-supply = <®_3p3v>; // 3.3v
AVDD-supply = <®_3p3v>; // 1.8v
DVDD-supply = <®_3p3v>; // 1.8v
PVDD-supply = <®_3p3v>; // 1.8v
clocks = <&clks 200>;
clock-names = "csi_mclk";
mipi_camera = <1>; /* Needed for v4l2 configuration */
ipu_id = <0>; /* IPU1 selected */
status = "okay";
};
}
regulators {
compatible = "simple-bus";
.
.
.
v4l2_out {
compatible = "fsl,mxc_v4l2_output";
status = "okay";
};
/* Centralp : */
/* 1/ Create /dev/video0 device */
/* 2/ Force imx_v4l capture definitions to use mipi bus */
v4l2_cap_1 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <0>; /* IPU1 selected */
csi_id = <1>; /* virtual channel1 selected */
mclk_source = <0>;
mipi_camera = <1>; /* Refs: http://sr.r00t.website/forum/viewtopic.php?t=2138 and https://community.nxp.com/thread/365929 */
status = "okay";
};
Our adv7282-m use only virtual channel #1.
We use gstreamer1.0 commands to make acquisition, for example :
gst-launch-1.0 -v imxv4l2src ! imxv4l2sink
gst-launch-1.0 -v imxv4l2src ! imxipuvideotransform deinterlace=true ! imxv4l2sink
gst-launch-1.0 imxv4l2src ! imxipuvideotransform deinterlace=true ! videocrop top=80 left=100 right=120 bottom=100 ! imxipuvideosink output-rotation=4
Hope theses informations help you.
Regards,
Gabriel GRANGE
Hi G.Grange,
In my device tree, i use IPU2 instead of IPU1, i think it's ok
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
adv7282-m {
compatible = "adv7282";
pinctrl-names = "default";
reg = <0x21>;
DOVDD-supply = <&vgen3_reg>; /* 3.3v */
AVDD-supply = <&vgen4_reg>; /* 1.8v */
DVDD-supply = <&vgen4_reg>; /* 1.8v */
PVDD-supply = <&vgen4_reg>; /* 1.8v */
clocks = <&clks 200>;
clock-names = "csi_mclk";
ipu_id = <1>; /* IPU2 is selected */
csi_id = <0>; /* CSI0 is selected */
cvbs = <1>; /* ANALOGIC channel INPUT#1 */
mipi_camera = <1>; /* Needed for v4l2 configuration */
status = "okay";
};
};
v4l2_cap_1 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <1>; /* IPU2 is selected */
csi_id = <0>; /* CSI0 is selected */
mclk_source = <0>;
mipi_camera = <1>;
status = "okay";
};
&mipi_csi {
status = "okay";
ipu_id = <1>; /* IPU2 is selected */
csi_id = <0>; /* CSI0 -> v_channel2 */
v_channel = <2>; /* virtual channel2 is selected */
lanes = <1>; /* only one lane data from 7280M */
};
and i set virtual channel 2 for adv7280m also: adv7282_csi_write(0x0D, 0x80); /* set VC_REF */
In this case, i use v4l2_cap_1 for mipi bus, but when mxc_v4l2_master_attach function in mxc_v4l2_capture.c running, i see it prints out:
In MVC: mxc_v4l2_master_attach
slave.name = adv7282
master.name = mxc_v4l2_cap0
mxc_v4l2_master_attach: ipu1:/csi0 mipi attached adv7282:mxc_v4l2_cap0
It's not v4l2_cap_1 as i configured, i'm not sure is it correct? but if i used:
v4l2_cap_0 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <1>; /* IPU2 is selected */
csi_id = <0>; /* CSI0 is selected */
mclk_source = <0>;
mipi_camera = <1>;
status = "okay";
};
Result is the same,
ERROR: v4l2 capture: mxc_v4l_read timeout counter 0
/system/bin/sh: cat: /dev/video0: Timer expired
May be i will review some configurations for adv7280m!
Thanks for your informations!
Regards,
Nguyen
Hi Gabriel,
have you tried export DISPLAY=:0 before calling.
gst-launch-1.0 --gst-debug=*:1 -v imxv4l2src device=/dev/video0 ! imxv4l2sink
Please also double check that the resolution settings are right.
I cannot do testing because I am not able to reproduce this case. You may contact also ADV so they can guide about new driver configuration.
Regards,
Carlos
Hi Carlos,
Thanks for this advice. I have a LXDE desktop that runs with iMX6 (Toradex Apalis module CPU) and adv7180. It works fine with gstreamer if we use
imxv4l2sink or imxeglvivsink (inside a window). We think we are looking for configuration problem.
Regards,
Gabriel