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 3C17178F3E for ; Mon, 3 Mar 2025 14:48:05 +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=1741013289; cv=none; b=ZkdnC9MHQ/FkBqxLLwtGAbdohchLFF/CBS0ipm6muQw3a9OeWhdBN4n4pht4nSUH0qcx6wbhkViuIKTjt7HUlVbFZLZoLZdXOBhSmUp0+6Kaekv6ednVLbDvsw5INYpCzXcnkXwfiMx20xDtI6zIaKutPeM1fCS4W+4blEIu6T4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741013289; c=relaxed/simple; bh=FVRD4iX3p9k8gSH9i17b/bed7/npTuICPWhmTSWXw5s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mKhGCxo5IJ7RHnmi2cbuPe9KG3d48UMBSyzuuNhdPQmw3lfT0vJ007z9PujG2Ktnxj7MSgMAvJ5dcaJoHYeR0zGWvsLwUBwF9iWM1Eiirjh5Zm5KgaPe/0Qq3QcIH4DhbQvrD5GWRbPtNc/KnbhXBvsygPrKbODBbffoU1WYg8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Th9M9mvu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="Th9M9mvu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741013285; 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=JeW7ILK4BHwph4vdjZBYJRZp3BpM7DGYuP2lQy/HDSs=; b=Th9M9mvuu96jjcoAqhERvfjZwhJcX6E8rj4u28NoO1/cWSaAUHeGmAV8HH5mvMSyfy5yUp LxQGzJGpycbrnx0QQEfLglqO7AidwPPsplgsxkxRtvSjg92jyt4qdGZg59nZxwz8nq+9TT zvPOlUPdjPYBhPDSibdqt3ksLnqkX+I= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-Arf2lOKvMdqSjXNRDRbD1A-1; Mon, 03 Mar 2025 09:47:54 -0500 X-MC-Unique: Arf2lOKvMdqSjXNRDRbD1A-1 X-Mimecast-MFC-AGG-ID: Arf2lOKvMdqSjXNRDRbD1A_1741013273 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-ab39f65dc10so572100266b.1 for ; Mon, 03 Mar 2025 06:47:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741013273; x=1741618073; 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=JeW7ILK4BHwph4vdjZBYJRZp3BpM7DGYuP2lQy/HDSs=; b=Cgz9Tad0rJBEMBIUORwGp22dk4s69IP5e0xzI+phFSpyrFlAVDGh9qyy0u4eaczePw N6FFP5YEdNjjoImN6gtk5Q6PfZ1/ILpUxpuUx2+kJ4igwNihFkXLLz2EMmBayhasL48N u6j6JcBQjUglDtnmn0CSm2WF4jLZhupWnB5q01mfEjLjMxEZ4FmXuxlPZSayO/cd91rC h7AYdq3b6GJyKwL4hJjmz/Ex+3GJ1/8Zom/xVJeQpLlYMSyHecLq/dEr50P68rzPXJyr yZc5rIjfIdT0dFhWPjIsFtW36sbI9ng3fQ5zfWIl1lWrfRhji32kZqxiIAL0fyKrg/I3 I0nQ== X-Forwarded-Encrypted: i=1; AJvYcCW2BxZOOwBFdzcF6sx9ctB75Je1pg2T3aaLgMbJ/r6YtgIA7VLJ55GpHz4phiqNpzbLjQ9ftAsLM9eUTtE=@vger.kernel.org X-Gm-Message-State: AOJu0YxCZw9ryateKyQbB76btv09vRGPDj8ft6MfZ6g2brcH36i7b+DQ QNlNkUr7aDcXkO6/ANrMKx2x94XE3NI5iYfC+O1MuU+V5ct1rZDLWd63LOOtb9PLsJCLjWigxrZ mkais2rDYso1SOsQ+nT0KaIxNUkKH+oogV+blpECaT6kSmUhGiDhIColmKQUElw== X-Gm-Gg: ASbGncs2PYT8unxThCyO8dhfdtdc/hWItXYbUHLnFRea/MVCXf5pBiMZY+edGLs3ZWt k+IRnSp6QwWfwUcD0WT8FO+F8Xvfd5G4V2HovfGdMKCUcx/siZoeWORkl1X+dZbge7FUL2SCDTw COmLOuCI1HHibEZZW7Hk8ZH3AmtwxduMioEn8x7yQfoX0Ew3w67OgwRBEM0IH2RWu+na9X4EZCp oh8jEKp6l0nuclNZaZkQLvDRiOQL8GPnepRAOQDS3Br+QgSePWvt7QBUPPb+uvqJaHOB3/5XrD1 9F3y4ybxaQH+wBGlzXw= X-Received: by 2002:a17:907:d90:b0:ac1:e332:b1ef with SMTP id a640c23a62f3a-ac1e332b45bmr212465666b.48.1741013272751; Mon, 03 Mar 2025 06:47:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxkGtJFlxPNSNyID6fMe+Mm/hHvV0XaEzpcB6ATKLdIpZJ9r5qZolbpF2E4TnEHvKU9ctYww== X-Received: by 2002:a17:907:d90:b0:ac1:e332:b1ef with SMTP id a640c23a62f3a-ac1e332b45bmr212462066b.48.1741013272258; Mon, 03 Mar 2025 06:47:52 -0800 (PST) Received: from [10.40.98.122] ([78.108.130.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abf0c6ee491sm822229966b.103.2025.03.03.06.47.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Mar 2025 06:47:51 -0800 (PST) Message-ID: Date: Mon, 3 Mar 2025 15:47:51 +0100 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] media: uvcvideo: Enable full UVC metadata for all devices To: Ricardo Ribalda , Mauro Carvalho Chehab , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250226-uvc-metadata-v1-1-6cd6fe5ec2cb@chromium.org> Content-Language: en-US, nl From: Hans de Goede In-Reply-To: <20250226-uvc-metadata-v1-1-6cd6fe5ec2cb@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, On 26-Feb-25 14:00, 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 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 removes the UVC_INFO_META macro and enables > V4L2_META_FMT_D4XX for every device. It also updates the documentation > to reflect the change. > > Signed-off-by: Ricardo Ribalda Thanks, patch looks good to me: Reviewed-by: Hans de Goede Regards, Hans > --- > .../userspace-api/media/v4l/metafmt-d4xx.rst | 19 +++-- > .../userspace-api/media/v4l/metafmt-uvc.rst | 6 +- > drivers/media/usb/uvc/uvc_driver.c | 83 ---------------------- > drivers/media/usb/uvc/uvc_metadata.c | 15 ++-- > drivers/media/usb/uvc/uvcvideo.h | 1 - > 5 files changed, 23 insertions(+), 101 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/metafmt-d4xx.rst b/Documentation/userspace-api/media/v4l/metafmt-d4xx.rst > index 0686413b16b2..1b18ef056934 100644 > --- a/Documentation/userspace-api/media/v4l/metafmt-d4xx.rst > +++ b/Documentation/userspace-api/media/v4l/metafmt-d4xx.rst > @@ -6,12 +6,23 @@ > V4L2_META_FMT_D4XX ('D4XX') > ******************************* > > -Intel D4xx UVC Cameras Metadata > +UVC Full Payload Header Data (formerly known as Intel D4xx UVC Cameras > +Metadata). > > > Description > =========== > > +V4L2_META_FMT_D4XX buffers follow the metadata buffer layout of > +V4L2_META_FMT_UVC with the only difference, that it also includes proprietary > +payload header data. It was originally implemented for Intel D4xx cameras, and > +thus the name, but now it can be used by any UVC device, when userspace wants > +full access to the UVC Metadata. > + > + > +Intel D4xx Metadata > +=================== > + > Intel D4xx (D435, D455 and others) cameras include per-frame metadata in their UVC > payload headers, following the Microsoft(R) UVC extension proposal [1_]. That > means, that the private D4XX metadata, following the standard UVC header, is > @@ -21,10 +32,8 @@ types are MetadataId_CaptureStats (ID 3), MetadataId_CameraExtrinsics (ID 4), > and MetadataId_CameraIntrinsics (ID 5). For their description see [1_]. This > document describes proprietary metadata types, used by D4xx cameras. > > -V4L2_META_FMT_D4XX buffers follow the metadata buffer layout of > -V4L2_META_FMT_UVC with the only difference, that it also includes proprietary > -payload header data. D4xx cameras use bulk transfers and only send one payload > -per frame, therefore their headers cannot be larger than 255 bytes. > +D4xx cameras use bulk transfers and only send one payload per frame, therefore > +their headers cannot be larger than 255 bytes. > > This document implements Intel Configuration version 3 [9_]. > > diff --git a/Documentation/userspace-api/media/v4l/metafmt-uvc.rst b/Documentation/userspace-api/media/v4l/metafmt-uvc.rst > index 784346d14bbd..a3aae580e89e 100644 > --- a/Documentation/userspace-api/media/v4l/metafmt-uvc.rst > +++ b/Documentation/userspace-api/media/v4l/metafmt-uvc.rst > @@ -6,7 +6,7 @@ > V4L2_META_FMT_UVC ('UVCH') > ******************************* > > -UVC Payload Header Data > +UVC Partial Payload Header Data (formerly known as UVC Payload Header Data). > > > Description > @@ -44,7 +44,9 @@ Each individual block contains the following fields: > them > * - :cspan:`1` *The rest is an exact copy of the UVC payload header:* > * - __u8 length; > - - length of the rest of the block, including this field > + - length of the rest of the block, including this field (please note that > + regardless of this value, the driver will never copy more than 12 > + bytes). > * - __u8 flags; > - Flags, indicating presence of other standard UVC fields > * - __u8 buf[]; > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > index deadbcea5e22..f19dcd4a7ac6 100644 > --- a/drivers/media/usb/uvc/uvc_driver.c > +++ b/drivers/media/usb/uvc/uvc_driver.c > @@ -2488,8 +2488,6 @@ static const struct uvc_device_info uvc_quirk_force_y8 = { > }; > > #define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q} > -#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \ > - {.meta_format = m} > > /* > * The Logitech cameras listed below have their interface class set to > @@ -3107,87 +3105,6 @@ static const struct usb_device_id uvc_ids[] = { > .bInterfaceSubClass = 1, > .bInterfaceProtocol = 0, > .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_DISABLE_AUTOSUSPEND) }, > - /* Intel D410/ASR depth camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0ad2, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D415/ASRC depth camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0ad3, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D430/AWG depth camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0ad4, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel RealSense D4M */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0b03, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D435/AWGC depth camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0b07, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D435i depth camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0b3a, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D405 Depth Camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0b5b, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D455 Depth Camera */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x0b5c, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > - /* Intel D421 Depth Module */ > - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE > - | USB_DEVICE_ID_MATCH_INT_INFO, > - .idVendor = 0x8086, > - .idProduct = 0x1155, > - .bInterfaceClass = USB_CLASS_VIDEO, > - .bInterfaceSubClass = 1, > - .bInterfaceProtocol = 0, > - .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) }, > /* Generic USB Video Class */ > { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) }, > { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) }, > diff --git a/drivers/media/usb/uvc/uvc_metadata.c b/drivers/media/usb/uvc/uvc_metadata.c > index 82de7781f5b6..5c44e6cdb83c 100644 > --- a/drivers/media/usb/uvc/uvc_metadata.c > +++ b/drivers/media/usb/uvc/uvc_metadata.c > @@ -60,18 +60,16 @@ static int uvc_meta_v4l2_try_format(struct file *file, void *fh, > struct v4l2_format *format) > { > struct v4l2_fh *vfh = file->private_data; > - 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 = fmt->dataformat == V4L2_META_FMT_D4XX ? > + V4L2_META_FMT_D4XX : 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; > @@ -110,19 +108,16 @@ static int uvc_meta_v4l2_enum_formats(struct file *file, void *fh, > struct v4l2_fmtdesc *fdesc) > { > struct v4l2_fh *vfh = file->private_data; > - struct uvc_streaming *stream = video_get_drvdata(vfh->vdev); > - struct uvc_device *dev = stream->dev; > u32 index = fdesc->index; > > - if (fdesc->type != vfh->vdev->queue->type || > - index > 1U || (index && !dev->info->meta_format)) > + if (fdesc->type != vfh->vdev->queue->type || index > 1U) > 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 = index ? V4L2_META_FMT_D4XX : V4L2_META_FMT_UVC; > > return 0; > } > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h > index 5e388f05f3fc..cc2092ae9987 100644 > --- a/drivers/media/usb/uvc/uvcvideo.h > +++ b/drivers/media/usb/uvc/uvcvideo.h > @@ -534,7 +534,6 @@ static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb) > > struct uvc_device_info { > u32 quirks; > - u32 meta_format; > u16 uvc_version; > }; > > > --- > base-commit: d98e9213a768a3cc3a99f5e1abe09ad3baff2104 > change-id: 20250226-uvc-metadata-2e7e445966de > > Best regards,