HW:
SOFTWARE:
ov5640_single_cam0: rbpcv2_ov5640_a@3c {
compatible = "nvidia,ov5640";
/* I2C device address */
reg = <0x3c>;
/* V4L2 device node location */
devnode = "video0";
/* Physical dimensions of sensor */
physical_w = "3.680";
physical_h = "2.760";
sensor_model = "ov5640";
use_sensor_mode_id = "true";
mode0 { /* ov5640_MODE_1920x1080_30FPS */
mclk_khz = "24000";
num_lanes = "2";
tegra_sinterface = "serial_a";
phy_mode = "DPHY";
discontinuous_clk = "no";
dpcm_enable = "false";
cil_settletime = "0";
active_w = "1920";
active_h = "1080";
pixel_t = "bayer_rggb";
readout_orientation = "90";
line_length = "2200";
inherent_gain = "1";
mclk_multiplier = "9.33";
pix_clk_hz = "84000000";
gain_factor = "16";
framerate_factor = "1000000";
exposure_factor = "1000000";
min_gain_val = "16"; /* 1.00x */
max_gain_val = "170"; /* 10.66x */
step_gain_val = "1";
default_gain = "16"; /* 1.00x */
min_hdr_ratio = "1";
max_hdr_ratio = "1";
min_framerate = "2000000"; /* 2.0 fps */
max_framerate = "30000000"; /* 30.0 fps */
step_framerate = "1";
default_framerate = "30000000"; /* 30.0 fps */
min_exp_time = "13"; /* us */
max_exp_time = "683709"; /* us */
step_exp_time = "1";
default_exp_time = "2495"; /* us */
embedded_metadata_height = "0";
};
num_csi_lanes = <2>;
max_lane_speed = <1500000>;
min_bits_per_pixel = <10>;
vi_peak_byte_per_pixel = <2>;
vi_bw_margin_pct = <25>;
max_pixel_rate = <240000>;
isp_peak_byte_per_pixel = <5>;
isp_bw_margin_pct = <25>;
/* Probe sensor model id registers */
err = ov5640_read_reg(s_data, ov5640_MODEL_ID_ADDR_MSB, ®_val[0]);
if (err) {
dev_err(dev, "%s: error during i2c read probe (%d)\n",
__func__, err);
goto err_reg_probe;
}
err = ov5640_read_reg(s_data, ov5640_MODEL_ID_ADDR_LSB, ®_val[1]);
if (err) {
dev_err(dev, "%s: error during i2c read probe (%d)\n",
__func__, err);
goto err_reg_probe;
}
if (!((reg_val[0] == 0x56) && reg_val[1] == 0x40)) //ov5640
dev_err(dev, "%s: invalid sensor model id: %x%x\n",
__func__, reg_val[0], reg_val[1]);
enum {
ov5640_MODE_1920x1080_30FPS,
ov5640_MODE_1280x720_60FPS,
ov5640_MODE_COMMON,
ov5640_START_STREAM,
ov5640_STOP_STREAM,
};
static ov5640_reg *mode_table[] = {
[ov5640_MODE_1920x1080_30FPS] = ov5640_mode_1920x1080_30fps,
[ov5640_MODE_1280x720_60FPS] = ov5640_mode_1280x720_60fps,
[ov5640_MODE_COMMON] = ov5640_mode_common,
[ov5640_START_STREAM] = ov5640_start_stream,
[ov5640_STOP_STREAM] = ov5640_stop_stream,
};
static const int ov5640_30fps[] = {
30,
};
static const int ov5640_60fps[] = {
60,
};
/*
* WARNING: frmfmt ordering need to match mode definition in
* device tree!
*/
static const struct camera_common_frmfmt ov5640_frmfmt[] = {
{{1920, 1080}, ov5640_30fps, 1, 0, ov5640_MODE_1920x1080_30FPS},
{{1280, 720}, ov5640_60fps, 1, 0, ov5640_MODE_1280x720_60FPS},
};
static struct tegracam_ctrl_ops ov5640_ctrl_ops = {
.numctrls = ARRAY_SIZE(ctrl_cid_list),
.ctrl_cid_list = ctrl_cid_list,
.set_gain = ov5640_set_gain,
.set_exposure = ov5640_set_exposure,
//.set_frame_rate = ov5640_set_frame_rate,
.set_group_hold = ov5640_set_group_hold,
};
vi如果报错timeout,首先示波器看是否有mipi输出,如果没有有则查看驱动配置是否正确,参数等,如下:
[ 99.405759] video4linux video0: frame start syncpt timeout!0
[ 99.613754] video4linux video0: frame start syncpt timeout!0
[ 99.821732] video4linux video0: frame start syncpt timeout!0
[ 100.029746] video4linux video0: frame start syncpt timeout!0
[ 100.237742] video4linux video0: frame start syncpt timeout!0
[ 100.445745] video4linux video0: frame start syncpt timeout!0
[ 100.653729] video4linux video0: frame start syncpt timeout!0
[ 100.861730] video4linux video0: frame start syncpt timeout!0
[ 101.069737] video4linux video0: frame start syncpt timeout!0
[ 101.277768] video4linux video0: frame start syncpt timeout!0
查看内核log
dmesg | grep ov5640
输出:
[ 103.352239] ov5640: loading out-of-tree module taints kernel.
[ 103.359115] ov5640 6-003c: tegracam sensor driver:ov5640_v2.0.6
[ 103.362288] vi 54080000.vi: subdev ov5640 6-003c bound
使用v4l2查看信息
v4l2-ctl -d /dev/video0 --all
输出:
Driver Info (not using libv4l2):
Driver name : tegra-video
Card type : vi-output, ov5640 6-003c
Bus info : platform:54080000.vi:0
Driver version: 4.9.253
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 0: no power)
Format Video Capture:
Width/Height : 1920/1080
Pixel Format : 'RG10'
Field : None
Bytes per Line : 3840
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
使用v4l2-ctl保存raw图测试:
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --stream-mmap --stream-count=1 -d /dev/video0 --stream-to=ov5640.raw
正常在当前目录下面会保存一张格式化好的raw图