mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: uvcvideo: Add support for NV21 pixel format
@ 2026-10-25 14:35 Manuel Herrmann
  2026-10-25 20:06 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel Herrmann @ 2026-10-25 14:35 UTC (permalink / raw)
  To: Laurent Pinchart, Hans de Goede
  Cc: Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media,
	linux-usb, linux-kernel, Manuel Herrmann

Add support for the NV21 (Y/VU 4:2:0) pixel format to the uvcvideo
driver. This format is exposed by the color camera of the Creality Pika
3D scanner (2bc5:0c0b), next to YUYV and MJPEG. Without it, the driver
skips the format as unknown.

NV21 only differs from NV12 in the order of the chroma samples, so
bytesperline is wWidth, as for NV12.

Signed-off-by: Manuel Herrmann <m@manuel-herrmann.de>
---
Tested on media next (d7e7bca71698) in a QEMU guest with the scanner passed
through. Before the patch, the driver logs

  uvcvideo 2-1:1.3: Unknown video format 3132564e-0000-0010-8000-00aa00389b71

and the color node only offers YUYV and MJPG. With the patch, NV21 is
listed, G_FMT reports a bytesperline of 1280 for 1280x960, and v4l2-ctl
streams it at 30 fps. A frame captured in the guest has the right
colors decoded as NV21, and red and blue swapped decoded as NV12.

 drivers/media/common/uvc.c       | 4 ++++
 drivers/media/usb/uvc/uvc_v4l2.c | 1 +
 include/linux/usb/uvc.h          | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/drivers/media/common/uvc.c b/drivers/media/common/uvc.c
index 0107cedd0..7d918ba0e 100644
--- a/drivers/media/common/uvc.c
+++ b/drivers/media/common/uvc.c
@@ -24,6 +24,10 @@ static const struct uvc_format_desc uvc_fmts[] = {
 		.guid		= UVC_GUID_FORMAT_NV12,
 		.fcc		= V4L2_PIX_FMT_NV12,
 	},
+	{
+		.guid		= UVC_GUID_FORMAT_NV21,
+		.fcc		= V4L2_PIX_FMT_NV21,
+	},
 	{
 		.guid		= UVC_GUID_FORMAT_MJPEG,
 		.fcc		= V4L2_PIX_FMT_MJPEG,
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 644c2f1cd..60732f5ac 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -232,6 +232,7 @@ static u32 uvc_v4l2_get_bytesperline(const struct uvc_format *format,
 {
 	switch (format->fcc) {
 	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
 	case V4L2_PIX_FMT_YVU420:
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_M420:
diff --git a/include/linux/usb/uvc.h b/include/linux/usb/uvc.h
index 99b070ab8..48419a862 100644
--- a/include/linux/usb/uvc.h
+++ b/include/linux/usb/uvc.h
@@ -85,6 +85,9 @@
 #define UVC_GUID_FORMAT_NV12 \
 	{ 'N',  'V',  '1',  '2', 0x00, 0x00, 0x10, 0x00, \
 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_NV21 \
+	{ 'N',  'V',  '2',  '1', 0x00, 0x00, 0x10, 0x00, \
+	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
 #define UVC_GUID_FORMAT_YV12 \
 	{ 'Y',  'V',  '1',  '2', 0x00, 0x00, 0x10, 0x00, \
 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}

base-commit: d7e7bca7169873b46e857c025c10f3336c1258d8
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-25 23:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 14:35 [PATCH] media: uvcvideo: Add support for NV21 pixel format Manuel Herrmann
2026-10-25 20:06 ` Laurent Pinchart
2026-10-25 23:26   ` Manuel Herrmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®