Skip to contentSkip to conversation

media: v4l2-core: v4l2-ioctl: Printing log with dev_warn() when the pixelformat is unknown

PATCH In review Kate Hsuan 3 participants 3 messages Mar 27, 2023 – Mar 29, 2023 Media (V4L/DVB)

lore
Share & tools
lore

Kate Hsuan

author
#0 lore raw

PATCH 1/1 media: v4l2-core: v4l2-ioctl: Printing log with dev_warn() when the pixelformat is unknown

The original implementation used WARN() to notify the user of the "unknown pixelformat" error. If fmt->description can be found, the function will simply return without warnings. Recently, the description had removed from uvc since v4l_fill_fmtdesc() can provide such kind of information. However, for some of the USB cameras, such as Intel Realsense F200 returns unknown format when probe(). Thus, the WARN() message shows and confuses the user. This work changed WARN() to dev_warn() to reduce the severity of the message.

The returned video format of Intel RealSense F200 is shown as follows.
kernel: uvcvideo 2-7:1.3: Unknown video format 52564e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 49524e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 494c4552-1314-f943-a75a-ee6bbf012e23
kernel: usb 2-7: Found UVC 1.10 device Intel(R) RealSense(TM) 3D Camera (Front F200) (8086:0a66)

---
 drivers/media/v4l2-core/v4l2-ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +3 -3
index 87f163a89c80..aae987243a5b 100644
@@ -1246,7 +1246,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
 	return ops->vidioc_enum_output(file, fh, p);
 }
 
-static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
+static void v4l_fill_fmtdesc(struct video_device *vdev, struct v4l2_fmtdesc *fmt)
 {
 	const unsigned sz = sizeof(fmt->description);
 	const char *descr = NULL;
@@ -1504,7 +1504,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 		default:
 			if (fmt->description[0])
 				return;
-			WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
+			dev_warn(&vdev->dev, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
 			flags = 0;
 			snprintf(fmt->description, sz, "%p4cc",
 				 &fmt->pixelformat);
@@ -1589,7 +1589,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
 		break;
 	}
 	if (ret == 0)
-		v4l_fill_fmtdesc(p);
+		v4l_fill_fmtdesc(vdev, p);
 	return ret;
 }
 
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 9 lines · Kate Hsuan

The original implementation used WARN() to notify the user of the "unknown pixelformat" error. If fmt->description can be found, the function will simply return without warnings. Recently, the description had removed from uvc since v4l_fill_fmtdesc() can provide such kind of information. However, for some of the USB cameras, such as Intel Realsense F200 returns unknown format when probe(). Thus, the WARN() message shows and confuses the user. This work changed WARN() to dev_warn() to reduce the severity of the message.

Quoted 8 lines

The returned video format of Intel RealSense F200 is shown as follows.
kernel: uvcvideo 2-7:1.3: Unknown video format 52564e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 49524e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 494c4552-1314-f943-a75a-ee6bbf012e23
kernel: usb 2-7: Found UVC 1.10 device Intel(R) RealSense(TM) 3D Camera (Front F200) (8086:0a66)

Thanks, patch looks good to me:

Regards,

Hans

Quoted 35 lines
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +3 -3
index 87f163a89c80..aae987243a5b 100644
@@ -1246,7 +1246,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
 	return ops->vidioc_enum_output(file, fh, p);
 }
 
-static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
+static void v4l_fill_fmtdesc(struct video_device *vdev, struct v4l2_fmtdesc *fmt)
 {
 	const unsigned sz = sizeof(fmt->description);
 	const char *descr = NULL;
@@ -1504,7 +1504,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 		default:
 			if (fmt->description[0])
 				return;
-			WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
+			dev_warn(&vdev->dev, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
 			flags = 0;
 			snprintf(fmt->description, sz, "%p4cc",
 				 &fmt->pixelformat);
@@ -1589,7 +1589,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
 		break;
 	}
 	if (ret == 0)
-		v4l_fill_fmtdesc(p);
+		v4l_fill_fmtdesc(vdev, p);
 	return ret;
 }
 
#2 lore raw
Quoted 42 lines · Hans de Goede

Hi,

Quoted 9 lines · Kate Hsuan

The original implementation used WARN() to notify the user of the "unknown pixelformat" error. If fmt->description can be found, the function will simply return without warnings. Recently, the description had removed from uvc since v4l_fill_fmtdesc() can provide such kind of information. However, for some of the USB cameras, such as Intel Realsense F200 returns unknown format when probe(). Thus, the WARN() message shows and confuses the user. This work changed WARN() to dev_warn() to reduce the severity of the message.

Quoted 8 lines

The returned video format of Intel RealSense F200 is shown as follows.
kernel: uvcvideo 2-7:1.3: Unknown video format 52564e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 49524e49-2d90-4a58-920b-773f1f2c556b
kernel: uvcvideo 2-7:1.3: Unknown video format 494c4552-1314-f943-a75a-ee6bbf012e23
kernel: usb 2-7: Found UVC 1.10 device Intel(R) RealSense(TM) 3D Camera (Front F200) (8086:0a66)

Thanks, patch looks good to me:

Regards,

Hans

Quoted 12 lines
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
index 87f163a89c80..aae987243a5b 100644
@@ -1246,7 +1246,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
 	return ops->vidioc_enum_output(file, fh, p);
 }
 
Quoted 11 lines

drivers/media/v4l2-core/v4l2-ioctl.c static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) · line 1507

Quoted 11 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2 -2
-static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
+static void v4l_fill_fmtdesc(struct video_device *vdev, struct v4l2_fmtdesc *fmt)
 {
 	const unsigned sz = sizeof(fmt->description);
 	const char *descr = NULL;
@@ -1504,7 +1504,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 		default:
 			if (fmt->description[0])
 				return;
-			WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
+			dev_warn(&vdev->dev, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);

I don't really like fixing this here. The real cause is in the uvc driver where it doesn't fill in the description for these non-standard formats.

A typical driver really should WARN here.

Quoted 4 lines
Quoted 4 lines
drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
 			flags = 0;
 			snprintf(fmt->description, sz, "%p4cc",
 				 &fmt->pixelformat);
@@ -1589,7 +1589,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
Quoted 9 lines

drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1595

Quoted 8 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1 -1
 		break;
 	}
 	if (ret == 0)
-		v4l_fill_fmtdesc(p);
+		v4l_fill_fmtdesc(vdev, p);
 	return ret;
 }
 

I'll post a new patch fixing this just in uvc.

Regards,

Hans