Regarding the white balance issue with the IMX219 camera

Hello, I tried to use the Orin NX to connect two IMX219 cameras. Since I used a custom carrier board, I rewrote the device tree file. Currently, the camera can capture images, but there are some color issues—the edges of the images have a noticeable red tint. I checked some similar issues on the forum, and it seems it may be related to the badge property under the tcp node. I have attached my device tree file. Do you know why this issue might be occurring?



/dts-v1/;
/plugin/;

/ {
	overlay-name = "Camera IMX219-02 starsea";  
	jetson-header-name = "Jetson 24pin CSI Connector";  
	compatible = "nvidia,p3768-0000+p3767-0000", "nvidia,p3768-0000+p3767-0001", "nvidia,p3768-0000+p3767-0003", "nvidia,p3768-0000+p3767-0004", "nvidia,p3768-0000+p3767-0005";


	
	fragment@0 {
		target = <&cam_i2c>; 
		__overlay__ {
			#address-cells = <0x01>;  
			#size-cells = <0x00>;  
			status = "okay";
			tca9548_77:tca9548@77{
				compatible = "nxp,pca9548";  
				reg = <0x77>;  
				#address-cells = <1>;
				#size-cells = <0>;
				i2c-mux-idle-disconnect;  
				skip_mux_detect;  
				force_bus_start = <0x1e>;  
				status = "okay";
				i2c_cam0:i2c@0 {
					reg = <0>;
					i2c-mux,deselect-on-exit;  
					#address-cells = <1>;
					#size-cells = <0>;
					status = "okay";
					NX4_imx219_cam0: imx219_a@10 {
						compatible = "sony,imx219";
						/* I2C device address */
						reg = <0x10>;

						/* V4L2 device node location */
						devnode = "video0";

						/* Physical dimensions of sensor */
						physical_w = "3.680";
						physical_h = "2.760";

						sensor_model = "imx219";

						use_sensor_mode_id = "true";

						reset-gpios = <&tca9534_38 0 0>;

						status = "okay";
						
						mode0 { /* IMX219_MODE_3280x2464_21FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_a";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "3280";
							active_h = "2464";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "21000000"; /* 21.0 fps */
							step_framerate = "1";
							default_framerate = "21000000"; /* 21.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						mode1 { /* IMX219_MODE_3280x1848_28FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_a";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "3280";
							active_h = "1848";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "28000000"; /* 28.0 fps */
							step_framerate = "1";
							default_framerate = "28000000"; /* 28.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						mode2 { /* IMX219_MODE_1920x1080_30FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_a";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "1920";
							active_h = "1080";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "2";
						};

						mode3 { /* IMX219_MODE_1640x1232_30FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_a";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "1640";
							active_h = "1232";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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"; /* 60.0 fps */
							step_framerate = "1";
							default_framerate = "30000000"; /* 60.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};

						mode4 { /* IMX219_MODE_1280x720_60FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_a";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "1280";
							active_h = "720";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "60000000"; /* 60.0 fps */
							step_framerate = "1";
							default_framerate = "60000000"; /* 60.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						
						
						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							port@0 {
								reg = <0>;
								NX4_imx219_out0: endpoint {
									port-index = <0>;
									bus-width = <2>;
									remote-endpoint = <&rbpcv3_imx477_csi_in0>;  
								};
							};
						};
					};
				};

				i2c_cam1:i2c@1 {
					reg = <1>;    
					i2c-mux,deselect-on-exit;
					#address-cells = <1>;
					#size-cells = <0>;
					status = "okay";
					NX4_imx219_cam1: imx219_b@10 {
						compatible = "sony,imx219";
						/* I2C device address */
						reg = <0x10>;

						/* V4L2 device node location */
						devnode = "video1";

						/* Physical dimensions of sensor */
						physical_w = "3.680";
						physical_h = "2.760";

						sensor_model = "imx219";

						use_sensor_mode_id = "true";

						reset-gpios = <&tca9534_38 1 0>;

						status = "okay";
						
						mode0 { /* IMX219_MODE_3280x2464_21FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_b";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "3280";
							active_h = "2464";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "21000000"; /* 21.0 fps */
							step_framerate = "1";
							default_framerate = "21000000"; /* 21.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						mode1 { /* IMX219_MODE_3280x1848_28FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_b";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "3280";
							active_h = "1848";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "28000000"; /* 28.0 fps */
							step_framerate = "1";
							default_framerate = "28000000"; /* 28.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						mode2 { /* IMX219_MODE_1920x1080_30FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_b";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";

							active_w = "1920";
							active_h = "1080";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "2";
						};

						mode3 { /* IMX219_MODE_1640x1232_30FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_b";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";							

							active_w = "1640";
							active_h = "1232";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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"; /* 60.0 fps */
							step_framerate = "1";
							default_framerate = "30000000"; /* 60.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};

						mode4 { /* IMX219_MODE_1280x720_60FPS */
							mclk_khz = "24000";
							num_lanes = "2";
							tegra_sinterface = "serial_b";
							phy_mode = "DPHY";
							discontinuous_clk = "yes";
							dpcm_enable = "false";
							cil_settletime = "0";
							lane_polarity = "6";							

							active_w = "1280";
							active_h = "720";
							mode_type = "bayer";
							pixel_phase = "rggb";
							csi_pixel_bit_depth = "10";
							readout_orientation = "90";
							line_length = "3448";
							inherent_gain = "1";
							mclk_multiplier = "9.33";
							pix_clk_hz = "182400000";

							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 = "60000000"; /* 60.0 fps */
							step_framerate = "1";
							default_framerate = "60000000"; /* 60.0 fps */
							min_exp_time = "13"; /* us */
							max_exp_time = "683709"; /* us */
							step_exp_time = "1";
							default_exp_time = "2495"; /* us */

							embedded_metadata_height = "2";
						};
						

						ports {
							#address-cells = <1>;
							#size-cells = <0>;

							port@0 {
								reg = <0>;
								NX4_imx219_out1: endpoint {
									port-index = <1>;
									bus-width = <2>;
									remote-endpoint = <&rbpcv2_imx219_csi_in1>;
								};
							};
						};
					};
				};

				
				i2c_gpio:i2c@6 {
					reg = <0x06>;
					i2c-mux,deselect-on-exit;
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					status = "okay";
					tca9534_38:tca9534@38 {
						compatible = "nxp,pca9534";
						reg = <0x38>;
						gpio-controller;  
						#gpio-cells = <0x02>;  
						status = "okay";
						tca9534_38_out {
							status = "okay";
							gpio-hog;  
							output-low;
							gpios = <0x00 0x00 0x01 0x00 0x02 0x00 0x03 0x00 0x04 0x00>;
							label = "cam0-pwdn","cam1-pwdn","cam2-pwdn","cam3-pwdn","test-pwdn";
						};
					};
				};

				
				i2c_eeprom:i2c@7 {
					reg = <0x07>;
					i2c-mux,deselect-on-exit;
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					status = "okay";

					eeprom_57:eeprom@57 {
						compatible = "atmel,at24c16";
						reg = <0x57>;
						status = "okay";
					};
				};
			};
		};
	};

	/* nvcsi@15a00000 setting */
	
	fragment@1 {
		target = <&rbpcv3_imx477_vi_in0>;
		__overlay__ {
			status = "okay";
			port-index = <0>;
			bus-width = <2>;
			remote-endpoint = <&rbpcv3_imx477_csi_out0>;
		};
	};

	
	fragment@2 {
		target = <&rbpcv3_imx477_csi_in0>;
		__overlay__ {
			status = "okay";
			port-index = <0>;
			bus-width = <2>;
			remote-endpoint = <&NX4_imx219_out0>;
		};
	};

	
	fragment@3 {
		target = <&rbpcv3_imx477_csi_out0>;
		__overlay__ {
			status = "okay";
			remote-endpoint = <&rbpcv3_imx477_vi_in0>;
		};
	};

	
	fragment@4 {
		target = <&rbpcv2_imx219_vi_in1>;
		__overlay__ {
			status = "okay";
			port-index = <1>;
			bus-width = <2>;
			remote-endpoint = <&rbpcv2_imx219_csi_out1>;
		};
	};

	
	fragment@5 {
		target = <&rbpcv2_imx219_csi_in1>;
		__overlay__ {
			status = "okay";
			port-index = <1>;
			bus-width = <2>;
			remote-endpoint = <&NX4_imx219_out1>;
		};
	};

	
	fragment@6 {
		target = <&rbpcv2_imx219_csi_out1>;
		__overlay__ {
			status = "okay";
			remote-endpoint = <&rbpcv2_imx219_vi_in1>;
		};
	};

	/* tegra-camera-platform setting */
	
	fragment@7 {
		target = <&cam_module0>;
		__overlay__ {
			badge = "imx219_front_RBP194";  
			position = "front";
			orientation = "1";
			status = "okay";
		};
	};

	fragment@8 {
		target = <&cam_module0_drivernode0>;
		__overlay__ {
			status = "okay";
			pcl_id = "v4l2_sensor";
			devname = "imx219 30-0010";  
			proc-device-tree = "/proc/device-tree/i2c@3180000/tca9548@77/i2c@0/imx219_a@10";  
		};
	};

	fragment@10 {
		target = <&cam_module1>;
		__overlay__ {
			badge = "imx219_rear_RBP194";
			position = "rear";
			orientation = "1";
			status = "okay";
		};
	};

	fragment@11 {
		target = <&cam_module1_drivernode0>;
		__overlay__ {
			status = "okay";
			pcl_id = "v4l2_sensor";
			devname = "imx219 31-0010";
			proc-device-tree = "/proc/device-tree/i2c@3180000/tca9548@77/i2c@1/imx219_b@10";
		};
	};

	fragment@13 {
		target = <&vi_port0>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@14 {
		target = <&vi_port1>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@20 {
		target = <&i2c_0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@21 {
		target = <&i2c_1>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@22 {
		target = <&imx219_cam0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@23 {
		target = <&imx219_cam1>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@24 {
		target = <&imx477_cam0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@25 {
		target = <&imx477_cam1>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@26 {
		target = <&rbpcv2_imx219_out0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@27 {
		target = <&rbpcv2_imx219_out1>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@28 {
		target = <&rbpcv3_imx477_out0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@29 {
		target = <&rbpcv3_imx477_out1>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@30 {
		target-path = "/";
		__overlay__ {
			aliases{
				i2c30 = "/i2c@3180000/tca9548@77/i2c@0";
				i2c31 = "/i2c@3180000/tca9548@77/i2c@1";
				i2c32 = "/i2c@3180000/tca9548@77/i2c@2";
			};
		};
	};
	
	fragment@31 {
		target-path = "/";
		__overlay__ {
			cam_i2cmux{
				status = "disabled";
			};
		};
	};

};



The badge is the information to load correct ISP configuration.

I have a general understanding of the function of the badge property, so I referred to the naming of the badge property in the tegra234-camera-rbpcv2-imx219.dtsi file. This is the naming I adopted for the badge property. Do you think there is anything inappropriate with it? Or, do you think there might be other potential issues causing the color problem in the camera images?

	/* tegra-camera-platform setting */
	
	fragment@7 {
		target = <&cam_module0>;
		__overlay__ {
			badge = "imx219_front_RBP194";  
			position = "front";
			orientation = "1";
			status = "okay";
		};
	};

	fragment@8 {
		target = <&cam_module0_drivernode0>;
		__overlay__ {
			status = "okay";
			pcl_id = "v4l2_sensor";
			devname = "imx219 30-0010";  
			proc-device-tree = "/proc/device-tree/i2c@3180000/tca9548@77/i2c@0/imx219_a@10";  
		};
	};

	fragment@10 {
		target = <&cam_module1>;
		__overlay__ {
			badge = "imx219_rear_RBP194";
			position = "rear";
			orientation = "1";
			status = "okay";
		};
	};

	fragment@11 {
		target = <&cam_module1_drivernode0>;
		__overlay__ {
			status = "okay";
			pcl_id = "v4l2_sensor";
			devname = "imx219 31-0010";
			proc-device-tree = "/proc/device-tree/i2c@3180000/tca9548@77/i2c@1/imx219_b@10";
		};
	};

If the camera module is different with the PI V2 IMX219 that couldn’t use the the same reference sensor’s badge info.
You can modify RBP194 to any others random strings to try.

Thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.