UYVY sensor support

Hi,guys:
I am using a UYVY sensor.I already modify camera_common.c and

static const struct camera_common_colorfmt camera_common_color_fmts[] = {
	{
		MEDIA_BUS_FMT_SRGGB12_1X12,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_SRGGB12,
	},
	...
	{
		MEDIA_BUS_FMT_UYVY8_2X8,
		V4L2_COLORSPACE_SRGB,
		V4L2_PIX_FMT_UYVY,
	},
	
};

sensor_common.c

static int extract_pixel_format(
	const char *pixel_t, u32 *format)
{
	size_t size = strnlen(pixel_t, OF_MAX_STR_LEN);

	printk(KERN_ERR "%s: pixel_t=%s\n", __func__, pixel_t);
	if (strncmp(pixel_t, "bayer_bggr10", size) == 0)
		*format = V4L2_PIX_FMT_SBGGR10;
	else if (strncmp(pixel_t, "bayer_rggb10", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB10;
	else if (strncmp(pixel_t, "bayer_grbg10", size) == 0)
		*format = V4L2_PIX_FMT_SGRBG10;
	else if (strncmp(pixel_t, "bayer_bggr12", size) == 0)
		*format = V4L2_PIX_FMT_SBGGR12;
	else if (strncmp(pixel_t, "bayer_rggb12", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB12;
	else if (strncmp(pixel_t, "bayer_wdr_pwl_rggb12", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB12;
	else if (strncmp(pixel_t, "bayer_wdr_dol_rggb10", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB10;
	else if (strncmp(pixel_t, "bayer_xbggr10p", size) == 0)
		*format = V4L2_PIX_FMT_XBGGR10P;
	else if (strncmp(pixel_t, "bayer_xrggb10p", size) == 0)
		*format = V4L2_PIX_FMT_XRGGB10P;
	else if (strncmp(pixel_t, "yuv_yuyv16", size) == 0)
		*format = V4L2_PIX_FMT_UYVY;
	else {
		pr_err("%s: Need to extend format%s\n", __func__, pixel_t);
		return -EINVAL;
	}

	return 0;
}

And i can capture frame from video0. But the frame is Blurred screen,looks like Y exchange with UV.
Sorry i can not find the way to upload the frame.

BTW,i already can capture awesome picture for YUYV format sensor,but UYVY not.

Somebody can help me?

hello xuhui1.wang,

it seems to me you had wrong configuration in sensor_common.c

else if (strncmp(pixel_t, "yuv_yuyv16", size) == 0)
		*format = V4L2_PIX_FMT_UYVY;

please checking with below suggestions,

  1. since low-level drivers configure format types depends-on sensor device tree definition, please check your sensor device tree settings.
  2. please refer to below standard video format types, you should also report correct fourcc.
    $l4t-r32.1/kerenl_src/kernel/kernel-4.9/include/uapi/linux/videodev2.h

Hi,JerryChang
Thanks for your replay.
My sensor should be UYVY. And is your mean i should modify device tree form “yuv_yuyv16” to “yuv_uvuy16” ? But pixel_t looks like just only one function to figure out format.

hello xuhui1.wang,

please upload abnormal images for checking.
you could attach the files by modify your comments, please check the “pin” icon on the top-right side to upload the files.
thanks

Hi、JerryChang
here is the file.
9.tar.gz (2.13 MB)

Hi xuhui1.wang,
Which camera are you using? Is it a GMSL system?

-Adrian

Hi,JerryChang,
Thanks for your help. I sloved the problem.I got the crossbar wrong.

Adrian ,yes i am using the GMSL system

Hi xuhui1.wang,

Yes, I was going to suggest you to set the serializer crossbar in order to align Y and UV. Good to hear you solved the issue.

-Adrian

Thanks for your help, Adrian.