mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manuel Herrmann <m@manuel-herrmann.de>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans de Goede <hansg@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-media@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Manuel Herrmann <m@manuel-herrmann.de>
Subject: [PATCH] media: uvcvideo: Add support for NV21 pixel format
Date: Sun, 25 Oct 2026 15:35:22 +0100	[thread overview]
Message-ID: <20261025143522.327365-1-m@manuel-herrmann.de> (raw)

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


             reply	other threads:[~2026-10-25 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 14:35 Manuel Herrmann [this message]
2026-10-25 20:06 ` Laurent Pinchart
2026-10-25 23:26   ` Manuel Herrmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261025143522.327365-1-m@manuel-herrmann.de \
    --to=m@manuel-herrmann.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®