TX1 camera driver format issue

I have modified following code and resolved incompitable issue of V4L2_MBUS_FMT_UYVY8_1X16。However, when I config V4L2_MBUS_FMT_YUYV10_2X10, the kernal is corrupt.
The code is as follows:
1、I have commented:

if (mf->code != V4L2_MBUS_FMT_SRGGB8_1X8 &&
                     mf->code != V4L2_MBUS_FMT_SRGGB10_1X10) {
                     mf->code = V4L2_MBUS_FMT_SRGGB10_1X10;
                     err = -EINVAL;
                 }
 2、I have added on:
static const struct camera_common_colorfmt camera_common_color_fmts[] = {
	{
		V4L2_MBUS_FMT_SRGGB12_1X12,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SRGGB12,
	},
	{
		V4L2_MBUS_FMT_SRGGB10_1X10,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SRGGB10,
	},
	{
		V4L2_MBUS_FMT_SRGGB8_1X8,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SRGGB8,
	},
	{	V4L2_MBUS_FMT_UYVY8_1X16,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_UYVY,
	},
	{	V4L2_MBUS_FMT_UYVY8_2X8,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_UYVY,
	},
	{	V4L2_MBUS_FMT_YUYV10_2X10,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_UYVY,
	},
};

3、Here are the error:
[ 6.866477] —> camera_common_g_fmt, 529, mf = ffffffc0ffe9ba60, fmt = ffffffc000be72bc
[ 6.877072] <— camera_common_g_fmt, 536, mf = ffffffc0ffe9ba60
[ 6.884389] Unable to handle kernel NULL pointer dereference at virtual address 00000018
[ 6.895220] pgd = ffffffc00007d000
[ 6.899985] [00000018] *pgd=000000017fc05003, *pmd=000000017fc06003, *pte=00e0000050041407
[ 6.911261] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[ 6.918420] Enter nvdumper_crash_setup_regs
[ 6.924223] nvdumper: all registers are saved.
[ 6.924226] nvdumper: all registers are saved.
[ 6.924227] nvdumper: all registers are saved.
[ 6.942333] nvdumper: all registers are saved.
[ 6.948229] Modules linked in:
[ 6.952726] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.96 #67
[ 6.960294] task: ffffffc0ffe94b80 ti: ffffffc0ffe98000 task.ti: ffffffc0ffe98000
[ 6.970748] PC is at tegra_channel_fmts_bitmap_init+0xf0/0x18c
[ 6.978081] LR is at tegra_chann
[ 6.985340] pc : [] lr : [] pstate: 60000105
[ 6.995584] sp : ffffffc0ffe9b9f0
[ 7.000304] x29: ffffffc0ffe9b9f0 x28: 0000000000000000
[ 7.007065] x27: ffffffc0fcb62660 x26: ffffffc01ff34070
[ 7.013783] x25: ffffffc00105a180 x24: ffffffc00105a040
[ 7.020442] x23: ffffffc0f7c928a8 x22: 0000000000000001
[ 7.027066] x21: ffffffc0f7c92018 x20: 0000000000003012
[ 7.033629] x19: ffffffc0fcb62660 x18: 0000000000000007
[ 7.040136] x17: 000000000000000e x16: 0720072007200720
[ 7.046644] x15: 0720072007200720 x14: 0000000000000001
[ 7.053113] x13: 0000000000000020 x12: ffffffc0fc9c4ea0
[ 7.059533] x11: 0000000000000001 x10: 00000000ffffffff
[ 7.065917] x9 : 0000000000000001 x8 : ffffff800096c620
[ 7.072279] x7 : ffffffc000b94428 x6 : 0000000000000000
[ 7.078637] x5 : 0000000000aaaaaa x4 : 0000000000000000
[ 7.085017] x3 : 0000000000002009 x2 : 0000000000000018
[ 7.091414] x1 : ffffffc000be7c30 x0 : 0000000000000000
[ 7.097833]
[ 7.097833] PC: 0xffffffc00070d500:
[ 7.104869] d500 97fffc08 37f800e0 2a1603e2 2a0003e1 aa1703e0 97f0a188 35000054 b9404bb4
[ 7.115244] d520 b94047a0 11000400 b90047a0 17ffffe9 528601e0 97fffbfb 37f800a0 52800022
[ 7.125711] d540 2a0003e1 912242a0 97f0a17b b40005f3 f9405660 f9400c00 b4000580 f9406c02
[ 7.136265] d560 b4000542 9101c3a1 aa1303e0 d63f0040 350004c0 b9407ba0 97fffbfe f9029aa0
[ 7.146956] d580 b9401801 b90502a1 b94083a1 b90512a1 b9407fa1 b90506a1 b94073a1 b904faa1
[ 7.157848] d5a0 b94077a2 b904fea2 794117a2 b9052aa2 b9400c00 1b017c00 b9050aa0 911422a3
[ 7.168956] d5c0 9113f2a2 9113e2a1 aa1503e0 97ffff66 b9450aa0 b944fea1 1b017c00 b9050ea0
[ 7.180287] d5e0 b9485ea0 7100041f 54000109 aa1503e0 97fffc63 14000005 35000094 17ffffcd

Could anyone kindly advise if I should modify anywhere else to make TX1 support V4L2_MBUS_FMT_YUYV10_2X10? Or TX1 will not capble of supporting this YUYV 10 bit format?

Hi
TX1 VI not support YUYV 10 bit.

Is the hardware not support YUYV 10bit?

Hi CalmCar
It should be the HW not support it, but I am not really sure of it. I will update here once get confirm.

Hi
VI HW will drop UV and the 9, 10 bit of Y for the YUV420 10 bit. That means you can only get the Y component like below table.

Another question:is NV ISP support GRBG format?It seems that support GRBG only.
When I modify $SOURCEDIR/drivers/media/platform/tegra/camera/camera_common.c a format struct as below

static const struct camera_common_colorfmt camera_common_color_fmts[] = {
	{
		V4L2_MBUS_FMT_SGRBG12_1X12,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SGRBG12,
	},

};

Then the argus_camera can’t work.
Thanks!

i could not debug the code in the kernel.cause it is really cost me a quite long time to setup the envirment.
but i call the ioctl function to communicate with the kernel and get the formate information.the pixformate is :
#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc(‘R’, ‘G’, ‘G’, ‘B’) /* 8 RGRG… GBGB… */
i wish i could change the date formate by i2c controller .how could find the API like this to change the pixel formate dynamically in userspace?

ps if the gst-lunch in gstreamer use v4l layer.why cannot the OPENCV use the v4l independently

This’s vi driver not relative to ISP. And the software not implement all of them yet. Below are the VI output format support.

Do you mean that nvcamerasrc(or any other) is not complete yet? Can I modify the code?What should I do to support GRBG ?
Thanks!

VI driver not implement but nvcamerasrc didn’t go to the VI driver. If you would like to support others format you can just try to modify the pixel_t = “bayer_xxxx” to try.

I can not find where the source code, where to modify this statement?
Thanks!

It’s in the device tree.

mode0 { // OV5693_MODE_2592X1944
				mclk_khz = "24000";
				num_lanes = "2";
				tegra_sinterface = "serial_c";
				discontinuous_clk = "no";
				dpcm_enable = "false";
				cil_settletime = "0";

				active_w = "2592";
				active_h = "1944";
				pixel_t = "bayer_bggr";
				readout_orientation = "90";
				line_length = "2688";
				inherent_gain = "1";
				mclk_multiplier = "6.67";
				pix_clk_hz = "160000000";

				min_gain_val = "1.0";
				max_gain_val = "16";
				min_hdr_ratio = "1";
				max_hdr_ratio = "64";
				min_framerate = "1.816577";
				max_framerate = "30";
				min_exp_time = "34";
				max_exp_time = "550385";
			};

I change it to bayer_grbg,it works!
Thanks!