AnsweredAssumed Answered

Command to capture video or image for 10 bit RGB layer with OV4689 IC

Question asked by Devendra Devadiga on Jun 9, 2020
Latest reply on Jun 19, 2020 by Devendra Devadiga

Hi,

Currenty I am working on i.MX8M Mini platform with Camera module OV4689.

OmniVision | CMOS Image Sensor Manufacturer | Imaging Solutions 

 

To add support for this driver, I used the driver from below opensource

linux-rk3328-box/ov4689.c at master · hanwckf/linux-rk3328-box · GitHub 

 

In our Linux 4.14.98 MIPI driver added support for MEDIA_BUS_FMT_SBGGR10_1X10 like this:

drivers/media/platform/mxc/capture/mx6s_capture.c


static struct mx6s_fmt formats[] = {
{
.name = "UYVY-16",
.fourcc = V4L2_PIX_FMT_UYVY,
.pixelformat = V4L2_PIX_FMT_UYVY,
.mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
.bpp = 2,
}, {
.name = "YUYV-16",
.fourcc = V4L2_PIX_FMT_YUYV,
.pixelformat = V4L2_PIX_FMT_YUYV,
.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
.bpp = 2,
}, {
.name = "YUV32 (X-Y-U-V)",
.fourcc = V4L2_PIX_FMT_YUV32,
.pixelformat = V4L2_PIX_FMT_YUV32,
.mbus_code = MEDIA_BUS_FMT_AYUV8_1X32,
.bpp = 4,
}, {
.name = "RAWRGB8 (SBGGR8)",
.fourcc = V4L2_PIX_FMT_SBGGR8,
.pixelformat = V4L2_PIX_FMT_SBGGR8,
.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
.bpp = 1,
}, {
.name = "RAWRGB10 (SBGGR10)",
.fourcc = V4L2_PIX_FMT_SBGGR10,
.pixelformat = V4L2_PIX_FMT_SBGGR10,
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
.bpp = 2,
}

};

 

drivers/media/platform/mxc/capture/mxc_mipi_csi.c

static const struct csis_pix_format mipi_csis_formats[] = {
{
.code = MEDIA_BUS_FMT_YUYV8_2X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
.data_alignment = 16,
}, {
.code = MEDIA_BUS_FMT_VYUY8_2X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
.data_alignment = 16,
}, {
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
.data_alignment = 8,
}, {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
.data_alignment = 16,
}

};

 

And Inside the ov4689.c driver file modified two function to support to higher 4.14.98 version

./drivers/media/i2c/ov4689.c

- sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
- ret = media_entity_init(&sd->entity, 1, &ov4689->pad, 0);

+ sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
+ ret = media_entity_pads_init(&sd->entity, 1, &ov4689->pad);

 

During boot, driver is initialized and OV4689 Camera IC is detecting.

/dev/video0 node also created and able to query the information.

 


root@iWave-G34M:~# 
root@iWave-G34M:~# v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'BG10'
Name : 10-bit Bayer BGBG/GRGR

root@iWave-G34M:~# v4l2-ctl --device /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'BG10'
Name : 10-bit Bayer BGBG/GRGR
Size: Discrete 2688x1520
Size: Discrete 1920x1080

root@iWave-G34M:~# 
root@iWave-G34M:~# 
root@iWave-G34M:~# v4l2-ctl --device /dev/video0 --list-framesizes=BG10
ioctl: VIDIOC_ENUM_FRAMESIZES
Size: Discrete 2688x1520
Size: Discrete 1920x1080
root@iWave-G34M:~#

 


I run below command to capture one frame and its creating frame.raw file

v4l2-ctl --device /dev/video0 --set-fmt-video=width=2688,height=1520,pixelformat=BG10
v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1

 

Once done I am able to convert that frame.raw file to png and image with black and white is there.

ov4689 image with 2 lane

 

Below is the content of dts file:

arch/arm64/boot/dts/freescale/fsl-imx8mm-iwg34m.dts

&csi1_bridge {
fsl,mipi-mode;
status = "okay";
port {
csi1_ep: endpoint {
remote-endpoint = <&csi1_mipi_ep>;
};
};
};

 

&mipi_csi_1 { /* MIPI CSI: OV5640 MIPI Camera */
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
port {
mipi1_sensor_ep: endpoint1 {
remote-endpoint = <&ov4689_mipi1_ep>;
data-lanes = <2>;
csis-hs-settle = <13>;
csis-clk-settle = <2>;
csis-wclk;
};

csi1_mipi_ep: endpoint2 {
remote-endpoint = <&csi1_ep>;
};
};
};

 

&i2c3 { /* I2C: I2C3 Bus */

....

ov4689: ov4689@36 { /* MIPI CSI: OV5640 Camera */
compatible = "ovti,ov4689";
status = "okay";
reg = <0x36>;
clocks = <&clk IMX8MM_CLK_CLKO1_DIV>;
clock-names = "xvclk";
/* avdd-supply = <>; */
/* dvdd-supply = <>; */
/* dovdd-supply = <>; */
/* reset-gpios = <>; */
avdd-supply = <&reg_2p8v>;
dovdd-supply = <&reg_1p8v>;
dvdd-supply = <&reg_1p2v>;

pinctrl-names = "iwg,camera_default";
pinctrl-0 = <&pinctrl_csi_rst_pwdn>;
assigned-clocks = <&clk IMX8MM_CLK_CLKO1_SRC>,
<&clk IMX8MM_CLK_CLKO1_DIV>;
assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
assigned-clock-rates = <0>, <24000000>;
csi_id = <0>;
reset-gpios = <&gpio5 24 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio5 23 GPIO_ACTIVE_LOW>;
mclk = <24000000>;
mclk_source = <0>;
port {
ov4689_mipi1_ep: endpoint {
remote-endpoint = <&mipi1_sensor_ep>;
};
};
};

}

 

arch/arm64/boot/dts/freescale/fsl-imx8mm.dtsi

csi1_bridge: csi1_bridge@32e20000 {
compatible = "fsl,imx8mm-csi", "fsl,imx8mq-csi", "fsl,imx6s-csi";
reg = <0x0 0x32e20000 0x0 0x10000>;
interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk IMX8MM_CLK_DISP_AXI_ROOT>,
<&clk IMX8MM_CLK_CSI1_ROOT>,
<&clk IMX8MM_CLK_DISP_APB_ROOT>;
clock-names = "disp-axi", "csi_mclk", "disp_dcic";
power-domains = <&dispmix_pd>;
status = "disabled";
};

mipi_csi_1: mipi_csi@32e30000 {
compatible = "fsl,imx8mm-mipi-csi";
reg = <0x0 0x32e30000 0x0 0x1000>;
interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
clock-frequency = <333000000>;
clocks = <&clk IMX8MM_CLK_CSI1_CORE_DIV>,
<&clk IMX8MM_CLK_CSI1_PHY_REF_DIV>,
<&clk IMX8MM_CLK_DISP_AXI_ROOT>,
<&clk IMX8MM_CLK_DISP_APB_ROOT>;
clock-names = "mipi_clk", "phy_clk", "disp_axi", "disp_apb";
bus-width = <4>;
csi-gpr = <&dispmix_gpr>;
power-domains = <&mipi_pd>;
status = "disabled";
};

 

From the datasheet I came to know that "CFA (Chroma): RGB Bayer"

When I tried to capture the video using below command I am getting error:

 

root@iWave-G34M:~#

gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! vpuenc_h264 ! avimux ! filesink location=test.mp4

Setting pipeline to PAUSED ...
====== VPUENC: 4.4.5 build on Mar 20 2020 10:11:59. ======
wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Feb 20 2020 11:05:40)
vpulib: 1.1.1
firmware: 1.1.1.65535
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../../../../git/libs/gst/base/gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.001057125
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
root@iWave-G34M:~#

root@iWave-G34M:~#gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw,width=2688,height=1520 ! vpuenc_h264 ! avimux ! filesink location=test.mp4

WARNING: erroneous pipeline: could not link v4l2src0 to vpuenc_h264-0, vpuenc_h264-0 can't handle caps video/x-raw, width=(int)2688, height=(int)1520
root@iWave-G34M:~#

 

 

Please provide the proper "gst-launch" command to capture the video or image for RGB Bayer format?

Is there any application is there to capture the image or video in linux ?

Anything I missed or configured wrong? Can you suggest me?

 

Thanks and Regards,

Devendra

Attachments

Outcomes