When changing to bggr12, a kernel panic occurs

hi

I am porting the camera driver in the following environment.

xavier@xavier-desktop:~/vsi/tpg$ cat /etc/nv_tegra_release 
# R32 (release), REVISION: 6.1, GCID: 27863751, BOARD: t186ref, EABI: aarch64, DATE: Mon Jul 26 19:36:31 UTC 2021

Since the camera settings are bggr and RAW12, I set the device tree accordingly, but when I did insmod, a kernel panic occurred.
kernel_log.txt (75.8 KB)

					mode0 {
						mclk_khz = "24000";
						num_lanes = "4";
						tegra_sinterface = "serial_a";
						phy_mode = "DPHY";
						discontinuous_clk = "no";
						dpcm_enable = "false";
						cil_settletime = "0";
						csi_pixel_bit_depth = "12";
						mode_type = "bayer";
						pixel_phase = "bggr";

						active_w = "3840";
						active_h = "2160";
						readout_orientation = "0";
						line_length = "3840";
						inherent_gain = "1";
						mclk_multiplier = "11";
						pix_clk_hz = "264000000";

						gain_factor = "10";
						min_gain_val = "0"; /* 0dB */
						max_gain_val = "120"; /* 12dB */
						step_gain_val = "3"; /* 0.3 */
						default_gain = "0";
						min_hdr_ratio = "1";
						max_hdr_ratio = "1";
						framerate_factor = "1000000";
						min_framerate = "1500000"; /* 1.5 */
						max_framerate = "30000000"; /* 30 */
						step_framerate = "1";
						default_framerate= "15000000";
						exposure_factor = "1000000";
						min_exp_time = "2433"; /* us */
						max_exp_time = "660000"; /* us */
						step_exp_time = "1";
						default_exp_time = "33334";/* us */

						embedded_metadata_height = "2";
					};

There are three things I checked.

  1. Through the call trace of the kenel log, I checked whether the fmt value in the camera_common_g_fmt function was null, and as a result, it was confirmed that it was null when set to bggr.
int camera_common_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
{
	struct camera_common_data *s_data = to_camera_common_data(sd->dev);
	const struct camera_common_colorfmt *fmt = s_data->colorfmt;

	dev_dbg(sd->dev, "%s++\n", __func__);
	if (fmt == NULL)
		dev_err(sd->dev, "%s: fmt null (%p)", __func__, fmt);
	else
		dev_err(sd->dev, "%s: fmt no null (%p)", __func__, fmt);

	mf->code	= fmt->code;
	mf->colorspace	= fmt->colorspace;
	mf->width	= s_data->fmt_width;
	mf->height	= s_data->fmt_height;
	mf->field	= V4L2_FIELD_NONE;
	mf->xfer_func = fmt->xfer_func;
	mf->ycbcr_enc = fmt->ycbcr_enc;
	mf->quantization = fmt->quantization;

	return 0;
}
  1. Added printk to the extract_pixel_format function in the sensor_common.c file to verify that V4L2_PIX_FMT_SRGGB12 is parsed properly.

  2. Among the camera_common_color_fmts variable values in camera_common.c file, V4L2_PIX_FMT_SBGGR10 is present, but V4L2_PIX_FMT_SBGGR12 is not.

I think I can add V4L2_PIX_FMT_SBGGR12 to the camera_common_color_fmts variable, can you tell me how to add it? If not, is there any other way?

why you print NULL variable here? please remove this debug print.

	if (fmt == NULL)
		dev_err(sd->dev, "%s: fmt null (%p)", __func__, fmt);

Thanks for your reply.

I put it in to check if it’s really a null value, and I’ll delete it as you said.

when I added the code to camera_common.c and executed it, it was confirmed that the color was changed and output.

static const struct camera_common_colorfmt camera_common_color_fmts[] = {
	{
		MEDIA_BUS_FMT_SBGGR12_1X12,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SBGGR12
	},

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