no error for MEDIA_BUS_FMT_UYVY8_1X16, but error “S_FMT cannot handle an invalid pixelformat.” for MEDIA_BUS_FMT_UYVY8_2X8!
when run command “v4l2-compliance -d /dev/video0”
MEDIA_BUS_FMT_UYVY8_2X8 is not supported currently?
no error for MEDIA_BUS_FMT_UYVY8_1X16, but error “S_FMT cannot handle an invalid pixelformat.” for MEDIA_BUS_FMT_UYVY8_2X8!
when run command “v4l2-compliance -d /dev/video0”
MEDIA_BUS_FMT_UYVY8_2X8 is not supported currently?
Hi,
Please share information about the source. Is it YUV sensor connecting to hardware VI engine?
In the Camera_common.c
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_SGRBG12_1X12,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_SGRBG12,
},
{
MEDIA_BUS_FMT_SRGGB10_1X10,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_SRGGB10,
},
{
MEDIA_BUS_FMT_SGRBG10_1X10,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_SGRBG10,
},
{
MEDIA_BUS_FMT_SBGGR10_1X10,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_SBGGR10,
},
{
MEDIA_BUS_FMT_SRGGB8_1X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_SRGGB8,
},
{
MEDIA_BUS_FMT_YUYV8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_YUYV,
},
{
MEDIA_BUS_FMT_YVYU8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_YVYU,
},
{
MEDIA_BUS_FMT_UYVY8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_UYVY,
},
{
MEDIA_BUS_FMT_VYUY8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_VYUY,
},
{
MEDIA_BUS_FMT_YUYV8_2X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_YUYV,
},
{
MEDIA_BUS_FMT_YVYU8_2X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_YVYU,
},
{
MEDIA_BUS_FMT_UYVY8_2X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_UYVY,
},
{
MEDIA_BUS_FMT_VYUY8_2X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_VYUY,
},
/*
* The below two formats are not supported by VI4,
* keep them at the last to ensure they get discarded
*/
{
MEDIA_BUS_FMT_XRGGB10P_3X10,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_XRGGB10P,
},
{
MEDIA_BUS_FMT_XBGGR10P_3X10,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_XRGGB10P,
},
};
the V4L2_PIX_FMT_UYVY is duplicated, and use below config is OK:
{
MEDIA_BUS_FMT_UYVY8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_UYVY,
},
there are errors when use below config:
{
MEDIA_BUS_FMT_UYVY8_2X8,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_UYVY,
},
Here is the error log:
hitron@nvidia-xavier:~/hitron/firmware$ v4l2-compliance -d /dev/video0
v4l2-compliance SHA : not available
Driver Info:
Driver name : tegra-video
Card type : vi-output, nvp6324_mipi 2-0031
Bus info : platform:15c10000.vi:2
Driver version: 4.9.140
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Test input 0:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 1 Private Controls: 15
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
warn: v4l2-test-formats.cpp(997): S_FMT cannot handle an invalid pixelformat.
warn: v4l2-test-formats.cpp(998): This may or may not be a problem. For more information see:
warn: v4l2-test-formats.cpp(999): http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
fail: v4l2-test-formats.cpp(1013): S_FMT cannot handle an invalid format
test VIDIOC_S_FMT: FAIL
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
fail: v4l2-test-formats.cpp(1550): doioctl(node, VIDIOC_S_FMT, &fmt)
fail: v4l2-test-formats.cpp(1647): doioctl(node, VIDIOC_S_FMT, &fmt)
test Scaling: FAIL
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
Test input 0:
Total: 43, Succeeded: 41, Failed: 2, Warnings: 3
What’s the result from v4l2-ctl --list-formats-ext?
Here is it:
hitron@nvidia-xavier:~/hitron/firmware$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'UYVY'
Name : UYVY 4:2:2
hello wangxiaopeng,
here’s sensor get format failure, please review below kernel sources to check which paragraph return failures.
thanks
<i>$l4t-r32.3.1/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c</i>
static int tegra_channel_get_format(struct file *file, void *fh, struct v4l2_format *format){...}
static int __tegra_channel_try_format(struct tegra_channel *chan, struct v4l2_pix_format *pix){...}
What’s your setting for the below parameter in device tree?
mode_type = "bayer";
pixel_phase = "bggr";
csi_pixel_bit_depth = "10";
mode_type = "yuv";
pixel_phase = "uyvy";
csi_pixel_bit_depth = "8";
Looks like you need to modify below function to add yuv_uyvy8 for it.
static int extract_pixel_format(
const char *pixel_t, u32 *format)
{
size_t size = strnlen(pixel_t, OF_MAX_STR_LEN);
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_YUYV;
else if (strncmp(pixel_t, "yuv_yvyu16", size) == 0)
*format = V4L2_PIX_FMT_YVYU;
else if (strncmp(pixel_t, "yuv_uyvy16", size) == 0)
*format = V4L2_PIX_FMT_UYVY;
else if (strncmp(pixel_t, "yuv_vyuy16", size) == 0)
*format = V4L2_PIX_FMT_VYUY;
else {
pr_err("%s: Need to extend format%s\n", __func__, pixel_t);
return -EINVAL;
}
return 0;
}
thanks, but I have already changed it, otherwise driver can’t be installed at all:
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_yuyv8", size) == 0)
*format = V4L2_PIX_FMT_YUYV;
else if (strncmp(pixel_t, "yuv_yvyu8", size) == 0)
*format = V4L2_PIX_FMT_YVYU;
else if (strncmp(pixel_t, "yuv_uyvy8", size) == 0)
*format = V4L2_PIX_FMT_UYVY;
else if (strncmp(pixel_t, "yuv_vyuy8", size) == 0)
*format = V4L2_PIX_FMT_VYUY;
thanks, tegra_channel_get_format returns 0 only! &
__tegra_channel_try_format is not called when implement v4l2-compliance -d /dev/video0
static int
__tegra_channel_try_format(struct tegra_channel *chan,
struct v4l2_pix_format *pix)
{
const struct tegra_video_format *vfmt;
struct v4l2_subdev_format fmt;
struct v4l2_subdev *sd = chan->subdev_on_csi;
int ret = 0;
/* Use the channel format if pixformat is not supported */
vfmt = tegra_core_get_format_by_fourcc(chan, pix->pixelformat);
if (!vfmt) {
pix->pixelformat = chan->format.pixelformat;
vfmt = tegra_core_get_format_by_fourcc(chan, pix->pixelformat);
}
fmt.which = V4L2_SUBDEV_FORMAT_TRY;
fmt.pad = 0;
v4l2_fill_mbus_format(&fmt.format, pix, vfmt->code);
ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &fmt);
if (ret == -ENOIOCTLCMD)
return -ENOTTY;
v4l2_fill_pix_format(pix, &fmt.format);
tegra_channel_set_bytesperline(chan, vfmt, pix);
tegra_channel_fmt_align(chan, vfmt,
&pix->width, &pix->height, &pix->bytesperline);
pix->sizeimage = get_aligned_buffer_size(chan,
pix->bytesperline, pix->height);
if (chan->fmtinfo->fourcc == V4L2_PIX_FMT_NV16)
pix->sizeimage *= 2;
<b>printk("__tegra_channel_try_format ret %d\n", ret);</b>
return ret;
}
Please have add print log to the __tegra_channel_set_format() to check if any failed at this function.
[ 111.565755] tegra_channel_try_format start
[ 111.565775] __tegra_channel_try_format ret 0
[ 111.565779] tegra_channel_try_format end 0
[ 111.565790] tegra_channel_try_format start
[ 111.565797] __tegra_channel_try_format ret 0
[ 111.565802] tegra_channel_try_format end 0
[ 111.565833] tegra_channel_set_format try_format start
[ 111.565840] __tegra_channel_try_format ret 0
[ 111.565845] tegra_channel_set_format set_format start
[ 111.565856] __tegra_channel_set_format ret -22
[ 111.565907] tegra_channel_set_format try_format start
[ 111.565914] __tegra_channel_try_format ret 0
[ 111.565918] tegra_channel_set_format set_format start
[ 111.565925] __tegra_channel_set_format ret -22
[ 111.566069] tegra_channel_set_format try_format start
[ 111.566080] __tegra_channel_try_format ret 0
[ 111.566084] tegra_channel_set_format set_format start
[ 111.566092] __tegra_channel_set_format ret -22
[ 111.566174] tegra_channel_set_format try_format start
[ 111.566182] __tegra_channel_try_format ret 0
[ 111.566187] tegra_channel_set_format set_format start
[ 111.566252] __tegra_channel_set_format ret -22
[ 111.573806] tegra_channel_set_format try_format start
[ 111.573833] __tegra_channel_try_format ret 0
[ 111.573836] tegra_channel_set_format set_format start
[ 111.573845] __tegra_channel_set_format ret -22
[ 111.573922] tegra_channel_set_format try_format start
[ 111.573930] __tegra_channel_try_format ret 0
[ 111.573933] tegra_channel_set_format set_format start
[ 111.573938] __tegra_channel_set_format ret -22
static int
__tegra_channel_set_format(struct tegra_channel *chan,
struct v4l2_pix_format *pix)
{
const struct tegra_video_format *vfmt;
struct v4l2_subdev_format fmt;
struct v4l2_subdev *sd = chan->subdev_on_csi;
int ret = 0;
vfmt = tegra_core_get_format_by_fourcc(chan, pix->pixelformat);
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
fmt.pad = 0;
v4l2_fill_mbus_format(&fmt.format, pix, vfmt->code);
ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &fmt);
if (ret == -ENOIOCTLCMD)
{
printk("__tegra_channel_set_format ret -ENOIOCTLCMD\n");
return -ENOTTY;
}
v4l2_fill_pix_format(pix, &fmt.format);
if (!ret) {
chan->format = *pix;
chan->fmtinfo = vfmt;
tegra_channel_update_format(chan, pix->width,
pix->height, vfmt->fourcc, &vfmt->bpp,
pix->bytesperline);
*pix = chan->format;
if (chan->total_ports > 1)
update_gang_mode(chan);
}
<b>printk("__tegra_channel_set_format ret %d\n", ret);</b>
return ret;
}
Have a trace to the set_fmt like below and check if any set_fmt implement in the sensor driver.
./csi/csi.c: .set_fmt = tegra_csi_set_format,
./tegracam_v4l2.c:static int v4l2sd_set_fmt(struct v4l2_subdev *sd,
<b>/* MIPI CSI could have changed the format, double-check */</b>
if (!camera_common_find_datafmt(mf->code))
{
<b>printk("camera_common_s_fmt1, EINVAL");</b>
return -EINVAL;
}
/* Find a data format by a pixel code in an array */
const struct camera_common_colorfmt *camera_common_find_datafmt(
unsigned int code)
{
int i;
for (i = 0; i < ARRAY_SIZE(camera_common_color_fmts); i++)
if (camera_common_color_fmts[i].code == code)
return camera_common_color_fmts + i;
return NULL;
}
CSI changed the format, but why?
Could you print the mf->code
camera_common_s_fmt(8207) size 1280 x 720
printk("%s(%u) size %i x %i\n", __func__,
mf->code, mf->width, mf->height);
Hello ShaneCCC,
Is there anyother suggestion?or try to tell me how it works of mipi & vi fmt?
Is there some document for reference?
Have trace why the mf->code is 8207(0x200F) the MEDIA_BUS_FMT_UYVY8_2X8 should be 0x2006, trace it from the user space or somewhere.