From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 686972566 for ; Mon, 26 May 2025 13:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748265420; cv=none; b=s0adVPqB5h4jtngi5TxomLRmLlQyQ4785OAJmBTpVVyY82OaipLI/b640eBBziomEjNLXtM/K6fZbWJGOuxljpnwDGlf75drgopJMulMOjUX1FNOAYce4P/fG13Qo0k3F9dXL6hGNIXSowHF62OaLOT74OwzAHlPBFyZjKKWxew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748265420; c=relaxed/simple; bh=4q0q6NEZFzc9IfGMB7XeTs+/9d8mRRN8STC5JzS8Sdg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MwWYgCku+xglIaisg95IgZOOdPaunZKp3d1E6k3AsGwt1NErVw9q7LQFuZ5xNSK+3aan8RQZLkB9GivJo8SxCYEysI0CkDhiiN/P5kDVq1IXqLoGOR6+OjufX6ThvH3F7OHYk56A1NNmP16Yjd83qCMs7YWYTREcUcNpHLPNOgU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Tk8/9ytZ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tk8/9ytZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748265414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GARNqGrj9Hq8FoX/S5BWp84kmJS3AdiiZew3Eo4GW38=; b=Tk8/9ytZUqbGS3HHRsm8TPPaHc/DoxyG7QaJdKw9M1CNB4AhxcLOVEh+ruT1EK3mAOIH3U iiI5UVTWRzonoUccKN93KYcPeBznpC7ryppMEDE837zx8ZF83DtCXj1ASiw2yHPCKrLtC9 qXIAth1XTVsy4++3LSeJxjCKF4wcLd0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-3ApeHR6TOOul52X0VMTLDw-1; Mon, 26 May 2025 09:16:52 -0400 X-MC-Unique: 3ApeHR6TOOul52X0VMTLDw-1 X-Mimecast-MFC-AGG-ID: 3ApeHR6TOOul52X0VMTLDw_1748265411 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-603f71f6432so1601214a12.3 for ; Mon, 26 May 2025 06:16:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748265411; x=1748870211; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GARNqGrj9Hq8FoX/S5BWp84kmJS3AdiiZew3Eo4GW38=; b=GnUrPw5GheixyKwOOnXo/6i4SnAN+sAi+oYe1BDuasdhGxK2cD9DIyYi+zPJDdi9Ln VUcICGmnkM+MabJU3tzln15Y63vwiMl2zVyUHlBoeAerP8sFH1dXWV0wlCHCYgj+1ZfM oWpzOqAtl21Bs3l52lswhT041U7TREd5NTNi8lPF62gZOERRskFXMTqyT8kM/sRRGfuX fCdz/ZujH2djLvrOWiTwUp6eJ+DPHG7KmkywEB1i407Sh8yD2B67kxRTrHHEcFDBcevP d8Vtk7B9l784F6Ok6uIipaWusQY+wI1a+qa6dA7gRp3R+bHzF3o3oDB6x3/bxVPri5Qw 8EgQ== X-Forwarded-Encrypted: i=1; AJvYcCV7yPTd/6r8NWILV33tauJGG4/VddJrk6BdnbM3BorPQcWejYGh4qk55JxLjAMspLIxxbi2wfykG5/50UA=@vger.kernel.org X-Gm-Message-State: AOJu0YznabfJnn80II/lLAKXSKYxoV5raAeEvEW98rdGHBilA7kq1+0h eoAA0iF9zc2bQ3lpmIIDPmYT21q7rPFlrDdITQj6CuwyZs28NOnt1ZNHdLwKf3inn1yexbyJqJx ScnyT55ui9Omep9KZQUx/ITZGQ8TuryejbRRkX3cXBcyzTiUVhg5tmEXRrzs7C3zD6g== X-Gm-Gg: ASbGncuRyOiTxSdcdwLJnHBFs34Oi2BJLPK3Xhz9oJfk+BBe1YeA2uryA3q9muesy0H SWY67rbCqDKS45kGUVo2c9+01SB03PCpu7IIZ25wRrX31lFDY1NohDxazoLsHCLSvA3V3qNhmeh vnv9vdLdAZVU4Q8OLYs/hxJ92lavZ2c0C4NsTtknfTjQWA5vijlX0fqGt7XhYFaOKY4MbSL40dp qUEMxfo/4qIk1P67xImRPeLtaH/MOKJpvrNfNpPgAmThofZ3jHEeXQ7/Ug0nzdZpl8kxK/ZRtt7 j/Ns01l6Nmed160= X-Received: by 2002:a17:906:f282:b0:ad6:9ea7:cb0a with SMTP id a640c23a62f3a-ad85b0507bemr483614966b.9.1748265411064; Mon, 26 May 2025 06:16:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvUeVhdV+Qz2GB6eUmtrEuoEqa8SpVQhDFfXK7oGmNH3seQLq34yXhMm8tjL5VLNDZq7atEA== X-Received: by 2002:a17:906:f282:b0:ad6:9ea7:cb0a with SMTP id a640c23a62f3a-ad85b0507bemr483612866b.9.1748265410594; Mon, 26 May 2025 06:16:50 -0700 (PDT) Received: from [10.40.98.122] ([78.108.130.194]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6020e441c84sm9941815a12.38.2025.05.26.06.16.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 May 2025 06:16:50 -0700 (PDT) Message-ID: Date: Mon, 26 May 2025 15:16:49 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/4] media: uvcvideo: Introduce V4L2_META_FMT_UVC_MSXU_1_5 To: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Guennadi Liakhovetski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250404-uvc-meta-v5-0-f79974fc2d20@chromium.org> <20250404-uvc-meta-v5-3-f79974fc2d20@chromium.org> Content-Language: en-US, nl From: Hans de Goede In-Reply-To: <20250404-uvc-meta-v5-3-f79974fc2d20@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, On 4-Apr-25 08:37, Ricardo Ribalda wrote: > The UVC driver provides two metadata types V4L2_META_FMT_UVC, and > V4L2_META_FMT_D4XX. The only difference between the two of them is that > V4L2_META_FMT_UVC only copies PTS, SCR, size and flags, and > V4L2_META_FMT_D4XX copies the whole metadata section. > > Now we only enable V4L2_META_FMT_D4XX for the Intel D4xx family of > devices, but it is useful to have the whole metadata section for any > device where vendors include other metadata, such as the one described by > Microsoft: > https://learn.microsoft.com/en-us/windows-hardware/drivers/stream/mf-capture-metadata > > This patch introduces a new format V4L2_META_FMT_UVC_MSXU_1_5, that is > identical to V4L2_META_FMT_D4XX. > > For now, flag this format with a new quirk. > > Suggested-by: Hans de Goede > Signed-off-by: Ricardo Ribalda Thanks, patch looks good to me: Reviewed-by: Hans de Goede Regards, Hans > --- > .../userspace-api/media/v4l/meta-formats.rst | 1 + > .../media/v4l/metafmt-uvc-msxu-1-5.rst | 23 ++++++++++++ > MAINTAINERS | 1 + > drivers/media/usb/uvc/uvc_metadata.c | 43 +++++++++++++++++++--- > drivers/media/usb/uvc/uvcvideo.h | 1 + > drivers/media/v4l2-core/v4l2-ioctl.c | 1 + > include/uapi/linux/videodev2.h | 1 + > 7 files changed, 65 insertions(+), 6 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Documentation/userspace-api/media/v4l/meta-formats.rst > index 86ffb3bc8ade2e0c563dd84441572ecea1a571a6..4de0d094e0702068be0c59154458c9dfecbfe28d 100644 > --- a/Documentation/userspace-api/media/v4l/meta-formats.rst > +++ b/Documentation/userspace-api/media/v4l/meta-formats.rst > @@ -19,6 +19,7 @@ These formats are used for the :ref:`metadata` interface only. > metafmt-pisp-fe > metafmt-rkisp1 > metafmt-uvc > + metafmt-uvc-msxu-1-5 > metafmt-vivid > metafmt-vsp1-hgo > metafmt-vsp1-hgt > diff --git a/Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst b/Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst > new file mode 100644 > index 0000000000000000000000000000000000000000..e6f95a88c0ff061df0b066b12cefc30f946b60aa > --- /dev/null > +++ b/Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst > @@ -0,0 +1,23 @@ > +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later > + > +.. _v4l2-meta-fmt-uvc-msxu-1-5: > + > +*********************************** > +V4L2_META_FMT_UVC_MSXU_1_5 ('UVCM') > +*********************************** > + > +Microsoft(R)'s UVC Payload Metadata. > + > + > +Description > +=========== > + > +V4L2_META_FMT_UVC_MSXU_1_5 buffers follow the metadata buffer layout of > +V4L2_META_FMT_UVC with the only difference that it includes all the UVC > +metadata, not just the first 2-12 bytes. > + > +For more details check the documentation from Microsoft(R) [1]. > + > +.. _1: > + > +[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/stream/uvc-extensions-1-5 > diff --git a/MAINTAINERS b/MAINTAINERS > index 306b1384eb6d4cb7a310ada44605eaeb88cc732f..a07ed31ab057b98cf801d919b5bbec5ee334c9ac 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -25059,6 +25059,7 @@ S: Maintained > W: http://www.ideasonboard.org/uvc/ > T: git git://linuxtv.org/media.git > F: Documentation/userspace-api/media/drivers/uvcvideo.rst > +F: Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst > F: Documentation/userspace-api/media/v4l/metafmt-uvc.rst > F: drivers/media/common/uvc.c > F: drivers/media/usb/uvc/ > diff --git a/drivers/media/usb/uvc/uvc_metadata.c b/drivers/media/usb/uvc/uvc_metadata.c > index 82de7781f5b6b70c5ba16bcba9e0741231231904..fe2678fc795d7fd5a64e8113199012f34c419176 100644 > --- a/drivers/media/usb/uvc/uvc_metadata.c > +++ b/drivers/media/usb/uvc/uvc_metadata.c > @@ -63,15 +63,21 @@ static int uvc_meta_v4l2_try_format(struct file *file, void *fh, > struct uvc_streaming *stream = video_get_drvdata(vfh->vdev); > struct uvc_device *dev = stream->dev; > struct v4l2_meta_format *fmt = &format->fmt.meta; > - u32 fmeta = fmt->dataformat; > + u32 fmeta; > + > + if (fmt->dataformat == dev->info->meta_format) > + fmeta = dev->info->meta_format; > + else if (fmt->dataformat == V4L2_META_FMT_UVC_MSXU_1_5) > + fmeta = V4L2_META_FMT_UVC_MSXU_1_5; > + else > + fmeta = V4L2_META_FMT_UVC; > > if (format->type != vfh->vdev->queue->type) > return -EINVAL; > > memset(fmt, 0, sizeof(*fmt)); > > - fmt->dataformat = fmeta == dev->info->meta_format > - ? fmeta : V4L2_META_FMT_UVC; > + fmt->dataformat = fmeta; > fmt->buffersize = UVC_METADATA_BUF_SIZE; > > return 0; > @@ -106,6 +112,27 @@ static int uvc_meta_v4l2_set_format(struct file *file, void *fh, > return ret; > } > > +static u32 uvc_meta_idx_to_fmeta(struct uvc_device *dev, u32 index) > +{ > + switch (index) { > + case 0: > + return V4L2_META_FMT_UVC; > + case 1: > + if (dev->info->meta_format) > + return dev->info->meta_format; > + if (dev->quirks & UVC_QUIRK_MSXU_META) > + return V4L2_META_FMT_UVC_MSXU_1_5; > + return 0; > + case 2: > + if (dev->info->meta_format && > + dev->quirks & UVC_QUIRK_MSXU_META) > + return V4L2_META_FMT_UVC_MSXU_1_5; > + return 0; > + } > + > + return 0; > +} > + > static int uvc_meta_v4l2_enum_formats(struct file *file, void *fh, > struct v4l2_fmtdesc *fdesc) > { > @@ -113,16 +140,20 @@ static int uvc_meta_v4l2_enum_formats(struct file *file, void *fh, > struct uvc_streaming *stream = video_get_drvdata(vfh->vdev); > struct uvc_device *dev = stream->dev; > u32 index = fdesc->index; > + u32 fmeta; > + > + if (fdesc->type != vfh->vdev->queue->type) > + return -EINVAL; > > - if (fdesc->type != vfh->vdev->queue->type || > - index > 1U || (index && !dev->info->meta_format)) > + fmeta = uvc_meta_idx_to_fmeta(dev, fdesc->index); > + if (!fmeta) > return -EINVAL; > > memset(fdesc, 0, sizeof(*fdesc)); > > fdesc->type = vfh->vdev->queue->type; > fdesc->index = index; > - fdesc->pixelformat = index ? dev->info->meta_format : V4L2_META_FMT_UVC; > + fdesc->pixelformat = fmeta; > > return 0; > } > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h > index b4ee701835fc016474d2cd2a0b67b2aa915c1c60..123446683e22589f23b5228a00240e54f00ae6f1 100644 > --- a/drivers/media/usb/uvc/uvcvideo.h > +++ b/drivers/media/usb/uvc/uvcvideo.h > @@ -77,6 +77,7 @@ > #define UVC_QUIRK_DISABLE_AUTOSUSPEND 0x00008000 > #define UVC_QUIRK_INVALID_DEVICE_SOF 0x00010000 > #define UVC_QUIRK_MJPEG_NO_EOF 0x00020000 > +#define UVC_QUIRK_MSXU_META 0x00040000 > > /* Format flags */ > #define UVC_FMT_FLAG_COMPRESSED 0x00000001 > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c > index a16fb44c7246e35f3710306fde5dfc15329b4d95..12f1232e5ca3acdefede8f9751f9e7191eeae58b 100644 > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > @@ -1457,6 +1457,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) > case V4L2_META_FMT_VSP1_HGO: descr = "R-Car VSP1 1-D Histogram"; break; > case V4L2_META_FMT_VSP1_HGT: descr = "R-Car VSP1 2-D Histogram"; break; > case V4L2_META_FMT_UVC: descr = "UVC Payload Header Metadata"; break; > + case V4L2_META_FMT_UVC_MSXU_1_5: descr = "UVC MSXU Metadata"; break; > case V4L2_META_FMT_D4XX: descr = "Intel D4xx UVC Metadata"; break; > case V4L2_META_FMT_VIVID: descr = "Vivid Metadata"; break; > case V4L2_META_FMT_RK_ISP1_PARAMS: descr = "Rockchip ISP1 3A Parameters"; break; > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index c8cb2796130f8d1b864d669267d2b31f73b839aa..0cf6885a5dc8752326bd10a893d5d09d47993c21 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -851,6 +851,7 @@ struct v4l2_pix_format { > #define V4L2_META_FMT_VSP1_HGT v4l2_fourcc('V', 'S', 'P', 'T') /* R-Car VSP1 2-D Histogram */ > #define V4L2_META_FMT_UVC v4l2_fourcc('U', 'V', 'C', 'H') /* UVC Payload Header metadata */ > #define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */ > +#define V4L2_META_FMT_UVC_MSXU_1_5 v4l2_fourcc('U', 'V', 'C', 'M') /* UVC MSXU metadata */ > #define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */ > > /* Vendor specific - used for RK_ISP1 camera sub-system */ >