Skip to content

Commit

Permalink
Fix C2(IMX490) on RQX-59G and RQX-58G R35.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
QQting committed Apr 16, 2024
1 parent f663843 commit f7fff10
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 53 deletions.
22 changes: 7 additions & 15 deletions drivers/src/make_overlay_dts_roscube-orin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ def get_min_gain_val(rev_r354_exception):
};
};"""
if IO_BOARD_TYPE == "LEOPARD":
str_i2c_imx490_n_p4.replace("num-lanes = <4>", "num-lanes = <2>")
str_i2c_imx490_n_p4 = str_i2c_imx490_n_p4.replace("num-lanes = <4>", "num-lanes = <2>")

str_i2c_imx490_0_p4 = str_i2c_imx490_n_p4
str_i2c_imx490_1_p4 = str_i2c_imx490_n_p4.replace(
Expand Down Expand Up @@ -2706,7 +2706,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_1_p3
+ str_i2c_isx021_1_p4
)
str_i2c_1_isp = ""
str_fragment_nvcsi1 = str_w_fragment_nvcsi1
str_camera_module1 = str_w_camera_module1
elif camera[i] == "C2":
Expand All @@ -2723,7 +2722,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_1_p3
+ str_i2c_imx490_1_p4
)
str_i2c_1_isp = str_i2c_isp_1
str_fragment_nvcsi1 = str_w_fragment_nvcsi1.replace(
"isx021_out1", "imx490_out1"
)
Expand Down Expand Up @@ -2757,7 +2755,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_2_p3
+ str_i2c_isx021_2_p4
)
str_i2c_2_isp = ""
str_i2c_1_isp = ""
str_fragment_nvcsi2 = str_w_fragment_nvcsi2
str_camera_module2 = str_w_camera_module2
elif camera[i] == "C2":
Expand All @@ -2774,7 +2772,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_2_p3
+ str_i2c_imx490_2_p4
)
str_i2c_2_isp = str_i2c_isp_2
str_i2c_1_isp = str_i2c_isp_1
str_fragment_nvcsi2 = str_w_fragment_nvcsi2.replace(
"isx021_out2", "imx490_out2"
)
Expand Down Expand Up @@ -2808,7 +2806,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_3_p3
+ str_i2c_isx021_3_p4
)
str_i2c_3_isp = ""
str_fragment_nvcsi3 = str_w_fragment_nvcsi3
str_camera_module3 = str_w_camera_module3
elif camera[i] == "C2":
Expand All @@ -2825,7 +2822,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_3_p3
+ str_i2c_imx490_3_p4
)
str_i2c_3_isp = str_i2c_isp_3
str_fragment_nvcsi3 = str_w_fragment_nvcsi3.replace(
"isx021_out3", "imx490_out3"
)
Expand Down Expand Up @@ -2859,7 +2855,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_4_p3
+ str_i2c_isx021_4_p4
)
str_i2c_4_isp = ""
str_i2c_2_isp = ""
str_fragment_nvcsi4 = str_w_fragment_nvcsi4
str_camera_module4 = str_w_camera_module4
elif camera[i] == "C2":
Expand All @@ -2876,7 +2872,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_4_p3
+ str_i2c_imx490_4_p4
)
str_i2c_4_isp = str_i2c_isp_2
str_i2c_2_isp = str_i2c_isp_2
str_fragment_nvcsi4 = str_w_fragment_nvcsi4.replace(
"isx021_out4", "imx490_out4"
)
Expand Down Expand Up @@ -2910,7 +2906,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_5_p3
+ str_i2c_isx021_5_p4
)
str_i2c_5_isp = ""
str_fragment_nvcsi5 = str_w_fragment_nvcsi5
str_camera_module5 = str_w_camera_module5
elif camera[i] == "C2":
Expand All @@ -2927,7 +2922,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_5_p3
+ str_i2c_imx490_5_p4
)
str_i2c_5_isp = str_i2c_isp_2
str_fragment_nvcsi5 = str_w_fragment_nvcsi5.replace(
"isx021_out5", "imx490_out5"
)
Expand Down Expand Up @@ -2961,7 +2955,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_6_p3
+ str_i2c_isx021_6_p4
)
str_i2c_6_isp = ""
str_i2c_3_isp = ""
str_fragment_nvcsi6 = str_w_fragment_nvcsi6
str_camera_module6 = str_w_camera_module6
elif camera[i] == "C2":
Expand All @@ -2978,7 +2972,7 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_6_p3
+ str_i2c_imx490_6_p4
)
str_i2c_6_isp = str_i2c_isp_3
str_i2c_3_isp = str_i2c_isp_3
str_fragment_nvcsi6 = str_w_fragment_nvcsi6.replace(
"isx021_out6", "imx490_out6"
)
Expand Down Expand Up @@ -3012,7 +3006,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_isx021_7_p3
+ str_i2c_isx021_7_p4
)
str_i2c_7_isp = ""
str_fragment_nvcsi7 = str_w_fragment_nvcsi7
str_camera_module7 = str_w_camera_module7
elif camera[i] == "C2":
Expand All @@ -3029,7 +3022,6 @@ def get_serdes_pix_clk(str_revision, str_camera_type):
+ str_i2c_imx490_7_p3
+ str_i2c_imx490_7_p4
)
str_i2c_7_isp = str_i2c_isp_3
str_fragment_nvcsi7 = str_w_fragment_nvcsi7.replace(
"isx021_out7", "imx490_out7"
)
Expand Down
32 changes: 16 additions & 16 deletions drivers/src/make_overlay_dts_roscube.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
target-path = \"/tegra-capture-vi\";
__overlay__ {
status = \"okay\";
num-channels = <0x08>;
num-channels = <8>;
};
};
Expand All @@ -249,8 +249,8 @@
target-path = \"/tegra-capture-vi/ports/port@0/endpoint\";
__overlay__ {
status = \"okay\";
port-index = <0>;
vc-id = <0>;
port-index = <0>;
bus-width = <2>;
};
};
Expand Down Expand Up @@ -841,7 +841,7 @@
target-path = \"/host1x@13e00000/nvcsi@15a00000/channel@0/ports/port@0/endpoint@0\";
__overlay__ {
status = \"okay\";
bus-width = <0x02>;
bus-width = <2>;
remote-endpoint = <&isx021_out0>;
};
};
Expand Down Expand Up @@ -887,8 +887,8 @@
target-path = \"/host1x@13e00000/nvcsi@15a00000/channel@1/ports/port@0/endpoint@0\";
__overlay__ {
status = \"okay\";
port-index = <0x00>;
bus-width = <0x02>;
port-index = <0>;
bus-width = <2>;
remote-endpoint = <&isx021_out1>;
};
};
Expand Down Expand Up @@ -1227,7 +1227,7 @@
target-path = \"/tegra-camera-platform\";
__overlay__ {
status = \"okay\";
num_csi_lanes = <0x02>;
num_csi_lanes = <2>;
max_lane_speed = <4000000>;
};
};
Expand Down Expand Up @@ -1434,7 +1434,7 @@
target-path = "/tegra-camera-platform\";
__overlay__ {
status = \"okay\";
num_csi_lanes = <0x02>;
num_csi_lanes = <2>;
max_lane_speed = <4000000>;
};
};
Expand Down Expand Up @@ -2355,7 +2355,7 @@ def get_min_gain_val(rev_r354_exception):
str_i2c_imx490_n_p1.replace("imx490_a@2b", "imx490_e@2b")
.replace("&max9295_ser_a", "&max9295_ser_c_0")
.replace("isp_a", "isp_e")
.replace("dser_a", "&dserb")
.replace("&dser", "&dserb")
.replace("reg_mux = <0>", "reg_mux = <2>")
)
str_i2c_imx490_5_p1_r325 = (
Expand Down Expand Up @@ -2411,8 +2411,8 @@ def get_min_gain_val(rev_r354_exception):
str_i2c_imx490_4_p1_r351 = (
str_i2c_imx490_n_p1.replace("imx490_a@2b", "imx490_e@2b")
.replace("&max9295_ser_a", "&max9295_ser_c_0")
.replace("isp_a", "isp_r")
.replace("dser_a", "&dser_2")
.replace("isp_a", "isp_e")
.replace("&dser", "&dser_2")
.replace("reg_mux = <0>", "reg_mux = <2>")
)
str_i2c_imx490_5_p1_r351 = (
Expand Down Expand Up @@ -2602,19 +2602,19 @@ def get_min_gain_val(rev_r354_exception):

str_i2c_imx490_0_p4 = str_i2c_imx490_n_p4
str_i2c_imx490_1_p4 = str_i2c_imx490_n_p4.replace(
'serdes-csi-link = "a"', ' serdes-csi-link = "b"'
'serdes-csi-link = "a"', 'serdes-csi-link = "b"'
).replace("vc-id = <0>", "vc-id = <1>")
str_i2c_imx490_2_p4 = str_i2c_imx490_n_p4
str_i2c_imx490_3_p4 = str_i2c_imx490_n_p4.replace(
'serdes-csi-link = "a"', ' serdes-csi-link = "b"'
'serdes-csi-link = "a"', 'serdes-csi-link = "b"'
).replace("vc-id = <0>", "vc-id = <1>")
str_i2c_imx490_4_p4 = str_i2c_imx490_n_p4
str_i2c_imx490_5_p4 = str_i2c_imx490_n_p4.replace(
'serdes-csi-link = "a"', ' serdes-csi-link = "b"'
'serdes-csi-link = "a"', 'serdes-csi-link = "b"'
).replace("vc-id = <0>", "vc-id = <1>")
str_i2c_imx490_6_p4 = str_i2c_imx490_n_p4
str_i2c_imx490_7_p4 = str_i2c_imx490_n_p4.replace(
'serdes-csi-link = "a"', ' serdes-csi-link = "b"'
'serdes-csi-link = "a"', 'serdes-csi-link = "b"'
).replace("vc-id = <0>", "vc-id = <1>")


Expand Down Expand Up @@ -2988,11 +2988,11 @@ def deploy_n_options(str_n_options):

dict_isx021_serdes_pix_clk = {
"325x": 'serdes_pix_clk_hz = "833333333"',
"351": 'serdes_pix_clk_hz = "180000000"',
"351": 'serdes_pix_clk_hz = "187500000"',
}
dict_imx490_serdes_pix_clk = {
"325x": 'serdes_pix_clk_hz = "1200000000"',
"351": 'serdes_pix_clk_hz = "180000000"',
"351": 'serdes_pix_clk_hz = "187500000"',
}


Expand Down
53 changes: 31 additions & 22 deletions drivers/src/tier4-imx490.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ static int camera_channel_count = 0;

// --- module parameter ---

static int trigger_mode;
static int trigger_mode = 0;
static int fsync_mfp = 0;
static int enable_auto_exposure = 0xCAFE;
static int enable_distortion_correction = 1;


Expand All @@ -157,6 +158,7 @@ static int shutter_time_min = IMX490_MIN_EXPOSURE_TIME;
static int shutter_time_max = IMX490_MAX_EXPOSURE_TIME;

module_param(trigger_mode, int, S_IRUGO | S_IWUSR);
module_param(enable_auto_exposure, int, S_IRUGO | S_IWUSR);
module_param(shutter_time_min, int, S_IRUGO | S_IWUSR);
module_param(shutter_time_max, int, S_IRUGO | S_IWUSR);

Expand Down Expand Up @@ -611,30 +613,32 @@ static int tier4_imx490_start_one_streaming(struct tegracam_device *tc_dev)
/* enable serdes streaming */

err = tier4_max9295_setup_streaming(priv->ser_dev);

if (err)
{
goto exit;
}

err = tier4_max9296_setup_streaming(priv->dser_dev, dev);

if (err)
{
dev_err(dev, "[%s] : Setup Streaming failed\n", __func__);
goto exit;
}

if (priv->auto_exposure == true)
if (enable_auto_exposure == 1)
{
err = tier4_imx490_set_auto_exposure(tc_dev);
priv->auto_exposure = true;
dev_info(dev, "[%s] : Parameter[enable_auto_exposure] = 1.\n", __func__);
}


if (err)
if (priv->auto_exposure == true)
{
dev_err(dev, "[%s] : Setting Digital Gain to default value failed\n", __func__);
goto exit;
err = tier4_imx490_set_auto_exposure(tc_dev);
if (err)
{
dev_err(dev, "[%s] : Enabling Auto Exposure failed.\n", __func__);
goto exit;
}
}

dev_info(dev, "[%s] : trigger_mode = %d\n", __func__, trigger_mode);
Expand Down Expand Up @@ -1183,23 +1187,28 @@ static int tier4_imx490_board_setup(struct tier4_imx490 *priv)
priv->distortion_correction = false;
}

err = of_property_read_string(node, "auto-exposure", &str_value);

if (err < 0)
if (enable_auto_exposure == 0xCAFE)
{
dev_err(dev, "[%s] : Inavlid Exposure mode.\n", __func__);
goto error;
}
err = of_property_read_string(node, "auto-exposure", &str_value);

if (!strcmp(str_value, "true"))
{
priv->auto_exposure = true;
}
else
{
priv->auto_exposure = false;
if (err < 0)
{
dev_err(dev, "[%s] : Inavlid Exposure mode.\n", __func__);
goto error;
}

if (!strcmp(str_value, "true"))
{
priv->auto_exposure = true;
}
else
{
priv->auto_exposure = false;
}
}

priv->auto_exposure = enable_auto_exposure != 0 ? true : false;

// For Ser node
ser_node = of_parse_phandle(node, "nvidia,gmsl-ser-device", 0);

Expand Down

0 comments on commit f7fff10

Please sign in to comment.