首页 > 技术知识 > 正文

1. 前言

这里需要通过Xilinx FGPA将一路CSI视频通过MIPI接口传输到xavier平台

硬件平台: Jetson AGX Xavier 软件版本: L4T 32.4.4 视频: 1920 x 1080, 30fps, YUV444

2. 硬件检验

使用官方自带的ov5693相机模块,出图正常; 说明硬件接收平台是没问题的

3. 根据官方自带模块移植

(1)按照官方的imx185的驱动进行移植修改 按照这个驱动进行修改,无法生成video0设备,I2C检测也异常

(2)按照官方的ov5693的驱动进行移植修改 可以出现设备

具体修改如下

4. 移植如下

(1)修改 tegra194-camera-e3326-a00.dtsi.

这里只使用了一个模式 1920*1080

/ { host1x { vi@15c10000 { num-channels = <1>; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; e3326_vi_in0: endpoint { port-index = <2>; bus-width = <4>; remote-endpoint = <&e3326_csi_out0>; }; }; }; }; nvcsi@15a00000 { num-channels = <1>; #address-cells = <1>; #size-cells = <0>; status = “okay”; channel@0 { reg = <0>; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; e3326_csi_in0: endpoint@0 { port-index = <2>; bus-width = <4>; remote-endpoint = <&e3326_ov5693_out0>; }; }; port@1 { reg = <1>; e3326_csi_out0: endpoint@1 { remote-endpoint = <&e3326_vi_in0>; }; }; }; }; }; }; i2c@3180000 { ov5693_c@36 { compatible = “nvidia,ov5693”; /* I2C device address */ reg = <0x36>; /* V4L2 device node location */ devnode = “video0”; /* Physical dimensions of sensor */ physical_w = “3.674”; physical_h = “2.738”; /* Define any required hw resources needed by driver */ /* ie. clocks, io pins, power sources */ avdd-reg = “vana”; iovdd-reg = “vif”; /* Sensor output flip settings */ vertical-flip = “true”; mode0 { // OV5693_MODE_2592X1944 mclk_khz = “24000”; num_lanes = “4”; tegra_sinterface = “serial_c”; phy_mode = “DPHY”; discontinuous_clk = “yes”; dpcm_enable = “false”; cil_settletime = “0”; active_w = “1920”; active_h = “1080”; mode_type = “bayer”; pixel_phase = “rggb”; csi_pixel_bit_depth = “8”; readout_orientation = “0”; line_length = “2688”; inherent_gain = “1”; mclk_multiplier = “6.67”; pix_clk_hz = “160000000”; gain_factor = “10”; min_gain_val = “10”;/* 1DB*/ max_gain_val = “160”;/* 16DB*/ step_gain_val = “1”; default_gain = “10”; min_hdr_ratio = “1”; max_hdr_ratio = “1”; framerate_factor = “1000000”; min_framerate = “1816577”;/*1.816577 */ max_framerate = “30000000”;/*30*/ step_framerate = “1”; default_framerate = “30000000”; exposure_factor = “1000000”; min_exp_time = “34”;/* us */ max_exp_time = “550385”;/* us */ step_exp_time = “1”; default_exp_time = “33334”;/* us */ embedded_metadata_height = “0”; }; // mode1 { //OV5693_MODE_2592X1458 // mclk_khz = “24000”; // num_lanes = “2”; // tegra_sinterface = “serial_c”; // phy_mode = “DPHY”; // discontinuous_clk = “yes”; // dpcm_enable = “false”; // cil_settletime = “0”; // // active_w = “2592”; // active_h = “1458”; // mode_type = “bayer”; // pixel_phase = “bggr”; // csi_pixel_bit_depth = “10”; // readout_orientation = “0”; // line_length = “2688”; // inherent_gain = “1”; // mclk_multiplier = “6.67”; // pix_clk_hz = “160000000”; // // gain_factor = “10”; // min_gain_val = “10”;/* 1DB*/ // max_gain_val = “160”;/* 16DB*/ // step_gain_val = “1”; // default_gain = “10”; // min_hdr_ratio = “1”; // max_hdr_ratio = “1”; // framerate_factor = “1000000”; // min_framerate = “1816577”;/*1.816577 */ // max_framerate = “30000000”;/*30*/ // step_framerate = “1”; // default_framerate = “30000000”; // exposure_factor = “1000000”; // min_exp_time = “34”;/* us */ // max_exp_time = “550385”;/* us */ // step_exp_time = “1”; // default_exp_time = “33334”;/* us */ // embedded_metadata_height = “0”; // }; // // mode2 { //OV5693_MODE_1280X720 // mclk_khz = “24000”; // num_lanes = “2”; // tegra_sinterface = “serial_c”; // phy_mode = “DPHY”; // discontinuous_clk = “yes”; // dpcm_enable = “false”; // cil_settletime = “0”; // // active_w = “1280”; // active_h = “720”; // mode_type = “bayer”; // pixel_phase = “bggr”; // csi_pixel_bit_depth = “10”; // readout_orientation = “0”; // line_length = “1752”; // inherent_gain = “1”; // mclk_multiplier = “6.67”; // pix_clk_hz = “160000000”; // // gain_factor = “10”; // min_gain_val = “10”;/* 1DB*/ // max_gain_val = “160”;/* 16DB*/ // step_gain_val = “1”; // default_gain = “10”; // min_hdr_ratio = “1”; // max_hdr_ratio = “1”; // framerate_factor = “1000000”; // min_framerate = “2787078”;/* 2.787078 */ // max_framerate = “120000000”;/* 120*/ // step_framerate = “1”; // default_framerate = “120000000”; // exposure_factor = “1000000”; // min_exp_time = “22”;/* us */ // max_exp_time = “358733”;/* us */ // step_exp_time = “1”; // default_exp_time = “8334”;/* us */ // embedded_metadata_height = “0”; // }; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; e3326_ov5693_out0: endpoint { port-index = <2>; bus-width = <4>; remote-endpoint = <&e3326_csi_in0>; }; }; }; }; }; e3326_lens_ov5693@P5V27C { min_focus_distance = “0.0”; hyper_focal = “0.0”; focal_length = “2.67”; f_number = “2.0”; aperture = “2.0”; }; tegra-camera-platform { compatible = “nvidia, tegra-camera-platform”; num_csi_lanes = <4>; max_lane_speed = <1500000>; min_bits_per_pixel = <8>; vi_peak_byte_per_pixel = <2>; vi_bw_margin_pct = <25>; max_pixel_rate = <160000>; isp_peak_byte_per_pixel = <5>; isp_bw_margin_pct = <25>; modules { module0 { badge = “e3326_front_P5V27C”; position = “rear”; orientation = “1”; drivernode0 { /* Declare PCL support driver (classically known as guid) */ pcl_id = “v4l2_sensor”; /* Driver v4l2 device name */ devname = “ov5693 2-0036”; /* Declare the device-tree hierarchy to driver instance */ proc-device-tree = “/proc/device-tree/i2c@3180000/ov5693_c@36”; }; drivernode1 { /* Declare PCL support driver (classically known as guid) */ pcl_id = “v4l2_lens”; proc-device-tree = “/proc/device-tree/e3326_lens_ov5693@P5V27C/”; }; }; }; }; };
<

(2)修改 tegra194-p2822-0000-camera-e3326-a00.dts

这里修改不多; 主要是使用的RST & PWDN 等GPIO管脚; 以及时钟电源等

#include <t19x-common-modules/tegra194-camera-e3326-a00.dtsi> #include “dt-bindings/clock/tegra194-clock.h” #define CAM0_RST_L TEGRA194_MAIN_GPIO(H, 3) #define CAM0_PWDN TEGRA194_MAIN_GPIO(H, 6) /* camera control gpio definitions */ / { i2c@3180000 { ov5693_c@36 { /* Define any required hw resources needed by driver */ /* ie. clocks, io pins, power sources */ /* mclk-index indicates the index of the */ /* mclk-name with in the clock-names array */ clocks = <&bpmp_clks TEGRA194_CLK_EXTPERIPH1>, <&bpmp_clks TEGRA194_CLK_PLLP_OUT0>; clock-names = “extperiph1”, “pllp_grtba”; mclk = “extperiph1”; clock-frequency = <24000000>; reset-gpios = <&tegra_main_gpio CAM0_RST_L GPIO_ACTIVE_HIGH>; pwdn-gpios = <&tegra_main_gpio CAM0_PWDN GPIO_ACTIVE_HIGH>; vana-supply = <&p2822_avdd_cam_2v8>; vif-supply = <&p2822_vdd_1v8_cvb>; status = “okay”; }; }; gpio@2200000 { camera-control-output-low { gpio-hog; output-low; gpios = <CAM0_RST_L 0 CAM0_PWDN 0>; label = “cam0-rst”, “cam0-pwdn”; }; }; };
<

(3)关闭 plugin manager.

因为xavier平台默认是使用插件模式进行设备管理的; 相机模块也是通过插件管理的; 所以这里单独配置某个相机模块时,需要将插件管理关闭

#include “common/tegra194-p2888-0001-p2822-0000-common.dtsi” //#include “common/tegra194-p2822-camera-modules.dtsi” //#include “t19x-common-modules/tegra194-camera-plugin-manager.dtsi” #include “common/tegra194-p2822-0000-camera-e3326-a00.dtsi”

(4)编辑ov5693.c

这里主要修改图像分辨率和帧率

#ifndef __OV5693_TABLES__ #define __OV5693_TABLES__ #include <media/camera_common.h> #define OV5693_TABLE_WAIT_MS 0 #define OV5693_TABLE_END 1 #define OV5693_MAX_RETRIES 3 #define OV5693_WAIT_MS 10 #define ov5693_reg struct reg_8 static const ov5693_reg ov5693_start[] = { {0x0100, 0x01}, /* mode select streaming on */ {OV5693_TABLE_END, 0x00} }; static const ov5693_reg ov5693_stop[] = { {0x0100, 0x00}, /* mode select streaming on */ {OV5693_TABLE_END, 0x00} }; static const ov5693_reg tp_colorbars[] = { {0x0600, 0x00}, {0x0601, 0x02}, {OV5693_TABLE_WAIT_MS, OV5693_WAIT_MS}, {OV5693_TABLE_END, 0x00} }; static const ov5693_reg mode_2592x1944[] = { {OV5693_TABLE_WAIT_MS, OV5693_WAIT_MS}, {OV5693_TABLE_END, 0x0000} }; enum { OV5693_MODE_2592X1944, OV5693_MODE_START_STREAM, OV5693_MODE_STOP_STREAM, OV5693_MODE_TEST_PATTERN }; static const ov5693_reg *mode_table[] = { [OV5693_MODE_2592X1944] = mode_2592x1944, [OV5693_MODE_START_STREAM] = ov5693_start, [OV5693_MODE_STOP_STREAM] = ov5693_stop, [OV5693_MODE_TEST_PATTERN] = tp_colorbars, }; static const int ov5693_30fps[] = { 30, }; static const struct camera_common_frmfmt ov5693_frmfmt[] = { {{1920, 1080}, ov5693_30fps, 1, 0, OV5693_MODE_2592X1944}, }; #endif /* __OV5693_TABLES__ */
<

(5)内核配置

开启ov5693的驱动配置 kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig. CONFIG_VIDEO_OV5693=y

(6)编译内核

(7)刷写内核 $ sudo ./flash.sh -k kernel-dtb jetson-xavier mmcblk0p1

猜你喜欢